Authentication
All API calls require authentication via API Key.
Get an API Key
- Register at the Client Portal
- After administrator approval, access the login
- Navigate to API Keys and click New API Key
- The key is shown only once, save it immediately
- The format is
feak_followed by 64 hexadecimal characters
Example:
feak_8738a27cee79a85c02fa5c96fc1bf1a2d31d856c98b0bf1a344be9f013f5ea67 Use the API Key
Include the key in all API requests. Choose one of these methods:
x-api-key header (recommended)
x-api-key: feak_8738a27cee79a85c02fa5c96fc1bf1a2d31d856c98b0bf1a344be9f013f5ea67 Authorization: Bearer header
Authorization: Bearer feak_8738a27cee79a85c02fa5c96fc1bf1a2d31d856c98b0bf1a344be9f013f5ea67 Call Example
curl -X POST https://connect.factflexi.com/v2/series
-H "Content-Type: application/json"
-H "x-api-key: feak_8738a27cee79a85c02fa5c96fc1bf1a2d31d856c98b0bf1a344be9f013f5ea67"
-d '{"nif":"5000537039","privateKey":"-----BEGIN PRIVATE KEY-----\n..."}' Authentication Error Responses
| HTTP | Response | Cause |
|---|---|---|
| 401 | { "success": false, "error": "Not authorized.", "code": "UNAUTHORIZED" } | API Key was not sent |
| 401 | { "success": false, "error": "Invalid API Key.", "code": "UNAUTHORIZED" } | API Key does not exist or was revoked |
| 403 | { "success": false, "error": "Insufficient scope.", "code": "FORBIDDEN" } | The key does not have permission for this endpoint |
| 429 | { "success": false, "error": "Too many requests. Try again later.", "code": "RATE_LIMITED" } | Request limit exceeded |
Rate Limiting
Each API Key has a request limit per minute (by default: 60/minute, configurable when creating the key). Requests without a valid key are also limited by IP.
When the limit is exceeded, the response comes with HTTP 429 and the Retry-After header (seconds to wait):
HTTP/1.1 429 Too Many Requests
Retry-After: 42 Best practice: implement exponential backoff in your system — upon receiving 429, wait for the indicated Retry-After instead of immediately retrying.
Scopes (Permissions)
Each API Key has scopes that define what it can do:
| Scope | Allows |
|---|---|
facturas:emitir | Issue documents and request series |
facturas:consultar | Check document status |
series:listar | List numbering series |
* | Full access to all endpoints |
Security
- The key is shown only once at creation time
- If you lose the key, use the Rotate option to generate a new one
- The previous key is automatically revoked upon rotation
- Keys are stored with SHA-256 hash, impossible to recover
- Store the key in a secret manager (e.g. environment variables, Vault)
Best Practices
- Never expose the API Key in the frontend, use it only in your system’s backend
- Use one key per environment, create separate keys for tests and production
- Rotate keys periodically, recommended every 90 days
- Handle 401 errors, log out / notify the administrator if the key is revoked
- Do not commit the key to Git, use
.envor a secret manager