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

# Authentication

> Learn how to authenticate Sharpe API requests with Bearer tokens or API key headers, manage credentials, and handle missing or invalid keys safely.

Authenticated Sharpe API requests under `https://www.sharpe.ai/api/v1/*` require an API key. The API supports two production-safe authentication methods: a Bearer token in the `Authorization` header (recommended) or an `X-API-Key` header. The API is paid-only: a key works while its account has an active [plan](https://www.sharpe.ai/pricing), and there is no free tier and no keyless API.

## Getting your API key

1. Sign in and choose a plan at [/dashboard/billing](https://www.sharpe.ai/dashboard/billing) (Hobbyist, Pro or Commercial; see [Rate limits](https://docs.sharpe.ai/rate-limits.md) for what each includes). Plans are paid in USDC, or any token swapped at checkout, through MoonPay Commerce.
2. Create your key from the [API key dashboard](https://www.sharpe.ai/dashboard/api-keys). Creating a key without an active plan answers `402`.

Each account has one API key. The REST API and the [MCP server](https://docs.sharpe.ai/mcp-server.md) both use it and share the plan's monthly quota.

## A key without an active plan

A key whose plan has ended answers `401` with type `expired_api_key` and the detail "This API key has no active plan. Subscribe or renew at [https://www.sharpe.ai/dashboard/billing](https://www.sharpe.ai/dashboard/billing)." Nothing is charged automatically: renewal reminders arrive on each of the 5 days before the paid period ends, and the key keeps working for 3 days after it. Renew at [/dashboard/billing](https://www.sharpe.ai/dashboard/billing) and the same key works again.

Every account gets one trial before it needs a plan: 7 days and 250 requests, starting with the key's first request (see [Rate limits](https://docs.sharpe.ai/rate-limits.md)). A key issued before 2026-11-11 no longer answers for free: its first request after that day starts the same trial. Once the trial is over the key answers `401` `expired_api_key` with the detail "This account's trial has ended. Choose a plan at [https://www.sharpe.ai/pricing](https://www.sharpe.ai/pricing) and this key works again." until the account has a plan.

Two endpoints need no key: `/v1/health` and `/v1/meta/coverage`.

> [!NOTE]
>
> The full key is shown once immediately after creation. Store it in a secret manager or local environment variable before closing the dialog.

Once you have your key, store it in an environment variable:

```bash Store your key theme={null}
export SHARPE_API_KEY="sk_live_your_key_here"
```

Verify the key works by making a test request:

```bash Verify your key theme={null}
curl -s -o /dev/null -w "%{http_code}\n" \
  https://www.sharpe.ai/api/v1/funding/rates?type=current \
  -H "Authorization: Bearer $SHARPE_API_KEY"
# Should print 200
```

***

## Bearer token (recommended)

Pass your API key as a Bearer token in the `Authorization` header. This is the standard approach and works with most HTTP clients out of the box.

```bash Bearer token authentication theme={null}
curl https://www.sharpe.ai/api/v1/funding/rates?type=current \
  -H "Authorization: Bearer sk_live_your_key_here"
```

## X-API-Key header

As an alternative, you can pass the key in the `X-API-Key` header. This is useful in environments where the `Authorization` header is reserved or stripped by a proxy.

```bash X-API-Key authentication theme={null}
curl https://www.sharpe.ai/api/v1/funding/rates?type=current \
  -H "X-API-Key: sk_live_your_key_here"
```

## Query parameters are not accepted

API keys must not be sent in URLs. Query strings are captured by browser history, server logs, analytics tools, and referrer headers, so `?api_key=` requests are rejected by default. Use `Authorization: Bearer` or `X-API-Key` instead.

## Key format

When both supported authentication methods are present, the API uses this precedence order: `Authorization: Bearer` header > `X-API-Key` header. Only the highest-priority credential is evaluated.

All API keys follow a predictable format so you can identify them in logs and configuration:

| Prefix | Environment | Example |
| - | - | - |
| `sk_live_` | Production | `sk_live_a1b2c3d4e5f6...` |

Keys are 56 characters long including the prefix (8-character prefix + 48 hex characters). Treat them like passwords. Never commit them to source control or expose them in client-side code.

## Rate limit and quota headers

Every authenticated v1 API response includes headers that tell you where you stand against your per-minute rate limit and monthly quota:

**X-RateLimit-Limit** `integer`

Maximum number of requests allowed per minute on your plan.

**X-RateLimit-Remaining** `integer`

Number of requests remaining in the current window.

**X-RateLimit-Reset** `integer`

Unix timestamp (seconds) when the rate limit window resets.

**X-Quota-Limit** `integer`

Monthly request quota of your plan. It resets on the 1st of each month (UTC).

**X-Quota-Remaining** `integer`

Monthly requests remaining in the current billing period.

**X-Quota-Reset** `string`

ISO 8601 timestamp when the monthly quota resets. Included when the quota store returns a reset timestamp.

**X-Request-Id** `string`

Unique identifier for the request. Include this when contacting support.

```bash Example response headers theme={null}
HTTP/2 200
content-type: application/json
x-ratelimit-limit: 120
x-ratelimit-remaining: 118
x-ratelimit-reset: 1743062460
x-quota-limit: 300000
x-quota-remaining: 299812
x-quota-reset: 2026-12-01T00:00:00.000Z
x-request-id: req_abc123def456
```

## Security best practices

* **Rotate keys** regularly and immediately if you suspect a compromise
* **Use environment variables** to store keys instead of hardcoding them
* **Revoke lost keys** from the [API key dashboard](https://www.sharpe.ai/dashboard/api-keys) before creating replacements
* **Restrict by IP** if your plan supports IP allowlisting

[See plans and rate limits](https://docs.sharpe.ai/rate-limits.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.