> For the complete documentation index, see [llms.txt](https://docs.samesystem.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.samesystem.dev/api-v2-reference/getting-authenticated.md).

# Getting authenticated

SameSystem API v2 uses **token-based authentication**. Before accessing protected API endpoints, your integration must authenticate using the dedicated API user provided by SameSystem.

See [**API Access**](/getting-started/api-access.md) for information about requesting an API user.

### Login

Use the **Login** endpoint to authenticate with the API user's credentials.

A successful login returns the authentication token required for subsequent API requests.

For the exact endpoint, request body, and response format, see the [**Login** ](/api-v2-reference/authentication.md)endpoint in the API v2 reference.

### Using the Access Token

After successfully authenticating, include the returned access token when making requests to protected API v2 endpoints.

The token must be sent in the `Authorization` header as a Bearer token:

`Authorization: Bearer <access_token>`

The token is valid for 60 minutes.

Your integration should securely store and reuse the token according to its validity rather than authenticating before every API request.

### Multiple clients

If you have multiple clients and one API user, you will need to login using the clientToken that belongs to the client where your API user is created.


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.samesystem.dev/api-v2-reference/getting-authenticated.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
