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>'
| Param | Mặc định | Mô tả |
|---|
limit | 5 | Số task muốn pull (tối đa 1000) |
status | — | Lọ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#
| Field | Mô tả |
|---|
id | ID task — dùng khi gọi start/complete/fail |
request_id | ID request cha |
status | Trạng thái hiện tại (connect) |
domain | Nền tảng Drive (docs.google.com, slides.google.com, sheets.google.com) |
website | Website khách hàng |
title | Tiêu đề bài viết — context cho worker tạo internal link liên quan chủ đề |
about | Nội dung mô tả (đã strip HTML tags) — context cho worker chèn link tự nhiên vào nội dung |
link_post | URL file Drive của task này (đã tạo ở bước Profile) |
folder_id | ID folder Drive |
connect_links | Danh sách URL cần chèn link vào file hiện tại (xem logic bên dưới) |
Logic tạo connect_links#
Assign đọc field stacking_connect (jsonb) trên stacking_request và tính ra connect_links:
stacking_connect | Kế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 param | Bắt buộc | Mô tả |
|---|
status | | Verify 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... } }
| Code | Response | Khi 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ừ connect → connecting.
| Trạng thái trước | Trạng thái sau |
|---|
connect | connecting |
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#
4. Báo hoàn thành
#
Báo connect thành công — task chuyển từ connecting → completed. Đây là bước cuối cùng của flow stacking.
| Trạng thái trước | Trạng thái sau |
|---|
connecting | completed |
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"
}'
| Field | Bắt buộc | Mô tả |
|---|
link_post | | URL 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) |
note | | Ghi chú (tuỳ chọn) |
Response#
5. Báo thất bại
#
Task chuyển từ connecting → connect_failed. Retry manager sẽ tự động re-queue nếu retry_count < max_retries.
| Trạng thái trước | Trạng thái sau |
|---|
connecting | connect_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"
}'
| Field | Bắt buộc | Mô tả |
|---|
error_message | ✔ | Mô tả ngắn lỗi (≤1000 ký tự) |
note | | Ghi chú thêm |
Response#