Skip to main content
POST
Upload a batch input file

Overview

Uploads a JSONL file of chat-completion requests with purpose: batch and returns its file_ id. Pass that id as input_file_id to create a batch. Each line is a BatchInputLine; files are capped at 100 MB and 50,000 lines.

Authorizations

Authorization
string
header
required

Morph API key, passed as Authorization: Bearer sk-.... Create keys at https://www.morphllm.com/dashboard/api-keys.

Body

multipart/form-data

The file plus its purpose, as multipart form data.

Multipart form for uploading a batch input file.

file
file
required

The JSONL file to upload. Up to 100 MB and 50,000 lines; every line is a BatchInputLine.

purpose
enum<string>
required

Must be batch.

Available options:
batch
Example:

"batch"

expires_after[anchor]
enum<string>

Anchor for the expiry policy. Only created_at is supported. Send together with expires_after[seconds].

Available options:
created_at
Example:

"created_at"

expires_after[seconds]
integer

Seconds after the anchor at which the file is deleted, from 3600 (1 hour) to 2592000 (30 days). Defaults to 30 days.

Required range: 3600 <= x <= 2592000
Example:

2592000

Response

The stored file.

A file you uploaded, or one a batch wrote for you.

id
string
required

File identifier, file_ prefixed. Pass it as input_file_id when creating a batch.

Example:

"file_9c2c1c3e-5b6a-4f0e-8d0f-2a1b3c4d5e6f"

object
string
required

Object type, always file.

Example:

"file"

bytes
integer
required

Size of the file in bytes.

Example:

48211

created_at
integer
required

Unix timestamp (seconds) for when the file was uploaded.

Example:

1780000000

expires_at
integer | null
required

Unix timestamp (seconds) for when the file and its content are deleted. Defaults to 30 days after upload (24 hours on zero-data-retention accounts).

Example:

1782592000

filename
string
required

The filename you uploaded, or the generated name for batch output and error files.

Example:

"requests.jsonl"

purpose
enum<string>
required

batch for files you upload; batch_output for the output and error files a batch produces.

Available options:
batch,
batch_output
Example:

"batch"

status
enum<string>
required

Deprecated OpenAI field, kept for SDK compatibility. Always uploaded.

Available options:
uploaded,
processed,
error
Example:

"uploaded"