Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up docs about API basics and authentication #179

Merged
merged 6 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed doc-assets/shots/api-token.png
Binary file not shown.
Binary file removed doc-assets/shots/orgid.png
Binary file not shown.
Binary file removed doc-assets/shots/personal-token.png
Binary file not shown.
Binary file modified doc-assets/shots/rest-orgid-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
268 changes: 0 additions & 268 deletions reference/api.mdx

This file was deleted.

2 changes: 1 addition & 1 deletion reference/settings.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: 'Get started with Settings'
title: 'Get started with settings'
description: 'Learn how to configure your account settings.'
sidebarTitle: 'Overview'
tags:
Expand Down
20 changes: 16 additions & 4 deletions reference/tokens.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ This reference article explains how you can authenticate your requests to the Ax
You can use the Axiom API and CLI to programmatically ingest and query data, and manage settings and resources. For example, you can create new API tokens and change existing datasets with API requests. To prove that these requests come from you, you must include forms of authentication called tokens in your API requests. Axiom offers two types of tokens:

- [API 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)](#personal-access-tokens-pat) provide full control over your Axiom account. Requests authenticated with a PAT can perform every action you can perform in Axiom.
- [Personal access tokens (PATs)](#personal-access-tokens-pat) 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.

<Warning>
Keep tokens confidential. Anyone with these forms of authentication can perform actions on your behalf such as sending data to your Axiom dataset.
Expand Down Expand Up @@ -77,8 +77,6 @@ To regenerate an advanced API token, follow these steps:

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.

To authenticate an API request with a PAT, include the Org ID in the requests. For more information, see [Get started with Axiom API](/restapi/introduction).

### Create PAT

1. Click <img src="/doc-assets/icons/settings.svg" className="inline-icon" alt="Settings icon" /> **Settings > Profile**.
Expand All @@ -91,4 +89,18 @@ To authenticate an API request with a PAT, include the Org ID in the requests. F

1. Click <img src="/doc-assets/icons/settings.svg" className="inline-icon" alt="Settings icon" /> **Settings > Profile**.
2. In the list, find the PAT that you want to delete.
3. To the right of the PAT, click <img src="/doc-assets/icons/delete.svg" className="inline-icon" alt="Delete icon" /> **Delete**.
3. To the right of the PAT, click <img src="/doc-assets/icons/delete.svg" className="inline-icon" alt="Delete icon" /> **Delete**.

## Determine org ID

If you authenticate requests with a PAT, you must include the org ID in the requests. For more information on including the org ID in the request, see [Axiom API](/restapi/introduction) and [Axiom CLI](/reference/cli).

Determine the org ID in one of the following ways:

- Click <img src="/doc-assets/icons/settings.svg" className="inline-icon" alt="Settings icon" /> **Settings**. Copy the org ID in the top right corner. In the example below, the org ID is `axiom-abcd`.

<Frame>
<img src="/doc-assets/shots/rest-orgid-1.png" alt="Axiom org ID" />
</Frame>

- Go to the [Axiom app](https://app.axiom.co/) and check the URL. For example, in the URL `https://app.axiom.co/axiom-abcd/datasets`, the org ID is `axiom-abcd`.
14 changes: 6 additions & 8 deletions restapi/ingest.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ tags: ['axiom documentation', 'documentation', 'axiom', 'axiom api', 'rest api',

This API allows you to send and load data into Axiom. You can use different methods to ingest logs depending on your requirements and log format.

## Authorization and Headers
## Authorization and headers

The only expected headers are the `Authorization: Bearer`, which is your API or personal token. Learn more about [API Token](/reference/tokens) and [Org ID](/restapi/introduction#organization-id).
The only expected header is `Authorization: Bearer` which is your to token to authenticate the request. For more information, see [Tokens](/reference/tokens).

## Using Axiom JS library to ingest data

Expand All @@ -23,14 +23,13 @@ npm install @axiomhq/js

If you use the [Axiom CLI](https://github.com/axiomhq/cli), run `eval $(axiom config export -f)` to configure your environment variables.

Otherwise create a personal token in [the Axiom settings](https://app.axiom.co/profile) and export it as `AXIOM_TOKEN`. Set `AXIOM_ORG_ID` to the organization ID from the settings page of the organization you want to access.
Otherwise, create an [API token](/reference/tokens) and export it as `AXIOM_TOKEN`.

You can also configure the client using options passed to the constructor of the Client:

```ts
const client = new Client({
token: process.env.AXIOM_TOKEN,
orgId: process.env.AXIOM_ORG_ID,
token: process.env.AXIOM_TOKEN
});
```

Expand All @@ -42,8 +41,7 @@ import { Axiom } from '@axiomhq/js';

async function main() {
const axiom = new Axiom({
token: process.env.AXIOM_TOKEN,
orgId: process.env.AXIOM_ORG_ID,
token: process.env.AXIOM_TOKEN
});

await axiom.ingest('my-dataset', [{ foo: 'bar' }]);
Expand All @@ -66,7 +64,7 @@ curl -X 'POST' 'https://api.axiom.co/v1/datasets/$DATASET_NAME/ingest' \
-H 'Content-Type: application/json' \
-d '[
{
"time":"2021-23-04302:11:23.222Z",
"time":"2025-01-12T00:00:00.000Z",
"data":{"key1":"value1","key2":"value2"}
},
{
Expand Down
Loading