Domains
Add, verify and remove custom domains.
See Custom domains for how verification works.
Add a domain
POST /v1/domains.createDomain
Adds a custom domain to an environment and starts verifying it. The response lists the DNS records to create. The domain serves traffic once it's verified. Verification gives up after 24 hours without the right records.
Permissions: the key needs one of environment.*.create_domain, environment.<environment_id>.create_domain.
Request
| Field | Type | Description |
|---|---|---|
project | string, required | The project, by ID or slug. 3 to 255 characters. |
app | string, required | The app, by ID or slug. 3 to 255 characters. |
environment | string, required | The environment: production, preview, or its ID. 3 to 255 characters. |
domain | string, required | The domain, such as api.example.com, without https://, port or path. It can be used in only one environment of the workspace. 4 to 253 characters. |
curl -X POST https://api.teral.dev/v1/domains.createDomain \
-H "Authorization: Bearer $TERAL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"project": "shop",
"app": "web",
"environment": "production",
"domain": "shop.example.com"
}'Response
On success the status is 200 OK. The fields in data:
| Field | Type | Description |
|---|---|---|
domainId | string | The domain's ID (dom_…). 3 to 255 characters. |
dnsRecords | object[] | The DNS records to create at your provider, already worked out for an apex domain or a subdomain. Create all of them. At least 1 items. |
dnsRecords[].type | string | CNAME for subdomains, ALIAS for apex domains, TXT for the ownership record. ALIAS stands for whatever your provider offers at the apex: ALIAS, ANAME or a flattened CNAME. One of CNAME, ALIAS, TXT. |
dnsRecords[].name | string | The full record name. Providers that want names relative to the zone need the zone removed: in example.com, _teral.api.example.com becomes _teral.api. 1 to 253 characters. |
dnsRecords[].value | string | The value to set, exactly as given. 1 to 512 characters. |
dnsRecords[].ttl | integer | The TTL to set, in seconds. At least 1. |
dnsRecords[].verified | boolean | Whether Teral has seen the record with the right value. Flattened or proxied routing records can stay false even when they work. |
dnsRecords[].note | string | What the record is for, worth showing to whoever edits the DNS. At most 512 characters. |
domainConnect | object | Present when the domain's DNS provider supports Domain Connect. Teral's setup template isn't registered with providers yet, so create the records from dnsRecords instead. |
domainConnect.provider | string | The DNS provider's name, such as Cloudflare. At most 256 characters. |
domainConnect.url | string | A Domain Connect link for the provider. It doesn't work until Teral's template is registered. At most 2048 characters. |
Error statuses: 400, 401, 403, 404, 409, 429, 500. See Errors for the codes behind them.
Get a domain
POST /v1/domains.getDomain
Returns a domain with its verification status and DNS records.
Permissions: the key needs one of environment.*.read_domain, environment.<environment_id>.read_domain.
Request
| Field | Type | Description |
|---|---|---|
domain | string, required | The domain, by name such as api.example.com or by ID. 4 to 253 characters. |
curl -X POST https://api.teral.dev/v1/domains.getDomain \
-H "Authorization: Bearer $TERAL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"domain": "shop.example.com"
}'Response
On success the status is 200 OK. The fields in data:
| Field | Type | Description |
|---|---|---|
id | string | The domain's ID. 3 to 255 characters. |
domain | string | The domain name. 4 to 253 characters. |
projectId | string | The project it belongs to. 8 to 255 characters. |
appId | string | The app it belongs to. 8 to 255 characters. |
environmentId | string | The environment it serves. 8 to 255 characters. |
status | string | pending until the first check, verifying while Teral checks the records, verified once it serves traffic, or failed after 24 hours without the right records. One of pending, verifying, verified, failed. |
verificationError | string | Why the last check didn't succeed, when there's a reason to show. At most 512 characters. |
dnsRecords | object[] | The records the domain needs, each with a verified flag. At least 1 items. |
dnsRecords[].type | string | CNAME for subdomains, ALIAS for apex domains, TXT for the ownership record. ALIAS stands for whatever your provider offers at the apex: ALIAS, ANAME or a flattened CNAME. One of CNAME, ALIAS, TXT. |
dnsRecords[].name | string | The full record name. Providers that want names relative to the zone need the zone removed: in example.com, _teral.api.example.com becomes _teral.api. 1 to 253 characters. |
dnsRecords[].value | string | The value to set, exactly as given. 1 to 512 characters. |
dnsRecords[].ttl | integer | The TTL to set, in seconds. At least 1. |
dnsRecords[].verified | boolean | Whether Teral has seen the record with the right value. Flattened or proxied routing records can stay false even when they work. |
dnsRecords[].note | string | What the record is for, worth showing to whoever edits the DNS. At most 512 characters. |
domainConnect | object | Present when the domain's DNS provider supports Domain Connect. Teral's setup template isn't registered with providers yet, so create the records from dnsRecords instead. |
domainConnect.provider | string | The DNS provider's name, such as Cloudflare. At most 256 characters. |
domainConnect.url | string | A Domain Connect link for the provider. It doesn't work until Teral's template is registered. At most 2048 characters. |
createdAt | integer | When it was created, in Unix milliseconds. |
updatedAt | integer | When it last changed, in Unix milliseconds. Missing if it never changed. |
Error statuses: 400, 401, 403, 404, 429, 500. See Errors for the codes behind them.
List domains
POST /v1/domains.listDomains
Returns the workspace's custom domains, a page at a time. Each filter works on its own.
Permissions: the key needs environment.*.read_domain.
Request
| Field | Type | Description |
|---|---|---|
project | any | Only domains of this project, by ID or slug. |
app | any | Only domains of this app, by ID or slug. |
environment | any | Only domains of this environment, by ID or slug. |
limit | integer | How many results to return in one page. Default 100. 1 to 100. |
cursor | string | The pagination.cursor of the previous response, to get the next page. |
search | string | Only domains whose name or ID contains this text. Not case sensitive. At most 256 characters. |
curl -X POST https://api.teral.dev/v1/domains.listDomains \
-H "Authorization: Bearer $TERAL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"project": "shop"
}'Response
On success the status is 200 OK. The fields in data:
| Field | Type | Description |
|---|---|---|
id | string | The domain's ID. 3 to 255 characters. |
domain | string | The domain name. 4 to 253 characters. |
projectId | string | The project it belongs to. 8 to 255 characters. |
appId | string | The app it belongs to. 8 to 255 characters. |
environmentId | string | The environment it serves. 8 to 255 characters. |
status | string | pending until the first check, verifying while Teral checks the records, verified once it serves traffic, or failed after 24 hours without the right records. One of pending, verifying, verified, failed. |
verificationError | string | Why the last check didn't succeed, when there's a reason to show. At most 512 characters. |
dnsRecords | object[] | The records the domain needs, each with a verified flag. At least 1 items. |
dnsRecords[].type | string | CNAME for subdomains, ALIAS for apex domains, TXT for the ownership record. ALIAS stands for whatever your provider offers at the apex: ALIAS, ANAME or a flattened CNAME. One of CNAME, ALIAS, TXT. |
dnsRecords[].name | string | The full record name. Providers that want names relative to the zone need the zone removed: in example.com, _teral.api.example.com becomes _teral.api. 1 to 253 characters. |
dnsRecords[].value | string | The value to set, exactly as given. 1 to 512 characters. |
dnsRecords[].ttl | integer | The TTL to set, in seconds. At least 1. |
dnsRecords[].verified | boolean | Whether Teral has seen the record with the right value. Flattened or proxied routing records can stay false even when they work. |
dnsRecords[].note | string | What the record is for, worth showing to whoever edits the DNS. At most 512 characters. |
domainConnect | object | Present when the domain's DNS provider supports Domain Connect. Teral's setup template isn't registered with providers yet, so create the records from dnsRecords instead. |
domainConnect.provider | string | The DNS provider's name, such as Cloudflare. At most 256 characters. |
domainConnect.url | string | A Domain Connect link for the provider. It doesn't work until Teral's template is registered. At most 2048 characters. |
createdAt | integer | When it was created, in Unix milliseconds. |
updatedAt | integer | When it last changed, in Unix milliseconds. Missing if it never changed. |
When pagination.hasMore is true, pass pagination.cursor as cursor to get the next page.
Error statuses: 400, 401, 403, 404, 429, 500, 503. See Errors for the codes behind them.
Verify a domain again
POST /v1/domains.verifyDomain
Restarts verification, for example after you fixed a record of a failed domain. The domain goes back to pending and gets another 24 hours.
Permissions: the key needs one of environment.*.verify_domain, environment.<environment_id>.verify_domain.
Request
| Field | Type | Description |
|---|---|---|
domain | string, required | The domain, by name or ID. 4 to 253 characters. |
curl -X POST https://api.teral.dev/v1/domains.verifyDomain \
-H "Authorization: Bearer $TERAL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"domain": "shop.example.com"
}'Response
On success the status is 202 Accepted.
Error statuses: 400, 401, 403, 404, 412, 429, 500. See Errors for the codes behind them.
Remove a domain
POST /v1/domains.deleteDomain
Removes a custom domain. It stops serving the app right away.
Permissions: the key needs one of environment.*.delete_domain, environment.<environment_id>.delete_domain.
Request
| Field | Type | Description |
|---|---|---|
domain | string, required | The domain, by name or ID. 4 to 253 characters. |
curl -X POST https://api.teral.dev/v1/domains.deleteDomain \
-H "Authorization: Bearer $TERAL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"domain": "shop.example.com"
}'Response
On success the status is 200 OK.
Error statuses: 400, 401, 403, 404, 429, 500. See Errors for the codes behind them.