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

# Authentication

Pactum utilizes **OAuth 2.0** to secure our APIs. Two different authentication approaches are supported: Client Credentials and Private JWT Key flow.

### Client Credentials

The **Client Credentials Flow** is a method for a client application to securely obtain an access token to call an API on its own behalf. This flow is used for **machine-to-machine (M2M)** communications, such as a backend service fetching data from another service.

The process involves the customer generating credentials —a **client ID** and a **client secret**— through Pactum Negotiations Suite. To use the credentials, they are sent to the authorization server's token endpoint. With valid credentials, the authorization server issues an access token to the client. The client can then use this token to authenticate itself when making requests to the API, proving it has the right to access the requested resources.

More detailed instructions on how to create credentials are available on the linked page

{% content-ref url="/pages/VrM074KjoO0Bf22PDNxt" %}
[Client Credentials](https://docs.eu-pactum.com/procurement-api/api-authentication/client-credentials.md)
{% endcontent-ref %}

### Private Key JWT

Pactum allows using a **Private Key JWT** for authentication, providing a secure method for clients to access its API. Instead of a static client secret, this process requires the client to create and sign a JSON Web Token (JWT) with a private key, which Pactum then verifies using a corresponding public key.

The authentication process involves the following key steps:

1. **Prerequisites:** Before authenticating, the client must:
   * Generate a 2048-bit to 4096-bit RSA key pair (a private and a public key).
   * Share the **public key** (in PEM format) with the Pactum team.
   * Receive a **Client ID** and an **Audience URL** from Pactum.
2. **Build a Client Assertion:** The client creates a short-lived (max 5 minutes recommended) JWT, known as the client assertion. This token must contain specific claims including the client ID (`iss` and `sub`), the audience URL (`aud`), and a unique token ID (`jti`). This JWT is then signed using the client's **private key**.
3. **Exchange for an Access Token:** The client sends this signed JWT assertion to the Pactum OAuth token endpoint. Pactum validates the JWT's signature using the previously shared public key.
4. **Call the API:** Upon successful validation, Pactum returns an `access_token`. This token must be included as a Bearer token in the `Authorization` header for all subsequent calls to the Pactum API.

More detailed instructions on how to generate an RSA key-pair are on the linked page

{% content-ref url="/pages/r29BwJtu9srup0Thrsjz" %}
[RSA key-pair](https://docs.eu-pactum.com/procurement-api/api-authentication/rsa-key-pair.md)
{% endcontent-ref %}
