Skip to content
Get Started

Add webhooks

webhooks.create(WebhookCreateParams**kwargs) -> WebhookCreateResponse
post/api/account/webhooks

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

ParametersExpand Collapse
webhooks: SequenceNotStr[Webhook]

Array of webhook URLs or webhook objects

Accepts one of the following:
str
class WebhookConfiguration:
url: str

Webhook endpoint URL for receiving callbacks

formaturi
secret: Optional[str]

Secret for webhook signature verification

global_secret: Optional[str]

Global secret for webhook signature verification

type: Optional[Literal["receive", "line_blocked", "line_assigned", "outbound"]]

Type of webhook to add

Accepts one of the following:
"receive"
"line_blocked"
"line_assigned"
"outbound"
ReturnsExpand Collapse
class WebhookCreateResponse:
message: Optional[str]
status: Optional[str]
webhooks: Optional[Webhooks]
global_secret: Optional[str]

Global secret applied to all webhooks

line_assigned: Optional[List[WebhooksLineAssigned]]

Webhooks for line assigned events

Accepts one of the following:
str
class WebhookConfiguration:
url: str

Webhook endpoint URL for receiving callbacks

formaturi
secret: Optional[str]

Secret for webhook signature verification

line_blocked: Optional[List[WebhooksLineBlocked]]

Webhooks for line blocked events

Accepts one of the following:
str
class WebhookConfiguration:
url: str

Webhook endpoint URL for receiving callbacks

formaturi
secret: Optional[str]

Secret for webhook signature verification

outbound: Optional[List[WebhooksOutbound]]

Webhooks for outbound message events

Accepts one of the following:
str
class WebhookConfiguration:
url: str

Webhook endpoint URL for receiving callbacks

formaturi
secret: Optional[str]

Secret for webhook signature verification

receive: Optional[List[WebhooksReceive]]

Webhooks for inbound message events

Accepts one of the following:
str
class WebhookConfiguration:
url: str

Webhook endpoint URL for receiving callbacks

formaturi
secret: Optional[str]

Secret for webhook signature verification

Add webhooks
import os
from sendblue_api import SendblueAPI

client = SendblueAPI(
    api_key=os.environ.get("SENDBLUE_API_API_KEY"),  # This is the default and can be omitted
    api_secret=os.environ.get("SENDBLUE_API_API_SECRET"),  # This is the default and can be omitted
)
webhook = client.webhooks.create(
    webhooks=["https://example.com"],
)
print(webhook.message)
{
  "message": "Webhooks added successfully",
  "status": "OK",
  "webhooks": {
    "globalSecret": "whsec_global123",
    "line_assigned": [
      "https://example.com"
    ],
    "line_blocked": [
      "https://example.com"
    ],
    "outbound": [
      "https://example.com"
    ],
    "receive": [
      "https://example.com"
    ]
  }
}
Returns Examples
{
  "message": "Webhooks added successfully",
  "status": "OK",
  "webhooks": {
    "globalSecret": "whsec_global123",
    "line_assigned": [
      "https://example.com"
    ],
    "line_blocked": [
      "https://example.com"
    ],
    "outbound": [
      "https://example.com"
    ],
    "receive": [
      "https://example.com"
    ]
  }
}