Skip to main content
Batches

Get Output File

GET /api/v1/forward/batches/{batch_id}/output Returns an OSS pre-signed download URL for output.jsonl. The batch must be in a terminal state; otherwise the endpoint returns 400 batch_not_ready.

Headers

HeaderRequiredDescription
AuthorizationYesBearer <PAT or SAT>

Path parameters

ParameterTypeRequiredDescription
batch_idstringYesBatch ID.

Example request

curl -s -X GET 'https://api.qoder.com.cn/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 pre-signed download URL containing Expires, OSSAccessKeyId, Signature, and response-content-disposition. The download filename is batch-<batch_id>-output.jsonl.
expires_atstringLink expiration time, RFC 3339. The download must complete before this time.

output.jsonl line format

Each Batch Task corresponds to one line:
{
  "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_id and identity_id are always returned. session_id is returned only after a Session has been created. started_at and completed_at are RFC 3339 UTC strings and are null when unavailable. started_at indicates the start time of the final persisted execution attempt. Successful lines return response and error: null. Other statuses return response: null and {"code": string, "message": string}. Valid JSON results are returned directly as response.body; plain text is wrapped as {"text": ...}. artifacts appears at the top level only when non-empty. Each item uses file_id, name, and size, and includes content_type when provided by the source. The response does not include filename or size_bytes, and artifacts are not duplicated in response.body. usage appears at the top level when the task has persisted valid CAS Session usage. It currently contains total_credits; explicit zero values are preserved, and the field is omitted when usage is missing or invalid. The unit is CAS Credit, not tokens or currency. If a transient error retry creates a new Session, only usage for the final or current Session is recorded; usage from replaced historical Sessions is not accumulated.

error.jsonl line format

Failed lines preserve the original body and include the same status, Session/Template/Identity, timestamps, structured error, and optional top-level artifacts as output lines. Currently, error.jsonl does not include usage:
{
  "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"}
}
These enhanced fields apply only to files generated after deployment. Historical output and error files are not backfilled.

Error codes

HTTPTypeCodeTrigger
400invalid_request_errorbatch_not_readyBatch is not in a terminal state.
404not_found_errorbatch_not_foundBatch does not exist, belongs to another user, or output file has not been generated.
410not_found_errorfile_expiredThe output file passed its 30-day retention and was purged.
401authentication_errorauthentication_requiredPAT is invalid or expired.

Notes

  • Output files are retained for 30 days. After retention, the endpoint returns 410 file_expired.
  • The download filename is batch-<batch_id>-output.jsonl.
  • Failed-line results appear in both output.jsonl and error.jsonl. Download the latter through the Batch /error endpoint.
  • Batch result files are not registered as general Forward file resources and cannot be retrieved through /api/v1/forward/files/{file_id} or /content.