Add a domain

Add a custom domain to the organization, pending verification.

POST /organizations/{org}/domains

Adds a hostname with status pending and returns the TXT and CNAME records to create. Once they are in DNS, call Verify a domain.

Authorization

Org owner. Anyone else gets 403 forbidden.

Path parameters

NameTypeDescription
orgstringThe organization: its id (org_…) or its slug. It has to be an org your token can manage (see Who can call it)

Body

FieldTypeRequiredDescription
hostnamestringyesA bare hostname with at least two labels, such as login.acme.com. It is trimmed and lowercased, and a trailing dot is dropped. A scheme, path or port is a 400

No other field is accepted.

Response

201 Created with the domain.

{
  "id": "dom_65f1c2a9e4b0d3f7a1c8e907",
  "hostname": "login.acme.com",
  "status": "pending",
  "verified_at": null,
  "created_at": "2026-10-18T09:12:00.000Z",
  "records": {
    "txt": { "name": "…", "value": "…" },
    "cname": { "name": "login.acme.com", "value": "…" }
  }
}

Errors

StatuserrorWhen
400invalid_requestAn unknown field, a hostname that is not a bare domain name, or one of LoginWith’s own domains
403forbiddenYou are not an owner of the org
409conflictThis org already has that domain, or another org has already verified it
404not_foundThe org does not exist, or your token cannot manage it

Example

curl -X POST https://loginwith.loginwith.dev/organizations/acme/domains \
  -H "Authorization: Bearer $TOKEN" -H "content-type: application/json" \
  -d '{"hostname": "login.acme.com"}'