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

# Authentication

> Authenticate Financial Context market-data requests

Financial Context accepts two credential types for external market-data calls:

* API keys created in Financial Context account settings
* OAuth bearer tokens for approved CLI, MCP, or agent clients

Use these Financial Context credentials for API requests.

## API Key Header

```bash theme={null}
curl "https://openapi.fcontext.com/api/market-data/quote?symbols=AAPL.US" \
  -H "x-api-key: YOUR_FCONTEXT_API_KEY"
```

`x-api-key` is the recommended header for server-to-server integrations.

## OAuth Bearer Token

```bash theme={null}
curl "https://openapi.fcontext.com/api/market-data/quote?symbols=AAPL.US" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
```

Bearer tokens must include market-data access for the `market_data` scope.

## JavaScript Example

```javascript theme={null}
const response = await fetch("https://openapi.fcontext.com/api/market-data/quote?symbols=AAPL.US", {
  headers: {
    "x-api-key": process.env.FCONTEXT_API_KEY,
  },
});

if (!response.ok) {
  throw new Error(`Request failed with ${response.status}`);
}

const data = await response.json();
```

## Python Example

```python theme={null}
import os
import requests

response = requests.get(
    "https://openapi.fcontext.com/api/market-data/quote",
    params={"symbols": "AAPL.US"},
    headers={"x-api-key": os.environ["FCONTEXT_API_KEY"]},
    timeout=30,
)
response.raise_for_status()
data = response.json()
```

## Error Responses

| Status | Meaning                                                     |
| ------ | ----------------------------------------------------------- |
| `401`  | Credential is missing, expired, or invalid                  |
| `402`  | A paid plan or remaining data request allowance is required |
| `403`  | Credential is valid but lacks market-data access            |

Rotate keys periodically and revoke keys that are no longer used.
