Generate Media ID Using File Upload

Use this API to generate the media ID using the file upload.

Recent Requests
Log in to see full request history
TimeStatusUser Agent
Retrieving recent requests…
LoadingLoading…
<PartnerPortalWarning />

<br />

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

## Request Parameters

<Table align={["left", "left", "left", "left", "left", "left"]}>
  <thead>
    <tr>
      <th style={{ textAlign: "left" }}>Key</th>
      <th style={{ textAlign: "left" }}>Description</th>
      <th style={{ textAlign: "left" }}>Values</th>
      <th style={{ textAlign: "left" }}>Data Type</th>
      <th style={{ textAlign: "left" }}>Required/Optional</th>
      <th style={{ textAlign: "left" }}>Constraints</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td style={{ textAlign: "left" }}>Authorization</td>
      <td style={{ textAlign: "left" }}>Access Token for the application</td>
      <td style={{ textAlign: "left" }}>`{{PARTNER_APP_TOKEN}}`</td>
      <td style={{ textAlign: "left" }}>String</td>
      <td style={{ textAlign: "left" }}>Required</td>
      <td style={{ textAlign: "left" }}>Should be a valid Partner App Access Token.</td>
    </tr>
    <tr>
      <td style={{ textAlign: "left" }}>appId</td>
      <td style={{ textAlign: "left" }}>App ID to fetch the access token</td>
      <td style={{ textAlign: "left" }}>`{{App_ID}}`</td>
      <td style={{ textAlign: "left" }}>String</td>
      <td style={{ textAlign: "left" }}>Required</td>
      <td style={{ textAlign: "left" }}>The ID should be a valid appId of Gupshup</td>
    </tr>
    <tr>
      <td style={{ textAlign: "left" }}>file_type</td>
      <td style={{ textAlign: "left" }}>File type to generate media id</td>
      <td style={{ textAlign: "left" }}>image/png</td>
      <td style={{ textAlign: "left" }}>String</td>
      <td style={{ textAlign: "left" }}>Required</td>
      <td style={{ textAlign: "left" }}>Param file must be a file with one of the following types:  
        `audio/aac, audio/mp4, audio/mpeg, audio/amr, audio/ogg, audio/opus, application/vnd.ms-powerpoint, application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document, application/vnd.openxmlformats-officedocument.presentationml.presentation, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/pdf, text/plain, application/vnd.ms-excel, image/jpeg, image/png, image/webp, video/mp4, video/3gpp. Received file of type ''.`
      </td>
    </tr>
    <tr>
      <td style={{ textAlign: "left" }}>file</td>
      <td style={{ textAlign: "left" }}>File path to upload file</td>
      <td style={{ textAlign: "left" }}>`/path/to/file`</td>
      <td style={{ textAlign: "left" }}>File</td>
      <td style={{ textAlign: "left" }}>Required</td>
      <td style={{ textAlign: "left" }}>Should be valid file path  
        File size should not be more than 100 MB
      </td>
    </tr>
  </tbody>
</Table>

## 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

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

Status Codes

Status CodeResponseComments
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.
Path Params
string
required

Unique identifier of the app.

Body Params
file
required
string
required
Headers
string
required

Your app token, please refer Get access token api to get the token from partner documentation.

Responses

Language
LoadingLoading…
Response
Click Try It! to start a request and see the response here! Or choose an example:
application/json