Sidebar

Displays the mobile sidebar.

Search the docs

Search the docs

The example
The example
What is in it
What it has, exactly
Making it yours
How it is built
How it is built
A page declares what it needs
Running it
The API of charter-example
The API of charter-example
Operations
Ways in
GET /api/hello
GET /api/notes
POST /api/notes
GET /api/notes/watch
DELETE /api/notes/{id}
GET /api/people
PUT /api/people/{id}/role
Types
ErrorDetail
ErrorModel
Note
Person
The database
The database
Tables
notes
activity
attachments
users
passkeys
tokens
ceremonies
Statements
What the Worker is bound to
What the Worker is bound to
Sign in

Time zone and clock

Dates and times on every page use these settings. Automatic uses your browser's time zone.

Loading…

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

OperationWhat it doesWho may call itHow often
GET /api/helloSay helloanyoneno limit of its own
GET /api/notesList notes, newest first (cursor pagination)anyoneno limit of its own
POST /api/notesCreate a notewrite100 calls in 60 s, for each caller
GET /api/notes/watchStream notes as they are created (Server-Sent Events). The stream ends after seconds; call again with after = the last note id to continue without gapsanyoneno limit of its own
DELETE /api/notes/{id}Remove a note: your own, or anyone's if you may moderatewriteno limit of its own
GET /api/peopleEveryone who signed up, and their roleadminno limit of its own
PUT /api/people/{id}/roleMake someone a member, a moderator or an adminadminno 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.

WayHow it is sent
accessClientIdA Cloudflare Access service token's Client ID: a machine's own (cf zero-trust access service-tokens create)
accessClientSecretThe service token's Client Secret
bearerA 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
oidcAn 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 answersWith
200 OKan object (application/json), below
default ErrorErrorModel (application/problem+json)

What it answers with:

FieldType
messagestringFor example Hello from charter-example

GET /api/notes

List notes, newest first (cursor pagination). In the SDKs and the specs it is listNotes.

It takesWhereType
cursorquerystringOpaque cursor from the previous page's next_cursor. For example 42
limitqueryinteger (int32)Default 20. From 1 to 100. For example 20
It answersWith
200 OKan object (application/json), below
422 Unprocessable EntityErrorModel (application/problem+json)
default ErrorErrorModel (application/problem+json)

What it answers with:

FieldType
datalist of Note
next_cursorstringOptional. 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):

FieldType
bodystringFor example Buy milk
It answersWith
200 OKNote (application/json)
401 UnauthorizedErrorModel (application/problem+json)
422 Unprocessable EntityErrorModel (application/problem+json)
429 Too Many Requests: more than 100 calls in 60 s by this callerErrorModel (application/problem+json)
default ErrorErrorModel (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 takesWhereType
afterquerystringResume after this note id (the id of the last note you received). Absent: only notes created from now on. For example 42
secondsqueryinteger (int32)How long to keep the stream open. Default 30. From 1 to 300. For example 30
It answersWith
200 OKNote (text/event-stream)
422 Unprocessable EntityErrorModel (application/problem+json)
default ErrorErrorModel (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 takesWhereType
idpathinteger (int64)Required. For example 42
It answersWith
204 No Contentnothing
401 UnauthorizedErrorModel (application/problem+json)
403 ForbiddenErrorModel (application/problem+json)
404 Not FoundErrorModel (application/problem+json)
422 Unprocessable EntityErrorModel (application/problem+json)
default ErrorErrorModel (application/problem+json)

GET /api/people

Everyone who signed up, and their role. In the SDKs and the specs it is listPeople.

It answersWith
200 OKan object (application/json), below
401 UnauthorizedErrorModel (application/problem+json)
default ErrorErrorModel (application/problem+json)

What it answers with:

FieldType
datalist 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 takesWhereType
idpathstringRequired. For example 4f1c9a0e7b2d4c6f8a1b3c5d7e9f0a1b

Its body is an object (application/json):

FieldType
rolestringOne of member, moderator, admin. For example moderator
It answersWith
200 OKPerson (application/json)
401 UnauthorizedErrorModel (application/problem+json)
404 Not FoundErrorModel (application/problem+json)
422 Unprocessable EntityErrorModel (application/problem+json)
default ErrorErrorModel (application/problem+json)

Types

ErrorDetail

FieldType
locationstringOptional. Where the error occurred, e.g. 'body.items[3].tags' or 'path.thing-id'
messagestringOptional. Error message text
valueanyOptional. The value at the given location

ErrorModel

FieldType
detailstringOptional. A human-readable explanation specific to this occurrence of the problem.. For example Property foo is required but is missing.
errorslist of ErrorDetailOptional. Optional list of individual error details
instancestring (uri)Optional. A URI reference that identifies the specific occurrence of the problem.. For example https://example.com/error-log/abc123
statusinteger (int64)Optional. HTTP status code. For example 400
titlestringOptional. A short, human-readable summary of the problem type. This value should not change between occurrences of the error.. For example Bad Request
typestring (uri)Optional. A URI reference to human-readable documentation for the error.. Default about:blank. For example https://example.com/errors/example

Note

FieldType
idinteger (int64)For example 42
bodystringFor example Buy milk
author_idstringWho wrote it: their id, empty for a program with one of the Worker's own tokens. For example 4f1c9a0e7b2d4c6f8a1b3c5d7e9f0a1b
authorstringWhat they call themselves. For example Ada
created_atstringFor example 2026-10-01 12:00:00

Person

FieldType
idstringFor example 4f1c9a0e7b2d4c6f8a1b3c5d7e9f0a1b
rolestringOne of member, moderator, admin. For example member
namestringOptional. For example Ada