1. medias
Peach
  • template-messages
    • Send a pre-approved template message
      POST
    • Poll template message status
      GET
    • Poll template messages status
      GET
    • Connect to AI Agent
      POST
    • Send an App message
      POST
  • broadcasts
    • List broadcasts
      GET
    • Launch a broadcast
      POST
    • Poll broadcast status
      GET
    • Get broadcast details
      GET
    • Archive broadcast
      PATCH
    • Cancel broadcast
      PATCH
  • whatsapp_templates
    • List all templates
      GET
    • Create a template
      POST
    • Update template
      PATCH
    • Archive template
      PATCH
    • Pause template
      PATCH
    • Submit template
      PATCH
    • Fetch template details
      GET
  • conversations
    • List messages
      GET
    • List conversations
      GET
    • Update conversation status
      PATCH
    • Agent Assignment
      POST
    • Close Conversation
      POST
  • contacts
    • Create multiple contacts
    • Update a contact
    • Create a contact
    • Bulk update communication preferences
  • orders
    • Create an order
    • Find order by ID
    • Create a refund for an order
  • medias
    • About uploaded media
    • List available medias
      GET
    • Add a media (Deprecated)
      POST
    • Remove a media
      DELETE
    • Create a direct upload for media
      POST
    • Finalize a direct uploaded media
      POST
  • webhooks
    • Order status webhooks
    • Flow execution status webhooks
    • Message delivery status webhooks
    • AI Agent Execution Webhooks
  • Schemas
    • Schemas
      • WhatsApp Template
      • WhatsApp Template Parameters
      • Order
      • RefundRequest
      • Contact
      • LineItem
      • OrderExpiry
      • TemplateMessage
      • AnyValue
      • Argument
      • Message
      • MessageResponse
  1. medias

About uploaded media

What is an uploaded media?#

Uploaded media is a file stored in Peach's media library that you can reference later using its media_url field.

Recommended upload flow#

Use the new direct upload flow for all new integrations:
1.
Call POST /api/v1/medias/direct_uploads to get a direct upload URL, headers, and a signed_id.
2.
Upload the raw file bytes with an HTTP PUT request to the returned direct_upload.url, including the returned direct_upload.headers. This upload goes directly to Peach storage, not back to the Peach API.
3.
Call POST /api/v1/medias/finalize with the signed_id to attach the blob into Peach's media library.
4.
Use the returned media_url (media://...) in subsequent API calls.

Example requests#

1. Create a direct upload#

Example response:
{
  "id": 101,
  "key": "1/abc123def456",
  "filename": "sample.png",
  "content_type": "image/png",
  "metadata": {
    "source": "api",
    "peach_media_direct_upload": true,
    "account_id": 1
  },
  "byte_size": 128349,
  "checksum": "I+Sf6zGPGY+9Fh0ymkvwow==",
  "created_at": "2026-04-22T10:00:00.000Z",
  "signed_id": "eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBdz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--example",
  "direct_upload": {
    "url": "https://storage.example.com/upload",
    "headers": {
      "Content-Type": "image/png"
    }
  }
}

2. Upload the bytes to storage#

Use the direct_upload.url and direct_upload.headers from the previous response.
If direct_upload.headers contains additional headers, include them exactly as returned.

3. Finalize the upload#

Example response:
{
  "id": 55,
  "filename": "sample.png",
  "content_type": "image/png",
  "signed_id": "eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBdz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--example",
  "media_url": "media://101",
  "created_at": "2026-04-22T10:00:05.000Z"
}

Common error responses#

401 Unauthorized#

{
  "message": "Unauthorized"
}

413 Payload Too Large#

{
  "status": "failed",
  "reason": {
    "blob": {
      "byte_size": [
        "is too large (max 5242880 bytes for image/png)"
      ]
    }
  }
}

422 Unprocessable Entity#

Unsupported content type:
{
  "status": "failed",
  "reason": {
    "blob": {
      "content_type": [
        "is not supported. Supported values: image/jpeg, image/png, video/mp4, video/3gpp, application/pdf, text/plain, application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document, application/vnd.ms-powerpoint, application/vnd.openxmlformats-officedocument.presentationml.presentation, audio/mp4, audio/mpeg, audio/amr, audio/ogg, audio/aac"
      ]
    }
  }
}
Missing content type:
{
  "status": "failed",
  "reason": {
    "blob": {
      "content_type": [
        "is blank"
      ]
    }
  }
}

Legacy upload endpoint#

POST /api/v1/medias still works for backward compatibility, but it is deprecated and should not be used for new integrations. It uploads base64 data through the app servers and is less performant.
Example request:
Example response:
{
  "id": 55,
  "filename": "sample.png",
  "content_type": "image/png",
  "signed_id": "eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBdz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--example",
  "media_url": "media://101",
  "created_at": "2026-04-22T10:00:05.000Z"
}

Orphaned uploads#

Direct-upload blobs that are never finalized are automatically cleaned up after 24 hours.

Why use uploaded media over inline file URLs?#

Using uploaded media can help in the following ways:
it can help reduce network load on your media servers
your payload sizes reduce, which lead to reduced network costs
since Peach doesn't have to do a network call to fetch the media, it reduces the latency for sending messages

Notes#

content_type is required for direct uploads.
Use the actual MIME type of the file. For example, a .jpeg file should use image/jpeg.
Meta's file size limits still apply when using the uploaded media in downstream messaging APIs.
Modified at 2026-04-22 04:48:05
Previous
Create a refund for an order
Next
List available medias
Built with