You can use the Axiom API (Application Programming Interface) to send data to Axiom, query data, and manage resources programmatically. This page covers the basics for interacting with the Axiom API.

Prerequisites

API basics

Axiom API follows the REST architectural style and uses JSON for serialization. You can send API requests to Axiom with curl or API tools such as Postman.

For example, the following curl command ingests data to an Axiom dataset:

curl -X 'POST' 'https://api.axiom.co/v1/datasets/{id}/ingest' \
  -H 'Authorization: Bearer {api_token}' \
  -H 'Content-Type: application/json' \
  -d '[
    {
      "axiom": "logs"
    }
  ]'

Regions

All examples in the Axiom API reference use the base domain https://api.axiom.co, which is the default for the US region. If your organization uses the EU region, change the base domain in the examples to https://api.eu.axiom.co.

For more information on regions, see Regions.

Content type

Encode the body of API requests as JSON objects and set the Content-Type header to application/json. Unless otherwise specified, Axiom encodes all responses (including errors) as JSON objects.

Authentication

To prove that API requests come from you, you must include forms of authentication called tokens in your API requests. Axiom offers two types of tokens:

  • API tokens let you control the actions that can be performed with the token. For example, you can specify that requests authenticated with a certain API token can only query data from a particular dataset.
  • Personal access tokens (PATs) provide full control over your Axiom account. Requests authenticated with a PAT can perform every action you can perform in Axiom. When possible, avoid using PATs.

If you use an API token for authentication, include the API token in the Authorization header.

Authorization: Bearer {token}

If you use a PAT for authentication, include the PAT in the Authorization header and the org ID in the x-axiom-org-id header. For more information, see Determine org ID.

Authorization: Bearer {token}
x-axiom-org-id: {org_id}

If authentication is unsuccessful for a request, Axiom returns the error status code 403.

Data types

Below is a list of the types of data used within the Axiom API:

NameDefinitionExample
IDA unique value used to identify resources.”io12h34io1h24i”
StringA sequence of characters used to represent text.”string value”
BooleanA type of two possible values representing true or false.true
IntegerA number without decimals.4567
FloatA number with decimals.15.67
MapA data structure with a list of values assigned to a unique key.{ “key”: “value” }
ListA data structure with only a list of values separated by a comma.[“value”, 4567, 45.67]