API reference
REST, MCP, the CloudEvents Subscriptions API and AsyncAPI
Gateways serve the APIs of Cloud Streams: on their public endpoint, ingestion and acknowledgements, and on their management endpoint, everything else (see Exposure).
| API | Path | Endpoint |
|---|---|---|
| Ingestion | POST /api/events/pub (see Ingestion) |
public |
| Acknowledgements | POST /api/resources/v1/namespaces/{namespace}/subscriptions/{name}/ack and .../nack (see Deferred acknowledgement) |
public |
| Resources | /api/resources/v1/namespaces/{namespace}/{gateways,brokers,subscriptions,sinks,feeds}, and /api/resources/v1/{namespaces,schemas} |
management |
| Subscription operations | POST .../subscriptions/{name}/suspend, resume, replay, skip, redeliver, and .../dead-letters (see Delivery) |
management |
| Cloud events | /api/resources/v1/namespaces/{namespace}/cloudevents/...: stream, stream/read, stream/activity, search, trace and partitions/{type}, and /api/resources/v1/cloudevents/... for the whole stream (see Operations) |
management |
| AsyncAPI | GET /api/resources/v1/namespaces/{namespace}/asyncapi (see AsyncAPI) |
management |
| Real-time hubs | /api/ws/resources/watch and /api/ws/events, over SignalR |
management |
| MCP | /mcp (see MCP) |
management |
| CloudEvents Subscriptions API | /api/cloudevents/v1/subscriptions (see below) |
management |
- OpenAPI: the gateway serves the OpenAPI document of its API at
/api/v1/doc/oas.json, and Swagger UI at/api/doc. - Client: the
CloudStreams.Core.Api.ClientNuGet package is a typed .NET client of the management API. - Kubernetes: in Kubernetes mode, resources are also custom resources, managed with
kubectl, and the operations above are subresources of an aggregated API, which thekubectl cloud-streamsplugin calls (see Kubernetes). - Errors: failures are described with problem details, whose
typeidentifies the problem, e.g.https://cloud-streams.io/problems/not-foundfor a path that serves nothing. - Upgrading: paths that changed between major versions are listed in UPGRADING.md.
MCP
The gateway and the API serve a Model Context Protocol endpoint at /mcp, over the Streamable HTTP transport, so that agents can inspect and operate Cloud Streams. It requires the reader role, and the tools that change something require the operator role, as the endpoints they mirror do. The endpoint is stateless, so it needs no session affinity behind several replicas.
| Tool | Does | Role |
|---|---|---|
GetStreamMetadata, GetPartitionMetadata |
gets the metadata of the stream, or of a partition | reader |
ListPartitions |
lists the ids of the partitions of a type, page by page | reader |
ReadStream |
reads events from the stream, or from a partition | reader |
ListSubscriptions |
lists the subscriptions, with their phase, lag, subscriber state and fault | reader |
GetSubscription |
gets a subscription, with its spec and status | reader |
ListDeadLetters |
lists the events a subscription failed to deliver | reader |
SuspendSubscription, ResumeSubscription |
suspends or resumes a subscription | operator |
ReplaySubscription |
replays a subscription, from the start of the stream or from a point in time | operator |
SkipSubscriptionEvent |
skips the event that faulted a subscription | operator |
PublishEvent |
publishes an event, e.g. to test a subscription, through the gateway’s admission pipeline. Gateways only | operator |
CloudEvents Subscriptions API
Cloud Streams implements the CloudEvents Subscriptions API on top of its subscriptions, at /api/cloudevents/v1/subscriptions. The specification’s HTTP binding is yet to be defined, so:
| Request | Does | Answers |
|---|---|---|
POST /api/cloudevents/v1/subscriptions |
creates a subscription, whose id the server assigns | 201 Created, with its Location |
GET /api/cloudevents/v1/subscriptions |
lists the subscriptions, including those created otherwise | 200 OK |
GET /api/cloudevents/v1/subscriptions/{id} |
gets a subscription | 200 OK, or 404 Not Found |
PUT /api/cloudevents/v1/subscriptions/{id} |
updates a subscription. It doesn’t create missing ones | 200 OK, or 404 Not Found |
DELETE /api/cloudevents/v1/subscriptions/{id} |
deletes a subscription | 200 OK with the deleted subscription, or 404 Not Found |
Reading requires the reader role, and writing the admin role. Errors are problem details.
{
"source": "https://github.com/cloudevents",
"filters": [
{ "any": [ { "exact": { "type": "com.github.push" } }, { "prefix": { "type": "com.github.pull_request" } } ] },
{ "not": { "suffix": { "subject": "/spec" } } }
],
"sink": "https://subscriber.example.com/events",
"protocol": "HTTP"
}
How a subscription maps onto Cloud Streams:
- Sink: the
sinkis the subscriber. - Filters:
source,typesandfiltersare compiled into the subscription’s filter:exact,prefixandsuffixexpressions on different attributes become attribute filters;- anything that uses
all,any,notorsqlotherwise becomes a CloudEvents SQL filter, e.g.(type = 'com.github.push') AND (NOT ((EXISTS subject AND subject LIKE '%/spec'))); - matches are case-sensitive, and an event that doesn’t define an attribute doesn’t match it: matches on optional attributes are guarded by
EXISTS, so thatnotkeeps that meaning; - a filter that CloudEvents SQL can’t address, on an attribute whose name isn’t made of lower-case letters and digits, or with a value that contains a backslash, becomes a runtime expression, as before. It can’t be combined with the
sqldialect.
- Offset: the subscription tracks an offset, starting at the end of the stream, which
config.offsetcan override. - Round trips: the subscription as submitted is kept in the
cloudevents.io/subscriptionannotation, and returned as is. Subscriptions created otherwise are described as well as they can be: a partition by source or type becomessourceortypes, attribute filters that are anchored literals becomeexact,prefixorsuffixfilters, and CloudEvents SQL filters becomesqlfilters. Other filters are left out.
Refused with 400 Bad Request:
- any
protocolother thanHTTP; sinkcredential;- the
headersprotocol setting, and anymethodother thanPOST; - configuration keys other than
offset; - a
sqlfilter that isn’t a valid CloudEvents SQL filter.
AsyncAPI
The gateways and the subscriptions of a namespace are described by an AsyncAPI 3.0 document, which tells what can be published, with the schemas of the data, and to whom it is delivered:
GET /api/resources/v1/namespaces/{namespace}/asyncapi # JSON, or YAML with 'Accept: application/yaml' or '?format=yaml'
GET /api/resources/v1/namespaces/{namespace}/asyncapi?gateway=orders
It requires the reader role in the namespace. The dashboard downloads it from the Gateways page, kubectl cloud-streams asyncapi writes it, and the GetAsyncApiDocument MCP tool returns it.
What it describes, from the point of view of the applications that use Cloud Streams:
- Servers: one per gateway, at its public address, which is its ingress host, or the first hostname of its HTTP route. A gateway whose address is unknown, e.g. one Cloud Streams doesn’t deploy, gets the placeholder host
gateway.example.com. Its security schemes are those of its publishers: an API key in a header, a bearer token, or a Standard Webhooks signature, and a bearer token when the cluster’s ingestion authentication is enabled. - Messages: one per entry of the gateway’s
spec.events. Their payload is the cloud event, in the structured content mode, whosesourceandtypeare constants when the patterns match a single value, and regular expressions otherwise. Itsdatais described by the JSON schema the entry binds, the pinned version or the latest one. A schema that isn’t registered is said to be missing. sendoperations: one per message, which publishers send to the gateway’s/api/events/pub.receiveoperations: one per subscription, on a channel at its subscriber’s address, orsink:{name}. They list every message of the namespace, which the subscription’s partition and filter narrow down: these are described as they are by thex-cloud-streams-partitionandx-cloud-streams-filterextensions, and the delivery mode, and whether deliveries are signed, byx-cloud-streams-delivery.
Typed clients can be generated from it with the AsyncAPI CLI, e.g. models of the events’ data:
$ kubectl cloud-streams asyncapi -n tenant-a > asyncapi.yaml
$ asyncapi generate models typescript asyncapi.yaml -o ./models
$ asyncapi generate models csharp asyncapi.yaml -o ./Models --namespace Orders.Events
Resource validation
Subscriptions, brokers and gateways are validated when they are created, replaced or patched, and rejected with 400 Bad Request if their spec could only fail at runtime. The response names each invalid field, e.g. “‘spec.subscriber.rateLimit’ must be greater than ‘0’”. The checks cover:
- Regular expressions that don’t compile: attribute filters (unless they are runtime expressions), authorization rules, and gateway event patterns.
- CloudEvents SQL filters that don’t parse, call a function that doesn’t exist, or can’t evaluate to a boolean.
- URIs: webhook, acknowledgement callback and service URIs must be absolute HTTP(S) URIs. The endpoints of subscribers, dead-letter services, sinks and feeds may also be the address of another transport, without credentials in it, and their authentication must suit their transport (see Transports).
- Retry policies: a backoff is required, an exponential backoff needs a positive exponent,
maxAttemptsmust be positive or-1, andstatusCodesmust be HTTP status codes. - Required fields: a filter’s expression, a mutation’s expression or webhook, a partition’s id, an attribute sequencing strategy’s attribute name, a payload rule’s maximum size, and the bounds of time-based rules (with
fromnot afterto). - Numbers: positive rate limits and split-horizon chain lengths, and stream offsets of at least
-1.
Status updates are never validated, so a broker can still record the state of a subscription that was stored before these checks existed.
?dryRun=true on POST, PUT and PATCH validates a resource without saving it, which is how the dashboard’s forms check what they are about to save:
- Validated:
200 OK. - Refused:
400 Bad Request, with the errors keyed by the path of each invalid field, e.g.{ "errors": { "spec.subscriber.endpoint": [ "..." ] } }. - Creating a resource that already exists:
409 Conflict.
A dry-run creation used to save the resource anyway.
POST api/resources/v1/namespaces/{namespace}/gateways/{name}/test evaluates a cloud event against a gateway spec that need not be saved, { "spec": { ... }, "event": { ... } }, without storing or counting the event; rate limits and deduplication do not apply. It responds with the outcome (accepted, ignored, rejected or invalid), the status publishers would get, the reason, and for an accepted event the attributes it would be stored with and the metadata extracted from it. It requires the Administer policy, and the standalone API, which ingests no events, responds 501 Not Implemented.
Concurrent updates
Every update of a resource is atomic: it only applies to the state it was computed against, so concurrent writers, such as the broker, the acknowledgement endpoints and the dashboard, never overwrite each other.
- A patch that names an expected
resourceVersionfails with409 Conflictif the resource has changed since then. Replacements always expect the version of the resource they carry. - A patch that doesn’t name one is applied again to the new state if the resource changes while it is being applied.
- A JSON patch that cannot be applied, for example because a
testoperation fails, fails with409 Conflictand changes nothing. It used to be reported as304 Not Modified.
The broker patches a subscription’s status against the latest version it knows of. On a conflict, it reads the subscription again and applies its change to the current state.