# Authentication

Browpay API works in two modes. Live Mode and Sandbox Mode

* The **Live mode** keys are retrieved from the main dashboard at <https://dashboard.browpay.com> and the Live mode API endpoint is at <https://api.browpay.com/v1/>&#x20;
  * In the Live mode there are real payments, real effects and data. Only switch to live api endpoint after you have reviewed your test integrations thoroughly.
* The **Sandbox Mode** keys are retrieved from the sandbox dashboard environment at <https://sandbox.browpay.com> and the Sandbox mode API endpoint is at [https://s-api.browpay.com/v1/](https://s-api.browpay.com)
  * In the Sandbox mode you have mock transactions, test payments and test transactions. Here is where you get the liberty to test and run your demo integrations just as it would respond in real transactions, but in sandbox no real money is processed.&#x20;

    **Also Note:** that we are bound to erase sandbox data after a year; which means you only get a year data interval for every tests you make.&#x20;

Sign up at <https://sandbox.browpay.com> to switch to sandbox mode and retrieve your test keys.

### API KEYS

* **Secret Key:** Your secret key authorizes your API requests. It is required to authenticate your API calls. Y**ou are expected to protect your secret keys from the public** and do not expose it in your frontend.
* **Public Key:** Your public key is primarily used to decrypt the webhook payloads we send to you. Further updates on public key utilization will be published in due time.
* **Encryption Key:** The encryption also works as a pair to the public key in decrypting the webhook payloads we send to you. We are working hard to ensure the security of your data while you consume our endpoints.

To retrieve your keys, navigate to **API Keys** in your  dashboard menu and copy your keys.

<figure><img src="/files/boDggK87PQKIFFpE8rgj" alt=""><figcaption><p>Browpay API Keys page</p></figcaption></figure>

{% hint style="warning" %}
**IMPORTANT**

If you suspect that your keys have been exposed or compromised, navigate to **API KEYS** in your dashboard menu and generate new keys to deactivate the previously exposed ones for your safety.
{% endhint %}

A sample secret key authorization would look like this:

{% tabs %}
{% tab title="Node JS" %}

```javascript
const axios = require('axios');

const apiUrl = 'browpay-api-endpoint';
const token = 'Your-secret-key';

axios.get(apiUrl, {
  headers: {
    'Authorization': `Bearer ${token}`
  }
})
  .then(response => {
    console.log(response.data);
  })
  .catch(error => {
    console.error(error);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

api_url = 'browpay-api-endpoint'
token = 'your-secret-key'

headers = {
    'Authorization': f'Bearer {token}'
}

response = requests.get(api_url, headers=headers)

print(response.json())
```

{% endtab %}

{% tab title="PHP" %}

```php
$options = [
    'http' => [
        'header' => "Authorization: Bearer 'your-secret-key'",
    ],
];

$context = stream_context_create($options);
$response = file_get_contents('browpay-api-endpoint', false, $context);

echo $response;
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: 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:

```
GET https://developer.browpay.com/authentication.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
