Authentication

All API calls require authentication via API Key.

Get an API Key

  1. Register at the Client Portal
  2. After administrator approval, access the login
  3. Navigate to API Keys and click New API Key
  4. The key is shown only once, save it immediately
  5. 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

HTTPResponseCause
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:

ScopeAllows
facturas:emitirIssue documents and request series
facturas:consultarCheck document status
series:listarList 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

  1. Never expose the API Key in the frontend, use it only in your system’s backend
  2. Use one key per environment, create separate keys for tests and production
  3. Rotate keys periodically, recommended every 90 days
  4. Handle 401 errors, log out / notify the administrator if the key is revoked
  5. Do not commit the key to Git, use .env or a secret manager