# API

Spindl's Server-to-Server API provides access to campaign and attribution management, and allows easy exporting of data and reports.

## API Key

If you don't already have an API key, you can generate one on the [Settings](https://app.spindl.xyz/settings) page in the Spindl app.

{% hint style="warning" %}
API keys are different from your SDK keys. Please be sure to keep your API access tokens secure and private! Do not share them in emails, client-side code or publicly accessible sites.

If you have accidentally shared an API access token publicly, you can revoke it in your [Settings](https://app.spindl.xyz/settings) by clicking the X button beside the token.
{% endhint %}

## Authentication

API requests are authenticated using the `X-API-Key` header. With the API token from the previous step, calling the Spindl API is as simple as:

```bash
curl -H "X-API-Key: <your_api_key>" https://api.spindl.xyz/v1/links
```

## Errors

Spindl uses HTTP response codes to indicate the success or failure of an API request.

* Codes in the `2xx` range indicate success
* Codes in the `4xx` range indicate incorrect or incomplete requests (e.g. a required parameter was omitted)
* Codes in the `5xx` range indicate an error on Spindl's servers.

On error responses, Spindl also provides error messages and code in the response body:

```json
{
    "statusCode": 404,
    "message": "link not found"
}
```


---

# 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.spindl.xyz/spindl/techncial/api.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.
