Skip to Content

Update Project Domain

Changes the project subdomain on the Zenifra platform.

This operation applies only to HTTP projects with exposure: "public". Private projects do not have a public domain; change the project exposure to public before configuring a subdomain or custom domains.

Required permissions

The minimum scope to change a subdomain or custom domains is project.domain.update on project:<project-id>. An owner session has full access; assistant, member, and organization API Keys need this grant.

PATCH /v1/project/:id/domain

Rate limit: 10 requests per minute (counted per source IP).

Path Parameters

ParameterTypeDescription
idstringProject ID

Headers

HeaderRequiredDescription
x-api-key or AuthorizationYesOrganization API Key or user token
x-organization-idWith a user tokenActive project organization. Not needed with an organization API key
Content-Type: application/jsonYesRequired because the request has a JSON body

Body

FieldTypeRequiredDescription
domainstringYesNew subdomain (3–54 characters, lowercase letters, numbers, and internal hyphens)

Example

{
  "domain": "my-subdomain"
}

Response

{
  "status": "success",
  "message": "updated with success"
}

Errors

StatusWhen it happens
400Missing or invalid domain (length, characters, hyphen at the start/end, or a reserved name)
403The project plan does not allow a custom subdomain
404Project not found
409The project is private (project is not publicly exposed) or the requested subdomain is already in use (DOMAIN_UNAVAILABLE)
409PROJECT_STATE_CONFLICT: the project is not running, stopped, or failing, or does not have a public route yet (for example, a Git project before its first build)
409PROJECT_OPERATION_IN_PROGRESS: another domain, exposure, or lifecycle operation is in progress for the project; wait and try again
422PROJECT_OPERATION_NOT_SUPPORTED: the project is not an HTTP application
500The change could not be applied; the previous address is kept and you can try again

Sending the subdomain the project already uses returns 200 without changing anything.


Custom domains

Sets the project's list of custom domains.

PATCH /v1/project/:id/custom-domains

Accepts a user session or an organization API Key and requires project.domain.update on project:<project-id>. Rate limit: 10 requests per minute (counted per source IP).

The body is the complete list

custom_domains replaces the project's whole list. Any domain left out of the list is removed and stops responding. To add a domain, send the current domains plus the new one; read the current list first with GET /v1/project/:id/custom-domains. Each call accepts at most one new domain.

Body

FieldTypeRequiredDescription
custom_domainsarray of stringsYesComplete list of the project's domains (maximum 20). Domains not in the list are removed
{
  "custom_domains": ["example.com", "www.example.com"]
}

Each call can add at most one new domain (only one custom domain can be added at a time); removing several at once is allowed. Zenifra's own domains are rejected.

Response

{
  "status": "success",
  "message": "custom domains updated with success",
  "custom_domains": ["example.com", "www.example.com"],
  "custom_domain_setup": [
    {
      "hostname": "www.example.com",
      "kind": "subdomain",
      "status": "pending",
      "ssl_status": "pending_validation",
      "certificate": "waiting_dns",
      "dns_records": [
        {
          "type": "CNAME",
          "name": "www.example.com",
          "value": "my-app.clients.zenifra.com",
          "purpose": "routing",
          "found": [],
          "verdict": "missing"
        }
      ],
      "verification_issues": []
    }
  ]
}

custom_domain_setup contains only the domain added in this call, in the same format as the read endpoint. The validation TXT records may take a few seconds to appear; call the GET right after to get the full list of records.

Errors

StatusWhen it happens
400Invalid body, reserved domain, or more than one new domain in the same call
404Project not found
409The project is private (project is not publicly exposed), or the domain is already in use by another project (DOMAIN_UNAVAILABLE)
409PROJECT_STATE_CONFLICT: the application does not have a public route yet (for example, a Git project before its first build)
409PROJECT_OPERATION_IN_PROGRESS: another domain, exposure, or lifecycle operation is in progress for the project
422PROJECT_OPERATION_NOT_SUPPORTED: the project is not an HTTP application
500The list could not be applied (failed to update custom domains); check the list with the GET and try again

Read custom domains

Lists the project's custom domains with the DNS records each one needs, what was already found in DNS, and the HTTPS certificate progress.

GET /v1/project/:id/custom-domains

Accepts a user session or an organization API Key and requires project.read on project:<project-id>. Rate limit: 30 requests per minute (counted per source IP).

Path Parameters

ParameterTypeDescription
idstringProject ID

Headers

HeaderRequiredDescription
x-api-key or AuthorizationYesOrganization API Key or user token
x-organization-idWith a user tokenActive project organization. Not needed with an organization API key

Response

{
  "status": "success",
  "custom_domain_setup": [
    {
      "hostname": "example.com",
      "kind": "apex",
      "status": "active",
      "ssl_status": "active",
      "certificate": "active",
      "dns_records": [
        {
          "type": "A",
          "name": "@",
          "value": "203.0.113.10",
          "purpose": "routing",
          "found": ["203.0.113.10"],
          "verdict": "ok"
        }
      ],
      "verification_issues": []
    },
    {
      "hostname": "www.example.com",
      "kind": "subdomain",
      "status": "pending",
      "ssl_status": "pending_validation",
      "certificate": "waiting_dns",
      "dns_records": [
        {
          "type": "CNAME",
          "name": "www.example.com",
          "value": "my-app.clients.zenifra.com",
          "purpose": "routing",
          "found": ["my-app.clients.zenifra.com"],
          "verdict": "ok"
        },
        {
          "type": "TXT",
          "name": "_acme-challenge.www.example.com",
          "value": "kX3v9QpL2mN8rT4wY7zB1cD6fH0jK5sU",
          "purpose": "certificate_validation",
          "found": [],
          "verdict": "missing"
        }
      ],
      "verification_issues": []
    }
  ]
}

A project without custom domains returns 200 with "custom_domain_setup": []. The sample values above are fictitious: always use the ones the API returns for your project.

Domain fields

FieldDescription
hostnameThe custom domain
kindsubdomain (such as www.example.com) or apex (root domain, such as example.com)
certificateHTTPS certificate progress. This is the field to check whether the domain is ready (see the table below)
statusDomain validation state, such as pending or active. Informational
ssl_statusDetailed certificate state, such as pending_validation or active. Informational
dns_recordsDNS records the domain needs at your DNS provider
verification_issuesProblems found during validation; empty when there are none
certificateMeaning
activeCertificate issued; the domain already answers over HTTPS
issuingAll DNS records are correct; the certificate is being issued
waiting_dnsA record in dns_records still needs to be created or fixed
blocked_by_access_restrictionAccess to the application is restricted to an IP list, which prevents issuance. Allow access from any IP in Network access

DNS record fields

FieldDescription
typeCNAME, A, AAAA, or TXT
nameRecord name. @ means the root domain itself
valueValue to create. null when the record must be deleted (verdict: "remove") or when there is no value to show yet
purposerouting (sends traffic to the application), domain_validation (proves you own the domain), or certificate_validation (allows the certificate to be issued)
foundValues currently found in public DNS for that name. [] when it does not exist; null when the DNS lookup failed at that moment
verdictok (correct record), missing (create the record with value), remove (delete the record with the value in found), or unknown (could not be checked now; read again)

Subdomains get a CNAME plus the validation TXT records; the same name may have more than one TXT, and all of them must be created. A root domain gets an A record on @; A or AAAA records other than the expected one show up with verdict: "remove".

verification_issuesWhat to do
cname_requiredThe domain's CNAME does not point to the expected value. Fix the CNAME record
verification_failedDomain validation failed. Check every record in dns_records
apex_readd_requiredRoot domain added before automatic setup. Remove the domain from the list and add it again to get the A record

Errors

StatusWhen it happens
400Invalid project id
401Missing or invalid credential
403The credential does not have project.read on the project
404Project not found (project not exists)
429Rate limit exceeded
502The domain status could not be read right now (failed to get custom domains setup); try again

Automate domain setup

To add domains from a script without deleting the existing ones:

  1. Read the current list with GET /v1/project/:id/custom-domains and keep the hostname values from custom_domain_setup.
  2. Add one domain with PATCH /v1/project/:id/custom-domains, sending the current list plus the new domain. One new domain per call.
  3. Get the DNS records with the GET and pick the item whose hostname is the new domain. If the TXT records are not there yet, repeat the GET after a few seconds.
  4. Create the records at your DNS provider: every item in dns_records with verdict: "missing", using exactly its type, name, and value. Delete the ones with verdict: "remove".
  5. Repeat the GET (for example, every 30 seconds, within the limit of 30 per minute) until certificate is active. While it is waiting_dns, check the records whose verdict is not ok.

Do not remove and re-add the same domain to get the records again. Each new registration changes the TXT values, and the records already created at your provider stop being valid. Use the GET.

# 1. Current list
curl -s "https://api.zenifra.com/v1/project/507f1f77bcf86cd799439011/custom-domains" \
  -H "x-api-key: your-api-key"

# 2. Current list + new domain
curl -X PATCH "https://api.zenifra.com/v1/project/507f1f77bcf86cd799439011/custom-domains" \
  -H "x-api-key: your-api-key" \
  -H "Content-Type: application/json" \
  -d '{"custom_domains": ["example.com", "www.example.com"]}'

# 3 and 5. DNS records and certificate progress
curl -s "https://api.zenifra.com/v1/project/507f1f77bcf86cd799439011/custom-domains" \
  -H "x-api-key: your-api-key"

To set up the records in the Console, see Custom domains.


Examples

curl -X PATCH "https://api.zenifra.com/v1/project/507f1f77bcf86cd799439011/domain" \
  -H "x-api-key: your-api-key" \
  -H "x-organization-id: your-organization-id" \
  -H "Content-Type: application/json" \
  -d '{"domain": "my-subdomain"}'

Python

import requests

API_KEY = "your-api-key"
ORGANIZATION_ID = "your-organization-id"
PROJECT_ID = "507f1f77bcf86cd799439011"

response = requests.patch(
    f"https://api.zenifra.com/v1/project/{PROJECT_ID}/domain",
    headers={"x-api-key": API_KEY, "x-organization-id": ORGANIZATION_ID},
    json={"domain": "my-subdomain"}
)
print(response.json())

Domain Rules

  • Minimum of 3 characters
  • Maximum of 54 characters
  • Lowercase letters, numbers, and internal hyphens only
  • Cannot start or end with hyphen
  • Reserved platform names are rejected with 400, such as admin, ai, api, app, auth, clients, console, docs, mail, managed, mcp, status, and www; automatic naming also skips them
  • The requested subdomain is reserved exactly as provided; if it is already in use, the API returns 409 instead of silently renaming it
  • The resulting Zenifra default domain uses the clients.zenifra.com zone
  • Private HTTP projects (exposure: "private") do not receive a subdomain and cannot update a public domain

Last updated on

On this page