Authentication
Every call carries the key and the secret of an API key. The key's scopes decide which routes it reaches.
The two headers
| Header | What it carries |
|---|---|
X-API-KEY | The public key of the credential, created in Settings → API keys. |
X-API-SECRET | The secret of the credential. It is shown only once, when the key is created. |
An authenticated call
curl "https://api.guria.io/api/v1/contacts" \
-H "X-API-KEY: $GURIA_API_KEY" \
-H "X-API-SECRET: $GURIA_API_SECRET"Scopes
Each key is created with the scopes you pick, and only gets through the routes they cover. A scope is a panel permission: View contacts is contacts.read, Send messages is messages.send.
- Each route's page says which scope it requires.
- Dependent scopes come along: picking Create contacts already includes View contacts.
- Whoever creates the key can only grant what their own profile has.
- Changing a key's scopes takes effect from its next call.
When authentication fails
| Status | What happened | What to do |
|---|---|---|
401 | One of the headers is missing, the key does not exist, was revoked, or the secret is wrong. A key that does not exist, a revoked key and a wrong secret all get the same response; without the key header, the 401 comes with no body. | Check both values and that the key is still active. |
403 | The key authenticated, but it lacks the route's scope, or the company's plan does not include the feature. | Add the scope to the key, in Settings → API keys. |
401
{
"error": "unauthorized",
"message": "Credenciais de API inválidas."
}Looking after the secret
- The secret is shown only once, when the key is created. Guria stores only its hash.
- Keep it in an environment variable or a secrets vault (
GURIA_API_KEYandGURIA_API_SECRETin the examples here), never in the repository. - Revoking a key is immediate: the integrations using it start getting
401.