ServicesFusion
API Reference
Complete API documentation for Fusion endpoints
👤 Sai Tharun
Fusion API Reference
Fusion exposes HTTP endpoints for enqueueing and managing background tasks. All endpoints accept JSON payloads.
Queue Tasks
POST /queue/
Immediately enqueue one or more tasks for processing.
Request Body:
[
{
"task": 1,
"task_type": 1,
"data": {
"contact": 9876543210,
"message": "Hello World",
"countryCode": 91,
"senderId": "CRELIO"
},
"log_tag": "SMS_OTP",
"headers": {},
"subscribe": "https://callback.url/notify",
"failed_task_handler": "https://callback.url/failed",
"success_task_handler": "https://callback.url/success",
"override_priority": 2
}
]Parameters:
| Field | Type | Required | Description |
|---|---|---|---|
task | int | Yes | Task type (1=SMS, 2=Email, 3=PN, 4=Webhook, 6=WhatsApp) |
task_type | int | Yes | Sub-type of the task |
data | object | Yes | Task-specific payload |
log_tag | string | No | Custom tag for logging |
headers | object | No | HTTP headers for webhooks |
subscribe | string | No | URL for result callbacks |
failed_task_handler | string | No | URL to call when task fails |
success_task_handler | string | No | URL to call when task succeeds |
override_priority | int | No | Override default priority (0, 1, or 2) |
retry | int | No | Number of retry attempts (max 10) |
Response:
{
"code": 200,
"job_ids": ["job-uuid-1", "job-uuid-2"]
}Task Types Reference
Task 1: SMS
| task_type | Name | Priority | Function |
|---|---|---|---|
| 1 | OTP | HIGH (2) | tasks.sms.sendOTPSMS |
| 2 | App Links | LOW (0) | tasks.sms.sendSMS |
| 3 | Welcome | MODERATE (1) | tasks.sms.sendSMS |
| 4 | Billing Report | MODERATE (1) | tasks.sms.sendSMS |
| 5 | Appointment/HC | MODERATE (1) | tasks.sms.sendSMS |
| 6 | Campaign | LOW (0) | tasks.sms.sendSMS |
| 7 | Reminder | HIGH (2) | tasks.sms.sendSMS |
SMS Payload:
{
"contact": 9876543210,
"message": "Your OTP is 1234",
"countryCode": 91,
"senderId": "CRELIO",
"otp": 1234,
"config": {
"provider": "msg91"
},
"callback_url": "https://..."
}Task 2: Email
| task_type | Name | Priority | Function |
|---|---|---|---|
| 1 | Welcome | MODERATE (1) | tasks._email_v2.send_plain_email |
| 2 | Billing Report | MODERATE (1) | tasks._email_v2.send_plain_email |
| 3 | Admin | MODERATE (1) | tasks._email_v2.send_plain_email |
| 4 | Misc | LOW (0) | tasks._email_v2.send_plain_email |
| 5 | Template | LOW (0) | tasks._email_v2.send_template_attachment_email |
| 6 | Attachment | LOW (0) | tasks._email_v2.send_template_attachment_email |
Email Payload:
{
"to": ["user@example.com"],
"cc": [],
"bcc": [],
"subject": "Email Subject",
"message": "<html>Email body</html>",
"sender_name": "CrelioHealth",
"sender_email": "no-reply@creliohealth.com",
"files": ["https://s3.amazonaws.com/.../file.pdf"],
"template": "<html>Template HTML</html>",
"is_template": 1,
"callback_url": "https://..."
}Task 3: Push Notification
| task_type | Name | Priority |
|---|---|---|
| 1 | Reports | MODERATE (1) |
| 2 | Appointment/HC | MODERATE (1) |
| 3 | Promotions | MODERATE (1) |
| 4 | Campaign | LOW (0) |
| 5 | Feedback | LOW (0) |
| 6 | Reminders | HIGH (2) |
Task 4: Webhook
| task_type | Name | Priority | Function |
|---|---|---|---|
| 1 | GET | MODERATE (1) | tasks.webhooks.GET |
| 2 | POST | MODERATE (1) | tasks.webhooks.POST |
| 3 | PUT | MODERATE (1) | tasks.webhooks.PUT |
| 4 | DELETE | MODERATE (1) | tasks.webhooks.DELETE |
Webhook Payload:
{
"url": "https://api.example.com/endpoint",
"args": {"key": "value"},
"isBody": 1,
"timeout": 15,
"callback": 1,
"callback_url": "https://callback.url",
"headers": {
"Authorization": "Bearer token"
}
}Task 6: WhatsApp
| task_type | Name | Priority | Function |
|---|---|---|---|
| 1 | Welcome | MODERATE (1) | tasks.whatsapp.sendWhatsapp |
| 2 | Billing Report | MODERATE (1) | tasks.whatsapp.sendWhatsapp_withFile |
Schedule Tasks
POST /schedule/
Schedule tasks for future execution.
Request Body:
[
{
"sch_time": "2024-01-15T10:30:00",
"task": 1,
"task_type": 2,
"data": {...},
"subscribe": "https://...",
"headers": {}
}
]Parameters:
| Field | Type | Required | Description |
|---|---|---|---|
sch_time | string | Yes | Scheduled time in YYYY-MM-DDTHH:MM:SS format (UTC) |
task | int | Yes | Task type |
task_type | int | Yes | Sub-type of the task |
data | object | Yes | Task-specific payload |
window_delay | string | No | Key for window-based consolidation |
override_window | int | No | 1 to override existing window |
Response:
{
"code": 200,
"job_ids": ["job-uuid-1"]
}Job Management
POST /jobInfo/
Get information about a specific job.
Request Body:
{
"id": "job-uuid"
}POST /cancelJob/
Cancel one or more scheduled jobs.
Request Body:
{
"job_id": ["job-uuid-1", "job-uuid-2"]
}Response:
{"code": 200} // Success
{"code": 401} // Job not found
{"code": 500} // ErrorPOST /rescheduleJob/
Reschedule a job to a new time.
Request Body:
{
"job_id": "job-uuid",
"resc_at": "2024-01-16T14:00:00"
}Response:
{"code": 200} // Success
{"code": 401} // Job not found or already executedPOST /retryTask/
Retry a failed task with a 2-minute delay.
Request Body:
[
{"job_id": "job-uuid"}
]Utility Endpoints
POST /mapping/
Queue dictionary mapping tasks for processing.
Request Body:
[
{"keyword": "term1", "data": {...}},
{"keyword": "term2", "data": {...}}
]POST /update_consent/
Update WhatsApp consent for a user.
Request Body:
{
"type": "consent_type",
"cache_key": "unique_key",
"details_obj": {...}
}Error Codes
| Code | Description |
|---|---|
| 200 | Success |
| 401 | Job not found |
| 500 | Internal server error |