HTTP API
Reference for the Pico protocol on the stream listener. The Kafka listener is covered in Kafka protocol, and the admin listener in Admin API.
OpenAPI spec: openapi.yaml
Conventions
- Names. The request path is the topic name, so
/logs/api/prodaddresses that topic. Slashes and dots are the same separator, and the/_namespace is reserved, see Topics and streams. - Encoding. Paths and query values are percent-decoded once. A value that does not decode to UTF-8 is a
400, never rewritten into another name. - Partitions. A topic has one partition unless it was created or grown with more. Every request to a topic with several partitions names one with
?partition=N, and leaving it out is a400. - Sequences. Record offsets within a partition, starting at
0and stable forever. - Headers. Custom headers use the
Pico-prefix. - Redirects. A request for a partition owned by another node returns
307with the owner's address inLocation. Standard HTTP clients dropAuthorizationon cross-origin redirects, so clients follow307s themselves and re-attach the credential. A hop must stay onhttporhttpsand never downgrade fromhttpstohttp, since the credential rides along, and the clients refuse such a hop asunsafe_redirect.picomq-client, the Go and TypeScript clients, and the CLI do all of this. - Auth. With auth required, every request sends
Authorization: Bearer <token>. See Authorization for scopes.
Errors
Errors on stream and group routes are JSON with a code:
json
{ "error": "conflict", "message": "producer epoch 3 is stale", "next_seq": 42 }message and next_seq appear when they help. next_seq is also sent as Pico-Next-Seq.
| Status | error | Meaning |
|---|---|---|
400 | bad_request | Malformed request |
401 | unauthenticated | No valid credential, with a WWW-Authenticate: Bearer challenge |
403 | permission_denied | Insufficient scope |
403 | fenced | Stale producer epoch, with the current one in Pico-Producer-Epoch |
404 | not_found | No such topic, partition, or group |
405 | method_not_allowed | A method this protocol does not serve |
409 | conflict | Create with different settings |
409 | sequence_gap | Producer sequence gap, with Pico-Expected-Seq and Pico-Received-Seq |
409 | closed | The topic is sealed, with Pico-Closed: true |
412 | match_failed | Pico-Match-Seq did not match the tail |
413 | Body larger than --max-request-size | |
500 | durability, internal | The WAL write failed, or an unexpected error |
503 | unavailable | The partition is moving between nodes, the node is stopping, or metadata is unreachable. Retry |
504 | timeout | The operation timed out. Retry |
Retrying 503 and 504 is safe. How the same failures look over Durable Streams and Kafka is in Protocols.
The topic config route, /_streams, is a control surface and answers errors as {"error": "<message>"}, like the admin API.
Lists
Every list on this listener and on the admin API pages the same way. Items come in their natural order, by name, id, or offset, never sorted another way, and the response is:
json
{ "items": [ ... ], "next": "opaque" }| Query parameter | Meaning |
|---|---|
limit | Items per page, 100 by default and 1000 at most |
cursor | The next of the previous page, to continue after it |
| Filters | Such as prefix, sent again with every page |
- Last page.
nextisnull. - Short pages. A page can hold fewer items than
limitwhilenextis set, when entries the token may not see were skipped or the page reached its size cap. Keep followingnextuntil it isnull. - Cursors. A cursor only continues the list it came from, so sending it with different filters is a
400.
Topic settings
A topic's settings are given as headers on create. Some can change later through the topic config route, and the rest are fixed for the topic's life.
| Setting | Create header | Config field | After create |
|---|---|---|---|
| Content type | Content-Type, default application/octet-stream | Fixed | |
| Partitions | Pico-Partitions, default 1 | partitions | Grows, never shrinks, by at most 10000 at a time |
| Expiry | Pico-TTL, seconds without appends or reads, or Pico-Expires-At, a fixed time. Not both | Fixed | |
| Retention | Pico-Retention-Ms, Pico-Retention-Bytes, unlimited by default | retentionMs, retentionBytes | Set, or removed with null |
| Sealed | Pico-Closed: true | Sealed by an append with Pico-Closed, never reopened | |
| Kafka name | Follows from the topic name | kafkaTopic | Fixed |
Limits must be positive, and a partition count of 0 is a 400.
Create
PUT /{topic}Creates a topic with the settings in its headers, with no body. 201 when created, 200 when it already exists with the same settings, 409 when the settings differ. The response carries the same headers as Inspect.
Append
POST /{topic}Appends records. The body is a single record in the topic's content type, a JSON batch (application/vnd.picomq.batch+json) of records, or a binary batch (application/vnd.picomq.batch). Returns 200.
| Request header | Meaning |
|---|---|
Pico-Key | Record key for a single-record body. Batch bodies carry keys inline |
Pico-Producer-Id, Pico-Producer-Epoch, Pico-Producer-Seq | Idempotent producer identity. A repeated seq is acknowledged without writing |
Pico-Match-Seq | Conditional append: succeeds only if the tail is at this sequence |
Pico-Closed | true seals the topic after this append. With no body, it only seals |
Pico-Trim-Seq | Turns the request into a trim, dropping records below this sequence. No body |
| Response header | Meaning |
|---|---|
Pico-Start-Seq | Sequence of the first record in this append, or the new start after a trim |
Pico-Next-Seq | The partition's next sequence after the append |
Pico-Timestamp | Timestamp assigned to the records |
Pico-Producer-Epoch, Pico-Producer-Seq | The producer state the append was accepted at |
Read
GET /{topic}?seq=0Reads records from a sequence. Without live it returns what exists and stops. seq=now starts at the tail, and an SSE reconnect can supply Last-Event-ID instead of seq.
| Query parameter | Meaning |
|---|---|
seq | Start position: a number, or now. Defaults to 0 |
count, bytes | Caps on records and bytes returned |
format | json (default), binary batch, or raw concatenated bodies |
live | long-poll waits for the next record, sse holds the response open as an event stream |
Records come back in the record shape, with seq and timestamp added.
| Response header | Meaning |
|---|---|
Pico-Next-Seq | Where to resume. Pass it as the next seq |
Pico-Up-To-Date | true when the response reaches the tail |
Pico-Closed | true when the topic is sealed and fully read |
Pico-Cursor | Opaque resume token for paginated catch-up reads |
Catch-up responses include an ETag and honor If-None-Match with 304, so polling readers that are caught up transfer nothing. A long poll that times out with no data returns 204. SSE delivers each record as an event with its sequence as the event id, and ends with a control event when the topic is sealed. A node that is shutting down ends live reads with 503, and the client reconnects.
Records
A JSON batch is {"records": [...]}, and each record has a key, ordered headers, and a body:
json
{
"key": "customer-1042",
"headers": [
{ "name": "trace-id", "value": "4f9c2a" },
{ "name": "trace-id", "value": "7d1e08" },
{ "name": "deleted-by", "value": null }
],
"body": "{\"order\":\"o-981\",\"amount\":42.5}"
}- Bytes. UTF-8 text goes in
key,body, and a header'svalue. Other bytes usekey_b64,body_b64, orvalue_b64with base64 instead. - Headers. A list, kept in order, so a name can repeat.
- Null. A
bodyofnullis a record with no value, the Kafka tombstone, and a headervalueofnullhas no value either. An absentkeymeans no key. A binary batch carries the same fields, with a length of-1for null.
Inspect
HEAD /{topic}Returns the topic's metadata in headers with no body, or 404.
| Response header | Meaning |
|---|---|
Content-Type | The topic's content type |
Pico-Partitions | Number of partitions |
Pico-Start-Seq, Pico-Next-Seq | The partition's readable range. On a topic with several partitions, only with ?partition= |
Pico-TTL, Pico-Expires-At | Expiry settings, when set |
Pico-Retention-Ms, Pico-Retention-Bytes | Retention limits, when set |
Pico-Closed | true when sealed |
Pico-Kafka-Topic | The topic's Kafka name, when it has one |
Delete
DELETE /{topic}Removes the topic, all of its partitions, and their records. 204 on success, 404 when it does not exist. The name is reusable at once.
List
GET /?prefix=/logs/&limit=100Lists topics in pages, filtered by name prefix. Each item has name, content_type, partitions, and closed, plus ttl and expires_at when the topic expires. With auth, only topics the token's stream matchers cover are listed.
Topic config
GET /_streams/{topic}
PATCH /_streams/{topic}Reads and changes a topic's settings as JSON, with the config fields from Topic settings. Both routes serve either HTTP protocol, and cover topics created over Kafka too. In a cluster they follow the ownership of partition 0.
json
{ "kafkaTopic": "orders", "partitions": 3, "retentionMs": 604800000, "retentionBytes": null }GETreturns every field, withnullfor an unset one.404when the topic does not exist.PATCHtakes only the fields to change and returns the result. An absent field is left alone, andnullremoves a setting. Apartitionsthat does not grow the topic, or akafkaTopic, is a400.- Auth.
GETneedsheadon the topic andPATCHneedscreate. Errors take the control surface's shape.
Consumer groups
How groups work is in Consumer groups. Group routes are served on a Pico listener, not on Durable Streams, and redirect to the group's coordinator like topic requests.
| Route | Does |
|---|---|
GET /_groups?prefix= | Lists group ids in pages, only the groups the token may describe |
GET /_groups/{group} | Describes a group: group, state, generation, and members |
DELETE /_groups/{group} | Deletes a group without members and its offsets. 204 |
POST /_groups/{group}/members | Joins. Returns once the rebalance completes |
GET /_groups/{group}/members/{member}?generation= | The member's current assignment |
POST /_groups/{group}/members/{member}/heartbeat | Keeps the member alive. 204 |
DELETE /_groups/{group}/members/{member} | Leaves. 204 |
PUT /_groups/{group}/offsets | Commits offsets. 204 |
GET /_groups/{group}/offsets?stream= | Fetches committed offsets, for the named topics or all of them |
A join sends the topics to subscribe to, at least one, and optionally the member's previous id, a static instanceId, a clientId, and timeouts:
json
{ "subscription": ["/orders", "/payments"], "sessionTimeoutMs": 30000 }and gets back the member id, generation, and the topics assigned to it:
json
{ "memberId": "m-1", "generation": 3, "assignment": ["/orders"], "members": ["m-1", "m-2"] }Heartbeats send {"generation": 3}. A commit sends offsets for at least one topic, with the member id and generation when committing as a member:
json
{ "offsets": { "/orders": { "position": 42, "metadata": "checkpoint" } }, "memberId": "m-1", "generation": 3 }Group errors use the error format above:
| Status | error | Meaning |
|---|---|---|
404 | unknown_member, not_found | The member or group does not exist |
409 | rebalance_in_progress | Rejoin to get the new assignment |
409 | illegal_generation | The member is behind the group's generation. Rejoin |
409 | inconsistent_protocol | The group is in use by Kafka members |
409 | conflict | Delete of a group with members, or a join replaced by a newer one |
403 | fenced | Another member holds this static instanceId |
429 | capacity_exceeded | The coordinator's group or member limits were hit |
503 | coordinator_unavailable | The coordinator is moving. Retry |
Durable Streams
A listener started with --protocol ds speaks the Durable Streams open protocol on its exact wire vocabulary, with Stream-* and Producer-* headers, raw record bodies, plain text errors, and one record per append. The topic settings the protocol has no header for are extensions under the same prefix: Stream-Partitions, Stream-Retention-Ms, and Stream-Retention-Bytes. Topics created through either HTTP protocol or Kafka are readable through all three.