Your first domain in two calls
Your API key needs the destinations:write and domains:write scopes.
1. Configure the destination
curl -X POST https://api.subdomain.to/v1/destinations \
-H "Authorization: Bearer $SUBDOMAIN_TO_API_KEY" \
-H "Idempotency-Key: main-destination" \
-H "Content-Type: application/json" \
-d '{"url":"https://app.example.com"}'
2. Connect the customer domain
Create the domain
curl -X POST https://api.subdomain.to/v1/domains \
-H "Authorization: Bearer $SUBDOMAIN_TO_API_KEY" \
-H "Idempotency-Key: customer-42-domain" \
-H "Content-Type: application/json" \
-d '{"hostname":"portal.customer.com"}'
const domain = await client.domains.create('portal.customer.com', 'customer-42-domain');
$domain = $client->domains()->create('portal.customer.com', 'customer-42-domain');
Show the returned dns_records to your customer, then poll GET /domains/{id} until status is active, or subscribe to webhooks.