Send data to Axiom via API
This page explains how to send to Axiom using the API.
The Axiom REST API accepts the following data formats:
This page explains how to send data to Axiom via cURL commands in each of these formats, and how to send data with the Axiom Node.js library.
For more information on other ingest options, see Send data.
For an introduction to the basics of the Axiom API and to the authentication options, see Introduction to Axiom API.
The API requests on this page use the ingest data endpoint. For more information, see the API reference.
Prerequisites
- Create an Axiom account.
- Create a dataset in Axiom where you send your data.
- Create an API token in Axiom with permissions to update the dataset you have created.
Send data in JSON format
To send data to Axiom in JSON format:
- Encode the events as JSON objects.
- Enter the array of JSON objects into the body of the API request.
- Optional: In the body of the request, set optional parameters such as
timestamp-field
andtimestamp-format
. For more information, see the ingest data API reference. - Set the
Content-Type
header toapplication/json
. - Set the
Authorization
header toBearer API_TOKEN
. ReplaceAPI_TOKEN
with the Axiom API token you have generated. - Send the POST request to
https://api.axiom.co/v1/datasets/DATASET_NAME/ingest
. ReplaceDATASET_NAME
with the name of the Axiom dataset where you want to send data.
Example with grouped events
The following example request contains grouped events. The structure of the JSON payload has the scheme of [ { "labels": { "key1": "value1", "key2": "value2" } }, ]
where the array contains one or more JSON objects describing events.
Example request
- Replace
API_TOKEN
with the Axiom API token you have generated. For added security, store the API token in an environment variable. - Replace
DATASET_NAME
with the name of the Axiom dataset where you want to send data.
Example response
Example with nested arrays
Example request
- Replace
API_TOKEN
with the Axiom API token you have generated. For added security, store the API token in an environment variable. - Replace
DATASET_NAME
with the name of the Axiom dataset where you want to send data.
Example response
Example with objects, strings, and arrays
Example request
- Replace
API_TOKEN
with the Axiom API token you have generated. For added security, store the API token in an environment variable. - Replace
DATASET_NAME
with the name of the Axiom dataset where you want to send data.
Example response
Send data in NDJSON format
To send data to Axiom in NDJSON format:
- Encode the events as JSON objects.
- Enter each JSON object in a separate line into the body of the API request.
- Optional: In the body of the request, set optional parameters such as
timestamp-field
andtimestamp-format
. For more information, see the ingest data API reference. - Set the
Content-Type
header toapplication/x-ndjson
. - Set the
Authorization
header toBearer API_TOKEN
. ReplaceAPI_TOKEN
with the Axiom API token you have generated. - Send the POST request to
https://api.axiom.co/v1/datasets/DATASET_NAME/ingest
. ReplaceDATASET_NAME
with the name of the Axiom dataset where you want to send data.
Example
- Replace
API_TOKEN
with the Axiom API token you have generated. For added security, store the API token in an environment variable. - Replace
DATASET_NAME
with the name of the Axiom dataset where you want to send data.
Example response
Send data in CSV format
To send data to Axiom in JSON format:
- Encode the events in CSV format. The first line specifies the field names separated by commas. Subsequent new lines specify the values separated by commas.
- Enter the CSV representation in the body of the API request.
- Optional: In the body of the request, set optional parameters such as
timestamp-field
andtimestamp-format
. For more information, see the ingest data API reference. - Set the
Content-Type
header totext/csv
. - Set the
Authorization
header toBearer API_TOKEN
. ReplaceAPI_TOKEN
with the Axiom API token you have generated. - Send the POST request to
https://api.axiom.co/v1/datasets/DATASET_NAME/ingest
. ReplaceDATASET_NAME
with the name of the Axiom dataset where you want to send data.
Example request
- Replace
API_TOKEN
with the Axiom API token you have generated. For added security, store the API token in an environment variable. - Replace
DATASET_NAME
with the name of the Axiom dataset where you want to send data.
Example response
Send data with Axiom Node.js
-
Install and configure the Axiom Node.js library.
-
Encode the events as JSON objects.
-
Pass the dataset name and the array of JSON objects to the
axiom.ingest
function.
For more information on other libraries you can use to query data, see Send data.
What’s next
After ingesting data to Axiom, you can query it via API or the Axiom app UI.
Was this page helpful?