# Obtaining a token for Patchworks API authentication

## Introduction

Patchworks API requests must be authenticated with a **bearer token**. To obtain a token, you need to send a login request which includes credentials that you use to access the Patchworks dashboard.

## The steps

<details>

<summary><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FpLMO12yvTCxi9PorCt53%2Ficons8-film.svg?alt=media&#x26;token=e59864bc-2d97-4f98-966c-a083c18e60db" alt="" data-size="line"> Show me</summary>

![](https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FKnJLDebAKfvkxoNfxd5R%2Fdemo%20token%20request.gif?alt=media\&token=a459207f-abeb-44d3-9da3-2b296f4f73cf)

</details>

**Step 1**\
Create a POST request for the following endpoint:

{% code lineNumbers="true" %}

```
https://svc-fabric.pwks.co/api/v1/login
```

{% endcode %}

{% hint style="info" %}
This endpoint  is for the Patchworks **production** environment.&#x20;
{% endhint %}

**Step 2**\
In the request body, add the **email** and **password** that you use to log into the Patchworks dashboard. You should add this as JSON - for example:

{% code lineNumbers="true" %}

```json
{
    "email": "joe.bloggs@wearepatchworks.com",
    "password": "mypassword123*"
}
```

{% endcode %}

<figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FTps7FWsKxFmi3p9FUYbe%2Flogin%20request%201.png?alt=media&#x26;token=89cc756e-9c14-4d27-b011-2dacaa817556" alt=""><figcaption></figcaption></figure>

**Step 3**\
Send the request - if successful, a token is returned. For example:

<figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FMy0ppDJcJ9whuOsggR0e%2Flogin%20request%202.png?alt=media&#x26;token=d7157204-efa5-40e6-b3a6-11447b65a8ea" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Access tokens are valid for 24 hours - for example: \
Issued: Wednesday 20th July at 10:03:08 GMT \
Expires: Tuesday 21st July at 10:03:08 GMT
{% endhint %}

**Step 4**\
Save this token ready for use in your [initialise request](https://doc.wearepatchworks.com/product-documentation/developer-hub/patchworks-core-api/core-api-spotlights/initialising-a-process-flow-and-sending-data-via-the-patchworks-api/the-steps/initialising-a-process-flow-and-sending-data).
