> ## Documentation Index
> Fetch the complete documentation index at: https://zeply.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Upload media

> Upload a multimedia attachment to temporary S3 storage prior to sending via WhatsApp

Upload an image, document, audio file, or video to Sayvy AI storage. The response contains a temporary S3 key (`media_url`) and MIME properties that can be directly passed into `POST /api/v1/inbox/messages/{inbox_id}`.

***

### Authentication

This endpoint requires Bearer token authentication.

```http theme={null}
Authorization: Bearer <token>
```

| Header          | Type     | Required | Description                                     | Format           |
| :-------------- | :------- | :------- | :---------------------------------------------- | :--------------- |
| `Authorization` | `string` | **Yes**  | Scoped organization API key or Bearer JWT token | `Bearer <token>` |

***

### Form Parameters

<ParamField header="Authorization" type="string" required>
  Bearer token for authentication. Format: `Bearer <token>`.
</ParamField>

<ParamField body="file" type="file" required>
  The binary multipart file upload. Supports PNG, JPG, PDF, DOCX, MP3, OGG, MP4.
</ParamField>

***

### Response Fields

<ResponseField name="media_url" type="string">
  Generated storage key (e.g. `inbox-media/temp/{org_id}/{temp_id}/{filename}`).
</ResponseField>

<ResponseField name="media_mime_type" type="string">
  Detected content MIME type of the uploaded file.
</ResponseField>

<ResponseField name="media_filename" type="string">
  Original filename extracted from multipart upload.
</ResponseField>

***

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://api.sayvy.ai/api/v1/inbox/upload" \
    -H "Authorization: Bearer <token>" \
    -F "file=@/path/to/invoice.pdf"
  ```

  ```python Python theme={null}
  import requests

  url = "https://api.sayvy.ai/api/v1/inbox/upload"
  headers = {
      "Authorization": "Bearer <token>"
  }

  with open("invoice.pdf", "rb") as f:
      files = {"file": ("invoice.pdf", f, "application/pdf")}
      response = requests.post(url, headers=headers, files=files)

  print(response.status_code)
  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const formData = new FormData();
  formData.append("file", fileInputElement.files[0]);

  const response = await fetch("https://api.sayvy.ai/api/v1/inbox/upload", {
    method: "POST",
    headers: {
      "Authorization": "Bearer <token>"
    },
    body: formData
  });

  const data = await response.json();
  console.log(data);
  ```
</RequestExample>

<ResponseExample>
  ```json 200 OK theme={null}
  {
    "media_url": "inbox-media/temp/e0b973dc-13a8-4c9f-861a-03e5b4b1a8d9/d3b07384-d113-46fb-a9fe-7a1a2b3c4d5e/invoice.pdf",
    "media_mime_type": "application/pdf",
    "media_filename": "invoice.pdf"
  }
  ```

  ```json 400 Bad Request theme={null}
  {
    "detail": "Valid organization_id header is required"
  }
  ```
</ResponseExample>
