purchaseDomain
Client function: buy a domain through Casino — returns a Stripe Checkout URL; registration + site auto-connect fire from the payment webhook (P0-163).
import { purchaseDomain } from 'flowstack-sdk'Non-React client function. Starts a domain purchase through Casino's registrar: POST /api/v1/registrar/purchase with a PurchaseDomainRequest returns a Stripe Checkout session_url — redirect the builder there to pay. Route 53 registration and (if site_id was set) automatic connectDomain-style wiring happen asynchronously from the payment webhook, NOT in this call. Use searchDomains first to confirm availability and price.
Signature
purchaseDomain(credentials, request, config?): Promise<ApiResponse<{ domain: string; price_usd: number; session_url: string; session_id: string }>>Parameters
| Param | Type | Notes | Description |
|---|---|---|---|
credentials | FlowstackCredentials | required | The builder's credentials (owner-scoped JWT). |
request | PurchaseDomainRequest | required | Domain (name without TLD), TLD, RegistrantContact, and options (auto_renew, whois_privacy, site_id for auto-connect). |
config | FlowstackClientConfig | — | Client config (baseUrl, appScope, tenantId as needed). |
Returns
| Field | Type | Description |
|---|---|---|
| — | Promise<ApiResponse<{ domain: string; price_usd: number; session_url: string; session_id: string }>> | The Stripe Checkout URL to redirect the builder to, plus the quoted first-year price. |
Examples
const res = await purchaseDomain(credentials, {
domain: 'thezengarden',
tld: 'com',
registrant: {
first_name: 'Ada', last_name: 'Lovelace', email: 'ada@example.com',
phone: '+12125551234', address_line1: '1 Main St', city: 'New York',
state: 'NY', zip_code: '10001', country_code: 'US',
},
auto_renew: true,
whois_privacy: true,
site_id: siteId,
});
if (res.data?.session_url) window.location.href = res.data.session_url;session_url, and Route 53 registration + site auto-connect fire from the payment webhook afterwards. Poll listDomains / getDomainStatus to observe completion; do not treat a 200 here as a completed purchase.builtAppSafe is false.phone must be E.164 (+12125551234), country_code a 2-char ISO code, state a 2-char code for US addresses. Invalid contact data fails the registration after payment — get these right up front.See also
searchDomains · PurchaseDomainRequest · RegistrantContact · listDomains · getDomainStatus
Source: src/api/client.ts (Domain Registrar, P0-163) · Also available in llms-full.txt and registry.json.