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

# Headers & Authentication

> Base URL, authentication, and optional request headers for the Tavily API.

## Base URL

The base URL for all requests to the Tavily API is:

```plaintext theme={null}
https://api.tavily.com
```

## Authentication

All Tavily endpoints are authenticated using API keys.
[Get your free API key](https://app.tavily.com).

```bash theme={null}
curl -X POST https://api.tavily.com/search \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer tvly-YOUR_API_KEY" \
  -d '{"query": "Who is Leo Messi?"}'
```

## Project Tracking

You can optionally attach a Project ID to your API requests to organize and track usage by project. This is useful when a single API key is used across multiple projects or applications.

To attach a project to your request, add the `X-Project-ID` header:

```bash theme={null}
curl -X POST https://api.tavily.com/search \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer tvly-YOUR_API_KEY" \
  -H "X-Project-ID: your-project-id" \
  -d '{"query": "Who is Leo Messi?"}'
```

**Key features:**

* An API key can be associated with multiple projects
* Filter requests by project in the [/logs endpoint](/documentation/api-reference/endpoint/logs) and platform usage dashboard
* Helps organize and track where requests originate from

> [!NOTE]
>
> When using the SDKs, you can specify a project using the `project_id`
> parameter when instantiating the client, or by setting the `TAVILY_PROJECT`
> environment variable.

## Session Tracking

You can optionally include session and anonymized user identifiers in your API requests as HTTP headers. Tavily uses these identifiers for attribution and analytics across multi-step user interactions and agent workflows.

```bash theme={null}
curl -X POST https://api.tavily.com/search \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer tvly-YOUR_API_KEY" \
  -H "X-Session-Id: 5874812a-2e9b-43ea-8978-6cc9225b587b" \
  -H "X-Human-Id: h_4f9ac" \
  -d '{"query": "Who is Leo Messi?"}'
```

**Headers:**

* `X-Session-Id` — opaque identifier for a session of related requests. Lets you group multiple calls together (e.g. all requests from one user task or conversation).
* `X-Human-Id` — opaque identifier for the end-user behind the request. Useful when a single API key serves many human users — it helps Tavily better understand multi-step interactions and improve response quality. For security, Tavily hashes human IDs before processing or storing them.

> [!NOTE]
>
> When you use the Tavily MCP server or remote MCP server, `X-Session-Id` is
> populated automatically — you don't need to set it yourself. `X-Human-Id`
> can't be generated by the MCP server on its own, so it's only forwarded if
> your agent or developer provides it. See the
> [MCP documentation](/documentation/mcp) for details.
