# Create next

URL: https://docs.hanzo.ai/docs/openapi/mq/post-mq-stream-by-stream-consumer-by-name-next

> Pulls the consumer's next batch.

`POST /v1/mq/stream/{stream}/consumer/{name}/next`

> [MQ →](https://docs.hanzo.ai/docs/openapi/mq) · [All API references →](https://docs.hanzo.ai/docs/openapi) · [Get started →](https://docs.hanzo.ai/docs/guides)

|               |                                                                   |
| ------------- | ----------------------------------------------------------------- |
| **Address**   | `https://api.hanzo.ai/v1/mq/stream/{stream}/consumer/{name}/next` |
| **Method**    | `POST`                                                            |
| **Operation** | `post_mq_stream_by_stream_consumer_by_name_next`                  |
| **Auth**      | `Authorization: Bearer $HANZO_API_KEY`                            |

Pulls the consumer's next batch. Delivered messages are acknowledged on
delivery — the broker will not redeliver what this call returns; an empty
wait answers 408.

## Request

7 fields, body `application/json` (required).

| Field     | In   | Type            | Required | Description                                                                     |
| --------- | ---- | --------------- | -------- | ------------------------------------------------------------------------------- |
| `stream`  | path | string          | yes      | Stream is the stream name, from the path.                                       |
| `name`    | path | string          | yes      | Name is the consumer name, from the path.                                       |
| `batch`   | body | integer (int64) | —        | Batch is how many messages to pull (1–1000, default 1).                         |
| `expires` | body | string          | —        | Expires is how long to wait for messages, e.g. "5s" (default "30s", max "60s"). |
| `name`    | body | string          | —        | Name is the consumer name, from the path.                                       |
| `no_wait` | body | boolean         | —        | NoWait answers immediately with whatever is available instead of waiting.       |
| `stream`  | body | string          | —        | Stream is the stream name, from the path.                                       |

## Response

| Status    | Body            | Meaning |
| --------- | --------------- | ------- |
| `200`     | mq.readOut      | ok      |
| `default` | problem-details | refused |

`200` body — 9 fields.

| Field                      | In   | Type               | Always | Description                                                                       |
| -------------------------- | ---- | ------------------ | ------ | --------------------------------------------------------------------------------- |
| `messages`                 | body | mq.Delivery\[]     | —      | Messages is what was read, stream-ordered.                                        |
| `messages[].data`          | body | string             | —      | Data is the payload, base64-encoded.                                              |
| `messages[].headers`       | body | object             | —      | Headers are the message headers, when any were published.                         |
| `messages[].headers.*`     | body | string\[]          | —      |                                                                                   |
| `messages[].num_delivered` | body | integer (int64)    | —      | Delivered is how many times a consumer has been handed this message (pulls only). |
| `messages[].num_pending`   | body | integer (uint64)   | —      | Remaining is how many messages follow this one for the consumer (pulls only).     |
| `messages[].sequence`      | body | integer (uint64)   | —      | Sequence is the message's stream sequence.                                        |
| `messages[].subject`       | body | string             | —      | Subject is the org-relative subject the message was stored under.                 |
| `messages[].timestamp`     | body | string (date-time) | —      | Timestamp is when the broker stored the message.                                  |

Failure carries the platform error shape — see [Errors](https://docs.hanzo.ai/docs/errors).

## Examples

**CLI**

```bash
hanzo mq stream consumer next <stream> <name>
```

**SDK**

**.ts**

```ts
import { Configuration, MqApi } from 'hanzoai';

const api = new MqApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.postMqStreamByStreamConsumerByNameNext({ stream: 'stream', name: 'name', batch: 0, expires: "<expires>" });
```

**.py**

```python
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_by_name_next(stream='stream', name='name', batch=0, expires="<expires>")
```

**.go**

```go
cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)

resp, _, err := client.MqAPI.PostMqStreamByStreamConsumerByNameNext(context.Background()).Execute()
if err != nil {
	return err
}
```

**.rs**

```rust
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_by_name_next(&cfg, Default::default()).await?;
```

**.java**

```java
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).postMqStreamByStreamConsumerByNameNext();
```

**HTTP**

```bash
curl -X POST https://api.hanzo.ai/v1/mq/stream/<stream>/consumer/<name>/next \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "batch": 0,
       "expires": "<expires>"
     }'
```

**MCP**

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:

```bash
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](https://docs.hanzo.ai/docs/openapi/mq) · [All Hanzo APIs](https://docs.hanzo.ai/docs/openapi) · [Interactive reference](https://docs.hanzo.ai/docs/openapi/reference)
