API ReferenceSubscriptions
Create a subscription
Create a webhook subscription to receive events from a channel.
POST
/v1/subscriptionsAuthorization
ApiKeyAuth AuthorizationBearer <token>
API key authentication. Keys are prefixed with environment:
npk_live_for productionnpk_test_for testing/staging
In: header
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/json
application/json
curl -X POST "https://api.npayload.com/v1/subscriptions" \ -H "Content-Type: application/json" \ -d '{ "channelId": "ch_abc123", "name": "Order Processor", "webhookUrl": "https://api.example.com/webhooks/orders", "eventTypes": [ "order.created", "order.updated" ], "retryPolicy": { "maxRetries": 5, "initialDelay": 1000, "maxDelay": 3600000, "backoffMultiplier": 2 } }'{
"id": "string",
"channelId": "string",
"name": "string",
"webhookUrl": "http://example.com",
"status": "active",
"eventTypes": [
"string"
],
"retryPolicy": {
"maxRetries": 5,
"initialDelay": 1000,
"maxDelay": 3600000,
"backoffMultiplier": 2
},
"headers": {
"property1": "string",
"property2": "string"
},
"createdAt": "2019-08-24T14:15:22Z",
"updatedAt": "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"
}
}Was this page helpful?