API workflow

You can use the Linode API to automate any task that you can perform in ​Akamai​'s Cloud Manager. This includes creating and managing all our productsincluding Compute Instances and Firewallsmanaging your customer accountsuch as adding new users or viewing invoicesand even creating support tickets.

Here's a basic curl workflow that deploys a new 2GB compute instance in the Newark data center using the Debian 11 image.

📘

If you complete this workflow, you'll create and be charged for a 2GB compute instance. See Linode Pricing for details on these charges.

1. Get an access token

Authorization for the Linode API is handled through personal access tokens. These tokens grant permissions to read or write to an API operation. All API requests to non-public resources need to be authenticated with an access token.

Check out Personal access tokens for help creating a token.

2. Authenticate requests

Once you've created a personal access token, you need to send it along in the header of most API requests. The header should use the format:

Authorization: Bearer <token-string>

3. Get configuration parameters

To create the new compute instance, you'll need to provide the type (a 2GB compute instance), the image (Debian 11), and the region (Newark) where it'll be located.

📘

These examples use the json_pp utility to process JSON data into a more human-readable format. This is optional. You can remove | json_pp from the operations and the API returns the response without indentation. You can save this output as a file and view it with a JSON-compatible file viewer. To install this utility, see the json_pp documentation.

  1. Review the list of compute instance types and store the id for the applicable one from the responsefor example, g5-standard-2 for a standard 2 GB compute instance.

    curl https://api.linode.com/v4/images/ | json_pp
    
  2. Review the list of image types and store the id for the applicable onefor example, linode/debian11 for a Debian 11 Linux image.

    curl https://api.linode.com/v4/images/ | json_pp
    
  3. Review the list of available data centers (regions) and store the id for the applicable onefor example, us-east for the Newark data center.

    curl https://api.linode.com/v4/regions | json_pp
    

4. Build the final query

Run this operation, populating it with these variable values:

  • <token-string>. Your personal access token.

  • type. Set this to the type id you stored.

  • region. Set this to the data center region you stored.

  • image. Set this to the image id you stored.

  • root_password. Set a root password to use to access your compute instance.

  • label. Set a name for the compute instance.

curl -X POST https://api.linode.com/v4/linode/instances \
    -H "Authorization: Bearer <token-string>" -H "Content-type: application/json" \
    -d '{"type": "g5-standard-2", "region": "us-east", "image": "linode/debian12", "root_pass": "root_password", "label": "prod-1"}'