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

# Access Token

## Returns your access token for making API calls.

<mark style="color:green;">`POST`</mark> `https://api.formdr.com/api/oauth/token`

#### Headers

| Name         | Type   | Description                       |
| ------------ | ------ | --------------------------------- |
| Content-Type | String | application/x-www-form-urlencoded |

#### Request Body

| Name                                             | Type   | Description                                                                           |
| ------------------------------------------------ | ------ | ------------------------------------------------------------------------------------- |
| grant\_type<mark style="color:red;">\*</mark>    | String | "password" or "client\_credentials"                                                   |
| username<mark style="color:red;">\*</mark>       | String | Account Email (required if grant\_type=password)                                      |
| password<mark style="color:red;">\*</mark>       | String | Account Password (required if grant\_type=password)                                   |
| client\_id<mark style="color:red;">\*</mark>     | String | Your Client ID                                                                        |
| client\_secret<mark style="color:red;">\*</mark> | String | Your Client Secret                                                                    |
| scope<mark style="color:red;">\*</mark>          | String | "read" \| "write" \| "edit" or combination separated by commas. ie: "read,write,edit" |

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

```javascript
{
    "accessToken": String,
    "accessTokenExpiresAt": DateString,
    "refreshToken": String,
    "refreshTokenExpiresAt": DateString,
    "scope": String
}
```

{% endtab %}
{% endtabs %}

You must first get your access token and attach this access token as a bearer token to all of your calls.

Bash example:

```bash
# replace ***** by your client id and secret
curl --location 'https://api.formdr.com/api/oauth/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Accept: application/json' \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'client_id=******' \
--data-urlencode 'client_secret=*****' \
--data-urlencode 'scope=read,write,edit'
```

{% hint style="danger" %}
Due to security protocols, access tokens have a limited lifespan.
{% endhint %}

{% hint style="danger" %}
If you are using an app instance that is not inside US, you will need a different host. For example, if you are using <https://app.formdr.co.uk/>, your api host will be <https://api.formdr.co.uk/api>
{% endhint %}

### Test Keys

After you're ready, and upon approval, we will enable access for you to create an app which can be used for testing. You'll know if you are still in testing if you are given "TEST" keys when making the call to get your access tokens.
