Add Domain
Last updated Changelog
On this page
POST /crates/{handle}/domains
Adds one of the customer’s subdomains to the crate. Point it at the crate first, or after, with a CNAME record to the crate’s cname_target (Get Crate‘s hostname); on Cloudflare, with the proxy off. Its CNAME is checked at once: already pointing at the crate, it’s served straight away (status active); otherwise it’s pending and checked again every 15 minutes, or with Check Domain.
A crate has up to 10 domains. A bare domain (example.com) can’t be added, as a CNAME can’t sit at a zone’s apex. The CNAME has to be to the crate’s own hostname: the server’s name is shared by every crate on it, so it proves nothing. Other crates can wait for the same name; the one its CNAME points at is served, and taken off any crate that served it before. A domain still pending 7 days after it was added is removed.
Parameters
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| hostname | string | Yes | A subdomain you control, like files.example.com |
|
| login | string | No | none | One sub-user’s full name (<handle>-<name>): the domain admits only that sub-user. Left out, it serves every login in the crate |
Response (201)
The domain, as in List Domains.
Errors
Besides the errors any endpoint can return:
| Status | Code | When |
|---|---|---|
| 400 | limit_reached |
The crate already has 10 domains (limit says how many). |
| 400 | operation_rejected |
The server behind the API (mail, database, storage) or the registrar refused the operation. error says why. |
| 403 | scope_denied |
This API key does not have Crates write access for this crate. |
| 403 | service_inactive |
This crate is not active. |
| 404 | not_found |
Crate not found. |
| 409 | conflict |
The crate already has that domain. |
| 422 | validation_failed |
The hostname isn’t a subdomain, is one of ours, login isn’t one of the crate’s sub-users, or the crate has no hostname of its own yet. |
| 502 | upstream_unavailable |
This crate has no storage node. |