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. Domains are identified by their name — there is no separate ID.

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({ domain: 'notifications.example.com' });

console.log(domain.domain);
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, record.purpose);
}

Parameters

ParameterTypeRequiredDescription
domainstringYesThe domain name to register (e.g. notifications.example.com), passed as { domain }.

Returns

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

Domain object

FieldTypeDescription
domainstringThe domain name (also its identifier).
statusstringVerification status: "pending", "verifying", "verified", or "failed".
sendingEnabledbooleanWhether sending from this domain is enabled.
healthStatusstringDomain health: "healthy", "degraded", or "failing".
dnsRecordsDnsRecord[]The DNS records that must be added to your domain's DNS configuration.
createdAtstringISO 8601 timestamp of when the domain was registered.
lastCheckedAtstringISO 8601 timestamp of the last verification check.
verifiedAtstringISO 8601 timestamp of when the domain was verified, when applicable.

DnsRecord object

FieldTypeDescription
typestringThe DNS record type: "TXT", "CNAME", or "MX".
namestringThe record name to add to your DNS.
valuestringThe record value.
purposestringWhat the record is for: "verification", "dkim", "spf", or "dmarc".

Errors

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

get

Retrieves a domain by name. Returns null if not found.

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

if (domain) {
  console.log(domain.domain, domain.status);
}

Parameters

ParameterTypeRequiredDescription
domainstringYesThe domain name.

Returns

Promise<Domain | null> — the domain object, or null if not found.


list

Lists registered domains with cursor-based pagination. Optionally filter by status.

const page = await kraiter.domains.list({ status: 'verified' });

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

Parameters

ParameterTypeRequiredDescription
statusstringNoFilter by status ("pending", "verifying", "verified", "failed").
limitnumberNoMaximum items per page.
cursorstringNoPagination cursor.

Returns

Promise<{ items: Domain[]; nextCursor?: string }> — a page of domain objects.


update

Updates a domain's settings — currently, whether sending from it is enabled.

const domain = await kraiter.domains.update('notifications.example.com', {
  sendingEnabled: false,
});

Parameters

ParameterTypeRequiredDescription
domainstringYesThe domain name.
sendingEnabledbooleanNoWhether sending from this domain is enabled.

Returns

Promise<Domain> — the updated domain object.

Errors

CodeWhen
NOT_FOUNDNo domain exists with this name.

verify

Triggers a DNS verification check for a domain. Call this after you have added the required DNS records.

const result = await kraiter.domains.verify('notifications.example.com');

if (result.verified) {
  console.log('Domain verified — you can now send emails');
} else {
  console.log('Verification failed for records:', result.failedRecords);
}

Parameters

ParameterTypeRequiredDescription
domainstringYesThe domain name to verify.

Returns

Promise<VerifyDomainResult> — an object with verified (boolean) and an optional failedRecords array naming the records that did not check out.

Error handling example

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

try {
  const result = await kraiter.domains.verify('notifications.example.com');

  if (!result.verified) {
    console.warn('DNS records not yet propagated — try again in a few minutes');
  }
} catch (error) {
  if (error instanceof MailerError && 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('notifications.example.com');

Parameters

ParameterTypeRequiredDescription
domainstringYesThe domain name to delete.

Returns

Promise<void>

Errors

CodeWhen
NOT_FOUNDNo domain exists with this name.

DNS propagation

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