Files

The Files API stores binary assets behind stable file_... IDs so the rest of Commerce can reference them safely. Use it for product images, product videos, digital downloads, and support documents when you want durable asset IDs instead of ad hoc remote URLs.


The file object

A file is the stable record for uploaded bytes. Other Commerce resources should store the file ID, not the original upload URL or local filename.

Properties

  • Name
    available_at
    Type
    timestamp
    Description

    When the file became available for use. Returned only after the file is available.

  • Name
    checksum_sha256
    Type
    string
    Description

    SHA-256 checksum of the original file bytes.

  • Name
    content_type
    Type
    string
    Description

    Effective MIME type after the upload has been normalized and validated.

  • Name
    created_at
    Type
    timestamp
    Description

    When the file record was created.

  • created_byobjectActor that created the file. Direct uploads commonly return { "type": "api_key" }.Click or tap to expand
    • Name
      email
      Type
      string
      Description
      Actor email when available.
    • Name
      id
      Type
      string
      Description
      Actor ID when available.
    • Name
      name
      Type
      string
      Description
      Actor display name when available.
    • Name
      type
      Type
      string
      Description
      Actor type such as api_key, system, or upload_request.
  • Name
    custom_data
    Type
    object
    Description

    String key-value custom data supplied during upload. Omitted when no custom data was supplied.

  • deliveryobjectPublic delivery metadata when the file purpose supports a stable public asset URL. Omitted for other purposes.Click or tap to expand
    • Name
      cache_control
      Type
      string
      Description
      Cache policy for the public response when present.
    • Name
      content_type
      Type
      string
      Description
      Content type served by the public URL when present.
    • Name
      public_url
      Type
      string
      Description
      Public asset URL. Use the returned value unchanged.
  • Name
    expires_at
    Type
    timestamp
    Description

    Expiry timestamp when the file has a policy-driven lifetime. Omitted when the file does not expire.

  • Name
    filename
    Type
    string
    Description

    Filename supplied with the upload. Omitted when no filename is available.

  • Name
    id
    Type
    string
    Description

    Unique file identifier. File IDs begin with file_.

  • latest_errorobjectMost recent processing error when the file could not be made available. Present only when the file has failed.Click or tap to expand
    • Name
      at
      Type
      timestamp
      Description
      When the error was recorded.
    • Name
      code
      Type
      string
      Description
      Stable error code for the most recent failure.
    • Name
      message
      Type
      string
      Description
      Human-readable failure message.
    • Name
      retryable
      Type
      boolean
      Description
      Whether retrying the same operation can succeed.
  • mediaobjectExtracted media details when Commerce can derive them from the uploaded file.Click or tap to expand
    • Name
      aspect_ratio
      Type
      string
      Description
      Aspect ratio when available.
    • Name
      codec
      Type
      string
      Description
      Detected codec when available.
    • Name
      color_space
      Type
      string
      Description
      Detected color space when available.
    • Name
      duration_ms
      Type
      integer
      Description
      Media duration in milliseconds when available.
    • Name
      frame_count
      Type
      integer
      Description
      Frame count when available.
    • Name
      has_alpha
      Type
      boolean
      Description
      Whether the media has an alpha channel when available.
    • Name
      height
      Type
      integer
      Description
      Media height in pixels when available.
    • Name
      kind
      Type
      string
      Description
      Media category such as image, video, or document.
    • Name
      page_count
      Type
      integer
      Description
      Page count for document-like files when available.
    • Name
      width
      Type
      integer
      Description
      Media width in pixels when available.
  • Name
    metadata
    Type
    object
    Description

    Service-generated metadata about the file. Read-only; use custom_data for caller-supplied data.

  • Name
    name
    Type
    string
    Description

    Human-friendly title for the file. Omitted when no title was supplied.

  • Name
    purpose
    Type
    string
    Description

    Purpose policy used to validate and store the file:

    • product_download for downloadable product files and merchant-managed attachments. Accepts .pdf, .zip, .txt, and .csv files up to 100 MiB. Not linkable through file links.
    • product_image for product images. Accepts JPEG, PNG, and GIF up to 10 MiB. Linkable through file links.
    • product_video for product videos. Accepts MP4, WebM, and QuickTime up to 250 MiB. Linkable through file links.
    • products_import for product-catalog imports. Accepts CSV files up to 32 MiB that follow the required import schema and contain no more than 10,000 data rows. Not linkable through file links.
    • support_document for support evidence and attachments. Accepts PDF, JPEG, PNG, and plain text up to 25 MiB. Not linkable through file links.
  • Name
    scan_status
    Type
    string
    Description

    Safety scanning state. Current synchronous uploads commonly return skipped.

  • Name
    size
    Type
    integer
    Description

    Original file size in bytes.

  • sourceobjectWhere the bytes came from.Click or tap to expand
    • Name
      service
      Type
      string
      Description
      Origin label when present.
    • Name
      type
      Type
      string
      Description
      Source type such as direct or upload_request.
    • Name
      upload_request_id
      Type
      string
      Description
      Upload-request ID when the file came from a delegated upload.
  • Name
    status
    Type
    string
    Description

    File lifecycle status: uploading, processing, available, failed, or deleted.

  • storageobjectPublic storage summary for the stored object.Click or tap to expand
    • Name
      encoding
      Type
      string
      Description
      Stored representation, such as identity or br.
    • Name
      stored_size
      Type
      integer
      Description
      Stored object size in bytes.
  • Name
    updated_at
    Type
    timestamp
    Description

    When the file record was last updated.

For products_import, every nonblank data row must contain at least these columns in order: name, type, price_currency, price_value, reference, description, about, category, tax_code, unit_dimension, price_label, publish, and attributes. An optional first header row may use those names in the same order. The file must contain between 1 and 10,000 data rows.


Upload a file

Upload one file with multipart/form-data. Use this endpoint when your backend already has the bytes; use Create an upload request when someone outside your backend should upload directly.

Send retry keys with the Idempotency-Key header. The API rejects idempotency_key form fields so the key cannot be confused with file custom data.

Request body

  • Name
    file
    Type
    file
    Description

    Multipart file part containing the bytes to store.

  • Name
    custom_data
    Type
    object
    Description

    Optional JSON object encoded as a form field. Keys and values must both be strings. The encoded object can be at most 25 KiB, and each key can be at most 256 characters.

  • Name
    purpose
    Type
    string
    Description

    File purpose: product_download, product_image, product_video, products_import, or support_document.

  • Name
    title
    Type
    string
    Description

    Optional display name for the file.

Response

The response returns a top-level file object. Store file.id on the Commerce resource that will reference the asset.

Request

POST
/files/create
curl https://api.zebo.dev/files/create \
  -H "Authorization: Bearer $COMMERCE_API_KEY" \
  -H "Idempotency-Key: upload-hero-image-001" \
  -F "purpose=product_image" \
  -F "title=Hero image" \
  -F 'custom_data={"product_ref":"SKU-12345"}' \
  -F "file=@./hero.png;type=image/png"
{
  "file": {
    "id": "file_4q6YcQk1RzPv2mDa8nFw0sHu",
    "purpose": "product_image",
    "status": "available",
    "scan_status": "skipped",
    "name": "Hero image",
    "filename": "hero.png",
    "content_type": "image/png",
    "size": 248391,
    "checksum_sha256": "db6f2f1d7b4b4d9d9c30a3ddcc7f9d506e8c9d67c4a61e5b9fd2dd9b0f5d0000",
    "created_by": { "type": "api_key" },
    "source": { "type": "direct" },
    "storage": { "encoding": "br", "stored_size": 211042 },
    "delivery": {
      "public_url": "<PUBLIC_FILE_URL>",
      "cache_control": "public, max-age=31536000, immutable",
      "content_type": "image/png"
    },
    "custom_data": { "product_ref": "SKU-12345" },
    "metadata": { "source_type": "direct" },
    "created_at": "2026-06-05T12:30:00Z",
    "updated_at": "2026-06-05T12:30:00Z",
    "available_at": "2026-06-05T12:30:00Z"
  }
}

Lookup a file

Retrieve details for one file. Lookup does not return file bytes; use Download file contents for the original object stream.

Request body

  • Name
    file_id
    Type
    string
    Description

    File ID to retrieve.

Response

The response returns a top-level file object.

Request

POST
/files/lookup
curl https://api.zebo.dev/files/lookup \
  -H "Authorization: Bearer $COMMERCE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"file_id":"file_4q6YcQk1RzPv2mDa8nFw0sHu"}'

Page files

List files for the authorized application. Filters are optional and can be combined to find files by lifecycle state, purpose, or creation window.

Request body

  • Name
    created_after
    Type
    timestamp
    Description

    Return files created at or after this RFC 3339 timestamp.

  • Name
    created_before
    Type
    timestamp
    Description

    Return files created at or before this RFC 3339 timestamp.

  • Name
    page_number
    Type
    integer
    Description

    Page number to retrieve. Defaults to 1.

  • Name
    page_size
    Type
    integer
    Description

    Requested number of files per page. Defaults to 25 and is capped at 256.

  • Name
    purpose
    Type
    string
    Description

    Filter by file purpose.

  • Name
    status
    Type
    string
    Description

    Filter by lifecycle status: uploading, processing, available, failed, or deleted.

Response

Files are returned newest first. The response returns a top-level page object with files, number, and size; size is the number of files returned, not the requested limit. An exhausted page returns files: [] and size: 0. Page numbers and sizes below 1 are normalized to their defaults.

Request

POST
/files/page
curl https://api.zebo.dev/files/page \
  -H "Authorization: Bearer $COMMERCE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"purpose":"product_image","status":"available","page_number":1,"page_size":25}'
{
  "page": {
    "number": 1,
    "size": 1,
    "files": [
      {
        "id": "file_4q6YcQk1RzPv2mDa8nFw0sHu",
        "purpose": "product_image",
        "status": "available",
        "content_type": "image/png",
        "size": 248391
      }
    ]
  }
}

Download file contents

Deliver the original file through an authenticated backend request. Use this for private downloads and for file purposes that cannot be exposed through file links.

Request body

  • Name
    disposition
    Type
    string
    Description

    Optional response disposition: attachment or inline. Defaults to attachment.

  • Name
    delivery
    Type
    string
    Description

    Delivery mode: stream or redirect. Defaults to stream.

  • Name
    file_id
    Type
    string
    Description

    File ID whose bytes should be delivered.

Response

With delivery: stream, the API returns 200 OK with the file bytes, its content type, Content-Disposition, and Cache-Control: private, max-age=60. Content-Length is present when the original byte length can be reported directly.

With delivery: redirect, the API returns 303 See Other with a short-lived download URL in Location and no file body. The current SDK download helpers use stream delivery; send the JSON request with your HTTP client when you need redirect delivery.

A missing file returns 404. Unreadable contents return 424, an unsupported stored representation returns 422, and a temporarily unavailable operation returns 503.

Stream request

POST
/files/contents
curl https://api.zebo.dev/files/contents \
  -H "Authorization: Bearer $COMMERCE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"file_id":"file_4q6YcQk1RzPv2mDa8nFw0sHu","disposition":"attachment"}' \
  --output hero.png

Delete a file

Tombstone a file when you no longer need it. Deletion returns 409 while live Commerce resources still reference the file. After deletion succeeds, links to the file can no longer serve its contents.

This endpoint supports Idempotency-Key. Reuse the same key and request when retrying an uncertain deletion result.

Request body

  • Name
    file_id
    Type
    string
    Description

    File ID to delete.

Response

The response returns the deleted file object with status set to deleted.

Request

POST
/files/delete
curl https://api.zebo.dev/files/delete \
  -H "Authorization: Bearer $COMMERCE_API_KEY" \
  -H "Idempotency-Key: delete-file-001" \
  -H "Content-Type: application/json" \
  -d '{"file_id":"file_4q6YcQk1RzPv2mDa8nFw0sHu"}'
{
  "file": {
    "id": "file_4q6YcQk1RzPv2mDa8nFw0sHu",
    "purpose": "product_image",
    "status": "deleted"
  }
}

Was this page helpful?