> For the complete documentation index, see [llms.txt](https://docs.ardentresearch.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ardentresearch.xyz/authentication-and-keys.md).

# Authentication and Keys

This page explains authentication for users integrating with the hosted API.

## 1. API key authentication

Protected endpoints require `X-API-Key`.

Header format:

```bash
X-API-Key: <api_key>
```

Protected endpoints:

1. `GET /wallet`
2. `POST /simulate`
3. `POST /execute`
4. `GET /status/:id`

## 2. Payment proof header

For manual payment flow, after you settle payment on-chain, include `X-Payment-Proof` with JSON payload.

Header format:

```bash
X-Payment-Proof: {"request_id":"your_request_id","payer":"0xYourPayer","token":"USDC","chain":"ethereum","tx_hash":"0xYourPaymentTxHash"}
```

Optional field:

1. `request_id` can be included when re-submitting against a specific quote context.

## 3. API key lifecycle

Hosted API users request keys through the onboarding channel.

Security behavior:

1. Keep key secret in server side configuration.
2. Do not hardcode keys in frontend code.
3. Request key rotation if exposure is suspected.

## 4. Recommended local shell setup

For raw curl usage:

```bash
BASE_URL="https://api.ardentresearch.xyz"
API_KEY="ak_your_key"
```

## 5. CLI and MCP server environment variables

The `ardent` CLI and the MCP server both resolve credentials from environment variables, not shell variables.

```bash
export ARDENT_API_KEY="ak_your_key"         # required for protected commands
export ARDENT_BASE_URL="https://api.ardentresearch.xyz"  # optional, shown for reference
```

`ARDENT_BASE_URL` defaults to `https://api.ardentresearch.xyz` when not set. Override it only when pointing at a self-hosted instance or a staging environment.

If `ARDENT_API_KEY` is not exported before running the CLI or starting the MCP server, protected commands will return an authentication error from the API.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.ardentresearch.xyz/authentication-and-keys.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
