# Access Token API

## Create/Refresh a merchant session

<mark style="color:green;">`POST`</mark> `/api/merchant/:merchantId/sessions`

Creates a new merchant session

**Headers**

<table><thead><tr><th width="353.567626953125">Name</th><th>Value</th></tr></thead><tbody><tr><td>Content-Type</td><td><code>application/json</code></td></tr><tr><td>Authorization</td><td><code>Basic &#x3C;API KEY></code></td></tr></tbody></table>

**Request**

<table><thead><tr><th width="203.2760009765625">Property</th><th width="147.427001953125">Type</th><th>Description</th></tr></thead><tbody><tr><td>access_token</td><td>string</td><td>Optional: If provided, invalidates existing token and provides a new one</td></tr><tr><td>expires_in</td><td>int</td><td>Optional: the value in seconds for the token expiration. default is 900 (15 min)</td></tr><tr><td>scope</td><td>string</td><td><p>Optional: <code>readonly</code> | <code>default</code></p><p></p><p>Setting scope to <code>readonly</code> restricts actions like hiding the Refund button in the transaction widget.<br><br>Note: if not provided, <code>default</code> will be applied.</p></td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
  access_token: "<Access Token>",
  expires_in: "<Duration>",
  scope: "default",
  type: "Session"
}
```

{% endtab %}

{% tab title="401" %}

```json
{
  "error": true,
  "message": "Unauthenticated"
}
```

{% endtab %}

{% tab title="422" %}

```json
{
    "success": false,
    "message": "Failed to validate",
    "errors": [
        {
            "field": "expires_in",
            "message": "expires_in must not be less than 60"
        }
    ]
}
```

{% endtab %}
{% endtabs %}

## Delete a merchant session

<mark style="color:green;">`DELETE`</mark> `/api/merchant/:merchantId/sessions/:accessToken`

Deletes a merchant session

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Basic <API KEY>`  |

**Response**

{% tabs %}
{% tab title="204" %}

```json
no reponse body expected
```

{% endtab %}
{% endtabs %}
