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

# Authentication

Use HTTP Basic authentication on every public API request.

## Quick reference

| Item                | Value                                            |
| ------------------- | ------------------------------------------------ |
| Scheme              | `Basic`                                          |
| Header              | `Authorization: Basic <base64(clientId:apiKey)>` |
| Testing base URL    | `https://api.testing.plexo.com.uy`               |
| Production base URL | `https://api.plexo.com.uy`                       |

{% hint style="warning" %}
Use API credentials only from your backend. Do not expose them in browser code, mobile apps, or public repositories.
{% endhint %}

## Build the header

Concatenate your `clientId`, a colon, and your `apiKey`, then Base64 encode the result.

```
clientId:apiKey
```

```
Authorization: Basic base64(clientId:apiKey)
```

Example:

```bash
printf '%s' 'test_12345:sk_test_abcdef123456789' | base64
```

## Example request

```bash
curl -X POST https://api.testing.plexo.com.uy/v1/payments \
  -H "Authorization: Basic <base64(clientId:apiKey)>" \
  -H "Content-Type: application/json" \
  -d '{
    "merchantId": 67890,
    "referenceId": "order-1001",
    "invoiceNumber": "1001",
    "amount": {
      "total": 100.00,
      "currency": "UYU"
    },
    "paymentMethod": {
      "source": "card",
      "card": {
        "number": "{{TEST_CARD_NUMBER}}",
        "expMonth": 12,
        "expYear": 2028,
        "cvc": "{{TEST_CARD_CVC}}",
        "cardholder": {
          "firstName": "Test",
          "lastName": "User",
          "email": "test.user@example.com"
        }
      }
    },
    "browserDetails": {
      "ipAddress": "203.0.113.10",
      "userAgent": "Mozilla/5.0"
    },
    "capture": {
      "method": "automatic"
    }
  }'
```

## Credentials

Request your testing or production credentials from Plexo support. Keep a separate `clientId`, `apiKey`, and `merchantId` for each environment.

## Common errors

### 401 Unauthorized

The request is not authenticated.

Common causes:

* Missing `Authorization` header
* Wrong `clientId` or `apiKey`
* Invalid Base64 value
* Using testing credentials against production, or the reverse

Example response:

```json
{
  "type": "api-error",
  "status": 401,
  "code": "unauthorized",
  "message": "Invalid credentials",
  "traceId": "0HMVG9K3R5T4J:00000001"
}
```

### 403 Forbidden

The credentials are valid, but the request is not allowed for that resource or merchant.

Example response:

```json
{
  "type": "api-error",
  "status": 403,
  "code": "forbidden",
  "message": "Access denied",
  "traceId": "0HMVG9K3R5T4J:00000002"
}
```

## Minimal security rules

* Store credentials in environment variables or a secrets manager.
* Rotate API keys periodically.
* Use different credentials for testing and production.
* Never send API credentials from client-side applications.

## Related resources

* [API Endpoints](/rest-api/getting-started/readme.md)
* [API Explorer](/rest-api/tools/api-explorer.md)
* [Payment Processing Guide](/rest-api/payments/payment-processing.md)
* [Error Codes Reference](/rest-api/reference/error-codes.md)


---

# 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://plexo.gitbook.io/rest-api/getting-started/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.
