Skip to main content
The Organization Domains API allows you to create, retrieve, verify, and delete domains associated with organizations.

Initialize

import { WorkOS } from '@workos-inc/node';

const workos = new WorkOS('sk_example_123456789');

Methods

get

Retrieve an organization domain by ID.
const domain = await workos.organizationDomains.get('org_domain_123');

console.log(domain.domain, domain.state);
id
string
required
The unique identifier of the organization domain.
organizationDomain
OrganizationDomain
The organization domain object.

create

Create a new organization domain.
const domain = await workos.organizationDomains.create({
  organizationId: 'org_123',
  domain: 'acme.com',
});

console.log(domain.verificationToken);
payload
CreateOrganizationDomainOptions
required
The organization domain data.
organizationDomain
OrganizationDomain
The created organization domain object.

verify

Verify an organization domain.
const domain = await workos.organizationDomains.verify('org_domain_123');

console.log(domain.state); // 'verified' if successful
id
string
required
The unique identifier of the organization domain to verify.
organizationDomain
OrganizationDomain
The verified organization domain object with updated state.

delete

Delete an organization domain.
await workos.organizationDomains.delete('org_domain_123');
id
string
required
The unique identifier of the organization domain to delete.

Domain Verification

DNS Verification

When creating a domain with the DNS verification strategy, you’ll receive a verificationToken. Add this as a TXT record:
TXT _workos.example.com "verification_token_here"
Then call the verify method to complete verification.

Manual Verification

For manual verification, WorkOS will verify domain ownership through alternative means. Contact support for manual verification options.

Example: Complete Domain Setup

// 1. Create the domain
const domain = await workos.organizationDomains.create({
  organizationId: 'org_123',
  domain: 'acme.com',
});

console.log('Add this TXT record:', domain.verificationToken);

// 2. After DNS propagation, verify the domain
const verifiedDomain = await workos.organizationDomains.verify(domain.id);

if (verifiedDomain.state === 'verified') {
  console.log('Domain verified successfully!');
} else {
  console.log('Verification failed or still pending');
}

Domain States

OrganizationDomainState
enum

Build docs developers (and LLMs) love