> ## Documentation Index
> Fetch the complete documentation index at: https://docs.compago.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Authentication

> How to authenticate requests using your API key.

All API requests require authentication using an **API key**. This key is unique to each merchant and must be included in every request to ensure secure and authorized access to our services.

## What is an API Key?

An API key is a secret token that identifies your application or system when making requests to Compago’s API. It ensures that only authorized systems can initiate transactions, retrieve data, or trigger any backend logic.

Keep your API key secure and never expose it in public client-side code.

## How to Generate an API Key

To create an API key:

1. Sign in to your Compago Dashboard.
2. Navigate to **Configuraciones** → **Desarrollador**.
3. Click **Create API Key**.
4. Enter a name for the key (e.g., `Production App`, `Test Integration`).
5. Confirm creation and **copy the key immediately** (it will only be visible once).

You can revoke or regenerate keys at any time from the same dashboard section.

## Using the API Key in Requests

Every request to a protected endpoint must include your API key in the request headers.

### Header Format

```
x-api-key: YOUR_API_KEY
```

Here’s an example using `curl`:

```bash theme={null}
curl -X POST https://api.compago.com/api/one-time-payment \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"amount":1200,"currency":"MXN",...}'
```

If the API key is missing or invalid, you will receive a `401 Unauthorized` response.

> 🔒 Always keep your API key secret. Rotate it regularly and never commit it to version control.
