---
title: Authentication
description: Two credentials, both bearer tokens, and where each one comes from.
---

Two credentials, in two headers. One says which partner you are. The other says
which customer you are acting for.

- **Authorization: Bearer <jwt>** — You. Exchange your partner username and password for it.
- **User-Authorization: Bearer <jwt>** — The customer. Their own token, from their own login.

There is no api-key form in this era, and no way to assert a customer by an
identifier you hold. Both credentials are tokens you have to obtain.

## Getting your token

`POST /api/v1/authenticate` takes your `username` and `password` and answers a
JWT plus a refresh token. Send the JWT as `Authorization: Bearer <jwt>`.

The JWT expires. `POST /api/v1/refresh` takes the `refreshToken` and answers a
new one, so you do not send credentials again on every call. Both of these are
public: they are the calls that get you a credential.

## Getting the customer's token

`POST /api/v1/user/login` logs a customer in and answers their token. It needs
your credential, because you are asking on their behalf.

## Which calls need what

Most calls accept **either** credential. That is unusual and worth reading
twice: these endpoints served a partner's own server and a logged-in customer's
browser through the same route, so either token satisfies them and you send one,
not both.

A smaller set needs only your credential, and a handful need none. Every
endpoint page states which, above its request.

## When it is refused

- **ER802** (401) — Authorization token not found. Nothing usable arrived in either header.
- **ER803** (403) — Multiple authorization methods used. Send one credential, not several.
- **ER806** (401) — API key not found.
- **ER038** (400) — Bad credentials, on the call that exchanges them for a token.
- **ER037** (400) — Refresh token is invalid. Authenticate again rather than refreshing.

Every refusal carries a code, a message and a suggested solution. See the
[error catalogue](https://partner.btcdirect.eu/v2/api/errors.md).
