> For the complete documentation index, see [llms.txt](https://docs.damisa.xyz/AkjkmImZjoUgeLkiUdam/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.damisa.xyz/AkjkmImZjoUgeLkiUdam/developer-guides/authentication.md). Agents can also search and read this documentation through its [MCP server](https://docs.damisa.xyz/AkjkmImZjoUgeLkiUdam/~gitbook/mcp).

# Authentication

How to obtain an API key and use it to authenticate against the Damisa API.

### Authorization

The Damisa API uses API keys. Every request must include the key in the `Authorization` header:

```http
Authorization: Bearer <your-api-key>
```

API keys are the only credential accepted by the public API — there is no OAuth flow for 3rd-party integrators, and `X-API-Key`/other custom headers are not used.

### How to create an API key

API keys are managed from the Damisa Portal.

#### **Open the developer settings**

1. Log in to the Damisa Portal.
2. Click the **user profile icon** in the top right and select **Developers** from the menu.

<figure><img src="https://829585684-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8TOkwwAxAnNqhyOVY5J5%2Fuploads%2F5I3YXsQdWwKDlcfvW5xt%2Fsettings-developers.png?alt=media&amp;token=ddb87839-77fa-4a95-8bf6-28bc2a2e474d" alt="Developers menu entry under the profile icon"><figcaption></figcaption></figure>

#### **Add a new key**

1. Click **Add token**.
2. Give the key a recognizable name (e.g. `production-payouts`) so you can tell your keys apart later.
3. Select the **permissions** the key needs — see the list below. Pick the minimum set required for what the integration will do.
4. Click **Add API Key**.

<figure><img src="https://829585684-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8TOkwwAxAnNqhyOVY5J5%2Fuploads%2FapjiKNMDbKFgtbdBYWfT%2Fadd-api-key.png?alt=media&amp;token=8d679f09-1339-474e-90e0-b11d54580486" alt="Add token form"><figcaption></figcaption></figure>

#### **Copy and store the key**

The full key value is shown **once**, immediately after creation. Copy it now and store it in your secret manager — Damisa cannot show it again later.

If you lose the key, delete it from the developer settings and create a new one.

> Each organization can hold up to **10 active keys**. Delete keys you no longer use from the same screen.

### Permissions

When you create a key you choose which actions it is allowed to perform. The available permissions for API keys are:

| Permission               | What it allows                                         |
| ------------------------ | ------------------------------------------------------ |
| `create:payment_request` | Create payment requests                                |
| `create:payout`          | Create and confirm payouts                             |
| `manage:contact_book`    | Create, list and update contacts and external accounts |
| `manage:webhook`         | Create, list and delete webhook subscriptions          |

A request that hits an endpoint requiring a permission your key does not hold returns **403 Forbidden** with error code `missing_permissions`.

> API keys can only be **created** from a logged-in Portal session — not via the API itself. This is intentional: every credential is tied to a real user in your organization.

Permissions only gate **write operations** (creating contacts, payouts, webhooks, etc.). All authenticated tokens can call **read** endpoints (list accounts, get transactions, list webhooks, …) regardless of which permissions they hold.

### Using your key

Add the `Authorization` header to every request:

```bash
curl https://api.damisa.xyz/api/v1/contacts \
  -H "Authorization: Bearer dms_live_xxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "Idempotency-Key: $(uuidgen)"
```

All `POST` endpoints additionally require an `Idempotency-Key` header — a unique UUID for the operation. Re-sending the same request body with the same key returns the original response and never executes the operation twice.

### Authentication errors

| HTTP | Code                         | Meaning                                            |
| ---- | ---------------------------- | -------------------------------------------------- |
| 401  | `auth_missing_authorization` | The `Authorization` header is missing              |
| 401  | `auth_invalid_token`         | The key is malformed, revoked, or no longer exists |
| 403  | `missing_permissions`        | The key lacks one of the required permissions      |

### Best practices

* **Never** commit API keys to source control or paste them into chat tools.
* Store keys in your platform's secret manager and inject them as environment variables at runtime.
* Use **separate keys** for different services or environments — that way you can revoke one without taking down the others.
* **Rotate** keys periodically. Create the new one, deploy it, then delete the old one.
* If you suspect a key is leaked, delete it immediately from **Settings / Developer**. Revocation takes effect within seconds.


---

# 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.damisa.xyz/AkjkmImZjoUgeLkiUdam/developer-guides/authentication.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.
