Skip to main content
POST
Upload a file
Returns a file_<id> you can pass as a media source on later calls. See the Files guide.

Authorizations

Authorization
string
header
required

API key authentication. Pass your API key as a Bearer token.

Body

multipart/form-data
file
file
required

The file bytes.

filename
string

Optional advisory filename (defaults to the upload's filename).

purpose
string
default:reference_media

Intended use; gates the accepted MIME types.

ttl_seconds
integer

Optional lifetime in seconds; omit for a permanent file. Can be changed later via PATCH /v3/files/{id}.

Response

Successful response

bytes
integer
created_at
string<date-time>
expires_at
string<date-time>
filename
string
id
string

file_… id

mime_type
string
object
string
Example:

"file"

purpose
string
status
string