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

# Authentication

{% hint style="warning" %}
**This API is deprecated.**

The Core API is no longer recommended for new integrations. It will remain functional exclusively for existing clients. Migration to the [Connect API](/caf-api/connect/getting_started.md) is strongly recommended.

For more details, see the [Deprecation Policy](/caf-api/deprecation-policy-for-resources.md).
{% endhint %}

## Authentication

To access CAF resources using REST API, you will first need a JWT token. This is a token that CAF provides for authorization and is used by the client when making each API call.

A token is a secret that only the client knows. Like Basic authentication, token-based authentication is only considered secure if used together with other security mechanisms such as HTTPS/SSL.

It is possible to define which scopes the tokens will have access and which actions it can execute in that scope. Use some token that **do not have the required permissions** to access a resource will end up in a **403 "Forbidden"** response, so you must be careful when set your token's permission by verifying which permissions are mandatory for each available resource.

{% hint style="warning" %}
You can create as many tokens as you need, so we recommend setting the minimum permissions necessary for each token.
{% endhint %}

Account users with appropriate permissions will be able to create tokens on the Trust Platform by following the below steps:

### Getting your access token

{% embed url="<https://app.arcade.software/share/XbowwlHpSCtDMLyzs43K>" %}

**Example request headers:**

```json
{
    "Authorization": "Bearer $CAF_TOKEN"
}
```

{% hint style="warning" %}
All calls to the API are authenticated and must have the token next to `Bearer` prefix in the `Authorization` header of the request. Calls with a missing or invalid access token will return code **401 "Unauthorized"**.
{% endhint %}

### Best practices for token-based authentication

To ensure a secure and reliable integration when using token-based authentication with our service, follow these recommended practices and avoid common pitfalls.

#### ✅ Recommended practices

| Practice                                   | Description                                                                        |
| ------------------------------------------ | ---------------------------------------------------------------------------------- |
| **Generate and sign tokens on the server** | Always issue JWTs from your trusted backend system to avoid exposing signing keys. |
| **Use HTTPS for all communications**       | Prevent man-in-the-middle attacks and ensure encryption in transit.                |
| **Monitor token usage and behavior**       | Implement logging and monitoring to detect abnormal or suspicious activity.        |

#### ❌ Unsafe practices

| Practice                                                    | Risk                                                                          |
| ----------------------------------------------------------- | ----------------------------------------------------------------------------- |
| **Generating tokens on the frontend**                       | Exposes your signing keys and compromises the entire authentication system.   |
| **Storing signing keys or secrets in frontend/mobile apps** | Secrets in client-side code can be extracted and misused.                     |
| **Hardcoding secrets in version-controlled code**           | Secrets in code repositories can be leaked or accessed by unauthorized users. |

{% hint style="warning" %}
**Important Notice on Authentication and Integrations**

All integrations with Caf APIs must be implemented exclusively via backend/server-side. Client-side or frontend-based integrations may be blocked and significantly increase the risk of authentication key exposure.

Caf continuously monitors the usage and exposure of authentication keys. Any key identified as exposed, compromised, or used in non-compliant implementations will be immediately revoked, which may result in the interruption of the associated operation, without prior notice.

It is the integrator’s responsibility to ensure compliance with the recommended authentication patterns and security best practices described in this documentation.
{% endhint %}


---

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.caf.io/caf-api/core-api/authentication.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
