Skip to content
  • Auto
  • Light
  • Dark
Get Started
View as Markdown
Copy Markdown

Open in Claude
Open in ChatGPT

Add new webhooks

client.webhooks.create(WebhookCreateParams { webhooks, globalSecret, type } body, RequestOptionsoptions?): WebhookCreateResponse { status, message, webhooks }
post/api/v2/account/webhooks

Add new webhooks to your account. This endpoint appends webhooks to the existing list.

ParametersExpand Collapse
body: WebhookCreateParams { webhooks, globalSecret, type }
webhooks: Array<string | WebhookObject { url, secret } >

Array of webhook URLs or webhook objects to add

Accepts one of the following:
string
WebhookObject { url, secret }
url: string

Webhook URL (HTTPS only)

formaturi
secret?: string

Secret for webhook verification

globalSecret?: string

Optional global secret to apply to all webhooks

type?: "receive" | "call_log" | "line_blocked" | 3 more

Webhook type (default to 'receive')

Accepts one of the following:
"receive"
"call_log"
"line_blocked"
"line_assigned"
"outbound"
"contact_created"
ReturnsExpand Collapse
WebhookCreateResponse { status, message, webhooks }
status: "OK" | "ERROR"
Accepts one of the following:
"OK"
"ERROR"
message?: string
webhooks?: WebhookConfiguration { call_log, contact_created, globalSecret, 5 more }

Updated webhook configration (partial)

call_log?: Array<string | WebhookObject { url, secret } >

Webhooks for call logs

Accepts one of the following:
string
WebhookObject { url, secret }
url: string

Webhook URL (HTTPS only)

formaturi
secret?: string

Secret for webhook verification

contact_created?: Array<string>

Webhooks for contact creation (URL strings only)

globalSecret?: string

Global secret applied to all webhooks

line_assigned?: Array<string | WebhookObject { url, secret } >

Webhooks for line assignment

Accepts one of the following:
string
WebhookObject { url, secret }
url: string

Webhook URL (HTTPS only)

formaturi
secret?: string

Secret for webhook verification

line_blocked?: Array<string | WebhookObject { url, secret } >

Webhooks for blocked lines

Accepts one of the following:
string
WebhookObject { url, secret }
url: string

Webhook URL (HTTPS only)

formaturi
secret?: string

Secret for webhook verification

outbound?: Array<string | WebhookObject { url, secret } >

Webhooks for outbound messages

Accepts one of the following:
string
WebhookObject { url, secret }
url: string

Webhook URL (HTTPS only)

formaturi
secret?: string

Secret for webhook verification

receive?: Array<string | WebhookObject { url, secret } >

Webhooks for inbound messages

Accepts one of the following:
string
WebhookObject { url, secret }
url: string

Webhook URL (HTTPS only)

formaturi
secret?: string

Secret for webhook verification

secret?: string

Legacy secret field

Add new webhooks
import SendblueAPI from 'sendblue';

const client = new SendblueAPI({
  apiKey: 'My API Key',
  apiSecret: 'My API Secret',
});

const webhook = await client.webhooks.create({
  webhooks: [
    'https://example.com/new-webhook',
    { url: 'https://example.com/webhook-with-secret', secret: 'my-webhook-secret' },
  ],
  globalSecret: 'optional-global-secret',
  type: 'receive',
});

console.log(webhook.status);
{
  "status": "OK",
  "message": "message",
  "webhooks": {
    "call_log": [
      "https://example.com/webhook"
    ],
    "contact_created": [
      "https://example.com"
    ],
    "globalSecret": "globalSecret",
    "line_assigned": [
      "https://example.com/webhook"
    ],
    "line_blocked": [
      "https://example.com/webhook"
    ],
    "outbound": [
      "https://example.com/webhook"
    ],
    "receive": [
      "https://example.com/webhook"
    ],
    "secret": "secret"
  }
}
Returns Examples
{
  "status": "OK",
  "message": "message",
  "webhooks": {
    "call_log": [
      "https://example.com/webhook"
    ],
    "contact_created": [
      "https://example.com"
    ],
    "globalSecret": "globalSecret",
    "line_assigned": [
      "https://example.com/webhook"
    ],
    "line_blocked": [
      "https://example.com/webhook"
    ],
    "outbound": [
      "https://example.com/webhook"
    ],
    "receive": [
      "https://example.com/webhook"
    ],
    "secret": "secret"
  }
}