Teral

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

FieldTypeDescription
projectstring, requiredThe project, by ID or slug. 3 to 255 characters.
appstring, requiredThe app, by ID or slug. 3 to 255 characters.
environmentstring, requiredThe environment: production, preview, or its ID. 3 to 255 characters.
domainstring, requiredThe 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:

FieldTypeDescription
domainIdstringThe domain's ID (dom_…). 3 to 255 characters.
dnsRecordsobject[]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[].typestringCNAME 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[].namestringThe 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[].valuestringThe value to set, exactly as given. 1 to 512 characters.
dnsRecords[].ttlintegerThe TTL to set, in seconds. At least 1.
dnsRecords[].verifiedbooleanWhether Teral has seen the record with the right value. Flattened or proxied routing records can stay false even when they work.
dnsRecords[].notestringWhat the record is for, worth showing to whoever edits the DNS. At most 512 characters.
domainConnectobjectPresent 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.providerstringThe DNS provider's name, such as Cloudflare. At most 256 characters.
domainConnect.urlstringA 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

FieldTypeDescription
domainstring, requiredThe 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:

FieldTypeDescription
idstringThe domain's ID. 3 to 255 characters.
domainstringThe domain name. 4 to 253 characters.
projectIdstringThe project it belongs to. 8 to 255 characters.
appIdstringThe app it belongs to. 8 to 255 characters.
environmentIdstringThe environment it serves. 8 to 255 characters.
statusstringpending 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.
verificationErrorstringWhy the last check didn't succeed, when there's a reason to show. At most 512 characters.
dnsRecordsobject[]The records the domain needs, each with a verified flag. At least 1 items.
dnsRecords[].typestringCNAME 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[].namestringThe 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[].valuestringThe value to set, exactly as given. 1 to 512 characters.
dnsRecords[].ttlintegerThe TTL to set, in seconds. At least 1.
dnsRecords[].verifiedbooleanWhether Teral has seen the record with the right value. Flattened or proxied routing records can stay false even when they work.
dnsRecords[].notestringWhat the record is for, worth showing to whoever edits the DNS. At most 512 characters.
domainConnectobjectPresent 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.providerstringThe DNS provider's name, such as Cloudflare. At most 256 characters.
domainConnect.urlstringA Domain Connect link for the provider. It doesn't work until Teral's template is registered. At most 2048 characters.
createdAtintegerWhen it was created, in Unix milliseconds.
updatedAtintegerWhen 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

FieldTypeDescription
projectanyOnly domains of this project, by ID or slug.
appanyOnly domains of this app, by ID or slug.
environmentanyOnly domains of this environment, by ID or slug.
limitintegerHow many results to return in one page. Default 100. 1 to 100.
cursorstringThe pagination.cursor of the previous response, to get the next page.
searchstringOnly 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:

FieldTypeDescription
idstringThe domain's ID. 3 to 255 characters.
domainstringThe domain name. 4 to 253 characters.
projectIdstringThe project it belongs to. 8 to 255 characters.
appIdstringThe app it belongs to. 8 to 255 characters.
environmentIdstringThe environment it serves. 8 to 255 characters.
statusstringpending 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.
verificationErrorstringWhy the last check didn't succeed, when there's a reason to show. At most 512 characters.
dnsRecordsobject[]The records the domain needs, each with a verified flag. At least 1 items.
dnsRecords[].typestringCNAME 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[].namestringThe 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[].valuestringThe value to set, exactly as given. 1 to 512 characters.
dnsRecords[].ttlintegerThe TTL to set, in seconds. At least 1.
dnsRecords[].verifiedbooleanWhether Teral has seen the record with the right value. Flattened or proxied routing records can stay false even when they work.
dnsRecords[].notestringWhat the record is for, worth showing to whoever edits the DNS. At most 512 characters.
domainConnectobjectPresent 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.providerstringThe DNS provider's name, such as Cloudflare. At most 256 characters.
domainConnect.urlstringA Domain Connect link for the provider. It doesn't work until Teral's template is registered. At most 2048 characters.
createdAtintegerWhen it was created, in Unix milliseconds.
updatedAtintegerWhen 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

FieldTypeDescription
domainstring, requiredThe 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

FieldTypeDescription
domainstring, requiredThe 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.

Edit on GitHub

On this page