Skip to content
Context docs
Tasks API

Files

Serverhttps://context.example.com/api/v1

Upload a file for a task to work on, then check that the upload finished before you attach it to a prompt or task.


Start a file upload

POST
https://context.example.com/api/v1
/files
Bearer (tsk_<prefix>_<secret>)

Returns a PUT URL that expires at upload.expiresAt. Upload the file's bytes there with no other credentials, then poll GET /files/{fileId} until its status is uploaded; pass the fileId to a prompt or task to attach it. The file is stored in the key owner's Drive.

Start a file upload › Request Body

Input for task file upload initialization
name
​string · minLength: 1 · maxLength: 512 · required

Original filename

namespace
​string · minLength: 1 · maxLength: 128

Optional namespace override; defaults from key scope

ownerUserId
​string · minLength: 1

Optional execution owner override by user ID. Service keys may set this. Mutually exclusive with ownerUserEmail.

ownerUserEmail
​string · email

Optional execution owner override by user email; resolved within the task key's organization. Service keys may set this. Mutually exclusive with ownerUserId.

contentType
​string · minLength: 1

MIME type for upload signing

sizeBytes
​integer

Optional expected size in bytes

Start a file upload › Responses

The file record and its upload URL.

Task file upload initialization result
fileId
​string · minLength: 1 · required

Opaque task file identifier

namespace
​string · minLength: 1 · required

Resolved namespace

status
​string · enum · required

Task file upload status

Enum values:
pending
uploaded
failed
​object · required

Get a file's upload status

GET
https://context.example.com/api/v1
/files/{fileId}
Bearer (tsk_<prefix>_<secret>)

Returns the metadata of a file uploaded with POST /files, with its upload status. A key reads files it created and files owned by the person it acts for.

Get a file's upload status › path Parameters

fileId
​string · required

The file's id.

Get a file's upload status › Responses

The file's metadata and upload status.

Task file metadata and upload status
fileId
​string · minLength: 1 · required
namespace
​string · minLength: 1 · required
name
​string · minLength: 1 · required
contentType
​string | null · required
sizeBytes
​integer | null · min: 0 · required
status
​string · enum · required

Task file upload status

Enum values:
pending
uploaded
failed
drivePath
​string · minLength: 1 · required
createdAt
​string · date-time · required
updatedAt
​string · date-time · required