Stacking — Connect#

Worker liên kết các file Google Drive trong cùng folder với nhau theo stacking_mode — tạo chuỗi internal link giữa các file Drive để tăng authority.

Base URL: https://manager.likepion.com/api/v1/stacking


1. Lấy danh sách task #

curl -X GET 'https://manager.likepion.com/api/v1/stacking/links?limit=5&status=connect' \
  -H 'X-API-Key: <api_key>'
ParamMặc địnhMô tả
limit5Số task muốn pull (tối đa 1000)
statusLọc theo trạng thái task (connect)

Response#

{
  "success": true,
  "data": [
    {
      "id": "c5d8e912-3a4b-5c6d-7e8f-abc123def456",
      "request_id": "f37e0e54-d93a-4b06-98cc-1002301c696c",
      "status": "connect",
      "domain": "docs.google.com",
      "website": "https://likepion.com",
      "title": "Best Marketing Tools 2026",
      "about": "Khám phá top 10 marketing tools giúp doanh nghiệp...",
      "link_post": "https://drive.google.com/file/d/1xYzAbc123/view?usp=sharing",
      "folder_id": "1AiNsOTpmIlINZa_2QaXmpQxOGLNEAz2a",
      "connect_links": [
        "https://drive.google.com/file/d/1aBcDef456/view?usp=sharing",
        "https://drive.google.com/file/d/2gHiJkl789/view?usp=sharing",
        "https://drive.google.com/file/d/3mNoPqr012/view?usp=sharing"
      ]
    }
  ]
}

Giải thích fields#

FieldMô tả
idID task — dùng khi gọi start/complete/fail
request_idID request cha
statusTrạng thái hiện tại (connect)
domainNền tảng Drive (docs.google.com, slides.google.com, sheets.google.com)
websiteWebsite khách hàng
titleTiêu đề bài viết — context cho worker tạo internal link liên quan chủ đề
aboutNội dung mô tả (đã strip HTML tags) — context cho worker chèn link tự nhiên vào nội dung
link_postURL file Drive của task này (đã tạo ở bước Profile)
folder_idID folder Drive
connect_linksDanh sách URL cần chèn link vào file hiện tại (xem logic bên dưới)

Assign đọc field stacking_connect (jsonb) trên stacking_request và tính ra connect_links:

stacking_connectKết quả connect_links
{"mode":"all"}Tất cả link_post (không rỗng) của các task cùng folder_id, order created_at ASC, max 150
{"mode":"disable"}[] — task vẫn claimable nhưng không cần connect link
{"mode":"limit","limit":4}Top N link_post cùng folder_id (N = limit)
{"mode":"custom","link":["https://a","https://b"]}Dùng trực tiếp mảng URL trong link

2. Lấy chi tiết task #

Lấy thông tin 1 task theo id. Không thay đổi DB.

Query paramBắt buộcMô tả
statusVerify task đang ở status mong đợi. Nếu task hiện KHÔNG ở status này → HTTP 404 (tránh worker xử lý nhầm phase). Bỏ qua để trả về task bất kể status.
# Kèm status để verify task đúng phase mong đợi
curl -X GET 'https://manager.likepion.com/api/v1/stacking/links/<task_id>?status=connect' \
  -H 'X-API-Key: <api_key>'

Response#

Trả về 1 object (không bọc trong mảng) — schema giống bước 1.

{ "success": true, "data": { ...task fields... } }
CodeResponseKhi nào
404{"success": false, "message": "task not found"}Task không tồn tại hoặc đã soft-delete
404{"success": false, "message": "task not in expected status", "current_status": "register", "expected": "connect"}Task tồn tại nhưng status không khớp ?status= — worker có thể decide pull lại / skip

3. Báo đang xử lý #

Sau khi pull task, bắt buộc gọi API này để chuyển task từ connectconnecting.

Trạng thái trướcTrạng thái sau
connectconnecting

Lưu ý: API chỉ chấp nhận task có status = connect. Task ở trạng thái khác sẽ bị từ chối.

curl -X POST 'https://manager.likepion.com/api/v1/stacking/links/<task_id>/start' \
  -H 'X-API-Key: <api_key>'

Response#

{ "success": true }

4. Báo hoàn thành #

Báo connect thành công — task chuyển từ connectingcompleted. Đây là bước cuối cùng của flow stacking.

Trạng thái trướcTrạng thái sau
connectingcompleted
curl -X POST 'https://manager.likepion.com/api/v1/stacking/links/<task_id>/complete' \
  -H 'X-API-Key: <api_key>' \
  -H 'Content-Type: application/json' \
  -d '{
    "link_post": "https://drive.google.com/file/d/1xYzAbc123/view?usp=sharing",
    "note": "Linked 3 files successfully"
  }'
FieldBắt buộcMô tả
link_postURL file Drive — optional: đã set ở phase Profile, chỉ gửi khi cần cập nhật (ví dụ: đã re-create file trong quá trình connect)
noteGhi chú (tuỳ chọn)

Response#

{ "success": true }

5. Báo thất bại #

Task chuyển từ connectingconnect_failed. Retry manager sẽ tự động re-queue nếu retry_count < max_retries.

Trạng thái trướcTrạng thái sau
connectingconnect_failed
curl -X POST 'https://manager.likepion.com/api/v1/stacking/links/<task_id>/fail' \
  -H 'X-API-Key: <api_key>' \
  -H 'Content-Type: application/json' \
  -d '{
    "status": "connect_failed",
    "error_message": "Cannot access file to insert links"
  }'
FieldBắt buộcMô tả
error_messageMô tả ngắn lỗi (≤1000 ký tự)
noteGhi chú thêm

Response#

{ "success": true }