Auth API reference

Auth API · Apps

post/v1/apps/{app_id}/custom-domainsAuth

Add a custom domain (such as auth.acme.com) for this app's sign-in.

Returns the two records to publish: a CNAME from the host to `edge_target`, and a TXT token at `_productcraft-auth.<host>` that proves the domain is yours. The zone and its DNS provider are detected, and the first check runs straight away, so `records[].state` and `conflicts` already say what is missing or in the way. Publish the records by hand, import `…/export`, or let `…/apply` write them with a short-lived provider token. The domain turns `active` once both records are seen. Sign-in tokens keep the canonical issuer (`https://api.auth.productcraft.co/{slug}`), so nothing changes for code that verifies them. One custom domain per app. While the feature is in early access it is switched on per workspace.

Path parameters

app_id*string

Id of the app.

Headers

Idempotency-Keystring

Stripe-style idempotency key. A retried create with the same key and body returns the first response. 24h TTL.

Request body

hostname*string · hostname

A subdomain you control, such as auth.acme.com. Not the root of a domain (it needs a CNAME record) and not a productcraft.co name.

Example: "auth.acme.com"

Response · 201 The domain, with its records and the first check's result.

id*string · uuid

Unique identifier of the custom domain.

Example: "1d2c3b4a-5e6f-4a7b-8c9d-0e1f2a3b4c5d"

app_id*string · uuid

The Auth app the custom domain belongs to.

Example: "0b6f3c7e-6a43-4c55-9d4b-2a9a7f5b1c11"

hostname*string · hostname

The custom auth hostname, e.g. `auth.acme.com`.

Example: "auth.acme.com"

status*object

`pending`: waiting for both records. `active`: both records are published; the host serves this app's sign-in routes. `failing`: was active, and a later check no longer finds the records. Checked every 5 minutes while pending (for 7 days) and hourly after that; `POST …/check` checks now.

Example: "pending"

serving*boolean

True when the host serves this app right now: the domain is `active` and custom domains are switched on for the workspace.

Example: false

edge_target*string · hostname

Where the CNAME must point.

Example: "edge.auth.productcraft.co"

dns_zone*string · hostname

The DNS zone holding the host, when it could be found.

Example: "acme.com"

dns_provider*object

Who hosts the zone, from its nameservers.

apply_providers*array

Providers `POST …/apply` can set the records up with for this zone. Empty when the zone is at a provider we cannot write to: publish the records by hand or download them with `…/export`.

Example: ["cloudflare"]

records*array

The two records to publish, routing first.

callback_urls*object

Once active: the OAuth redirect URLs on this host. A sign-in started on the custom host returns to it, so add these to each provider's app next to the existing ones. Null while not active.

verified_at*string · date-time

When the domain last became active.

failing_since*string · date-time

When the domain started failing its checks (ISO 8601), or `null` while healthy.

last_checked_at*string · date-time

When the DNS records were last checked (ISO 8601), or `null`.

created_at*string · date-time

When the custom domain was created (ISO 8601).

Example

Request

POST https://api.auth.productcraft.co/v1/apps/{app_id}/custom-domains
Authorization: Bearer YOUR_TOKEN
Content-Type: application/json

{
  "hostname": "auth.acme.com"
}

Response

{
  "id": "1d2c3b4a-5e6f-4a7b-8c9d-0e1f2a3b4c5d",
  "app_id": "0b6f3c7e-6a43-4c55-9d4b-2a9a7f5b1c11",
  "hostname": "auth.acme.com",
  "status": "pending",
  "serving": false,
  "edge_target": "edge.auth.productcraft.co",
  "dns_zone": "acme.com",
  "dns_provider": {},
  "apply_providers": [
    "cloudflare"
  ],
  "records": [
    {
      "purpose": "routing",
      "type": "CNAME",
      "host": "auth.acme.com",
      "name": "auth",
      "value": "edge.auth.productcraft.co",
      "ttl": 3600,
      "state": "verified",
      "observed": [
        "edge.auth.productcraft.co"
      ],
      "conflicts": [
        {
          "code": "cname_foreign",
          "severity": "blocking",
          "message": "auth.acme.com already points at acme.netlify.app. Change that CNAME to edge.auth.productcraft.co, or use another name.",
          "suggested_value": "edge.auth.productcraft.co"
        }
      ],
      "last_checked_at": "2026-01-01T00:00:00.000Z",
      "verified_at": "2026-01-01T00:00:00.000Z"
    }
  ],
  "callback_urls": {},
  "verified_at": "2026-01-01T00:00:00.000Z",
  "failing_since": "2026-01-01T00:00:00.000Z",
  "last_checked_at": "2026-01-01T00:00:00.000Z",
  "created_at": "2026-01-01T00:00:00.000Z"
}