post https://partner.gupshup.io/partner/app//media
Use this API to generate the media ID using the file upload.
All media files sent through this endpoint are encrypted and persist for 30 days, unless they are deleted earlier.
Request Parameters
Key | Description | Values | Data Type | Required/Optional | Constraints |
---|---|---|---|---|---|
Authorization | Access Token for the application | {{PARTNER_APP_TOKEN}} | String | Required | Should be a valid Partner App Access Token. |
appId | App ID to fetch the access token | {{App_ID}} | String | Required | The ID should be a valid appId of Gupshup |
file_type | File type to generate media id | image/png | String | Required | 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 ''." |
file | File path to upload file | </path/to/file> | File | Required | Should be valid file path File size should not be more than 100 MB |
Sample Request
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 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. |