Create consumer

Creates a durable pull consumer on a stream and returns it.

POST /v1/mq/stream/{stream}/consumer

Addresshttps://api.hanzo.ai/v1/mq/stream/{stream}/consumer
MethodPOST
Operationpost_mq_stream_by_stream_consumer
AuthAuthorization: Bearer $HANZO_API_KEY

Creates a durable pull consumer on a stream and returns it.

Request

13 fields, body application/json (required).

FieldInTypeRequiredDescription
streampathstringyesStream is the stream name, from the path.
ack_policybodystring—
ack_waitbodystring—
deliver_policybodystring—
descriptionbodystring—
durable_namebodystring—
filter_subjectbodystring—
max_ack_pendingbodyinteger (int64)—
max_deliverbodyinteger (int64)—
opt_start_seqbodyinteger (uint64)—
opt_start_timebodystring (date-time)—
replay_policybodystring—
streambodystring—Stream is the stream name, from the path.

Response

StatusBodyMeaning
201mq.Consumercreated
defaultproblem-detailsrefused

201 body — 25 fields.

FieldInTypeAlwaysDescription
ack_floorbodymq.Sequences—
ack_floor.consumer_seqbodyinteger (uint64)—Consumer is the consumer's own sequence.
ack_floor.stream_seqbodyinteger (uint64)—Stream is the corresponding stream sequence.
configbodymq.Durable—
config.ack_policybodystring—Ack is the acknowledgment policy: explicit (default), all, or none.
config.ack_waitbodystring—AckWait is how long the broker waits for an ack before redelivering, e.g. "30s" (default).
config.deliver_policybodystring—Deliver is where delivery starts: all (default), last, new, by_start_sequence, by_start_time, or last_per_subject.
config.descriptionbodystring—Description says what this consumer is for.
config.durable_namebodystring—Name is the durable consumer name (alphanumeric, hyphens, underscores).
config.filter_subjectbodystring—Filter delivers only messages on this org-relative subject (wildcards supported).
config.max_ack_pendingbodyinteger (int64)—MaxAckPending caps unacknowledged messages in flight (default 1000).
config.max_deliverbodyinteger (int64)—MaxDeliver caps delivery attempts per message; -1 (default) is unlimited.
config.opt_start_seqbodyinteger (uint64)—StartSeq is the starting sequence for deliver_policy by_start_sequence.
config.opt_start_timebodystring (date-time)—StartTime is the starting instant for deliver_policy by_start_time.
config.replay_policybodystring—Replay is the replay pacing: instant (default) or original.
createdbodystring (date-time)—Created is when the consumer was created.
deliveredbodymq.Sequences—
delivered.consumer_seqbodyinteger (uint64)—Consumer is the consumer's own sequence.
delivered.stream_seqbodyinteger (uint64)—Stream is the corresponding stream sequence.
namebodystring—Name is the consumer name.
num_ack_pendingbodyinteger (int64)—AckPending is the number of delivered, not yet acknowledged messages.
num_pendingbodyinteger (uint64)—Pending is the number of messages yet to be delivered.
num_redeliveredbodyinteger (int64)—Redelivered is the number of messages currently being redelivered.
num_waitingbodyinteger (int64)—Waiting is the number of pull requests waiting for messages.
stream_namebodystring—Stream is the stream this consumer reads.

Failure carries the platform error shape — see Errors.

Examples

hanzo mq stream consumer create <stream>
import { Configuration, MqApi } from 'hanzoai';

const api = new MqApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.postMqStreamByStreamConsumer({ stream: 'stream', ack_policy: "<ack_policy>", ack_wait: "<ack_wait>" });
from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import MqApi

client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = MqApi(client).post_mq_stream_by_stream_consumer(stream='stream', ack_policy="<ack_policy>", ack_wait="<ack_wait>")
cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)

resp, _, err := client.MqAPI.PostMqStreamByStreamConsumer(context.Background()).Execute()
if err != nil {
	return err
}
use hanzo_client::apis::{configuration::Configuration, mq_api};

let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();

let result = mq_api::post_mq_stream_by_stream_consumer(&cfg, Default::default()).await?;
import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.MqApi;

ApiClient client = new ApiClient();
client.setBearerToken(System.getenv("HANZO_API_KEY"));

var result = new MqApi(client).postMqStreamByStreamConsumer();
curl -X POST https://api.hanzo.ai/v1/mq/stream/<stream>/consumer \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "ack_policy": "<ack_policy>",
       "ack_wait": "<ack_wait>"
     }'

MCP reaches mq through the mq tool, which names its 15 operations with its own verbs — this one among them, under a name only MCP declares. describe explains any of them:

curl -X POST https://api.hanzo.ai/v1/mcp \
  -H "Content-Type: application/json" \
  -d '{
       "jsonrpc": "2.0",
       "id": 1,
       "method": "tools/call",
       "params": {
         "name": "describe",
         "arguments": {
           "op": "get_mq_health"
         }
       }
     }'

MQ API · All Hanzo APIs · Interactive reference

Was this page useful?