> ## Documentation Index
> Fetch the complete documentation index at: https://docs.airmdr.com/llms.txt
> Use this file to discover all available pages before exploring further.

# API Authentication with Token

> API tokens are used to authenticate requests to our API in a secure and stateless way.

## Overview

To access our AirMDR API, you need to authenticate using an API token. API tokens allow your application to interact with our AirMDR API on your behalf without requiring a username and password.

## Generate API Token via AirMDR UI

✨ **Step-by-Step for End Users**

<Steps>
  <Step title="Log in to Your Account">
    1. Navigate to the [AirMDR](https://app.airmdr.com/casesv2) dashboard.
    2. Use your username and password to sign in.
  </Step>

  <Step title="Access API Settings">
    1. In the left navigation pane, click on the User profile/avatar.
    2. Click on **Go to Admin dashboard**.

           <Note>
             Only users with Admin or Super Admin role can view admin dashboard and create token.
           </Note>
    3. Select **API Tokens** from the sidebar menu.\\
           <img src="https://mintcdn.com/airmdr/sh-V_ECLjKGzq_9L/images/APIToken2.png?fit=max&auto=format&n=sh-V_ECLjKGzq_9L&q=85&s=2fec4664b112da316a7a28ac7f75db05" alt="API Token2 Pn" width="556" height="614" data-path="images/APIToken2.png" />
  </Step>

  <Step title="Create a New Token">
    1. Click the **"Create API Token"** button.\\
           <img src="https://mintcdn.com/airmdr/sh-V_ECLjKGzq_9L/images/APIToken3.png?fit=max&auto=format&n=sh-V_ECLjKGzq_9L&q=85&s=3ecf7c19bdf1c0a21fffe3f5b1046a15" alt="API Token3 Pn" width="2954" height="640" data-path="images/APIToken3.png" />
    2. Provide a ***Name*** to the generated API (e.g., "AirMDR App Integration").\\
           <img src="https://mintcdn.com/airmdr/sh-V_ECLjKGzq_9L/images/APIToken6.png?fit=max&auto=format&n=sh-V_ECLjKGzq_9L&q=85&s=bb8c645c80214dce675b6322744f159a" alt="API Token6 Pn" width="992" height="520" data-path="images/APIToken6.png" />
    3. Click **Create**.
  </Step>

  <Step title="Copy the Token">
    <Warning>
      Once created, your API token will be displayed **only once**. You **won’t** be able to see it again!
    </Warning>

    * Click **Copy** and store it securely (e.g., environment variable, secrets manager).\\

          <img src="https://mintcdn.com/airmdr/sh-V_ECLjKGzq_9L/images/APIToken7.png?fit=max&auto=format&n=sh-V_ECLjKGzq_9L&q=85&s=069989e4013fdf0175060d276e966b18" alt="API Token7 Pn" width="828" height="492" data-path="images/APIToken7.png" />

          <Note>
            You can also view the generated API Token, click on **Show Token** button.
          </Note>

          <Tip>
            You can revoke the token access by deleting the token as required

            * Navigate to **API Tokens** from the sidebar menu
            * Use the **Delete** option under ACTION.
          </Tip>

          <img src="https://mintcdn.com/airmdr/sh-V_ECLjKGzq_9L/images/APIToken8.png?fit=max&auto=format&n=sh-V_ECLjKGzq_9L&q=85&s=cb3c7d79fe039543906f2f3965dad4ec" alt="API Token8 Pn" width="1686" height="306" data-path="images/APIToken8.png" />
  </Step>
</Steps>

### 📥 Using the Token

After obtaining your token, include it in the `Authorization` header for subsequent API requests.

<Note>
  All necessary headers (like `Authorization`) are automatically prefilled when you generate a new API token.
</Note>

**cURL Example**:

```

curl --location 'https://app.airmdr.com/airmdrapi/organization' \
--header 'Cookie: Session="<API Token Here>"'
```

### 🔒 Best Practices

* Use HTTPS for all API calls.
* Never share your token publicly (e.g., in GitHub repos).
* Use separate tokens for different environments/projects.
* Delete and regenerate tokens regularly or if you suspect a leak.
* Prefer scoped and expiring tokens for extra security.

### 💡 Tips for Developers

* Handle token expiration gracefully by checking for `401 Unauthorized` responses.
