---
title: Authentication
description: Two credentials, two headers. Yours identifies you; the customer's identifies who you are acting for.
---

A request carries **your** credential. A request that acts for one of your
customers carries **theirs as well**, in a separate header. Both go on the
same call.

## Your credential

Send exactly one of these. Every v3 endpoint requires it, except the one that
issues a token.

- **x-api-key: <key>** (Simplest) — Issue as many as you need under an integration, and rotate or revoke them yourself in the console.
- **Authorization: Bearer <token>** — Exchange your partner username and password at POST /api/v3/auth/tokens for a token, and send that.

A token expires. `POST /api/v3/auth/tokens/refresh` gives you a new one
without sending the password again.

> **Send one, never both**
>
> Sending `x-api-key` and `Authorization` on the same request answers `403`. It
> is not resolved by picking one for you. Sending neither answers `401`.

## The customer's credential

Only calls that act for a customer need this layer: creating a quote or an
order, reading a customer's orders or profile, and similar. Whether a given
endpoint needs it, and whether it will run without it, is stated on that
endpoint's own page.

- **User-Authorization: Bearer <token>** (They log in) — The token from POST /api/v3/users/login. The customer authenticated themselves.
- **User-Identifier: <your id>** (You assert) — Your own identifier for that customer. We resolve it against your partner account, so no customer login is involved.

**Which one you use is a product decision, not a technical one.** A customer
session means the customer proved who they are to us. An identifier means you
are vouching for them, on your own authority, and it only resolves within your
own account.

Sending both on the same request is fine: `User-Authorization` wins and
`User-Identifier` is ignored, never the reverse.

> **An identifier is a claim, not a secret**
>
> `User-Identifier` says "this is my user number 4821". Anyone who can send
> requests with your partner credential can therefore act as any of your
> customers. That is the point of it, and the reason your api key is the thing
> to protect.

## Acting for a business

A customer who represents a business can act as themselves or as that
business. `PUT /api/v3/users/me/acting-context` switches between them, and a
delegated call can assert it directly with a `Business-Identifier` header
alongside `User-Identifier`. See
[act as a business](https://partner.btcdirect.eu/v3/api/switch-acting-context.md).

No endpoint accepts an acting-as field in its body. The context always comes
from the credential, never from a field you send alongside it.

## What 401 and 403 mean

`401` means a credential is missing or wrong: no partner credential where one
is required, no authenticated customer where one is required, or, on the two
calls that exchange credentials for a token (`/auth/tokens`, `/users/login`),
a wrong username, password, or email in the request body itself.

`403` means both credentials were understood, but the request is not allowed
for that identity. Three cases produce it today: sending `x-api-key` and
`Authorization` together, switching to a business you do not represent, and
pointing an order at a payment instrument that belongs to someone else.

An authentication failure answers a code and a message, for example
`{"code": "ER802", "message": "Authorization token not found."}`. Branch on the
status; the message is prose and can be reworded at any time.

## Keeping them apart

Sandbox and production credentials are separate and not interchangeable. See
[base URLs](https://partner.btcdirect.eu/v3/api/base-urls.md).
