> ## Documentation Index
> Fetch the complete documentation index at: https://docs.parchmenthealth.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Token Creation

> How to create partner authentication tokens

# Partner Token Creation

This guide explains how to generate authentication tokens for the Parchment API using the `/v1/token` endpoint.

## Credentials Setup

Before you can generate tokens, you need to obtain your partner credentials:

1. Navigate to **Settings > Organisation > Edit > Partner Integrations** in your sandbox environment
2. Copy the partner credentials:  `organization_id`, `organization_secret`, and `user_id`

<Warning>
  **Keep these credentials on your backend.** Do not embed `organization_secret` (or any partner secret) in browser/mobile client code, and do not call Parchment endpoints directly from a frontend. The API is server-to-server only — CORS is not enabled, and any credential exposed to the client can be read by end users and used to impersonate your organization. Proxy all calls through your server.
</Warning>

<div style={{ textAlign: 'center' }}>
  <img src="https://mintcdn.com/parchment/1bLaXHJaAzuuTRdz/images/demo-tile.png?fit=max&auto=format&n=1bLaXHJaAzuuTRdz&q=85&s=5b0c282bd583988f403b28319f591747" alt="Demo tile" width="600" loading="lazy" style={{ borderRadius: '8px', margin: '8px auto', maxWidth: '100%', height: 'auto', display: 'block' }} data-path="images/demo-tile.png" />
</div>

<div style={{ textAlign: 'center' }}>
  <img src="https://mintcdn.com/parchment/R_S6cYGsCPnCsVx0/images/integration-start.jpg?fit=max&auto=format&n=R_S6cYGsCPnCsVx0&q=85&s=3b402904e91773425619fba18c297fcd" alt="Integration generate new key" width="600" loading="lazy" style={{ borderRadius: '8px', margin: '8px auto', maxWidth: '100%', height: 'auto', display: 'block' }} data-path="images/integration-start.jpg" />
</div>

<div style={{ textAlign: 'center' }}>
  <img src="https://mintcdn.com/parchment/R_S6cYGsCPnCsVx0/images/integration-creds-generated.jpg?fit=max&auto=format&n=R_S6cYGsCPnCsVx0&q=85&s=a0419e80b1e949afbf52839ddc7d6540" alt="Credentials generated successfully" width="600" loading="lazy" style={{ borderRadius: '8px', margin: '8px auto', maxWidth: '100%', height: 'auto', display: 'block' }} data-path="images/integration-creds-generated.jpg" />
</div>

## Token Request

To generate an access token, make a POST request to `/v1/token` with the required headers and request body.

### Required Headers

| Header                  | Description                               |
| ----------------------- | ----------------------------------------- |
| `x-partner-id`          | Partner ID provided by Parchment          |
| `x-partner-secret`      | Partner secret provided by Parchment      |
| `x-organization-id`     | Organization ID provided by Parchment     |
| `x-organization-secret` | Organization secret provided by Parchment |
| `x-user-id`             | User ID provided by Parchment             |

### Request Body

```json theme={null}
{
  "grantType": "client_credentials",
  "scope": ["create:patient", "read:patient_prescription"]
}
```

| Field       | Type      | Required | Description                           |
| ----------- | --------- | -------- | ------------------------------------- |
| `grantType` | string    | Yes      | Must be `client_credentials`          |
| `scope`     | string\[] | Yes      | Array of permission scopes to request |

### Available Scopes

See [Authentication Scopes](/authentication/partner/scopes) for a complete list of available scopes.
