Automation API#

API CRUD automation voi flow data (nodes va edges).

Base URL: https://app.socialking.vn/api/v1

Rate Limit: 1000 req/sec


1. Tao Automation#

POST /automation/create #

Auth: API Key

Request Body:

{
  "name": "Auto Post Timeline",
  "description": "Tu dong dang bai len timeline",
  "status": "draft",
  "flowData": {
    "nodes": [
      {
        "id": "node-1",
        "type": "trigger",
        "position": { "x": 0, "y": 0 },
        "data": {
          "label": "Start",
          "nodeTypeId": "trigger_schedule",
          "params": {}
        }
      }
    ],
    "edges": [
      {
        "id": "edge-1",
        "source": "node-1",
        "target": "node-2",
        "type": "smoothstep"
      }
    ]
  }
}
FieldTypeRequiredValidation
namestringYes1-255 ky tu
descriptionstringNoMax 1000 ky tu
statusstringNodraft | active | paused | archived
flowData.nodesarrayYesMin 1 node, moi node can id, type, position
flowData.edgesarrayNoMoi edge can id, target

Response (201):

{
  "success": true,
  "message": "Automation created successfully",
  "data": {
    "id": "automation-uuid",
    "name": "Auto Post Timeline",
    "status": "draft",
    "createdAt": "2026-03-30T10:00:00Z",
    "_count": {
      "fbNodes": 1,
      "fbEdges": 0,
      "fbSchedules": 0
    }
  }
}

2. Tao nhieu Automation#

POST /automation/create-bulk #

Auth: API Key

Request Body: Giong POST /create, co the la object hoac array.


3. Cap nhat Automation#

PUT /automation/update/:id #

Auth: API Key

URL Params: id (UUID)

Request Body: Cac fields giong tao, tat ca optional.


4. Cap nhat nhieu Automation#

PUT /automation/update-bulk #

Auth: API Key

Request Body:

{
  "automations": [
    {
      "id": "uuid-1",
      "name": "Updated 1",
      "status": "active"
    }
  ]
}

5. Chi tiet Automation#

GET /automation/get-by-id/:id #

Auth: API Key

URL Params: id (UUID)

Response (200):

{
  "success": true,
  "data": {
    "id": "automation-uuid",
    "name": "Auto Post Timeline",
    "description": "Description",
    "status": "active",
    "flowData": { "nodes": [...], "edges": [...] },
    "createdAt": "2026-03-30T10:00:00Z",
    "schedule": {
      "id": "schedule-uuid",
      "nextRunAt": "2026-03-30T11:00:00Z",
      "lastRunAt": "2026-03-30T10:00:00Z",
      "runCount": 5,
      "timezone": "Asia/Ho_Chi_Minh"
    },
    "relations": {
      "nodes": [...],
      "edges": [...],
      "schedules": [...]
    },
    "stats": {
      "totalNodes": 3,
      "totalEdges": 2,
      "totalSchedules": 1,
      "activeSchedules": 1,
      "tasks": {
        "total": 10,
        "completed": 8,
        "failed": 1,
        "pending": 1,
        "running": 0
      }
    }
  }
}

6. Danh sach Automation#

GET /automation/get-all #

Auth: API Key

Query Parameters:

ParamTypeDefaultMo ta
_pagenumber1Trang
_limitnumber10Items/trang
_sortstring-Field sap xep
_orderstringdescasc | desc