Définir une autorisation d'API d'application
PUT /v1/applications/{application_id}/api-grants/{api_id} · permission applications:write
Remplace, dans son intégralité, les scopes qu'une application peut demander pour une API. Une application peut détenir des autorisations pour au maximum 50 API.
Demande
| Paramètre | Dans | Description |
|---|---|---|
application_id |
path | Identifiant de l'application (app_…). |
api_id |
path | Identifiant de l'API (api_…). |
Corps
| Champ | Type | Obligatoire | Description |
|---|---|---|---|
scopes |
string[] | oui | Scopes autorisés (resource:action) ; chacun doit être défini sur l'API. Au maximum 1000. |
default_scopes |
string[] | non | Scopes accordés par défaut ; un sous-ensemble de scopes. |
Réponse
200 OK avec l'autorisation.
{
"application_id": "app_6f8d0cjgbmf0gtn2rg6pscp3cg",
"api_id": "api_0000000000000000000000001z",
"scopes": ["orders:read", "orders:write"],
"default_scopes": ["orders:read"],
"created_at": "2026-10-05T10:00:01Z",
"updated_at": "2026-10-05T10:00:01Z"
}
Erreurs
| HTTP | code |
Quand |
|---|---|---|
| 401 | unauthenticated |
La clé est manquante, invalide ou révoquée. |
| 403 | insufficient_permissions |
La clé n'a pas la permission requise. |
| 404 | not_found |
L'application ou l'autorisation n'existe pas dans cet environnement. |
| 422 | validation_failed |
Un scope est malformé ou non défini sur l'API, ou default_scopes n'est pas un sous-ensemble de scopes. |
| 403 | quota_exceeded |
L'application détient déjà des autorisations pour 50 API. |
| 400 | unknown_field |
Le corps a un champ qui ne fait pas partie du schéma. |
Exemple
curl -X PUT https://api.eu.keenauth.com/v1/applications/app_6f8d0cjgbmf0gtn2rg6pscp3cg/api-grants/api_0000000000000000000000001z \
-H "Authorization: Bearer $KEENAUTH_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{"scopes":["orders:read","orders:write"],"default_scopes":["orders:read"]}'