Webhooks API Reference
Manage webhooks programmatically using the Pollarix REST API.
Authentication
All API requests require authentication:
- Bearer Token
- Session Cookie
curl -H "Authorization: Bearer YOUR_API_TOKEN" \
https://api.pollarix.com/department/{departmentId}/webhook/
# Cookies are automatically included in browser requests
# Use this for frontend applications
Base URL
https://api.pollarix.com
Endpoints Overview
| Method | Endpoint | Description |
|---|---|---|
GET | /department/{id}/webhook/ | List all webhooks |
POST | /department/{id}/webhook/ | Create webhook |
POST | /department/{id}/webhook/add | Add webhook |
PUT | /department/{id}/webhook/{webhookId} | Update webhook |
DELETE | /department/{id}/webhook/{webhookId} | Delete webhook |
POST | /department/{id}/webhook/test-send | Test webhook |
List Webhooks
GET
/department/{departmentId}/webhook/Get all webhooksRetrieve all webhooks for a department.
Parameters
| Parameter | Type | Location | Description |
|---|---|---|---|
departmentId | string | path | Department identifier |
Response
Success Response (200 OK)
{
"departmentId": "dept_xyz789",
"webhooks": [
{
"id": "wh_abc123",
"name": "CRM Sync",
"url": "https://your-server.com/webhooks/pollarix",
"events": ["SURVEY_COMPLETED"],
"headers": {
"Authorization": "Bearer token123"
},
"isActive": true
},
{
"id": "wh_def456",
"name": "Slack Notifications",
"url": "https://hooks.slack.com/services/...",
"events": ["SURVEY_COMPLETED", "SURVEY_STATUS_CHANGED"],
"headers": {},
"isActive": true
}
]
}
Example
- cURL
- Node.js
- Python
curl -X GET \
'https://api.pollarix.com/department/dept_xyz789/webhook/' \
-H 'Authorization: Bearer YOUR_API_TOKEN' \
-H 'Content-Type: application/json'
const axios = require('axios');
const response = await axios.get(
'https://api.pollarix.com/department/dept_xyz789/webhook/',
{
headers: {
'Authorization': 'Bearer YOUR_API_TOKEN'
}
}
);
console.log(response.data.webhooks);
import requests
response = requests.get(
'https://api.pollarix.com/department/dept_xyz789/webhook/',
headers={
'Authorization': 'Bearer YOUR_API_TOKEN'
}
)
webhooks = response.json()['webhooks']
Create Webhook
POST
/department/{departmentId}/webhook/Create new webhookCreate a new webhook for a department.
Parameters
| Parameter | Type | Location | Description |
|---|---|---|---|
departmentId | string | path | Department identifier |
Request Body
{
"name": "My Webhook",
"url": "https://your-server.com/webhooks/pollarix",
"events": ["SURVEY_COMPLETED", "COUPON_REDEEMED"],
"headers": {
"Authorization": "Bearer your-secret-token",
"X-Custom-Header": "custom-value"
},
"isActive": true
}
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Webhook display name |
url | string | Yes | Target endpoint URL |
events | array | Yes | Events to subscribe to |
headers | object | No | Custom HTTP headers |
isActive | boolean | No | Enable webhook (default: true) |
Response
Success Response (201 Created)
{
"departmentId": "dept_xyz789",
"webhooks": [
{
"id": "wh_new123",
"name": "My Webhook",
"url": "https://your-server.com/webhooks/pollarix",
"events": ["SURVEY_COMPLETED", "COUPON_REDEEMED"],
"headers": {
"Authorization": "Bearer your-secret-token",
"X-Custom-Header": "custom-value"
},
"isActive": true
}
]
}
Example
- cURL
- Node.js
- Python
curl -X POST \
'https://api.pollarix.com/department/dept_xyz789/webhook/' \
-H 'Authorization: Bearer YOUR_API_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"name": "CRM Integration",
"url": "https://your-server.com/webhooks/pollarix",
"events": ["SURVEY_COMPLETED"],
"headers": {
"Authorization": "Bearer secret123"
},
"isActive": true
}'
const axios = require('axios');
const response = await axios.post(
'https://api.pollarix.com/department/dept_xyz789/webhook/',
{
name: 'CRM Integration',
url: 'https://your-server.com/webhooks/pollarix',
events: ['SURVEY_COMPLETED'],
headers: {
'Authorization': 'Bearer secret123'
},
isActive: true
},
{
headers: {
'Authorization': 'Bearer YOUR_API_TOKEN',
'Content-Type': 'application/json'
}
}
);
console.log('Created webhook:', response.data);
import requests
response = requests.post(
'https://api.pollarix.com/department/dept_xyz789/webhook/',
json={
'name': 'CRM Integration',
'url': 'https://your-server.com/webhooks/pollarix',
'events': ['SURVEY_COMPLETED'],
'headers': {
'Authorization': 'Bearer secret123'
},
'isActive': True
},
headers={
'Authorization': 'Bearer YOUR_API_TOKEN',
'Content-Type': 'application/json'
}
)
print('Created webhook:', response.json())
Add Webhook
POST
/department/{departmentId}/webhook/addAdd additional webhookAdd an additional webhook to a department that already has webhooks.
Parameters
| Parameter | Type | Location | Description |
|---|---|---|---|
departmentId | string | path | Department identifier |
Request Body
Same as Create Webhook.
Example
- cURL
- Node.js
- Python
curl -X POST \
'https://api.pollarix.com/department/dept_xyz789/webhook/add' \
-H 'Authorization: Bearer YOUR_API_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"name": "Analytics Pipeline",
"url": "https://analytics.company.com/ingest",
"events": ["SURVEY_COMPLETED"],
"isActive": true
}'
const response = await axios.post(
'https://api.pollarix.com/department/dept_xyz789/webhook/add',
{
name: 'Analytics Pipeline',
url: 'https://analytics.company.com/ingest',
events: ['SURVEY_COMPLETED'],
isActive: true
},
{ headers: { 'Authorization': 'Bearer YOUR_API_TOKEN' } }
);
response = requests.post(
'https://api.pollarix.com/department/dept_xyz789/webhook/add',
json={
'name': 'Analytics Pipeline',
'url': 'https://analytics.company.com/ingest',
'events': ['SURVEY_COMPLETED'],
'isActive': True
},
headers={'Authorization': 'Bearer YOUR_API_TOKEN'}
)
Update Webhook
PUT
/department/{departmentId}/webhook/{webhookId}Update webhookUpdate an existing webhook configuration.
Parameters
| Parameter | Type | Location | Description |
|---|---|---|---|
departmentId | string | path | Department identifier |
webhookId | string | path | Webhook identifier |
Request Body
{
"id": "wh_abc123",
"name": "Updated Webhook Name",
"url": "https://new-endpoint.com/webhooks",
"events": ["SURVEY_COMPLETED", "SURVEY_STATUS_CHANGED"],
"headers": {
"Authorization": "Bearer new-token"
},
"isActive": true
}
Example
- cURL
- Node.js
- Python
curl -X PUT \
'https://api.pollarix.com/department/dept_xyz789/webhook/wh_abc123' \
-H 'Authorization: Bearer YOUR_API_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"id": "wh_abc123",
"name": "Updated CRM Sync",
"url": "https://your-server.com/webhooks/v2/pollarix",
"events": ["SURVEY_COMPLETED"],
"headers": {},
"isActive": false
}'
const response = await axios.put(
'https://api.pollarix.com/department/dept_xyz789/webhook/wh_abc123',
{
id: 'wh_abc123',
name: 'Updated CRM Sync',
url: 'https://your-server.com/webhooks/v2/pollarix',
events: ['SURVEY_COMPLETED'],
headers: {},
isActive: false
},
{ headers: { 'Authorization': 'Bearer YOUR_API_TOKEN' } }
);
response = requests.put(
'https://api.pollarix.com/department/dept_xyz789/webhook/wh_abc123',
json={
'id': 'wh_abc123',
'name': 'Updated CRM Sync',
'url': 'https://your-server.com/webhooks/v2/pollarix',
'events': ['SURVEY_COMPLETED'],
'headers': {},
'isActive': False
},
headers={'Authorization': 'Bearer YOUR_API_TOKEN'}
)
Delete Webhook
DELETE
/department/{departmentId}/webhook/{webhookId}Delete webhookPermanently delete a webhook.
Parameters
| Parameter | Type | Location | Description |
|---|---|---|---|
departmentId | string | path | Department identifier |
webhookId | string | path | Webhook identifier |
Response
Returns 204 No Content on success.
Example
- cURL
- Node.js
- Python
curl -X DELETE \
'https://api.pollarix.com/department/dept_xyz789/webhook/wh_abc123' \
-H 'Authorization: Bearer YOUR_API_TOKEN'
await axios.delete(
'https://api.pollarix.com/department/dept_xyz789/webhook/wh_abc123',
{ headers: { 'Authorization': 'Bearer YOUR_API_TOKEN' } }
);
console.log('Webhook deleted');
response = requests.delete(
'https://api.pollarix.com/department/dept_xyz789/webhook/wh_abc123',
headers={'Authorization': 'Bearer YOUR_API_TOKEN'}
)
if response.status_code == 204:
print('Webhook deleted')
Test Webhook
POST
/department/{departmentId}/webhook/test-sendTest webhookSend a test payload to a webhook URL to verify connectivity.
Parameters
| Parameter | Type | Location | Description |
|---|---|---|---|
departmentId | string | path | Department identifier |
Request Body
{
"url": "https://your-server.com/webhooks/pollarix"
}
Response
Returns 200 OK if the test request was sent successfully.
Example
- cURL
- Node.js
- Python
curl -X POST \
'https://api.pollarix.com/department/dept_xyz789/webhook/test-send' \
-H 'Authorization: Bearer YOUR_API_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"url": "https://your-server.com/webhooks/pollarix"
}'
const response = await axios.post(
'https://api.pollarix.com/department/dept_xyz789/webhook/test-send',
{ url: 'https://your-server.com/webhooks/pollarix' },
{ headers: { 'Authorization': 'Bearer YOUR_API_TOKEN' } }
);
console.log('Test sent:', response.status === 200);
response = requests.post(
'https://api.pollarix.com/department/dept_xyz789/webhook/test-send',
json={'url': 'https://your-server.com/webhooks/pollarix'},
headers={'Authorization': 'Bearer YOUR_API_TOKEN'}
)
print('Test sent:', response.status_code == 200)
Error Responses
Error Format
{
"status": 400,
"detail": [
{
"msg": "Invalid URL format",
"type": "validation_error"
}
]
}
Error Codes
| Status | Error | Description |
|---|---|---|
400 | Bad Request | Invalid request body or parameters |
401 | Unauthorized | Missing or invalid authentication |
403 | Forbidden | Insufficient permissions or plan restrictions |
404 | Not Found | Webhook or department not found |
422 | Validation Error | Invalid field values |
429 | Too Many Requests | Rate limit exceeded |
500 | Server Error | Internal server error |
Complete Code Examples
Node.js Webhook Manager
const axios = require('axios');
class WebhookManager {
constructor(apiToken, departmentId) {
this.client = axios.create({
baseURL: 'https://api.pollarix.com',
headers: {
'Authorization': `Bearer ${apiToken}`,
'Content-Type': 'application/json'
}
});
this.departmentId = departmentId;
}
async list() {
const { data } = await this.client.get(
`/department/${this.departmentId}/webhook/`
);
return data.webhooks;
}
async create(webhook) {
const { data } = await this.client.post(
`/department/${this.departmentId}/webhook/`,
webhook
);
return data;
}
async update(webhookId, webhook) {
const { data } = await this.client.put(
`/department/${this.departmentId}/webhook/${webhookId}`,
{ id: webhookId, ...webhook }
);
return data;
}
async delete(webhookId) {
await this.client.delete(
`/department/${this.departmentId}/webhook/${webhookId}`
);
}
async test(url) {
await this.client.post(
`/department/${this.departmentId}/webhook/test-send`,
{ url }
);
}
}
// Usage
const manager = new WebhookManager('YOUR_API_TOKEN', 'dept_xyz789');
// List webhooks
const webhooks = await manager.list();
console.log('Webhooks:', webhooks);
// Create webhook
await manager.create({
name: 'My Integration',
url: 'https://my-server.com/webhooks',
events: ['SURVEY_COMPLETED'],
isActive: true
});
Python Webhook Manager
import requests
from typing import List, Dict, Optional
class WebhookManager:
def __init__(self, api_token: str, department_id: str):
self.base_url = 'https://api.pollarix.com'
self.headers = {
'Authorization': f'Bearer {api_token}',
'Content-Type': 'application/json'
}
self.department_id = department_id
def list(self) -> List[Dict]:
response = requests.get(
f'{self.base_url}/department/{self.department_id}/webhook/',
headers=self.headers
)
response.raise_for_status()
return response.json()['webhooks']
def create(self, webhook: Dict) -> Dict:
response = requests.post(
f'{self.base_url}/department/{self.department_id}/webhook/',
json=webhook,
headers=self.headers
)
response.raise_for_status()
return response.json()
def update(self, webhook_id: str, webhook: Dict) -> Dict:
response = requests.put(
f'{self.base_url}/department/{self.department_id}/webhook/{webhook_id}',
json={'id': webhook_id, **webhook},
headers=self.headers
)
response.raise_for_status()
return response.json()
def delete(self, webhook_id: str) -> None:
response = requests.delete(
f'{self.base_url}/department/{self.department_id}/webhook/{webhook_id}',
headers=self.headers
)
response.raise_for_status()
def test(self, url: str) -> None:
response = requests.post(
f'{self.base_url}/department/{self.department_id}/webhook/test-send',
json={'url': url},
headers=self.headers
)
response.raise_for_status()
# Usage
manager = WebhookManager('YOUR_API_TOKEN', 'dept_xyz789')
# List webhooks
webhooks = manager.list()
print('Webhooks:', webhooks)
# Create webhook
manager.create({
'name': 'My Integration',
'url': 'https://my-server.com/webhooks',
'events': ['SURVEY_COMPLETED'],
'isActive': True
})
Next Steps
- Security Best Practices - Secure your webhook implementation
- Events Reference - Detailed event payload documentation
Was this page helpful?