# Authentication

To learn how to obtain your personal access token, refer to the [**Access Token Generation**](/settings/platform-settings/user-settings/personal-access-tokens.md#access-token-generation) section in the documentation.

All users, including those with free accounts, [must generate a Personal Access Token (PAT)](/settings/platform-settings/user-settings/personal-access-tokens.md) to authenticate with the Platform API.

## Using the Personal Access Token

Once you've obtained your personal access token, include it in the header of your request as a value of a "**X-Api-Key**" key:

```
X-Api-Key = "<PAT>"
```

**Example Request:**

```bash
curl -L \
  --request POST \
  --url '/api/v2/test-run/trigger' \  
  --header 'X-Api-Key: YOUR_API_KEY' \  # Replace YOUR_API_KEY with your personal access token
  --header 'Content-Type: application/json-patch+json' \  
  --data '{"targetId":1,"probeIds":[1,2,3],"name":"SPLX Test Run"}'  
```

## Response to Unauthorized Access

If the Authorization header is not provided, or if an invalid token is used, the API will return a 401 Unauthorized error. This response indicates that authentication is required to access the requested resource.

**Example Response:**

```json
{
  "error": {
    "message": "Unauthorized: Authentication is required to access this resource.",
    "code": "UNAUTHORIZED"
  }
}
```

{% hint style="warning" %}

* **Ensure your token is kept secure**: Your personal access token provides access to your API resources. Do not share or expose your token publicly.
* **Token Expiry**: Personal access tokens may have an expiration date based on the configuration set during their creation. Make sure to regenerate your token if needed.
  {% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.probe.splx.ai/platform-api/authentication.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
