What is an API Key?
An API key is a secret token that identifies your application or system when making requests to Compago’s Sales Partner API. It ensures that only authorized systems can query payment data, retrieve reports, or access any API functionality. Keep your API key secure and never expose it in public client-side code.How to Generate an API Key
To create an API key:- Sign in to your Sales Partner Dashboard.
- Navigate to Configuraciones > Desarrollador.
- Click Crear API Key.
- Enter a name for the key (e.g.,
Production Dashboard,Reporting Integration). - Click Crear and copy the key immediately.
Using the API Key in Requests
Every request to a protected endpoint must include your API key in thex-api-key header.
Header Format
curl:
401 Unauthorized response.
Example with Code
Security Best Practices
Keep your API key secret
Keep your API key secret
Never expose your API key in client-side code, public repositories, or browser requests. Always make API calls from your server-side application.
Use environment variables
Use environment variables
Store your API key in environment variables rather than hardcoding it in your source code.
Rotate keys regularly
Rotate keys regularly
Periodically generate new API keys and revoke old ones. This limits the impact if a key is accidentally exposed.
Use separate keys per environment
Use separate keys per environment
Create different API keys for development, staging, and production environments. This way, revoking a development key does not affect your production integration.
Access Scope
API keys are scoped to your sales partner account. This means:- You can only access payment data for organizations that belong to your sales partner account.
- Even if you provide an
organizationIdfilter, the API will only return results for organizations under your account. - There is no way to access data belonging to other sales partners or organizations outside your scope.
Error Responses
| Status Code | Description |
|---|---|
401 Unauthorized | API key is missing, invalid, or has been revoked |
403 Forbidden | API key does not have permission for the requested resource |