# 변경 알림

한도 조정, 키 변경, API 업데이트 기록.

> Source: https://tokenearly.com/ko/developers/rest/notices · Docs index: https://tokenearly.com/ko/developers/llms.txt · OpenAPI: https://api.tokenearly.com/v1/openapi.json

`GET https://api.tokenearly.com/v1/notices`

이 키와 관련된 알림을 최신순으로 반환합니다: 전체 공지, 계정 변경, 이 키의 변경. 전체·계정 알림은 키 생성 시각으로 거르지 않으므로 새 키에서도 생성 전에 게시된 알림이 보이며, 키 단위 알림은 키를 만든 뒤부터 생깁니다. 스트림이 열려 있으면 같은 알림이 `op = "notice"`로 즉시 푸시되며, 오프라인 후에는 `since`로 따라잡습니다.

**API 키 필요**

## 파라미터

| 파라미터 | 위치 | 타입 | 필수 | 설명 |
|---|---|---|---|---|
| `since` | query | integer |  | 이 Unix 시간(초) 이후 알림만 반환, 0이면 전체. |
| `limit` | query | integer |  | 최대 개수 1–200, 기본 50. |

## 요청 예시

**cURL**

```bash
curl "https://api.tokenearly.com/v1/notices?limit=10" \
  -H "Authorization: Bearer $TOKENEARLY_API_KEY"
```

**Python**

```python
import os, requests

resp = requests.get(
    "https://api.tokenearly.com/v1/notices?limit=10",
    headers={"Authorization": f"Bearer {os.environ['TOKENEARLY_API_KEY']}"},
    timeout=10,
)
resp.raise_for_status()
print(resp.json())
```

**Node.js**

```javascript
// Node 18+ (built-in fetch)
async function main() {
  const resp = await fetch("https://api.tokenearly.com/v1/notices?limit=10", {
    headers: { Authorization: `Bearer ${process.env.TOKENEARLY_API_KEY}` },
  });
  const body = await resp.json();
  if (!resp.ok) throw new Error(`${body.error.code}: ${body.error.message}`);
  console.log(body);
}

main().catch((err) => {
  console.error(err);
  process.exit(1);
});
```

**Go**

```go
package main

import (
	"fmt"
	"io"
	"net/http"
	"os"
)

func main() {
	req, _ := http.NewRequest("GET", "https://api.tokenearly.com/v1/notices?limit=10", nil)
	req.Header.Set("Authorization", "Bearer "+os.Getenv("TOKENEARLY_API_KEY"))
	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()
	body, _ := io.ReadAll(resp.Body)
	fmt.Println(resp.Status, string(body))
}
```

## 응답 예시

```json
{
  "notices": [
    {
      "id": "ntc_3f9c2a71d0b84e6c5a12",
      "kind": "key_limits_changed",
      "scope": "key",
      "key_id": "key_8d2f0c1b7a6e4d3c2b1a",
      "title": {
        "zh": "API Key 限额已调整",
        "en": "API key limits changed",
        "ko": "API 키 한도 변경"
      },
      "body": {
        "zh": "te_live_Ab12…  每把 Key 的实时连接数: 1 → 2",
        "en": "te_live_Ab12…  Stream connections per key: 1 → 2",
        "ko": "te_live_Ab12…  키당 실시간 연결 수: 1 → 2"
      },
      "data": {
        "key_id": "key_8d2f0c1b7a6e4d3c2b1a",
        "prefix": "te_live_Ab12",
        "changes": {
          "streams_per_key": [
            1,
            2
          ]
        }
      },
      "created_at": 1794208744
    }
  ]
}
```

## 오류

| 코드 | HTTP | 설명 |
|---|---|---|
| `missing_api_key` | 401 | 키가 없습니다. `Authorization: Bearer <키>`를 쓰세요. |
| `invalid_api_key` | 401 | 키가 없거나 재설정 또는 폐기되었습니다. |
| `key_expired` | 401 | 체험 키가 만료되었습니다. 새 체험 키를 신청하거나 구독 후 정식 키를 만드세요. |
| `plan_required` | 403 | 현재 플랜에 개발자 API(또는 해당 기능)가 없습니다. |
| `ip_not_allowed` | 403 | 키에 IP 허용 목록이 설정되어 있고 요청 IP가 목록에 없습니다. |
| `invalid_parameter` | 400 | 파라미터 타입이나 값이 잘못되었습니다(예: limit 범위 초과). |
| `rate_limited` | 429 | 이 키의 요청 빈도를 넘었습니다(REST와 MCP 합산, 간격은 `/v1/me`의 `limits.rest_interval_seconds`). Retry-After 초만큼 기다린 뒤 다시 시도하세요. |

## 알림 종류

| kind | scope | 의미 |
|---|---|---|
| `defaults_changed` | `global` | 기본 한도 조정(이전 → 이후) |
| `account_limits_changed` | `user` | 내 계정 한도 조정 |
| `key_limits_changed` | `key` | 특정 키 한도 조정 |
| `ip_allowlist_changed` | `key` | 특정 키 IP 허용 목록 변경(data.before / data.after) |
| `key_reset` | `key` | 특정 키 재설정(data.old_prefix / data.prefix는 이전·새 접두사, 새 키로 전송되며 기존 키의 연결은 이미 끊김) |
| `key_revoked` | `key` | 특정 키 폐기 |
| `access_expiring` | `user` | API가 포함된 멤버십 만료 임박(7·3·1일 전 각 1회, data.expires_at은 만료 시각) |
| `access_expired` | `user` | API가 포함된 멤버십 만료. 키는 403 plan_required / 4003으로 거부되며 갱신하면 같은 키가 바로 다시 동작 |
| `api_update` | `global` | API 공지 |

- `scope`: `global` = 전체, `user` = 내 계정, `key` = 특정 키(`key_id` 참고).
- `data.changes`는 `{항목: [이전, 이후]}`이며 `null`은 기본값입니다.
- `since`는 배타적(그 이후 알림만)이며 호출당 최대 200건, 커서는 없습니다. 마지막 알림의 `created_at`을 다음 `since`로 쓰세요.
