# 2s PubSub Publish

> 2s PubSub Publish is a paid API for AI agents from 2s.io, paid per call via x402, $0.005/call, status unknown (last checked 2026-09-15).

Publishes a JSON message payload to a topic, fanning it out to all subscribers in real time.

## Facts

- Endpoint: POST https://2s.io/api/pubsub/publish
- Price: $0.005/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-15
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/2s-pubsub-publish-6730e8d6
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_nhimoV0t43uhWB8jFB5bl

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability 2s-pubsub-publish-6730e8d6 -d '<json body>'
```

Example prompt: Publish this JSON payload — {"event":"order_placed","orderId":"abc123"} — to my topic 'orders-prod' so all subscribers get notified right away.

## When to prefer this

Use this endpoint when you need to fan out a JSON event or task to multiple subscribers on a topic you own within the 2s.io pub/sub infrastructure — especially inside agent pipelines where workers listen on named topics. Prefer this over generic HTTP webhooks when you need delivery confirmation (count of recipients) and pay-per-use billing with no API key setup.

## Known failure modes

- Invalid or non-owned topicId — topic not found or permission denied
- Payload exceeds 64 KB limit — message rejected
- Malformed JSON in message body — parse error returned
- No subscribers on topic — delivers 0, ok still true
- Payment failure via x402 — call not executed

## How this service works

The (most) everything API: 575+ pay-per-call endpoints for AI agents — ground-truth data, a full AI gateway, and agent infrastructure (storage, queues, watchers). USDC via x402, no signup, no API keys, and upto billing: pay actual usage, not the quote.

## Output

Returns a JSON object with ok: true, an items array containing the topicId and the number of subscribers the message was delivered to, and a total count. Lets the caller confirm how many listeners received the fan-out.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "message": {
   "description": "The payload to fan out — any JSON, up to 64 KB."
  },
  "topicId": {
   "type": "string",
   "description": "The topic you own (from pubsub.create-topic)."
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/2s-pubsub-publish-6730e8d6/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from 2s.io](https://www.zero.xyz/host/2s.io/llms.txt)
