Azion API quickstart
Authenticate to the Azion API v6 with a personal token, list your workloads, and create, read, rename, and delete a network list.
This guide instructs you through your first requests to the Azion API.
- Get a personal token to authenticate your requests.
- List the workloads of your account.
- Create a network list.
- Read the network list and rename it.
- Delete the network list and confirm that it is gone.
Every request goes to the base URL https://api.azion.com/v6 and carries your personal token in the Authorization header. The guide creates one object, a network list with one IP address, and links it to nothing else. You delete it in the last stage, so the account ends as it started. For every endpoint, refer to the Azion API reference.
Prerequisites
- An Azion account that uses API v6.
curl, or another HTTP client.
Get a personal token
A personal token authenticates your requests to the Azion API. To create one in Azion Console, refer to Manage personal tokens. Copy the token when Azion Console shows it, because you can only see it when you create it.
The Azion API reads the token from the Authorization header. Every request in this guide sends it in this form:
You have the header that authenticates every request in the next stages.
List your workloads
A list request returns the workloads of your account and confirms that the token works. The response is one page of results.
Send a GET request to the workloads endpoint. The page_size=100 parameter asks for up to 100 workloads on one page, and fields=id returns only the ID of each workload:
A 200 returns the page of workloads:
The count field holds the number of workloads in the account, and results holds the workloads of the page. For pagination, fields, ordering, and search, refer to Azion API.
Create a network list
A network list holds a set of values of one type. The request needs a name, a type, and the items of the list. The type takes ip_cidr, asn, or countries, and items takes from 1 to 20,000 entries. This guide creates an ip_cidr list with one address from the documentation range 192.0.2.0/24.
Send a POST request to the network lists endpoint:
A 201 returns the network list inside data:
The body carries the id, name, type, and items of the list, its last_editor, last_modified, and created_at, and the version_id and version_state of its version. Record the id. The next stages send it in the URL.
Read and rename the network list
Reading the network list returns its current values. A rename changes one field and leaves the others as they are.
Send a GET request to the network list. Replace <network-list-id> with the id the create request returned:
A 200 returns the network list inside data, with the fields of the create response.
To rename the network list, send a PATCH request with the new name only:
A 200 returns the network list inside data, with the new name:
The type and items fields keep the values of the create request, and last_modified changes.
Delete the network list
Deleting the network list returns the account to the state it had before you created the list.
Send a DELETE request to the network list:
A 204 confirms the deletion, and the response has no body.
To confirm the deletion, send the GET request that read the list again. A 404 returns the error envelope:
The network list no longer exists.