Azion API quickstart
Authenticate to the Azion API 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/v4 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.
The Azion CLI gets the same results from the terminal. Each stage shows the API request and the CLI command that matches it. For every endpoint, with request examples in curl and other languages, refer to the Azion API reference.
Prerequisites
CLI
- An Azion account. To create one, refer to Create an account.
- The Azion CLI installed. To install it, refer to Azion CLI quickstart.
Get a personal token
A personal token authenticates your requests to the Azion API and the Azion CLI. 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.
CLI
Save the token in the Azion CLI. Replace [TOKEN VALUE] with your token:
The CLI stores the token in its configuration folder, and later commands use it without the flag. For more information about the CLI configuration, refer to Azion CLI quickstart.
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.
CLI
List the workloads with the Azion CLI. The --page-size 1 flag returns one workload, and --details adds columns:
The command prints one row for the workload:
Without --page-size, azion list workload prints the ID and name of every workload in the account.
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.
CLI
Create the network list with the Azion CLI:
The command prints the ID of the network list:
Record the ID. The next stages pass it to --network-list-id.
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.
CLI
Describe the network list. Replace <network-list-id> with the ID the create command printed:
The command prints the name, the type, the items, and the state of the network list:
Rename the network list:
The command confirms the update:
Describe the network list again:
The output shows the new name and a new Last Modified value, and the type and items are unchanged:
Delete the network list
Deleting the network list returns the account to the state it had before you created the list.
CLI
Delete the network list with the Azion CLI:
The command confirms the deletion:
To confirm the deletion, describe the network list again:
The command exits with status 1 and prints the error:
The network list no longer exists.