Skip to main content
Batches

出力ファイルの取得

バッチ出力ファイルの署名付きダウンロード URL を取得します。

GET /api/v1/forward/batches/{batch_id}/output output.jsonl の OSS プリサインドダウンロード URL を返します。バッチは終端状態でなければならず、そうでない場合は 400 batch_not_ready を返します。

Headers

HeaderRequiredDescription
AuthorizationYesBearer <PAT または SAT>

Path parameters

ParameterTypeRequiredDescription
batch_idstringYesバッチ ID。

Example request

curl -s -X GET 'https://api.qoder.com/api/v1/forward/batches/batch_completed001/output' \
  -H "Authorization: Bearer $QODER_ACCESS_TOKEN"

Example response

HTTP 200 OK
{
  "url": "https://cloud-agents-storage.oss-cn-beijing.aliyuncs.com/files%2F<user_id>%2F<file_id>%2Fcontent?Expires=1783685162&OSSAccessKeyId=<ak>&Signature=<sig>&response-content-disposition=attachment%3B%20filename%3Dbatch-batch_completed001-output.jsonl",
  "expires_at": "2026-07-10T12:06:02Z"
}

Response fields

FieldTypeDescription
urlstringOSS プリサインドダウンロード URL。Expires / OSSAccessKeyId / Signature および response-content-disposition を含みます。ダウンロード時のファイル名は batch-<batch_id>-output.jsonl です。
expires_atstringリンクの有効期限。RFC 3339。この時刻までにダウンロードを完了する必要があります。

output.jsonl の行形式

各 Batch Task が 1 行に対応します。
{
  "custom_id": "task-001",
  "status": "completed",
  "session_id": "sess_abc",
  "template_id": "tmpl_abc",
  "identity_id": "idn_abc",
  "started_at": "2026-08-06T14:01:03Z",
  "completed_at": "2026-08-06T14:03:41Z",
  "response": {"body": {"text": "report generated"}},
  "error": null,
  "usage": {
    "total_credits": 2.75
  },
  "artifacts": [
    {
      "file_id": "file_abc",
      "name": "report.xlsx",
      "size": 20480,
      "content_type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
    }
  ]
}
template_ididentity_id は常に出力されます。session_id は Session が作成された場合にのみ出力されます。started_atcompleted_at は RFC 3339 UTC 文字列で、値がない場合は null です。started_at は、永続化された最終実行試行の開始時刻を示します。 成功した行では responseerror: null を出力します。それ以外のステータスでは response: null{"code": string, "message": string} を出力します。有効な JSON 結果は response.body として直接返され、通常のテキストは {"text": ...} でラップされます。 artifacts は空でない場合にのみ行のトップレベルに現れます。各項目は file_idnamesize を使用し、提供元に値がある場合は content_type も含みます。filenamesize_bytes は返さず、response.body 内にも artifacts を重複して含めません。 usage は、タスクに有効な CAS Session 使用量が永続化されている場合に行のトップレベルに現れます。現在は total_credits を含みます。明示的なゼロ値は保持され、使用量がないか無効な場合は省略されます。単位は CAS Credit であり、token 数や金額ではありません。一時的なエラーの再試行で新しい Session が作成された場合、最終または現在の Session の使用量のみを記録し、置き換えられた過去の Session 使用量は加算しません。

error.jsonl の行形式

失敗した行では元の body を保持し、output 行と同じステータス、Session/Template/Identity、時刻、構造化エラー、および任意のトップレベル artifacts を含めます。現在、error.jsonlusage を出力しません。
{
  "custom_id": "task-002",
  "status": "failed",
  "session_id": "sess_def",
  "template_id": "tmpl_abc",
  "identity_id": "idn_abc",
  "started_at": "2026-08-06T14:01:03Z",
  "completed_at": "2026-08-06T14:01:20Z",
  "body": {"input": "generate report"},
  "response": null,
  "error": {"code": "session_error", "message": "sandbox terminated unexpectedly"}
}
これらの拡張フィールドは、デプロイ後に新しく生成されたファイルにのみ適用されます。過去の output/error ファイルには反映されません。 構造解析、バックグラウンドの事前検証、または Session の最終検証でファイルリソースが失敗した場合も、同じ形式を使用します。元の body.resources は保持されます。Session の作成前に失敗した場合、session_id は省略されます。
{
  "custom_id": "task-file-missing",
  "status": "failed",
  "template_id": "tmpl_abc",
  "identity_id": "idn_abc",
  "started_at": null,
  "completed_at": "2026-08-29T09:20:11Z",
  "body": {
    "input": "レポートを分析する",
    "resources": [
      {
        "type": "file",
        "file_id": "opaque-missing-id",
        "mount_path": "/data/input/report.pdf"
      }
    ]
  },
  "response": null,
  "error": {
    "code": "config_error",
    "message": "file resource is unavailable"
  }
}
リソースエラーの code には、invalid_lineconfig_errorpermission_denied、および再試行を使い切った後の transient_error があります。失敗メッセージには安全な分類説明を使用し、ファイル所有者、上流の内部状態、ファイルが実際に存在するかどうかを示すメタデータは返しません。

Error codes

HTTPTypeCodeTrigger
400invalid_request_errorbatch_not_readyバッチが終端状態ではありません。
404not_found_errorbatch_not_foundバッチが存在しない、他ユーザーのもの、または出力ファイルが未生成です。
410not_found_errorfile_expired出力ファイルは 30 日保持期間を過ぎて削除されています。
401authentication_errorauthentication_requiredPAT または SAT が無効、もしくは期限切れです。

Notes

  • 出力ファイルは 30 日間保持されます。保持期間を過ぎると 410 file_expired を返します。
  • ダウンロードファイル名は batch-<batch_id>-output.jsonl です。
  • 失敗行の結果は output.jsonlerror.jsonl の両方に含まれます。後者は Batch の /error エンドポイントからダウンロードします。
  • Batch 結果ファイルは Forward の汎用ファイルリソースとして登録されないため、/api/v1/forward/files/{file_id} または /content から取得できません。
出力ファイルの取得 - Qoder