Azion API
Call the Azion API v6 with a personal token, read its list pages, its asynchronous responses, and its errors, and check the bounds of each request.
An application programming interface (API) lets a program act on a service without its web interface. A REST API gives each object of the service its own URL. The client reads the object with GET, creates it with POST, changes it with PUT or PATCH, and removes it with DELETE. Because every action is an HTTP request, the same call runs from a terminal, a script, or a CI/CD pipeline.
Azion API exposes the resources of your Azion account as a REST API over HTTPS, at the base URL https://api.azion.com/v6. Each request carries a personal token or an access token, and responses return JSON. Besides the resources under /workspace, the API serves deployments, environments, variables, and resource usage at the root of the base URL. Use the Azion API to manage the resources of your account, such as applications, firewalls, and workloads, and to publish versions through releases.
Request structure
A request names a resource path under the base URL and sends the personal token in a header. This request lists the IDs of the workloads in an account:
A 200 returns one page of results:
- Path: most resource endpoints sit under
/v6/workspace/, such as/v6/workspace/workloadsand/v6/workspace/network_lists. Deployments, environments, variables, and resource usage sit at the root, such as/v6/deploymentsand/v6/variables. Login and tokens sit under/v6/account/. - Header:
Authorizationcarries the personal token with theTokenscheme. - Query parameters:
page_size=100asks for up to 100 results on the page, andfields=idkeeps only theidof each result. - List envelope:
countis the number of workloads in the account,total_pagesandpageplace the page in the list, andresultsholds the workloads.nextandpreviousarenullbecause the list has one page.
If you have called a REST API that returns JSON, the model transfers unchanged: a method, a URL, a credential header, and a JSON body. The Azion API reference lists every path, method, parameter, and response. The API serves its OpenAPI specification at https://api.azion.com/v6/openapi/openapi.yaml, which declares version 6.0.0.
Methods and responses
Most endpoints take the same methods, split between a collection path and an item path. The status of a successful response tells whether the change is already done:
- Methods: a collection path, such as
/v6/workspace/network_lists, takesGETto list andPOSTto create. An item path, such as/v6/workspace/network_lists/<network-list-id>, takesGET,PUT,PATCH, andDELETE. Another method returns405with code10007, and theAllowheader of the response lists the methods the path takes. - Version actions: a resource with versions takes a
POSTon the path of each action, such as/v6/workspace/network_lists/<network-list-id>/versions/<version-id>/build. Applications, connectors, custom pages, firewalls, functions, network lists, and WAFs takebuild,cancel, andarchive. Workloads, certificates, CRLs, environments, deployments, and variables takerevert, which clones an archived version and makes the clone active. - Response bodies: a request for one resource returns it inside
data. A variable and a version return their fields at the top level of the body instead, withversion_idandversion_state.
Each operation returns one of four success statuses. The reference lists the status of each operation:
| Status | Meaning |
|---|---|
200 |
The API read, changed, or deleted the resource before it answered. |
201 |
The API created the resource before it answered. |
202 |
The API accepted the request and processes it asynchronously, after it answers. Creating an Application and deleting one return 202, and so do building a version and deleting a version. |
204 |
The API deleted the resource, and the response has no body. Deleting a network list returns 204. |
Errors
An error returns an errors array. Each item carries a code, a title, a detail, and a status written as a string. An item can also carry a source, which names the header or the field at fault, and a meta object with more details:
A request that conflicts with the state of a version returns 409. The code names the conflict:
| Code | Title | Cause |
|---|---|---|
10101 |
Max Drafts Exceeded | The resource has reached its maximum number of draft versions. |
10102 |
Version Deployed | The request changes a version that is in use. |
10105 |
Version Not Editable | The request edits a version that is not in the draft state. |
10106 |
Version Already Built | The version is already built, or its build is in progress. |
10107 |
Version Not Archivable | The version cannot be archived in its current state. |
The versions of a resource return three more errors. A 403 with code 10104 means that resource versioning is not enabled for the account. A 400 with code 10108 means that the resource is not versioned. A 400 with code 10111 names a feature that is not available.
Deployments endpoints also return 409 when a deployment with the same name already exists. They return it too when a request changes the policy of a deployment that has active versions. A release returns 409 while it is building or being removed, when the draft limit is reached, or while its deployment is being deleted.
A Variables endpoint can return 503 with code 10100 while the service is temporarily unavailable. Deployments, Environments, and Resource Usage endpoints can return 504 with code 10067.
Authentication
Every request to the Azion API carries a credential in the Authorization header. A personal token takes the Token scheme:
The API also takes the Bearer scheme, with a personal token or with an access token, as Authorization: Bearer [TOKEN VALUE]. An access token is a JWT that POST /v6/account/auth/login returns, and POST /v6/account/auth/token issues a new one from the refresh token. You create a personal token in Azion Console. To create one, refer to Manage personal tokens.
A request without the header returns 401 with code 10002. Under /v6/workspace/ and /v6/variables, a request whose token the API does not accept returns 401 with code 10001 and the header WWW-Authenticate: Bearer realm="api". Under /v6/deployments, /v6/environments, and /v6/resource_usage, the same request returns 401 with code 10002 and Invalid token in detail.
Pagination and query parameters
A list request returns one page of results, and five query parameters choose which page and what each result holds. The page count comes back in total_pages. next and previous hold the URL of the next and the previous page, or null when no such page exists. To read the following page, send the request in next, or send the same request with page increased by one.
| Parameter | Effect |
|---|---|
page |
Selects one page of the list, counted from 1. |
page_size |
Sets the number of results per page, from 1 to 100. Without it, a list returns 10 results per page. |
fields |
Returns the fields that a comma-separated list names, such as fields=id,name. |
ordering |
Sorts the list by one field, such as ordering=name. A - before the field, as in ordering=-name, reverses the order. The reference lists the fields that each list accepts. |
search |
Narrows the list to the results that match a search term. The reference lists the fields that each list searches, such as name and last_editor. |
On a list whose reference names the accepted fields, an ordering value that names another field returns 400 with code 10088. The meta of the error lists the accepted fields. Lists also take filters of their own, such as name, last_modified__gte, and last_modified__lte.
Limits
A list takes up to 100 results per page. A page_size outside the range from 1 to 100 returns 400 with code 10097. The range is the same on a list of resources and on a list of versions.
Two other bounds return an error past them. A request body larger than a Deployments or Environments endpoint accepts returns 413 with code 10112. A request over the rate the API accepts returns 429 with code 10010. Responses under /v6/workspace/ and /v6/account/ carry the headers X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, and X-RateLimit-Scope, which give the rate limit that applies to the request.