The Webhooks API allows you to receive real-time notifications about events in your SMASHSEND account. You can create webhooks to receive notifications for various events, such as when a new contact is created, when a campaign is sent, or when a user opens an email.
Webhooks send HTTP POST requests to your specified URL when events happen in your SMASHSEND account.
Webhooks can be configured to listen for the following events:
CONTACT_CREATED
- A new contact was createdCONTACT_UPDATED
- A contact was updatedCONTACT_UNSUBSCRIBED
- A contact has unsubscribedCONTACT_RESUBSCRIBED
- A contact has resubscribedCONTACT_DELETED
- A contact was deletedWORKSPACE_TEAM_MEMBER_JOINED
- A team member joined the workspaceLists all webhooks for the authenticated workspace.
Authentication
Requires a valid API key with api_user
scope.
Request
curl "https://api.smashsend.com/v1/webhooks" \
-H "Authorization: Bearer YOUR_API_KEY"
Response
{
"webhooks": {
"items": [
{
"id": "wh_123456789",
"url": "https://example.com/webhooks/smashsend",
"events": ["CONTACT_CREATED", "CONTACT_UPDATED"],
"createdAt": "2023-03-01T10:00:00Z"
},
{
"id": "wh_987654321",
"url": "https://example.com/webhooks/smashsend-campaigns",
"events": ["CONTACT_DELETED", "WORKSPACE_TEAM_MEMBER_JOINED"],
"createdAt": "2023-04-10T14:30:00Z"
}
],
"hasMore": false
}
}
Retrieves details of a specific webhook.
Authentication
Requires a valid API key with user
scope.
Path Parameters
webhookId
- The ID of the webhook to retrieve
Request
curl "https://api.smashsend.com/v1/webhooks/wh_123456789" \
-H "Authorization: Bearer YOUR_API_KEY"
Response
{
"webhook": {
"id": "wh_123456789",
"url": "https://example.com/webhooks/smashsend",
"events": ["CONTACT_CREATED", "CONTACT_UPDATED"],
"token": "wht_a1b2c3d4e5f6g7h8i9j0",
"createdAt": "2023-03-01T10:00:00Z"
}
}
Creates a new webhook.
Authentication
Requires a valid API key with api_user
scope.
Request Body
{
"url": "https://example.com/webhooks/smashsend",
"events": ["CONTACT_CREATED", "CONTACT_UPDATED"],
"token": "optional_secret_token"
}
Request
curl -X POST "https://api.smashsend.com/v1/webhooks" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com/webhooks/smashsend",
"events": ["CONTACT_CREATED", "CONTACT_UPDATED"],
"token": "optional_secret_token"
}'
Response
{
"webhook": {
"id": "wh_123456789",
"url": "https://example.com/webhooks/smashsend",
"events": ["CONTACT_CREATED", "CONTACT_UPDATED"],
"token": "wht_a1b2c3d4e5f6g7h8i9j0",
"createdAt": "2023-04-16T15:45:00Z"
}
}
Updates a webhook.
Authentication
Requires a valid API key with user
scope.
Path Parameters
webhookId
- The ID of the webhook to update
Request Body
{
"events": ["CONTACT_CREATED", "CONTACT_UPDATED", "WORKSPACE_TEAM_MEMBER_JOINED"]
}
Request
curl -X PUT "https://api.smashsend.com/v1/webhooks/wh_123456789" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"events": ["CONTACT_CREATED", "CONTACT_UPDATED", "WORKSPACE_TEAM_MEMBER_JOINED"]
}'
Response
{
"webhook": {
"id": "wh_123456789",
"url": "https://example.com/webhooks/smashsend",
"events": ["CONTACT_CREATED", "CONTACT_UPDATED", "WORKSPACE_TEAM_MEMBER_JOINED"],
"token": "wht_a1b2c3d4e5f6g7h8i9j0",
"createdAt": "2023-03-01T10:00:00Z"
}
}
Deletes a webhook.
Authentication
Requires a valid API key with user
scope.
Path Parameters
webhookId
- The ID of the webhook to delete
Request
curl -X DELETE "https://api.smashsend.com/v1/webhooks/wh_123456789" \
-H "Authorization: Bearer YOUR_API_KEY"
Response
{
"deleted": true
}
When an event occurs, SMASHSEND will send a POST request to your webhook URL with a JSON payload. The payload will contain information about the event, including the event type and the data related to the event.
Example Payload for CONTACT_CREATED event:
{
"event": "CONTACT_CREATED",
"createdAt": "2023-04-16T15:45:00Z",
"data": {
"contact": {
"id": "ctc_B7OSYsnTUVwBPOGrgYTjvSGS",
"email": "newcontact@example.com",
"properties": {
"firstName": "New",
"lastName": "Contact",
"email": "newcontact@example.com"
},
"createdAt": "2023-04-16T15:45:00Z",
"workspaceId": "wrk_ENGTK86JEXXckyDVJthKkPer"
}
}
}
Example Payload for WORKSPACE_TEAM_MEMBER_JOINED event:
{
"event": "WORKSPACE_TEAM_MEMBER_JOINED",
"createdAt": "2023-04-16T16:30:00Z",
"data": {
"workspace": {
"id": "wrk_ENGTK86JEXXckyDVJthKkPer",
"name": "My Workspace"
},
"user": {
"id": "usr_987654321",
"email": "teammember@example.com",
"name": "Team Member"
}
}
}
To verify that the webhook request is coming from SMASHSEND, you can check the X-SMASHSEND-Signature
header. This header contains a signature generated using your webhook token and the request payload.
To verify the signature:
X-SMASHSEND-Signature
header value from the requestExample in Node.js:
const crypto = require('crypto');
function verifyWebhookSignature(body, signature, token) {
const hmac = crypto.createHmac('sha256', token);
const computedSignature = hmac.update(body).digest('hex');
return crypto.timingSafeEqual(
Buffer.from(signature),
Buffer.from(computedSignature)
);
}
// In your webhook handler
app.post('/webhooks/smashsend', (req, res) => {
const signature = req.headers['x-smashsend-signature'];
const body = JSON.stringify(req.body);
const token = 'YOUR_WEBHOOK_TOKEN';
if (verifyWebhookSignature(body, signature, token)) {
// Process the webhook event
console.log('Webhook signature verified!');
// Handle the event based on req.body.event
res.status(200).send('Webhook received');
} else {
console.log('Webhook signature verification failed!');
res.status(401).send('Unauthorized');
}
});