跳到主要内容
开发者文档API 参考装载

创建装载任务

校验请求,从积分中预留最高可能费用,并将任务加入队列。

POSThttps://runner.cargoduo.com/v1/pack

返回 202 和该任务;之后轮询 GET /v1/jobs/{id},或传入 ?wait= 让响应等到任务结束再返回。校验失败(422)不收费,也不会创建任务。

认证

Bearer API 密钥 · 所需权限范围pack:write了解更多

查询参数

名称类型必填说明
waitinteger
integer
否

响应等待任务完成的最长秒数。在此时间内完成:返回 200,结果内联在响应中;否则返回 202。

默认值 00–60

请求头参数

名称类型必填说明
Idempotency-Keystring
string
否

任意唯一字符串,例如 UUID 或您的订单号。24 小时内使用相同的键会返回原任务,而不会创建新任务并再次扣费。

≤ 128 chars

请求体参数

application/json
名称类型必填说明
referencestring
string
否

您自己的参考编号(订单号、货运单号…)。会原样返回在任务中。

≤ 128 chars
vehiclesVehicle[]必填
Vehicle[]
是

车辆定义。每项的 quantity 可大于 1。至少一项。

itemsItem[]必填
Item[]
是

物品定义。每项的 quantity 可大于 1。至少一项。

groupsGroup[]
Group[]
否

可选的分组(客户、站点、订单)。当 options.group_routing 不为 "none" 时,物品引用的每个分组都必须在此列出;否则会按物品中分组名称的出现顺序自动创建分组。

optionsOptions
Options
否

装载选项。所有字段均为可选。

请求示例

curl -X POST "https://runner.cargoduo.com/v1/pack" \
  -H "Authorization: Bearer $CARGODUO_API_KEY" \
  -H "Idempotency-Key: order-1042-v1" \
  -H "Content-Type: application/json" \
  -d '{
    "reference": "order-1042",
    "vehicles": [
      {
        "id": "trailer",
        "type": "trailer",
        "name": "13.6 m trailer",
        "length": 1360,
        "width": 245,
        "height": 270,
        "max_weight": 24000
      }
    ],
    "items": [
      {
        "id": "pallet-eu",
        "label": "Euro pallet",
        "length": 120,
        "width": 80,
        "height": 140,
        "weight": 450,
        "quantity": 18,
        "stackable": false
      },
      {
        "id": "carton-a",
        "label": "Carton A",
        "length": 60,
        "width": 40,
        "height": 40,
        "weight": 12,
        "quantity": 40,
        "rotation": "upright"
      }
    ],
    "options": {
      "packing_mode": "auto"
    }
  }'

响应示例

202 Accepted · Job
{
  "id": "job_4bK9mT2xQe7LpW1zRc8VdN3f",
  "object": "job",
  "status": "queued",
  "reference": "order-1042",
  "source": "api",
  "created_at": "2026-10-19T09:12:03Z",
  "started_at": null,
  "finished_at": null,
  "progress": {
    "stage": "queued",
    "vehicles_done": 0,
    "placed_items": 0
  },
  "summary": {
    "items_requested": 58,
    "items_placed": 0,
    "items_unplaced": 0,
    "vehicles_used": 0,
    "total_weight": 0,
    "volume_utilization": 0,
    "queue_ms": 0,
    "compute_ms": 0
  },
  "cost": {
    "credits": 0,
    "reserved_credits": 1.11,
    "rate_card_version": 1,
    "breakdown": {
      "base": 0,
      "vehicles": 0,
      "compute": 0,
      "large_load": 0
    }
  },
  "error": null,
  "warnings": [],
  "result_url": "https://runner.cargoduo.com/v1/jobs/job_4bK9mT2xQe7LpW1zRc8VdN3f/result",
  "pdf_url": "",
  "expires_at": "2026-11-02T09:12:03Z"
}

响应

  • 200OK任务在 ?wait 时间内完成,结果已内联。已结束任务的幂等重放也返回此状态。
    名称类型必填说明
    idstring必填
    string
    是

    任务 ID(job_…)。

    objectstring必填
    string
    是

    始终为 job。

    job
    statusstring必填
    string
    是

    queued → running → succeeded | failed | canceled。

    queuedrunningsucceededfailedcanceled
    referencestring
    string
    否

    请求中提供的参考编号。

    sourcestring
    string
    否

    任务的创建来源。

    apiplayground
    project_idstring
    string
    否

    POST /v1/projects/{id}/pack 任务将方案保存到的项目(prj_…)。其他任务不含此字段。

    created_atstring必填
    string
    是

    RFC 3339 时间戳。

    started_atstring | null
    string | null
    否

    开始计算的时间(RFC 3339),或 null。

    finished_atstring | null
    string | null
    否

    任务结束时间(RFC 3339),或 null。

    progressJobProgress
    JobProgress
    否

    排队中/运行中的实时进度。

    summaryJobSummary
    JobSummary
    否

    计数和耗时。

    costJobCost
    JobCost
    否

    已扣积分(任务结束后为最终值)以及运行期间预留的积分。

    errorJobError | null
    JobError | null
    否

    任务失败或被取消的原因;否则为 null。

    warningsWarning[]
    Warning[]
    否

    关于请求的非阻断性提示(结果中也会重复列出)。

    result_urlstring
    string
    否

    status 为 succeeded 后,对此 URL 发起 GET 请求以获取完整结果。

    pdf_urlstring
    string
    否

    浏览器链接,打开后会将装载方案生成为 PDF(3D 视图 + 装载步骤)。在 expires_at 之前有效,过期后为空。

    expires_atstring
    string
    否

    请求体/结果体和 PDF 链接的删除时间(RFC 3339)。任务元数据和扣费记录会保留。

    resultResult
    Result
    否

    完整结果,仅在请求时(?include=result)或 POST /v1/pack?wait= 按时完成时内联返回。

  • 202Accepted任务已接受(排队中或运行中)。
    名称类型必填说明
    idstring必填
    string
    是

    任务 ID(job_…)。

    objectstring必填
    string
    是

    始终为 job。

    job
    statusstring必填
    string
    是

    queued → running → succeeded | failed | canceled。

    queuedrunningsucceededfailedcanceled
    referencestring
    string
    否

    请求中提供的参考编号。

    sourcestring
    string
    否

    任务的创建来源。

    apiplayground
    project_idstring
    string
    否

    POST /v1/projects/{id}/pack 任务将方案保存到的项目(prj_…)。其他任务不含此字段。

    created_atstring必填
    string
    是

    RFC 3339 时间戳。

    started_atstring | null
    string | null
    否

    开始计算的时间(RFC 3339),或 null。

    finished_atstring | null
    string | null
    否

    任务结束时间(RFC 3339),或 null。

    progressJobProgress
    JobProgress
    否

    排队中/运行中的实时进度。

    summaryJobSummary
    JobSummary
    否

    计数和耗时。

    costJobCost
    JobCost
    否

    已扣积分(任务结束后为最终值)以及运行期间预留的积分。

    errorJobError | null
    JobError | null
    否

    任务失败或被取消的原因;否则为 null。

    warningsWarning[]
    Warning[]
    否

    关于请求的非阻断性提示(结果中也会重复列出)。

    result_urlstring
    string
    否

    status 为 succeeded 后,对此 URL 发起 GET 请求以获取完整结果。

    pdf_urlstring
    string
    否

    浏览器链接,打开后会将装载方案生成为 PDF(3D 视图 + 装载步骤)。在 expires_at 之前有效,过期后为空。

    expires_atstring
    string
    否

    请求体/结果体和 PDF 链接的删除时间(RFC 3339)。任务元数据和扣费记录会保留。

    resultResult
    Result
    否

    完整结果,仅在请求时(?include=result)或 POST /v1/pack?wait= 按时完成时内联返回。

  • 400Bad requestinvalid_jsonidempotency_key_invalid
    • invalid_json请求体不是有效的 JSON,或某个字段类型错误。
    • idempotency_key_invalidIdempotency-Key 请求头超过 128 个字符。
    名称类型必填说明
    errorErrorBody必填
    ErrorBody
    是
    全部错误码
  • 401Unauthorizedunauthorizedkey_revokedkey_expired
    • unauthorizedAPI 密钥缺失、格式错误或无法识别。
    • key_revoked密钥已被撤销。
    • key_expired密钥已过期。
    名称类型必填说明
    errorErrorBody必填
    ErrorBody
    是
    全部错误码
  • 402Payment requiredinsufficient_credits
    • insufficient_credits可用积分不足以支付该任务的最低可能费用。
    名称类型必填说明
    errorErrorBody必填
    ErrorBody
    是
    全部错误码
  • 403Forbiddenip_not_allowedsubscription_inactiveaccount_inactivescope_missing
    • ip_not_allowed调用方 IP 不在该密钥的 IP 白名单中。
    • subscription_inactive组织没有包含 API 的有效订阅。
    • account_inactive组织已被暂停使用,或其所有者的账户均未处于有效状态。
    • scope_missing密钥缺少此接口所需的权限范围。
    名称类型必填说明
    errorErrorBody必填
    ErrorBody
    是
    全部错误码
  • 413Payload too largepayload_too_large
    • payload_too_large请求体超过 10 MB。
    名称类型必填说明
    errorErrorBody必填
    ErrorBody
    是
    全部错误码
  • 422Unprocessable entityvalidation_failed
    • validation_failed请求是格式正确的 JSON,但描述的任务无效。details[] 列出了所有问题。
    名称类型必填说明
    errorErrorBody必填
    ErrorBody
    是
    全部错误码
  • 429Too many requeststoo_many_jobsrate_limited
    • too_many_jobs组织的排队中 + 运行中任务数已达上限。
    • rate_limited当前分钟、小时或天内的请求过多(按密钥或按组织计),或您的 IP 地址每分钟认证失败超过 60 次。
    名称类型必填说明
    errorErrorBody必填
    ErrorBody
    是
    全部错误码
  • 500Internal server errorinternal_error
    • internal_error服务端发生内部错误。
    名称类型必填说明
    errorErrorBody必填
    ErrorBody
    是
    全部错误码
  • 503Service unavailableapi_disabled
    • api_disabledAPI 暂时停用(维护中),或已对该组织关闭。
    名称类型必填说明
    errorErrorBody必填
    ErrorBody
    是
    全部错误码