API key format
Pear API keys follow the formatmk_live_ followed by a random string:
Two ways to authenticate
You can pass your API key using either of these methods. Both are equivalent.Bearer token (recommended)
Include your key in theAuthorization header with the Bearer prefix:
X-API-Key header
Alternatively, pass the key directly in theX-API-Key header:
If both headers are present, the
Authorization: Bearer header takes precedence.Key scopes
Each API key has one or more scopes that determine what it can access:| Scope | Description |
|---|---|
read | Access events, markets, comparisons, search, and account data. Required for all GET endpoints. |
write | Create and manage API keys. Required for POST and DELETE operations. |
read scope. Use write only for keys that manage other keys.
Creating API keys
Create a new key via the API:Revoking API keys
If a key is compromised or no longer needed, revoke it immediately:401 Unauthorized response.
Listing your keys
View all keys on your account (key values are partially masked):Error responses
| Status | Error | Description |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
403 | forbidden | The key does not have the required scope for this operation. |
Security best practices
Use separate keys per environment
Create dedicated keys for development, staging, and production. This limits the blast radius if a key is exposed.
Use the minimum required scope
Most applications only need
read access. Only grant write scope to keys that need to manage other keys.Store keys in environment variables
Never hardcode API keys in your source code. Use environment variables or a secrets manager.
Rotate keys periodically
Create a new key, update your application, then revoke the old key. Regular rotation limits the window of exposure.
Monitor usage
Use the usage logs endpoint to audit which keys are being used and from where.