
# 애플리케이션 API 권한 부여 설정

`PUT /v1/applications/{application_id}/api-grants/{api_id}` · 권한 `applications:write`

애플리케이션이 한 API에 대해 요청할 수 있는 범위를 전체적으로 대체합니다. 애플리케이션은 최대 50개 API에 대한 권한 부여를 보유할 수 있습니다.

## 요청

| 매개변수 | In | 설명 |
|---|---|---|
| `application_id` | path | 애플리케이션 id(`app_…`). |
| `api_id` | path | API id(`api_…`). |

**Body**

| 필드 | 유형 | 필수 | 설명 |
|---|---|---|---|
| `scopes` | string[] | 예 | 허용된 범위(`resource:action`). 각각은 API에서 정의되어야 합니다. 최대 1000개. |
| `default_scopes` | string[] | 아니오 | 기본적으로 부여된 범위. `scopes`의 부분집합입니다. |

## 응답

`200 OK`와 권한 부여.

```json
{
  "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"
}
```

## 오류

| HTTP | `code` | 조건 |
|---|---|---|
| 401 | `unauthenticated` | 키가 누락되었거나, 유효하지 않거나, 취소되었습니다. |
| 403 | `insufficient_permissions` | 키에 필요한 권한이 없습니다. |
| 404 | `not_found` | 이 환경에서 애플리케이션이나 권한 부여가 존재하지 않습니다. |
| 422 | `validation_failed` | 범위가 잘못되었거나 API에서 정의되지 않았거나, `default_scopes`가 `scopes`의 부분집합이 아닙니다. |
| 403 | `quota_exceeded` | 애플리케이션이 이미 50개 API에 대한 권한 부여를 보유합니다. |
| 400 | `unknown_field` | 본문에 스키마에 없는 필드가 있습니다. |

## 예제

```bash
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"]}'
```
