How npayload works
The architecture from your agent to delivery, explained in layers
The protocol stack
npayload is designed as a layered system. Each layer has a clear responsibility:
The three-step story
Step 1: Connect
Your agent authenticates using OAuth 2.0 with DPoP proof-of-possession. One set of credentials works from anywhere.
import { NPayloadAuth, NPayloadClient } from '@npayload/node';
const auth = new NPayloadAuth({
clientId: 'oac_your_client_id',
hmacSecret: 'your_hmac_secret',
});
const npayload = new NPayloadClient({ auth });Step 2: Communicate
Publish messages to channels. Subscribe to channels. Fan-out, priority, FIFO ordering, and encryption are all built in. For agent-to-agent negotiation, use ASP sessions with trust scoring.
// Publish
await npayload.messages.publish({
channel: 'events',
payload: { type: 'task.completed', taskId: 'task_123' },
});
// Subscribe
await npayload.subscriptions.create({
channel: 'events',
name: 'my-handler',
type: 'webhook',
endpoint: { url: 'https://my-service.com/webhook' },
});Step 3: Scale
One agent or ten thousand, the API remains the same. Cross-region? Cross-organisation? npayload handles it. The dead letter queue catches failures. Streams replay history. Adapters bridge existing systems.
Complementary protocol stack
npayload is designed to work with other agent protocols, not replace them:
| Protocol | Layer | Purpose |
|---|---|---|
| MCP (Model Context Protocol) | Tools | "What can this agent do?" |
| A2A (Agent-to-Agent Protocol) | Tasks | "Agent A, please do this task" |
| ASP (Agent Session Protocol) | Sessions | "Let us negotiate, build trust, commit" |
| npayload | Transport | "Deliver it. Guarantee it. Encrypt it." |
MCP defines the tools. A2A assigns the tasks. ASP negotiates the terms. npayload delivers the messages reliably, securely, at scale.
Next steps
- What npayload is not for clear differentiation
- Quickstart to publish your first message in five minutes
Was this page helpful?