# OAuth 2 (client credentials)

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

{% hint style="info" %}
This authentication mechanism is pre-configured and ready to use in our [Core API Postman collection](/product-documentation/developer-hub/patchworks-core-api/core-api-spotlights.md) - if you haven't seen it, we advise checking this first!
{% endhint %}

## Obtaining a token for Patchworks API authentication

<details>

<summary><img src="/files/JOYoP4EdSu7WJ3CMdAAS" alt="" data-size="line"> Show me</summary>

![](/files/T27BCHjwFTEGvYvpXXzn)

</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="/files/GaYbjxthq5giRz6jkMT5" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/8ZeH7yT9VLZ54OlZfJBZ" 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 API requests.&#x20;


---

# 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://doc.wearepatchworks.com/product-documentation/developer-hub/patchworks-core-api/core-api-authentication/oauth-2-client-credentials.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.
