Overview
Every request to the Recoup API must be authenticated using exactly one of two mechanisms:| Method | Header | Use case |
|---|---|---|
| API Key | x-api-key | Server-to-server integrations |
| Access Token | Authorization: Bearer <token> | Frontend apps authenticated via Privy |
401 error.
API Keys
API keys are the primary way to authenticate programmatic access to the Recoup API.Creating an API Key
- Navigate to chat.recoupable.com/keys
- Enter a descriptive name (e.g.
"Production Server") - Click Create API Key
Using an API Key
Pass your key in thex-api-key header:
Access Tokens (Privy)
If you’re building a frontend application that authenticates users via Privy, you can pass the user’s Privy JWT as a Bearer token instead of an API key.Personal vs. Organization API Keys
API keys inherit the type of account they were created under.Personal API Keys
- Created by a standard user account
- Can only access your own account’s data
orgIdisnullon the resolved auth context
Organization API Keys
- Created by an organization account (an account that has members)
- Can access data for any member account within the organization
orgIdis set to the organization’s account ID
An account is recognized as an organization when it has at least one member in the
account_organization_ids table.How We Determine Key Type at Creation
When a key is created under an account, the API checks whether that account has any organization members:How We Verify Access on API Calls
Every authenticated request goes throughvalidateAuthContext, which enforces the following access rules:
Personal API Key or Bearer Token
Can only access their own account. Attempting to pass anaccount_id belonging to another account returns 403 Forbidden.
Organization API Key
Can access any account that is a member of the organization:account_organization_ids table for a record linking the target account to the organization.
The Recoup internal admin organization has universal access to all accounts.
Organization Access via organization_id
Some endpoints accept an organization_id parameter. When provided, the API additionally validates that the authenticated account is either:
- A member of the organization, or
- The organization account itself
Error Responses
| Status | Cause |
|---|---|
401 | Missing or invalid credentials, or both x-api-key and Authorization headers provided |
403 | Valid credentials but insufficient access to the requested account_id or organization_id |
Security Notes
- API keys are never stored in plaintext — only an HMAC-SHA256 hash (keyed with your project secret) is persisted in the database
- Never include
account_idin your API key creation request — the account is always derived from your authenticated credentials - Rotate keys immediately if compromised via the API Keys Management Page
