Automation Run API#
API chạy và theo dõi automation. Hỗ trợ SSE (Server-Sent Events) để theo dõi realtime.
Base URL: https://app.socialking.vn/api/v1
1. Chạy Automation#
POST /automation/run/:id/start
#
Auth: Bearer Token (JWT)
Rate Limit: 5 req/phút
URL Params:
| Param | Type | Mô tả |
|---|---|---|
id | UUID | Automation ID |
Request Body:
{
"skipScheduleNode": true
}| Field | Type | Required | Validation |
|---|---|---|---|
skipScheduleNode | boolean | No | Default true, bỏ qua schedule node |
Response (200):
{
"success": true,
"data": {
"runId": "uuid-string",
"automationId": "uuid-string",
"status": "running",
"startedAt": "2026-03-30T10:30:00Z"
}
}2. Dừng Automation#
POST /automation/run/:runId/stop
#
Auth: Bearer Token (JWT)
Rate Limit: 10 req/phút
URL Params:
| Param | Type | Mô tả |
|---|---|---|
runId | UUID | Run ID |
Response (200):
{
"success": true,
"message": "Run stopped"
}3. Xem trạng thái Run#
GET /automation/run/:runId/status
#
Auth: Bearer Token (JWT)
Rate Limit: 60 req/phút
URL Params:
| Param | Type | Mô tả |
|---|---|---|
runId | UUID | Run ID |
Response (200):
{
"success": true,
"data": {
"runId": "uuid-string",
"status": "running",
"progress": 65,
"completedAt": null
}
}4. SSE - Theo dõi Realtime#
GET /automation/run/:runId/sse
#
Auth: Bearer Token (JWT)
Protocol: Server-Sent Events
Response: SSE Stream
event: status
data: {"runId":"...","status":"running","progress":30,"message":"Processing..."}
event: status
data: {"runId":"...","status":"completed","progress":100,"message":"Done"}5. Danh sách Run đang chạy#
GET /automation/run/active
#
Auth: Bearer Token (JWT)
Rate Limit: 30 req/phút
Query Parameters:
| Param | Type | Default | Mô tả |
|---|---|---|---|
_limit | number | 10 | Số lượng items |
Response (200):
{
"success": true,
"data": [
{
"runId": "uuid-string",
"automationId": "uuid-string",
"status": "running",
"startedAt": "2026-03-30T10:30:00Z"
}
]
}6. Lịch sử Run#
GET /automation/run/history
#
Auth: Bearer Token (JWT)
Rate Limit: 30 req/phút
Query Parameters:
| Param | Type | Default | Mô tả |
|---|---|---|---|
_page | number | 1 | Trang |
_limit | number | 10 | 1-100 items/trang |
_order | string | desc | asc | desc |
_status | string | all | all | pending | running | success | failed | canceled | skipped |
_fbAutomationId | UUID | - | Required - Automation ID |
_triggeredBy | string | all | all | manual | schedule | api |
Response (200):
{
"success": true,
"data": {
"runs": [
{
"runId": "uuid-string",
"automationId": "uuid-string",
"status": "success",
"triggeredBy": "manual",
"startedAt": "2026-03-30T10:30:00Z",
"completedAt": "2026-03-30T10:35:00Z"
}
],
"total": 42,
"page": 1
}
}