Domains
Azion Lib functions of the azion package that create, list, read, update, and delete domains through Azion API v3.
The azion/domains module is the Azion Lib library for Domains. Its functions create, list, read, update, and delete the domains of your account, and each domain points to an application by its ID. The module calls Azion API v3, and every function returns a response envelope.
Install the package:
The azion package receives bug fixes only, and its maintenance ends in December 2026.
The samples on this page are TypeScript ES modules that use top-level await, and they run in Node.js. They import types with import type, which keeps them loadable when the type annotations are stripped.
Authentication
The functions read your personal token from the AZION_TOKEN environment variable. A client created with createClient takes the token in its token field instead.
| Variable | Description |
|---|---|
AZION_TOKEN | Your Azion personal token. |
AZION_DEBUG | With true, turns on debug mode. |
For how the Azion Lib packages resolve the token and the debug setting, refer to How Azion Lib works.
Response envelope
Every function returns an AzionDomainsResponse object, { data?, error? }. On success, data holds the domain, the list of domains, or the deleted domain. On failure, error holds { message, operation }, where operation names the call that failed.
A successful deleteDomain returns data too: an AzionDeletedDomain with the id of the deleted domain.
createClient
Creates a client that holds a token and request options and exposes the five domain functions as methods. createClient is also the default export of the module.
| Parameter | Type | Required | Description |
|---|---|---|---|
token | string | No | Your Azion personal token. |
options | AzionClientOptions | No | Request options for every call the client makes. |
Returns an AzionDomainsClient. Its methods take the same arguments as the matching functions on this page.
This sample creates a client and a domain with it:
Output:
createDomain
Creates a domain that points to an application.
| Parameter | Type | Required | Description |
|---|---|---|---|
domain | AzionCreateDomain | Yes | The settings of the domain. name and edgeApplicationId are required. |
options | AzionClientOptions | No | Request options. |
Returns data as the created AzionDomain. The domain carries the id the API assigned, and url holds the Azion address of the domain.
Output:
getDomains
Lists the domains of the account, one page at a time.
| Parameter | Type | Required | Description |
|---|---|---|---|
options | AzionClientOptions | No | Request options. |
queryParams | { orderBy?, page?, pageSize?, sort? } | No | Pagination. Of these keys, the function sends only page to the API, and every page holds 10 domains. |
Returns data as an AzionDomainCollection: results holds the page, and count holds the number of domains in the account, not the length of the page.
Output:
getDomain
Returns one domain by its ID.
| Parameter | Type | Required | Description |
|---|---|---|---|
domainId | number | Yes | The ID of the domain. |
options | AzionClientOptions | No | Request options. |
Returns data as an AzionDomain.
Output:
updateDomain
Updates a domain by its ID. The function sends a PUT request, and every call carries name and edgeApplicationId.
| Parameter | Type | Required | Description |
|---|---|---|---|
domainId | number | Yes | The ID of the domain to update. |
domain | AzionUpdateDomain | Yes | The settings of the domain. name and edgeApplicationId are required. |
options | AzionClientOptions | No | Request options. |
Returns data as the updated AzionDomain.
Output:
deleteDomain
Deletes a domain by its ID.
| Parameter | Type | Required | Description |
|---|---|---|---|
domainId | number | Yes | The ID of the domain to delete. |
options | AzionClientOptions | No | Request options. |
Returns data as an AzionDeletedDomain with the id of the deleted domain.
Output:
Types
The azion/domains module exports these types. Import them with import type.
AzionDomainsClient
The client that createClient returns.
| Method | Arguments | Returns |
|---|---|---|
createDomain | domain: AzionCreateDomain, options?: AzionClientOptions | Promise<AzionDomainsResponse<AzionDomain>> |
getDomains | options?: AzionClientOptions, queryParams? | Promise<AzionDomainsResponse<AzionDomainCollection>> |
getDomain | domainId: number, options?: AzionClientOptions | Promise<AzionDomainsResponse<AzionDomain>> |
updateDomain | domainId: number, domain: AzionUpdateDomain, options?: AzionClientOptions | Promise<AzionDomainsResponse<AzionDomain>> |
deleteDomain | domainId: number, options?: AzionClientOptions | Promise<AzionDomainsResponse<AzionDeletedDomain>> |
AzionDomainsCreateClient
The type of createClient.
AzionClientOptions
Request options that every function takes in options, and createClient takes for all its calls.
| Property | Type | Required | Description |
|---|---|---|---|
debug | boolean | No | Turns on debug mode. |
force | boolean | No | Declared by the type. No sample on this page uses it. |
AzionDomainsResponse
The envelope every function returns. For how to read it, refer to Response envelope.
| Property | Type | Required | Description |
|---|---|---|---|
data | T | No | The result of the call. |
error | { message: string; operation: string } | No | The error message and the operation that failed. |
AzionDomain
A domain.
| Property | Type | Required | Description |
|---|---|---|---|
name | string | Yes | The name of the domain. |
state | ResponseState | No | The state of the request. |
id | number | No | The ID of the domain. |
url | string | No | The Azion address of the domain. |
environment | string | No | The environment of the domain, such as production. |
active | boolean | No | Whether the domain is active. |
edgeApplicationId | number | No | The ID of the application the domain points to. |
cnameAccessOnly | boolean | No | With true, blocks access through the Azion address of the domain, so only its CNAMEs reach the application. |
cnames | string[] | No | The CNAMEs of the domain. |
edgeFirewallId | number | No | The ID of the firewall of the domain. The API returns null when the domain has none. |
digitalCertificateId | string | number | null | No | The ID of the digital certificate of the domain. |
mtls | { verification; trustedCaCertificateId; crlList? } | No | The mutual TLS settings of the domain. |
mtls.verification | 'enforce' | 'permissive' | Yes | The verification mode of mutual TLS. |
mtls.trustedCaCertificateId | number | Yes | The ID of the trusted CA certificate. |
mtls.crlList | number[] | No | The IDs of the certificate revocation lists. |
AzionCreateDomain
The settings createDomain takes: the AzionDomain properties without id, environment, active, url, and state.
| Property | Type | Required | Description |
|---|---|---|---|
name | string | Yes | The name of the domain. |
edgeApplicationId | number | Yes | The ID of the application the domain points to. |
cnameAccessOnly | boolean | No | With true, blocks access through the Azion address of the domain, so only its CNAMEs reach the application. |
cnames | string[] | No | The CNAMEs of the domain. |
edgeFirewallId | number | No | The ID of the firewall of the domain. |
digitalCertificateId | string | number | null | No | The ID of the digital certificate of the domain. |
mtls | { verification; trustedCaCertificateId; crlList? } | No | The mutual TLS settings of the domain. |
AzionUpdateDomain
The settings updateDomain takes: the AzionDomain properties without id, environment, url, and state. Unlike AzionCreateDomain, it takes active.
| Property | Type | Required | Description |
|---|---|---|---|
name | string | Yes | The name of the domain. |
edgeApplicationId | number | Yes | The ID of the application the domain points to. |
active | boolean | No | Whether the domain is active. |
cnameAccessOnly | boolean | No | With true, blocks access through the Azion address of the domain, so only its CNAMEs reach the application. |
cnames | string[] | No | The CNAMEs of the domain. |
edgeFirewallId | number | No | The ID of the firewall of the domain. |
digitalCertificateId | string | number | null | No | The ID of the digital certificate of the domain. |
mtls | { verification; trustedCaCertificateId; crlList? } | No | The mutual TLS settings of the domain. |
AzionDomainCollection
A page of domains.
| Property | Type | Required | Description |
|---|---|---|---|
state | ResponseState | Yes | The state of the request. |
count | number | Yes | The number of domains in the account. |
pages | number | Yes | The number of pages. |
results | AzionDomain[] | Yes | The domains on the page. |
AzionDeletedDomain
The result of deleteDomain.
| Property | Type | Required | Description |
|---|---|---|---|
id | number | No | The ID of the deleted domain. |
state | ResponseState | No | The state of the deletion. |
ResponseState
The state of a request.