Merchant onboarding
Onboard a new merchant under your workspace and get a Stripe Connect URL in one round trip.
import { v4 as uuid } from 'uuid'
const res = await fetch(`https://api.swft.co.uk/v2/agencies/${workspaceId}/merchants`, { method: 'POST', headers: { 'Authorization': `Bearer ${SWFT_PARTNER_KEY}`, 'Content-Type': 'application/json', 'Idempotency-Key': uuid(), }, body: JSON.stringify({ name: 'Cobalt Pilates', store_url: 'https://cobalt-pilates.com', return_url: 'https://unstack.co.uk/studio/cobalt-pilates/stripe-return', refresh_url: 'https://unstack.co.uk/studio/cobalt-pilates/stripe-refresh', }),})
const { merchant, stripe } = await res.json()// Save merchant.id + merchant.api_key on YOUR side; redirect to stripe.onboarding_urlredirectStudio(stripe.onboarding_url)What happens
Section titled “What happens”- Swft creates a merchant row with
workspace_id = yourWorkspaceId,created_via = 'agency', and freshapi_key/api_secretvalues. - Swft opens a Stripe Standard connected account with
metadata.swft_merchant_idset, and stores thestripe_account_idon the merchant. - Swft creates a one-time Stripe AccountLink and returns the URL.
- The studio completes Stripe’s hosted onboarding; Stripe redirects
to your
return_urlwhen they’re done.
Polling completion
Section titled “Polling completion”The merchant row’s stripe_onboarded flag flips to true when Stripe
reports details_submitted=true. You can either:
- Poll
GET /v2/agencies/mewithX-Swft-Merchant: <id>and inspect the returned scopes (the legacystripe_onboardedfield is being added to the introspection response in a future date version), OR - Subscribe to the
merchant.stripe.readywebhook event (Phase 2) on the merchant’s webhook URL.
Bundling custom domain
Section titled “Bundling custom domain”After creation, immediately assign a checkout subdomain in the same wizard step:
await fetch( `https://api.swft.co.uk/v2/agencies/${workspaceId}/merchants/${merchant.id}/custom-domain`, { method: 'POST', headers: { 'Authorization': `Bearer ${SWFT_PARTNER_KEY}`, 'Content-Type': 'application/json', 'Idempotency-Key': uuid(), }, body: JSON.stringify({ subdomain: 'cobalt-pilates' }), },)// → checkout served from cobalt-pilates.checkouts.unstack.co.uksubdomain only works once your workspace has a delegated zone — see
the DNS delegation guide.