# Getting authenticated

{% hint style="info" %}
We’ll be using the [sandbox environment](https://sandbox.pgecom.com/signin) of our API. The sandbox lets you develop the PG Rewards API using mock data. The sandbox environment's URL is <https://sandbox.pgecom.com/signin>
{% endhint %}

## :key: Getting an API Key

1. Sign up or log in to your sandbox account at: <https://sandbox.pgecom.com/signin>
2. Navigate to **Settings > Developer Setting**
3. Click on **Generate New Credentials t**o get new credentials

<figure><img src="/files/52hdPZzmStPt7wFF4w9l" alt=""><figcaption><p>Developer Settings</p></figcaption></figure>

### :tada: Make your first request

## Generate your first token

<mark style="color:green;">`POST`</mark> `https://sandbox.pgecom.com/api/v1/token`

#### Request Body

| Name                                        | Type   | Description |
| ------------------------------------------- | ------ | ----------- |
| apiKey<mark style="color:red;">\*</mark>    | String |             |
| secretKey<mark style="color:red;">\*</mark> | String |             |

{% tabs %}
{% tab title="200: OK Success" %}

```json
{
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCIIkpXVCJ9.eyJ1c2VySUQiOiI1ZjU2ZGZhMy1hNDE1LTQ4MTgtODI3NS00GZjNjNlY2UzZmQiLCJpc0FjdGl2ZSI6dHJ1ZSwiaXNBZ2VudCI6dHJ1ZSwiaXNTdXBlckFkbWluIjpmYWxzZSwiYWdlbnRTZXR0aW5nIjp7Il9fdHlwZW5hbWUiOiJTZXR0aW5ncyIsIl9sYXN0Q2hhbmdlZEF0IjoxNjUxMDQ1MDcwMDM1LCJfdmVyc2lvbiI6MSwidG9wVXBGZWVzIjo0LCJ2aXJ0dWFsQ2FyZEZlZXMiOjExLCJ1cGRhdGVkQXQiOiIyMDIyLTA1LTIwVDAxOjIwOjI5LjgzMloiLCJ1c2VySUQiOiI1ZjU2ZGZhMy1hNDE1LTQ4MTgtODI3NS00NGZjNjNlY2UzZmQiLCJ0cmFuc0ZlckZlZXMiOjMsImNyZWF0ZWRBdCI6IjIwMjItMDQtMjdUMDc6Mzc6NTAuMDM1WiIsImlkIjoiNWY1NmRmYTMtYTQxNS00ODE4LTgyNzUtNDRmYzYzZWNlM2ZkIiwiY2FyZEZlZXMiOjV9LCJhZ2VudEJhbmtSZXdhcmRGZWVzIjo3LCJ0b3B1cEZlZXMiOjAuNDEsImFnZW50VHJhbnNGZXJGZWVzIjoxLCJpc1N0cmlwZUlzc3VpbmdFbmFibGVkIjp0cnVlLCJpc0JhbGFuY2VFbmFibGVkIjp0cnVlLCJhZ2VudFBheVBhbEZlZXMiOjQsImNhc2hBcHBGZWVzIjozLCJpc1RvcFVwRW5hYmxlZCI6dHJ1ZSwiaWQiOiI3ODFiYTliOS1lMDJkLTQ3ODktYTRhNi0wNjNiM2UyNTg1N2MiLCJ6ZWxsZUZlZXMiOjMsImZWVzIjo1LCJwYXlwYWxGZWVzIjo4LCJpc1VTQUJhbmtSZXdhcmRzRW5hYmxlZCI6dHJ1ZSwidmlydHVhbENhcmRGZWVzIjo4LCJ1cGRhdGVkQXQiOiIyMDIyLTA2LTMwVDEwOjE3OjIyLjkyMVoiLCJpc1BheVBhbEVuYWJsZWQiOnRydWUsImlzTW9uQ2FzaEVuYWJsZWQiOnRydWUsImFnZW50VG9wdXBGZWVzIjoxLCJpc1N0cmlwZUVuYWJsZWQiOnRydWUsImlzVmlydHVhbENhcmRFbmFibGVkIjp0cnVlLCJhZ2VudENhcmRGZWVzIjo0LCJpc1BheW1lRW5hYmxlZCI6dHJ1ZSwiaWF0IjoxNjU2ODM1MTE4LCJleHAiOjE2NTk0MjcxMTh9.PQwvdewWXJ3UROAleG8Q9pEkeQWtYSaawbtT4EaUOg8"
}
```

{% endtab %}

{% tab title="400: Bad Request Bad Request" %}

```json
{
    "message": "User not found",
    "status": 400
}
```

{% endtab %}

{% tab title="401: Unauthorized Unauthorized" %}

```json
{
    "message": "API Secret Key is invalid",
    "status": 401
}
```

{% endtab %}
{% endtabs %}

Congrats, you've authenticated and made your first request!

<br>


---

# 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://docs.pgecom.com/guides/entwiksyon.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.
