Skip to content
Get Started

Add webhooks

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

Add new webhooks to the account. Webhooks are appended to existing ones.

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

Array of webhook URLs or webhook objects

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

Webhook endpoint URL for receiving callbacks

formaturi
secret?: string

Secret for webhook signature verification

globalSecret?: string

Global secret for webhook signature verification

type?: "receive" | "line_blocked" | "line_assigned" | 4 more

Type of webhook to add

Accepts one of the following:
"receive"
"line_blocked"
"line_assigned"
"outbound"
"typing_indicator"
"call_log"
"contact_created"
ReturnsExpand Collapse
WebhookCreateResponse { message, status, webhooks }
message?: string
status?: string
webhooks?: Webhooks { call_log, contact_created, globalSecret, 5 more }
call_log?: Array<string | WebhookConfiguration { url, secret } >

Webhooks for call log events

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

Webhook endpoint URL for receiving callbacks

formaturi
secret?: string

Secret for webhook signature verification

contact_created?: Array<string>

Webhooks for contact created events (URL strings only)

globalSecret?: string

Global secret applied to all webhooks

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

Webhooks for line assigned events

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

Webhook endpoint URL for receiving callbacks

formaturi
secret?: string

Secret for webhook signature verification

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

Webhooks for line blocked events

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

Webhook endpoint URL for receiving callbacks

formaturi
secret?: string

Secret for webhook signature verification

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

Webhooks for outbound message status updates

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

Webhook endpoint URL for receiving callbacks

formaturi
secret?: string

Secret for webhook signature verification

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

Webhooks for inbound message events

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

Webhook endpoint URL for receiving callbacks

formaturi
secret?: string

Secret for webhook signature verification

typing_indicator?: Array<string | WebhookConfiguration { url, secret } >

Webhooks for typing indicator events

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

Webhook endpoint URL for receiving callbacks

formaturi
secret?: string

Secret for webhook signature verification

Add webhooks

import SendblueAPI from 'sendblue';

const client = new SendblueAPI({
  apiKey: process.env['SENDBLUE_API_API_KEY'], // This is the default and can be omitted
  apiSecret: process.env['SENDBLUE_API_API_SECRET'], // This is the default and can be omitted
});

const webhook = await client.webhooks.create({ webhooks: ['https://example.com'] });

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