/projects/{project_id}/branches/{branch_id}/custom-domainsbetaRegister a custom domain on a branch
Registers a customer-owned domain (for example dashboard.acme.com) on the
branch and points it at a target entity, chosen by entity_type +
entity_id. In v1 only entity_type: function is supported (an
unsupported type is rejected with 400), where entity_id is the function
slug and the function must already exist on the branch (else 404).
The response includes the cname_target the customer must point their
domain at with a CNAME record; the domain goes live only once that DNS
resolves and a certificate is issued on the first request. A domain already
registered to another resource is rejected with 409 and no detail about
the owner. Re-registering the same domain for the same entity is idempotent.
Note: This endpoint is currently in Beta.
Quick start
curl "https://console.neon.tech/api/v2/projects/$PROJECT_ID/branches/$BRANCH_ID/custom-domains" \
-X POST \
-H "Authorization: Bearer $NEON_API_KEY"import { createNeonClient, raw } from '@neon/sdk';
const neon = createNeonClient({ apiKey: process.env.NEON_API_KEY });
const { data } = await raw.registerProjectBranchCustomDomain({
client: neon.client,
path: {
project_id: process.env.PROJECT_ID,
branch_id: process.env.BRANCH_ID
}
});Parameters
project_idThe Neon project ID
branch_idThe Neon branch ID
Request body
3 required Required: domain, entity_type, entity_id.
domainThe custom domain to register (for example dashboard.acme.com).
Case-insensitive; normalized to lowercase (a trailing root dot is
stripped, so the 254-char bound admits a fully-qualified name whose
normalized form is 253 chars). Neon-managed and internal hostnames are
rejected.
≥3 chars, ≤254 chars
entity_typeThe kind of branch entity to point the domain at. v1 supports only
function; any other value is rejected with invalid_entity_type.
≥1 chars, ≤32 chars
entity_idThe target entity's identifier within the branch. For function this
is the function slug (which must already exist on the branch).
≥1 chars, ≤255 chars
Response
201The registered custom domain
Errors
General error
This endpoint can return the standard Neon API error response.
Response fields
messageRequired. Human-readable error message.codeRequired. Machine-readable error code.request_idOptional. Request identifier for debugging. You can provide one with theX-Request-IDheader.
Retry guidance
If no response is returned, the request may still have reached the server. This is why retry safety depends on the method and status code.
Idempotent methods (GET, HEAD, OPTIONS) are generally safe to retry after a network error or timeout. Non-idempotent methods (POST, PATCH, DELETE, PUT) can change state, so avoid automatic retries unless your workflow can tolerate duplicate effects.
Responses with 423 Locked or 503 Service Unavailable are safe to retry. 423 Locked means the resource is temporarily locked, usually because another operation is in progress.








