The API of charter-example
Every operation the API has, who may call it, what it takes and what it answers.
Written by charter from the API's contract (fern/openapi.json, which charter check holds to the Go types the API is written in): it is what the app has now, and changes when that does.
The contract itself, for a program to read: /api/openapi.json. The API is served at https://charter-example.gedw99.workers.dev.
Operations
| Operation | What it does | Who may call it | How often |
|---|---|---|---|
GET /api/hello | Say hello | anyone | no limit of its own |
GET /api/notes | List notes, newest first (cursor pagination) | anyone | no limit of its own |
POST /api/notes | Create a note | write | 100 calls in 60 s, for each caller |
GET /api/notes/watch | Stream notes as they are created (Server-Sent Events). The stream ends after seconds; call again with after = the last note id to continue without gaps | anyone | no limit of its own |
DELETE /api/notes/{id} | Remove a note: your own, or anyone's if you may moderate | write | no limit of its own |
GET /api/people | Everyone who signed up, and their role | admin | no limit of its own |
PUT /api/people/{id}/role | Make someone a member, a moderator or an admin | admin | no limit of its own |
Ways in
A caller says who it is in one of these ways. What it may then do is what it was granted: the scopes above.
| Way | How it is sent |
|---|---|
accessClientId | A Cloudflare Access service token's Client ID: a machine's own (cf zero-trust access service-tokens create) |
accessClientSecret | The service token's Client Secret |
bearer | A token of the Worker's own, or one a person who signed in to the app made for a program on their account page: it may do what they may, or less |
oidc | An access token from the OpenID Connect issuer the deployment trusts (OIDC_ISSUER), with the operation's scopes |
GET /api/hello
Say hello. In the SDKs and the specs it is hello.
| It answers | With |
|---|---|
| 200 OK | an object (application/json), below |
| default Error | ErrorModel (application/problem+json) |
What it answers with:
| Field | Type | |
|---|---|---|
message | string | For example Hello from charter-example |
GET /api/notes
List notes, newest first (cursor pagination). In the SDKs and the specs it is listNotes.
| It takes | Where | Type | |
|---|---|---|---|
cursor | query | string | Opaque cursor from the previous page's next_cursor. For example 42 |
limit | query | integer (int32) | Default 20. From 1 to 100. For example 20 |
| It answers | With |
|---|---|
| 200 OK | an object (application/json), below |
| 422 Unprocessable Entity | ErrorModel (application/problem+json) |
| default Error | ErrorModel (application/problem+json) |
What it answers with:
| Field | Type | |
|---|---|---|
data | list of Note | |
next_cursor | string | Optional. Pass as cursor for the next page; absent on the last page. For example 41 |
POST /api/notes
Create a note. In the SDKs and the specs it is createNote.
Its body is an object (application/json):
| Field | Type | |
|---|---|---|
body | string | For example Buy milk |
| It answers | With |
|---|---|
| 200 OK | Note (application/json) |
| 401 Unauthorized | ErrorModel (application/problem+json) |
| 422 Unprocessable Entity | ErrorModel (application/problem+json) |
| 429 Too Many Requests: more than 100 calls in 60 s by this caller | ErrorModel (application/problem+json) |
| default Error | ErrorModel (application/problem+json) |
GET /api/notes/watch
Stream notes as they are created (Server-Sent Events). The stream ends after seconds; call again with after = the last note id to continue without gaps. Each event's SSE id is the note id, so a browser EventSource resumes by itself (Last-Event-ID). In the SDKs and the specs it is watchNotes.
| It takes | Where | Type | |
|---|---|---|---|
after | query | string | Resume after this note id (the id of the last note you received). Absent: only notes created from now on. For example 42 |
seconds | query | integer (int32) | How long to keep the stream open. Default 30. From 1 to 300. For example 30 |
| It answers | With |
|---|---|
| 200 OK | Note (text/event-stream) |
| 422 Unprocessable Entity | ErrorModel (application/problem+json) |
| default Error | ErrorModel (application/problem+json) |
DELETE /api/notes/{id}
Remove a note: your own, or anyone's if you may moderate. In the SDKs and the specs it is deleteNote.
| It takes | Where | Type | |
|---|---|---|---|
id | path | integer (int64) | Required. For example 42 |
| It answers | With |
|---|---|
| 204 No Content | nothing |
| 401 Unauthorized | ErrorModel (application/problem+json) |
| 403 Forbidden | ErrorModel (application/problem+json) |
| 404 Not Found | ErrorModel (application/problem+json) |
| 422 Unprocessable Entity | ErrorModel (application/problem+json) |
| default Error | ErrorModel (application/problem+json) |
GET /api/people
Everyone who signed up, and their role. In the SDKs and the specs it is listPeople.
| It answers | With |
|---|---|
| 200 OK | an object (application/json), below |
| 401 Unauthorized | ErrorModel (application/problem+json) |
| default Error | ErrorModel (application/problem+json) |
What it answers with:
| Field | Type | |
|---|---|---|
data | list of Person |
PUT /api/people/{id}/role
Make someone a member, a moderator or an admin. In the SDKs and the specs it is setRole.
| It takes | Where | Type | |
|---|---|---|---|
id | path | string | Required. For example 4f1c9a0e7b2d4c6f8a1b3c5d7e9f0a1b |
Its body is an object (application/json):
| Field | Type | |
|---|---|---|
role | string | One of member, moderator, admin. For example moderator |
| It answers | With |
|---|---|
| 200 OK | Person (application/json) |
| 401 Unauthorized | ErrorModel (application/problem+json) |
| 404 Not Found | ErrorModel (application/problem+json) |
| 422 Unprocessable Entity | ErrorModel (application/problem+json) |
| default Error | ErrorModel (application/problem+json) |
Types
ErrorDetail
| Field | Type | |
|---|---|---|
location | string | Optional. Where the error occurred, e.g. 'body.items[3].tags' or 'path.thing-id' |
message | string | Optional. Error message text |
value | any | Optional. The value at the given location |
ErrorModel
| Field | Type | |
|---|---|---|
detail | string | Optional. A human-readable explanation specific to this occurrence of the problem.. For example Property foo is required but is missing. |
errors | list of ErrorDetail | Optional. Optional list of individual error details |
instance | string (uri) | Optional. A URI reference that identifies the specific occurrence of the problem.. For example https://example.com/error-log/abc123 |
status | integer (int64) | Optional. HTTP status code. For example 400 |
title | string | Optional. A short, human-readable summary of the problem type. This value should not change between occurrences of the error.. For example Bad Request |
type | string (uri) | Optional. A URI reference to human-readable documentation for the error.. Default about:blank. For example https://example.com/errors/example |
Note
| Field | Type | |
|---|---|---|
id | integer (int64) | For example 42 |
body | string | For example Buy milk |
author_id | string | Who wrote it: their id, empty for a program with one of the Worker's own tokens. For example 4f1c9a0e7b2d4c6f8a1b3c5d7e9f0a1b |
author | string | What they call themselves. For example Ada |
created_at | string | For example 2026-10-01 12:00:00 |
Person
| Field | Type | |
|---|---|---|
id | string | For example 4f1c9a0e7b2d4c6f8a1b3c5d7e9f0a1b |
role | string | One of member, moderator, admin. For example member |
name | string | Optional. For example Ada |