tx-agent-kit
Storage

Storage API Endpoints

HTTP endpoints for generating presigned URLs, listing objects, and managing stored files

All storage endpoints require authentication via a Bearer token in the Authorization header.

POST /v1/storage/upload-url

Generate a presigned URL for uploading a file directly to R2.

Request body

FieldTypeRequiredDescription
keystringYesObject key (path) in the bucket
contentTypestringYesMIME type of the file being uploaded
expiresInnumberNoURL expiry in seconds (default: 3600)

Response

{
  "url": "https://....r2.cloudflarestorage.com/octospark-dev/org-123/avatar.png?X-Amz-Signature=..."
}

Client usage

// 1. Get presigned URL from API
const { url } = await api.post('/v1/storage/upload-url', {
  key: 'org-123/avatar.png',
  contentType: 'image/png'
})

// 2. Upload directly to R2
await fetch(url, {
  method: 'PUT',
  headers: { 'Content-Type': 'image/png' },
  body: fileBlob
})

POST /v1/storage/download-url

Generate a presigned URL for downloading a file from R2.

Request body

FieldTypeRequiredDescription
keystringYesObject key to download
expiresInnumberNoURL expiry in seconds (default: 3600)

Response

{
  "url": "https://....r2.cloudflarestorage.com/octospark-dev/org-123/avatar.png?X-Amz-Signature=..."
}

POST /v1/storage/delete

Delete an object from the bucket.

Request body

FieldTypeRequiredDescription
keystringYesObject key to delete

Response

{
  "deleted": true
}

GET /v1/storage/objects

List objects in the bucket, optionally filtered by prefix.

Parameters

NameInTypeRequiredDescription
prefixquerystringNoFilter objects by key prefix

Response

{
  "keys": [
    "org-123/avatar.png",
    "org-123/banner.jpg"
  ]
}

GET /v1/storage/objects/{key}/metadata

Get metadata for a specific object.

Parameters

NameInTypeRequiredDescription
keypathstringYesObject key

Response

{
  "key": "org-123/avatar.png",
  "contentType": "image/png",
  "contentLength": 204800,
  "lastModified": "2026-03-24T12:00:00.000Z",
  "etag": "\"abc123\""
}

Error responses

All endpoints return standard error responses:

StatusDescription
400Invalid request or storage operation failed
401Missing or invalid Bearer token
500Internal server error
PageDescription
Storage OverviewArchitecture and upload flow
ConfigurationEnvironment variables and credentials

On this page