Skip to main content
npayload is launching soon.
npayloadDocs
API ReferenceMessages

Publish a message

Publish an event message to the channel. The message will be delivered to all active subscriptions. Supports idempotency via the `Idempotency-Key` header.

POST/v1/channels/{channelId}/messages

Authorization

ApiKeyAuth
AuthorizationBearer <token>

API key authentication. Keys are prefixed with environment:

  • npk_live_ for production
  • npk_test_ for testing/staging

In: header

Path Parameters

channelId*string

Channel ID

Header Parameters

Idempotency-Key?string

Unique key for idempotent requests (24 hour TTL)

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

application/json

application/json

curl -X POST "https://api.npayload.com/v1/channels/string/messages" \  -H "Content-Type: application/json" \  -d '{    "eventType": "order.created",    "payload": {      "orderId": "ord_12345",      "amount": 99.99,      "currency": "USD",      "customer": {        "id": "cus_abc123",        "email": "customer@example.com"      }    },    "metadata": {      "source": "checkout-service",      "version": "1.0"    }  }'
{
  "id": "string",
  "status": "accepted",
  "publishedAt": "2019-08-24T14:15:22Z"
}
{
  "error": {
    "code": "INVALID_REQUEST",
    "message": "Validation failed",
    "details": {
      "field": "name",
      "reason": "Name is required"
    }
  }
}
{
  "error": {
    "code": "UNAUTHORIZED",
    "message": "Invalid or missing API key"
  }
}
{
  "error": {
    "code": "NOT_FOUND",
    "message": "Resource not found"
  }
}
{
  "error": {
    "code": "RATE_LIMITED",
    "message": "Rate limit exceeded"
  }
}

Was this page helpful?