---
updatedAt: 2025-11-20T08:26:33.000Z
agentTools:
  projectIndex: https://partner-docs.gupshup.io/llms.txt
---

# Generate Media ID Using File Uplaod

Use this API to generate media IDs for WhatsApp messaging by uploading files directly from your local system. Media IDs are required when sending media messages (images, videos, documents, audio) through WhatsApp Business API.

> ⚠️ All media files sent through this endpoint are encrypted and persist for 30 days, unless they are deleted earlier.

## Request Parameters

```curl
curl --location --request POST 'https://partner.gupshup.io/partner/app/{{APP_ID}}/media' \
--header 'Authorization: {{PARTNER_APP_TOKEN}}' \
--form 'file_type="{{FILE_TYPE}}"' \
--form 'file=@"/path/to/file"'
```

<br />

## Sample Request

```curl
curl --location --request POST 'https://partner.gupshup.io/partner/app/{{APP_ID}}/media' \
--header 'token: {{PARTNER_APP_TOKEN}}' \
--form 'file_type="{{FILE_TYPE}}"' \
--form 'file=@"/path/to/file"'
```

## Sample Response

```json
{
    "mediaId": "<mediaId>",
    "status": "success"
}
```

## Status Codes

| Status Code | Response                                                                                        | Comments                                                                              |
| :---------- | :---------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------ |
| **Success** |                                                                                                 |                                                                                       |
| 200         | `{       "mediaId": "<mediaId>",       "status": "success"   }`                                 |                                                                                       |
| **Error**   |                                                                                                 |                                                                                       |
| 400         | `{       "message": "Only CAPI apps allowed to generate media ID",       "status": "error"   }` | Bad Request when app is non CAPI                                                      |
| 413         | `{       "message": "File size exceeds the maximum limit!",       "status": "error"   }`        | Supported 100 MB file size                                                            |
| 500         | `{       "message": "Unable to upload requested Media",       "status": "error"   }`            | Internal Error occurred. Try after some time. If issue persists contact support team. |

# OpenAPI definition

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "Generate Media ID",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://partner.gupshup.io"
    }
  ],
  "paths": {
    "/partner/app/{appId}/media": {
      "post": {
        "tags": [
          "default"
        ],
        "summary": "Generate Media ID Using File Uplaod",
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "file",
                  "file_type"
                ],
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary"
                  },
                  "file_type": {
                    "type": "string",
                    "example": "image/jpeg"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "header",
            "schema": {
              "type": "string"
            },
            "description": "Your app token, please refer [**Get access token api**](https://docs.gupshup.io/reference/get_partner-app-appid-token) to get the token from partner documentation.",
            "example": "sk_61b3021c97214370b341f8baaae0xxxx",
            "required": true
          },
          {
            "name": "appId",
            "in": "path",
            "schema": {
              "type": "string"
            },
            "required": true,
            "description": "Unique identifier of the app.",
            "example": "9e97650d-xxxx-xxxx-xxxx-4cdf47c3fa68"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "mediaId": {
                      "type": "string",
                      "example": "3674626312780147"
                    },
                    "status": {
                      "type": "string",
                      "example": "success"
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "Content Too Large",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string",
                      "example": "File size exceeds the maximum limit!"
                    },
                    "status": {
                      "type": "string",
                      "example": "error"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string",
                      "example": "Unable to upload requested Media"
                    },
                    "status": {
                      "type": "string",
                      "example": "error"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "x-readme": {
    "explorer-enabled": true,
    "proxy-enabled": true
  }
}
```