Kraiter
SDK Reference

Domains

SDK reference for registering and verifying sending domains in Kraiter.

The kraiter.domains namespace provides methods for registering sending domains and verifying their DNS configuration. You must verify at least one domain before you can send emails.

create

Registers a new sending domain. After creating a domain, you will need to add DNS records and then call verify to complete the setup.

const domain = await kraiter.domains.create('notifications.example.com');

console.log(domain.id);
console.log(domain.status); // "pending"

// The domain object includes the DNS records you need to add
for (const record of domain.dnsRecords) {
  console.log(record.type, record.name, record.value);
}

Parameters

ParameterTypeRequiredDescription
domainstringYesThe domain name to register (e.g. notifications.example.com).

Returns

Promise<Domain> — the newly created domain object, including DNS records to configure.

Domain object

FieldTypeDescription
idstringUnique domain ID.
domainstringThe domain name.
statusstringCurrent verification status: "pending", "verified", or "failed".
dnsRecordsDnsRecord[]The DNS records that must be added to your domain's DNS configuration.
createdAtstringISO 8601 timestamp of when the domain was registered.
verifiedAtstring | nullISO 8601 timestamp of when the domain was verified, or null.

DnsRecord object

FieldTypeDescription
typestringThe DNS record type (e.g. CNAME, TXT).
namestringThe record name to add to your DNS.
valuestringThe record value.

Errors

CodeWhen
CONFLICTThis domain is already registered.
VALIDATION_ERRORThe domain name is invalid.

get

Retrieves a domain by ID.

const domain = await kraiter.domains.get('dom_abc123');
console.log(domain.domain, domain.status);

Parameters

ParameterTypeRequiredDescription
idstringYesThe domain ID.

Returns

Promise<Domain> — the domain object.

Errors

CodeWhen
NOT_FOUNDNo domain exists with this ID.

list

Lists all registered domains. Unlike other list methods, this returns a Promise that resolves to an array rather than an async iterator, since the number of domains per tenant is typically small.

const domains = await kraiter.domains.list();

for (const domain of domains) {
  console.log(domain.domain, domain.status);
}

Returns

Promise<Domain[]> — an array of domain objects.


verify

Triggers a DNS verification check for a domain. Call this after you have added the required DNS records. If verification succeeds, the domain status changes to "verified" and you can start sending from it.

const domain = await kraiter.domains.verify('dom_abc123');

if (domain.status === 'verified') {
  console.log('Domain verified — you can now send emails');
} else {
  console.log('Verification failed — check your DNS records');
  for (const record of domain.dnsRecords) {
    console.log(record.type, record.name, record.value);
  }
}

Parameters

ParameterTypeRequiredDescription
idstringYesThe domain ID to verify.

Returns

Promise<Domain> — the domain object with an updated status.

Errors

CodeWhen
NOT_FOUNDNo domain exists with this ID.

Error handling example

import { KraiterError } from '@kraiter/sdk';

try {
  const domain = await kraiter.domains.verify('dom_abc123');

  if (domain.status !== 'verified') {
    console.warn('DNS records not yet propagated — try again in a few minutes');
  }
} catch (error) {
  if (error instanceof KraiterError && error.code === 'NOT_FOUND') {
    console.error('Domain not found — register it first with domains.create()');
  } else {
    throw error;
  }
}

delete

Removes a registered domain. You will no longer be able to send emails from this domain.

await kraiter.domains.delete('dom_abc123');

Parameters

ParameterTypeRequiredDescription
idstringYesThe domain ID to delete.

Returns

Promise<void>

Errors

CodeWhen
NOT_FOUNDNo domain exists with this ID.

DNS propagation

DNS changes can take up to 48 hours to propagate, though most providers complete within a few minutes. If verify returns a "pending" or "failed" status, wait and try again. The Kraiter dashboard also provides a real-time view of your domain's DNS status.