Partner Token Creation
This guide explains how Parchment validates partner authentication tokens and how to implement proper token creation in your applications.Token Structure
Parchment uses JWT (JSON Web Tokens) with the RS256 algorithm for partner authentication. JWT tokens consist of three parts:- Header: Contains metadata about the token type and signing algorithm
- Payload: Contains claims about the entity (partner) and additional data
- Signature: Ensures the token hasn’t been altered
Token Payload
A typical token payload contains:| Field | Description |
|---|---|
organization_id | Unique identifier for the organization |
partner_id | Unique identifier for the partner |
user_id | Identifier for the end-user (if applicable) |
scope | Array of permission scopes granted to this token |
iat | Issued At - timestamp when the token was created |
exp | Expiration - timestamp when the token expires |
Validation Process
When validating a partner token, our API performs the following checks:- Organization ID Check: Verifies the organization ID in the request path/params matches the one in the token
- Signature Verification: Validates the token signature using the appropriate public key
- Expiration Check: Ensures the token has not expired
- Scope Check: Confirms the token includes the required scope for the requested operation
- Organization Secret Check: Validates the provided organization secret matches our records
Required Headers
For successful authentication, API requests must include these headers:JWKS Endpoint
Parchment provides a JWKS (JSON Web Key Set) endpoint that serves the public keys needed to verify token signatures. This follows standard OAuth 2.0 practices for key rotation and management.Error Responses
When token validation fails, you’ll receive an error response with HTTP status code 401 or 403 and a message explaining the reason:| Status | Error | Description |
|---|---|---|
| 401 | invalid_token | The token is malformed or has an invalid signature |
| 401 | expired_token | The token has expired |
| 403 | insufficient_scope | The token does not have the required scope |
| 403 | organization_mismatch | Organization ID in the request doesn’t match the token |
| 401 | invalid_secret | The organization secret is invalid |
Best Practices
- Always verify tokens on the server-side, never in client-side code
- Implement proper error handling for authentication failures
- Use a token management library that handles JWT validation correctly
- Don’t store tokens in local storage or cookies accessible by JavaScript
- Implement token refresh logic to handle expiration gracefully

