ToAPIsToAPIs
任務

取得帳戶任務詳情

按任務 ID 查詢任務中繼資料與帳務狀態

GET
/api/v1/tasks/{task_id}

中國大陸用戶請注意: 中國大陸用戶請使用 https://api.toapis.cn 作為接口地址 (Base URL). 文檔示例中的 https://api.toapis.com 請替換為 https://api.toapis.cn.

驗證, 分頁及錯誤處理請參閱接入方式.

使用說明

按 task_id 回傳任務的持久化元資料和可確認帳務, 用於追蹤生成任務的進度和花費. 不回傳生成結果, 提示詞或重放資料; 查詢不會主動重新整理任務狀態, 也不會觸發結算或 Webhook. 只能用 task_id 查詢, 不會回退到 client_business_id; 屬於他人或不存在的任務統一回傳 404.

影片轉存或結算未完成時狀態仍為 processing 且 finished_at=null. 介面在回傳帳務資料前會先做可確認性檢查: 檢查未通過時直接回傳 503, 而不是給出不可靠的資料. 單筆任務的帳務無法確認時 billing=null.

billing.status=pending 時省略金額欄位, 確認後為 settled 或 refunded.

驗證

Authorizationstring請求頭必填

使用系統存取權杖, 格式為 Bearer YOUR_SYSTEM_ACCESS_TOKEN. 此介面不接受模型 API Key, 不需要 X-User-Id.

請求參數

task_idstring路徑必填

平台任務 ID, 不接受業務 ID 代替, 不允許前後空白或控制字元.

限制: minLength=1; maxLength=191.

請求範例

請求示例

curl --request GET \
  --url 'https://api.toapis.com/api/v1/tasks/task_example_01' \
  --header 'Authorization: Bearer YOUR_SYSTEM_ACCESS_TOKEN'
import requests

response = requests.get(
    "https://api.toapis.com/api/v1/tasks/task_example_01",
    headers={"Authorization": "Bearer YOUR_SYSTEM_ACCESS_TOKEN"},
    timeout=30,
)
response.raise_for_status()
print(response.json())
const url = new URL("https://api.toapis.com/api/v1/tasks/task_example_01");

const response = await fetch(url, {
  headers: { Authorization: "Bearer YOUR_SYSTEM_ACCESS_TOKEN" },
  signal: AbortSignal.timeout(30_000),
});

if (!response.ok) {
  throw new Error(`HTTP ${response.status}: ${await response.text()}`);
}
console.log(await response.json());

回應欄位

範例使用虛構資料, 並假設 credits_per_usd="100". 實際換算請以回應為準.

codeinteger

業務狀態碼, 成功時為 0.

messagestring

回應訊息, 成功時為空字串. 錯誤訊息依請求語言回傳.

dataobject

本次查詢的結果物件.

data.idstring

平台任務 ID. 任務詳情使用此值, 並非業務 ID.

data.client_business_idstring | null

建立任務時儲存的客戶端業務 ID, 與平台任務 ID 不同. 無法確認或不適用時為 null.

data.api_key_idstring | null

關聯模型 API Key 的 ID. 無關聯時為 null.

data.typestring

任務類型. 可選值: image, video, music, other.

data.modelstring

模型識別碼.

data.statusstring

任務公開狀態. 影片轉存或結算未完成時仍為 processing. 可選值: pending, processing, completed, failed.

data.progressinteger

任務進度百分比, 範圍為 0-100.

data.created_atstring | null

建立時間. 時間格式為含時區的 RFC 3339. 無法確認或不適用時為 null.

data.finished_atstring | null

可確認的任務終態時間. 處理中或尚未確認時為 null. 時間格式為含時區的 RFC 3339.

data.billingobject | null

可確認的任務帳務資訊, 無法確認時為 null.

data.billing.statusstring

任務帳務狀態. pending 不回傳金額; 確認後為 settled 或 refunded. 可選值: pending, settled, refunded.

data.billing.creditsstring

確認後的任務帳務金額, 單位為 credits. pending 時省略. 以十進位字串回傳以保留精度.

data.billing.cost_usdstring

確認後的任務帳務 USD 金額. pending 時省略. 以十進位字串回傳以保留精度.

回應範例

響應示例

{
  "code": 0,
  "message": "",
  "data": {
    "id": "task_example_01",
    "client_business_id": "order_example_01",
    "api_key_id": "42",
    "type": "video",
    "model": "example-video-model",
    "status": "completed",
    "progress": 100,
    "created_at": "2026-11-01T08:00:00Z",
    "finished_at": "2026-11-01T08:01:00Z",
    "billing": {
      "status": "settled",
      "credits": "2",
      "cost_usd": "0.02"
    }
  }
}