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

# Authentication

{% hint style="warning" %}
**Important:** A new Bearer token should be generated for each request to ensure that every API call is properly authenticated.
{% endhint %}

## Environments

{% tabs %}
{% tab title="Development" %}
<https://api.aplazo.net/api>
{% endtab %}

{% tab title="Production" %}
<https://api.aplazo.mx/api>
{% endtab %}
{% endtabs %}

{% openapi src="/files/9LjWj62EfrRCRGt9S68y" path="/auth" method="post" %}
[openapi3\_20250109.yaml](https://1083542398-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fkw5JIHAGdl5dlteKuPH4%2Fuploads%2FvrmbWgNQr4PvSvj5NrM9%2Fopenapi3_20250109.yaml?alt=media\&token=ffbafb02-f400-462e-93ac-8d13051a8268)
{% endopenapi %}

## Response Examples

<details>

<summary><mark style="color:green;background-color:green;">200</mark> - Successful Authentication</summary>

{% code title="Authentication Request" %}

```bash
curl --location 'https://api.aplazo.net/api/auth' \
--header 'Content-Type: application/json' \
--data '{
    "apiToken": "93e28f44-e352-42df-af84-7a9ffc9f5734",
    "merchantId": 2639
}'
```

{% endcode %}

{% code title="Response: 200 OK" overflow="wrap" %}

```json
{
    "Authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJwcm9kdWN0X3NvbHV0aW9uX2VuZ19vbmxpbmUrYXBsYXpvQGdtYWlsLmNvbSIsInJvbGUiOiJST0xFX01FUkNIQU5UIiwic2Vzc2lvbklkIjoiZWZhMDU2ZmQtYTU0Yi00MGExLTk1MWEtNmZmY2Y4YTY1ZjVmIiwiZXhwIjoxNzM2NzgzNTIwfQ.8Thmx67K9zF0AukYJaTgZ2qZFYUb-MfmsfbyNtw3eiDtOI_Ya88OUXa3vqqI4CpjU5j_Okl3-gcSlLVzI1PO6B"
}
```

{% endcode %}

</details>

<details>

<summary><mark style="color:red;background-color:red;">404</mark> - Merchant doesn't exist</summary>

{% code title="Response: 404 Not Found" fullWidth="true" %}

```json
{
    "timestamp": "2025-01-03T15:58:32.023+00:00",
    "status": 404,
    "error": "Not Found",
    "path": "/api/auth"
}
```

{% endcode %}

</details>

<details>

<summary><mark style="color:red;background-color:red;">400</mark> - Merchant isn't approved</summary>

{% code title="Response: 400 Bad Request" fullWidth="true" %}

```json
{
    "timestamp": "2025-01-03T15:58:32.023+00:00",
    "status": 400,
    "error": "Bad request",
    "path": "/api/auth"
}
```

{% endcode %}

</details>

<details>

<summary><mark style="color:red;background-color:red;">400</mark> - Missing field or invalid data type</summary>

{% code fullWidth="true" %}

```
empty response body
```

{% endcode %}

</details>
