Skip to Content
DomainsAdd a custom domain

Add a custom domain

Attach a hostname to an app, configure DNS using the returned records, then verify when propagation finishes.

Add the domain

Create the domain on your app. The response includes expectedDnsRecords / expected_dns_records to add at your DNS provider. Set isDefault / is_default if this should be the app’s primary hostname.

addAppDomain.js
1
const app = await client.apps.retrieve("da_XYZ");
2
 
3
const domain = await client.apps.domains.create({
4
  app: app.id,
5
  hostname: "www.example.com",
6
  isDefault: false, // true = primary hostname for this app
7
});
8
// Should return: {// { ... }
17
console.log(domain.id, domain.state, domain.expectedDnsRecords);

Verify DNS

After DNS propagates, call verify with the domain id. Returns true when the hostname is verified.

addAppDomain.js
1
const verified = await client.apps.domains.verify(domain.id);
2
// Should return: true
3
console.log("verified:", verified);

Source: stackmachine/sdks  examples.