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

# Authentication API

Papaya Global ensures the secure authentication of requests by employing an API key and Client ID. It is crucial to avoid sharing these credentials in publicly accessible areas like GitHub or client-side code. A bearer token is necessary to authenticate all API requests. All API requests must be made over HTTPS, as requests made over plain HTTP will not be successful. Moreover, any API requests made without proper authentication will also fail. It is important to note that the sandbox and production environments have separate keys and client IDs. Used for authenticating with Papaya Global servers.

### Obtain Access Token <a href="#authenticationapi-obtainaccesstoken" id="authenticationapi-obtainaccesstoken"></a>

To acquire an access token, include your `api_key` and `client_secret` in the HTTP request header (Will be provided to you by the integration support). This token is essential for making calls to any other API endpoints, and the HTTP header must contain Authorization: Bearer \[token]. The access token remains valid for 24 hours and can be utilized multiple times for all other API endpoints until it expires. It is advisable to rely on the expiration time provided (valid\_until) in the response for a precise token expiration time.

<mark style="color:green;">**`POST`**</mark> [/token](https://authentication-service.staging.pay.papayaglobal.work/token)

**Body Parameters Request**

<table><thead><tr><th>Name</th><th>Type</th><th width="285.42578125">Description</th><th width="132.12890625">Required</th></tr></thead><tbody><tr><td>api_key</td><td>string</td><td>This is a unique identifier used to authenticate the client making the request (Will be provided to you by the integration support).</td><td>Yes</td></tr><tr><td>client_secret</td><td>string</td><td>This is a secret key associated with the API key. It acts as a password to provide an additional layer of security (Will be provided to you by the integration support).</td><td>Yes</td></tr><tr><td>token_name</td><td>string</td><td>This field specifies a name for the token being created. If provided, this name will be assigned to the token. If not provided, a new random UUID will be used as the token name</td><td>No</td></tr></tbody></table>

**Body parameters Response**

<table><thead><tr><th>Name</th><th>Type</th><th width="319.75">Description</th></tr></thead><tbody><tr><td>valid_until</td><td>ISO 8601 date-time format</td><td>This field indicates the expiration date and time of the token.</td></tr><tr><td>token</td><td>JWT</td><td>This field contains the JWT itself.</td></tr><tr><td>token_name</td><td>string</td><td>This field specifies the name of the token being created.</td></tr></tbody></table>

**Request Example**

`POST /token`

```json
{
   "api_key": "82725488-22bf-40d1-ace6-9ea6ee42f870",
   "client_secret": "MySecret!!!",
   "token_name": "82725488-22bf"
}
```

**Response**

{% tabs %}
{% tab title="201 - Created" %}

```json
{
   "valid_until": "2024-07-11T07:48Z",
   "token": "eyJ0eXAiOiJKV1QiLCJraWQiOiJBUElLRVkwIiwiYXBpX3Rva2VuX2lkIjoiYjZmMzhhN2QtMDc4MS00OGIyLWFhMTEtODUzMzA5NjEyNWFiIiwiYWxnIjoiUlMyNTYifQ.eyJpYXQiOjE3MjA1OTc3MTEsImV4cCI6MTcyMDY4NDExMSwic3ViIjoiYWNjZXNzIiwidXNlciI6eyJpZCI6IjgyNzI1NDg4LTIyYmYtNDBkMS1hY2U2LTllYTZlZTQyZjg3MCIsImVtYWlsIjoiZXlhbDEubmV0QGdtYWlsLmNvbSIsIm93bmVyIjp7ImlkIjoiMjAxMDAwIiwib3duZXJUeXBlIjoib3JnX2lkIn19fQ.gLmL4am5bro27H_ICzLT2OMxnh7MtyuenND9yR1J_jmZyxcnB_XbN1hTXLsqU4l-73UWLNWB9eMseFLVEVSx0z-XtDtDyPvwWHsicxTwC-PmZrhg1EvQRrRgEzUk5D-wJNqXRnfP5CNS78pPo6ZRHwW7N1t1fpop48gKnPdtyOt5m0w0apOyzgLPOWwsTHMKw8qCe5e5d6IumjKpxxeJUcgpzffEibUmaqGL9PFAS5Yky0ABFe37VFwdgj89muLW5RdaOz3HvYiZYLdtH91SIJYKhWMME38_xWSFb8wxoHZsRH3taBdyBUuU5zE8J7wfYQYsm_iA1BMlNZ9d73R71g"
   "token_name": "82725488-22bf"
}
```

{% endtab %}

{% tab title="401  - Authorization Required" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}


---

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

```
GET https://docs.papayaglobal.com/api-reference/authentication-api.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.
