# Create request

URL: https://docs.hanzo.ai/docs/openapi/pubsub/post-pubsub-request

> Sends one request on the org's bus and waits for one reply — the synchronous half of pub/sub, for callers speaking to a responder subscribed on the NATS port.

`POST /v1/pubsub/request`

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

|               |                                          |
| ------------- | ---------------------------------------- |
| **Address**   | `https://api.hanzo.ai/v1/pubsub/request` |
| **Method**    | `POST`                                   |
| **Operation** | `post_pubsub_request`                    |
| **Auth**      | `Authorization: Bearer $HANZO_API_KEY`   |

Sends one request on the org's bus and waits for one reply — the
synchronous half of pub/sub, for callers speaking to a responder subscribed
on the NATS port. 404 when nobody is listening on the subject; 408 when a
responder exists but no reply arrived within the timeout.

## Request

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

| Field       | In   | Type            | Required | Description                                                            |
| ----------- | ---- | --------------- | -------- | ---------------------------------------------------------------------- |
| `data`      | body | string          | —        | Data is the request payload, carried verbatim as UTF-8 text.           |
| `headers`   | body | object          | —        | Headers are optional request headers, one value per name.              |
| `headers.*` | body | string          | —        |                                                                        |
| `subject`   | body | string          | —        | Subject is the subject a responder listens on, in the org's namespace. |
| `timeoutMs` | body | integer (int64) | —        | TimeoutMs bounds the wait for a reply.                                 |

## Response

| Status    | Body              | Meaning |
| --------- | ----------------- | ------- |
| `200`     | pubsub.busMessage | ok      |
| `default` | problem-details   | refused |

`200` body — 6 fields.

| Field       | In   | Type             | Always | Description                                                                  |
| ----------- | ---- | ---------------- | ------ | ---------------------------------------------------------------------------- |
| `data`      | body | string           | —      | Data is the payload as UTF-8 text.                                           |
| `headers`   | body | object           | —      | Headers are the message's headers, when it carries any.                      |
| `headers.*` | body | string\[]        | —      |                                                                              |
| `seq`       | body | integer (uint64) | —      | Seq is the message's stream sequence — fetched messages only.                |
| `subject`   | body | string           | —      | Subject is the message's subject in the org's own namespace.                 |
| `time`      | body | string           | —      | Time is when the stream stored the message, RFC3339 — fetched messages only. |

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

## Examples

**CLI**

```bash
hanzo pubsub request
```

**SDK**

**.ts**

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

const api = new PubsubApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.postPubsubRequest({ data: "<data>", headers: {} });
```

**.py**

```python
from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import PubsubApi

client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = PubsubApi(client).post_pubsub_request(data="<data>", headers={})
```

**.go**

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

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

**.rs**

```rust
use hanzo_client::apis::{configuration::Configuration, pubsub_api};

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

let result = pubsub_api::post_pubsub_request(&cfg, Default::default()).await?;
```

**.java**

```java
import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.PubsubApi;

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

var result = new PubsubApi(client).postPubsubRequest();
```

**HTTP**

```bash
curl -X POST https://api.hanzo.ai/v1/pubsub/request \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "data": "<data>",
       "headers": {}
     }'
```

**MCP**

MCP declares no tool for **pubsub** — `tools/list` on `https://api.hanzo.ai/v1/mcp` names the products it does reach. Use HTTP or an SDK.

---

[Pubsub API](https://docs.hanzo.ai/docs/openapi/pubsub) · [All Hanzo APIs](https://docs.hanzo.ai/docs/openapi) · [Interactive reference](https://docs.hanzo.ai/docs/openapi/reference)
