Media
Overview
The Media API provides capabilities to upload, modify and fetch video assets.
Usage:
- To create an allocation to upload a video asset and an optional closed caption file
- To upload the video asset and closed Caption File to the uploadUrl
- To accept the video upload notification
- To fetch the video validation outcome by passing the mediaId of the video asset
- To update the media file name
Limitations
- Currently, we do not have the capability to delete the media file for an advertiser
- We do not support previewing the video file
To understand details about ‘Request Header' or 'Authorization’, please refer to the Authorization Guide
Upload Media
Description: The upload media endpoint is used to create a location to upload a video asset and an optional closed caption file (recommended if the video has spoken words). This location is short-lived and expires in 15 minutes.
End Point: /api/v1/media/upload
HTTP Method: POST
Query Parameters
Parameter | Description | Type | Required | Possible Values |
---|---|---|---|---|
advertiserId | ID of the advertiser, uploading video asset | Integer | Y | Unique numeric identifier |
mediaType | The value of mediaType is “video”. | String | Y | Relevant string value representing the media type |
Note: mediaType
paramerter should be follow:
- The file size must be less than 500 MB.
- The file format must be .MP4 or .MOV
- The aspect ratio should be 16:9.
- The dimensions must be 1920 x 1080px – 3840 x 2160px.
- The duration must be 5–30 seconds.
- Video codec must be H.264 or H.265.
- The audio codec must be AAC, MP3, PC.
- Caption file format should be .srt or .vtt.
- Currently, there is no restriction on the number of videos that an advertiser can upload for an advertiser account
Sample Request
Response
Element | Description | Type |
---|---|---|
code | Possible values of the response code: success or failure | String |
details | Details of the error if response code is failure | String |
mediaUploadRequestId | Id that is generated in response to receiving a request for uploading a video asset | Integer |
uploadUrl | The URL to upload the media. Note: The URL expires in 15 minutes. The upload location only supports PUT HTTP method to upload the media content. |
String |
captionUrl | The URL to upload the closed caption file. Note: The URL expires in 15 minutes. The upload location only supports PUT HTTP method to upload the caption file. |
String |
Sample Response
[
{
"code": "success",
"details": "",
"mediaUploadRequestId": 600001,
"uploadUrl":
"https://b4e0184a3estg.blob.core.windows.net/video.mp4?sv=2021-08-06&se=2022-08-19T05%3A05%3A23Z&sr=b&sp=rcwl&sig=DvVyinZhZo1gNahI%2BRobR4oxXMyXmQG8gD04ZraInoY%3D",
"captionUrl": "https://b4e0184a3estg.blob.core.windows.net/caption.srt?sv=2021-08-06&se=2022-08-19T05%3A05%3A23Z&sr=b&sp=rcwl&sig=1aVWrnICQAQGV7lZ3JDuL1W8gOkPOqLYLim6JtRN6X0%3D"
}
]
HTTP Status Code
Status Code | Description | Possible Error Messages |
---|---|---|
400 | Bad Request |
|
403 | Forbidden |
|
429 | Too Many Requests | <Exception Message> |
500 | Internal Server Error | There was an error processing the request |
Upload the Media File to Upload Location
Description
Use this endpoint to
- Upload the video asset to the uploadUrl
- Upload the closed caption file to captionUrl. Upload of caption file is optional
-
Request body to include binary data of mp4 or .mov video file
Note: You receive the
uploadUrl
andcaptionUrl
in response ofPOST
operation
Sample Request
Sample Response 1
- If the video upload is successful - response 201
- If video upload failure – generic error message
Sample Response 2
- If closed caption file upload successful – response 201
- If closed caption file upload failure - generic error message
Complete Media Upload
Description
- Use this endpoint to accept video upload notification
- This endpoint is called once the media is uploaded to the location provided by the /api/v1/media/upload API endpoint
- This API creates a media resource for the video asset. The media resource is represented by a media identifier. The media identifier can be used to associate the media with the adGroup for Sponsored Videos.
- Once the media is uploaded, the API internally kicks off a background process for validating the technical specifications of the media file. As a result, the media may not be immediately available for use in a Sponsored Video campaign. See /api/v1/media endpoint to get details on when the media is available to be used in a campaign.
End Point: /api/v1/media/complete
HTTP Method: PUT
Query Parameters
Parameter | Description | Type | Required | Possible Values |
---|---|---|---|---|
advertiserId | The ID of the ad group. Required only if updating an existing ad group. | Integer | Y | Unique numeric identifier |
mediaName | The title of the video is creative. The maximum file name size is 45 characters and no special characters are allowed. | String | Y | Relevant string value representing the name of the video asset |
mediaUploadRequestId | ID that is generated in response to receiving a request for uploading a video asset. | Integer | Y | Unique numeric identifier |
Sample Request
Response
Element | Description | Type |
---|---|---|
code | Status of the ad group update operation Values: Success or Failure | String |
details | Details of the failure in case of video file/caption file validation error | String |
mediaId | Details of the failure in case of video file/caption file validation error | Integer |
errors | Error description in case of failure. It consists of the following with string datatype: message, type, code | Array |
Sample Response
[
{
"code": "success",
"details": "",
"mediaId": 600001,
"errors": [
{
"message": "message1",
"type": "VALIDATION",
"code": "E_ASPECT_RATIO"
},
{
"message": "message2",
"type": "VALIDATION",
"code": "E_MIN_PIXEL"
}
]
}
]
HTTP Status Code
Status Code | Description | Possible Error Messages |
---|---|---|
200 | OK |
|
400 | Bad Request |
|
403 | Forbidden |
|
404 | Not Found | MediaUploadRequest not found |
429 | Too Many Requests | <Exception Message> |
500 | Internal Server Error | There was an error processing the request |
Update the Media Details
Description: Use this endpoint to Update the media file name
End Point: /api/v1/media
HTTP Method: PUT
Query Parameters
Parameter | Description | Type | Required | Possible Values |
---|---|---|---|---|
advertiserId | The ID of the advertiser | Integer | Y | Unique numeric identifier |
mediaName | The title of the video asset Note: The mediaName can have a maximum size of 45 characters, with no special characters allowed |
String | Y | Relevant string value representing the name of the video asset |
mediaId | The unique Id of the media file | Integer | Y | Unique numeric identifier |
Sample Request
Response
Element | Description | Type |
---|---|---|
code | Status of the ad group update operation Values: success or Failure | String |
details | Details of the update | String |
mediaId | The unique Id of the media file whose title is changed successfully | Integer |
Sample Response
[
{
"code": "success",
"details": "",
"mediaId": 700001
}
]
HTTP Status Code
Status Code | Description | Possible Error Messages |
---|---|---|
400 | Bad Request |
|
403 | Forbidden |
|
404 | Not Found | MediaDetails not found |
429 | Too Many Requests | <Exception Message> |
500 | Internal Server Error | There was an error processing the request |
List All the Media
Description:
- This endpoint is used to fetch the video validation outcome by passing the mediaId of the video asset. It polls Sam's Club system to check the video validation status and returns the result.
- For a video asset to be associated with a campaign, the corresponding media file should be in AVAILABLE status. The AVAILABLE status guarantees that the background process has completed the processing of the video asset and that it is available for usage in a Sponsored Video campaign. The validated video asset represents the video profile.
- The background processing can take approximately take ~30 minutes to complete. We recommend polling the system to check for the video validation 30 minutes after uploading, with a backoff timer of 15 minutes.
- The endpoint can also be used to list all the video files along with their status for a given advertiser. Optionally, you can also filter by the status of the media file (PENDING, FAILED or AVAILABLE) to list only files matching the status for a given.
End Point: /api/v1/media
HTTP Method: GET
Query Parameters
Parameter | Description | Type | Required | Possible Values |
---|---|---|---|---|
advertiserId | The ID of the advertiser | Integer | Y | Unique numeric identifier |
mediaId | The unique Id of the media file generated from the notify media upload complete call Note: When an advertiser id and multiple media ids are provided, the service shall return the media details qualifying for the first media id. |
Integer | N | Unique numeric identifier |
status | The value represents the status of the media file. Note: When an advertiser id and multiple status are provided, the service shall return the media details qualifying for the first status. |
String | N | Relevant string value representing the status (PENDING, FAILED, AVAILABLE) |
Sample Request
Response
Element | Description | Type |
---|---|---|
mediaId | The unique Id of the media file generated from the notify media upload complete call | Integer |
status | Expected values: PENDING, AVAILABLE, FAILED | String |
details | Details of the media | String |
name | Name of the media | String |
thumbnail | URL for the image snapshot of video | String |
Sample Response
[
{
"mediaId": 500003,
"status": "AVAILABLE",
"details": "details abc",
"name": "abc 4",
"thumbnail": "https://advertising.com"
}
]
Sample Response - Validation Failure
[
{
"mediaId": 123456,
"status": "FAILED",
"details": "[{\"validationReason\":\"Video file is empty.\",\"resourceType\":\"VIDEO\",\"code\":\"E_EMPTY_VIDEO\",\"message\":\"Video file is empty.\",\"type\":\"VALIDATION\"}]",
"name": "sample",
"thumbnail": "https://advertising.com",
"videoUrl": "{media-url}",
"captionUrl": "{cc-url}",
"confidenceLevel": 0.0,
"attached": false,
"autoGenerated": false
}
]
Additional Validation Error Codes
Status Code | Validation Error Description |
---|---|
E_BITRATE_KBPS_NOT_POSITIVE | [{"validationReason": "Video bitrate kbps should be greater than zero.","resourceType": "VIDEO","code": "E_BITRATE_KBPS_NOT_POSITIVE", "message": "Video bitrate kbps should be greater than 0.", "type": "VALIDATION"}] |
E_BAD_CAPTION | [{"validationReason": "Closed caption data is invalid. FFProbe identified it as bad closed caption data.","resourceType": "CAPTION","code": "E_BAD_CAPTION","message": "Closed caption data is invalid. FFProbe identified it as bad closed caption data.","type": "VALIDATION"}] |
E_MAX_DURATION_SECONDS | [{"validationReason": "Video is longer than max duration requirement. Value x is greater than upper bound 45.","resourceType": "VIDEO","code": "E_MAX_DURATION_SECONDS","meta": {"maximumValue": "45","actualValue": "x"},"message": "Video longer than maxDurationSeconds. Value x is greater than upper bound 45.","type": "VALIDATION"}] |
E_MIN_FRAME_RATE_PER_SECOND | [{"validationReason": "Video frame rate is less than minimum frame rate per second requirement. Value x is less than lower bound 15.0.","resourceType": "VIDEO","code": "E_MIN_FRAME_RATE_PER_SECOND","meta": {"minimumValue": "15.0","actualValue": "x"},"message": "Video frame rate less than minFrameRatePerSecond. Value x is less than lower bound 15.0.","type": "VALIDATION"}] |
E_SUPPORTED_CONTAINERS | [{"validationReason": "Unsupported container. None of the container formats jpeg_pipe were in the list of supported container formats: matroska, mp3, mp4, wav, avi, webm, mov.","resourceType": "VIDEO","code": "E_SUPPORTED_CONTAINERS","meta": {"actualValues": ["jpeg_pipe"],"expectedValues": ["matroska","mp3","mp4","wav","avi","webm","mov"]},"message": "Unsupported container. None of the container formats jpeg_pipe were in the list of supported container formats: matroska, mp3, mp4, wav, avi, webm, mov","type": "VALIDATION"}] |
E_MIN_VIDEO_BITRATE_KBPS | [{"validationReason": "Video bitrate is less than minimum video bitrate kbps requirement. Value x is less than lower bound 512.","resourceType": "VIDEO","code": "E_MIN_VIDEO_BITRATE_KBPS","meta": {"minimumValue": "512","actualValue": "x"},"message": "Video bitrate less than minVideoBitrateKbps. Value x is less than lower bound 512.","type": "VALIDATION"}] |
E_MIN_WIDTH_PIXELS | [{"validationReason": "Video is narrower than minimum pixel width requirement. Value x is less than lower bound 1280.","resourceType": "VIDEO","code": "E_MIN_WIDTH_PIXELS","meta": {"minimumValue": "1280","actualValue": "x"},"message": "Video narrower than minWidthPixels. Value x is less than lower bound 1280.","type": "VALIDATION"}] |
E_MIN_DURATION_SECONDS | [{"validationReason": "Video is shorter than minimum duration requirement. Value x is less than lower bound 5.","resourceType": "VIDEO","code": "E_MIN_DURATION_SECONDS","meta": {"actualValue": "x","minimumValue": "5"},"message": "Video shorter than minDurationSeconds. Value x is less than lower bound 5.","type": "VALIDATION"}] |
E_CAPTION_CUE | [{"validationReason": "Closed caption cue data is invalid. Cue identifier cannot be standalone: 'npm ERR! A complete log of this run can be found in: debug.log'.","resourceType": "CAPTION","code": "E_CAPTION_CUE","message": "Closed caption cue data is invalid. Cue identifier cannot be standalone: 'npm ERR! A complete log of this run can be found in: debug.log'.","type": "VALIDATION"}] |
E_SUPPORTED_VIDEO_CODECS | [{"validationReason": "Unsupported video codec. Unsupported video codec mjpeg. The supported video codecs are: dnxhd, mpeg1video, mpeg4, h261, hevc, h263, h264, vp8, vp9, dvvideo, mpeg2video, prores, theora, vc1.","resourceType": "VIDEO","code": "E_SUPPORTED_VIDEO_CODECS","meta": {"actualValue": "mjpeg","expectedValues": ["dnxhd","mpeg1video","mpeg4","h261","hevc","h263","h264","vp8","vp9","dvvideo","mpeg2video","prores","theora","vc1"]},"message": "Unsupported video codec. Unsupported video codec mjpeg. The supported video codecs are: dnxhd, mpeg1video, mpeg4, h261, hevc, h263, h264, vp8, vp9, dvvideo, mpeg2video, prores, theora, vc1","type": "VALIDATION"}] |
E_ASPECT_RATIO | [{"validationReason": "Video does not match aspect ratio requirement. m:n is not 16:9.","resourceType": "VIDEO","code": "E_ASPECT_RATIO","meta": {"expectedValue": "16:9","actualValue": "m:n"},"message": "Video does not match aspectRatio. m:n is not 16:9.","type": "VALIDATION"}] |
E_VIDEO_STREAM_COUNT | [{"message": "There must be exactly one video stream. The provided video had 0 video streams.","type": "VALIDATION","code": "E_VIDEO_STREAM_COUNT"}] |
E_EMPTY_VIDEO | {[{"validationReason": "Video file is empty.","resourceType": "VIDEO","code": "E_EMPTY_VIDEO","message": "Video file is empty.","type": "VALIDATION"}] |
E_MIN_HEIGHT_PIXELS | [{"validationReason": "Video is shorter than minimum pixel height requirement. Value x is less than lower bound 720.","resourceType": "VIDEO","code": "E_MIN_HEIGHT_PIXELS","meta": {"minimumValue": "720","actualValue": "x"},"message": "Video shorter than minHeightPixels. Value x is less than lower bound 720.","type": "VALIDATION"}] |
E_MIN_AUDIO_BITRATE_KBPS | [{"validationReason": "Audio bit rate is less than minimum audio bitrate kbps requirement. Value x is less than lower bound 64.","resourceType": "VIDEO","code": "E_MIN_AUDIO_BITRATE_KBPS","meta": {"minimumValue": "64","actualValue": "x"},"message": "Audio bitrate less than minAudioBitrateKbps. Value x is less than lower bound 64.","type": "VALIDATION"}] |
E_VIDEO_DURATION_NOT_POSITIVE | [{"validationReason": "Video duration should be greater than zero.","resourceType": "VIDEO","code": "E_VIDEO_DURATION_NOT_POSITIVE","message": "Video duration should be greater than 0.","type": "VALIDATION"}] |
E_BAD_VIDEO | [{"validationReason": "Failed to decode video.","resourceType": "VIDEO","code": "E_BAD_VIDEO","message": "Failed to decode video.","type": "VALIDATION"}] |
E_SUPPORTED_AUDIO_CODECS | [{"validationReason": "Unsupported audio codec. The audio codec xyz is Unsupported. The supported audio codecs are: mp3, ac3, aac, vorbis, wmav1, wmav2, eac3, opus.","resourceType": "VIDEO","code": "E_SUPPORTED_AUDIO_CODECS","meta": {"expectedValues": ["mp3","ac3","aac","vorbis","wmav1","wmav2","eac3","opus"],"actualValue": "xyz"},"message": "Unsupported audio codec. The audio codec xyz is Unsupported. The supported audio codecs are: mp3, ac3, aac, vorbis, wmav1, wmav2, eac3, opus","type": "VALIDATION"}] |
E_MAX_FILE_SIZE_MB | [{"validationReason": "Video file size is greater than max file size requirement. Value x is greater than upper bound 500.","resourceType": "VIDEO","code": "E_MAX_FILE_SIZE_MB","meta": {"maximumValue": "500","actualValue": "x"},"message": "Video file size greater than maxFileSizeMB. Value x is greater than upper bound 500.","type": "VALIDATION"}] |
E_VTT_CAPTION | [{"validationReason": "VTT closed caption data is invalid. Couldn't find blank line between header and content or content is empty.","resourceType": "CAPTION","code": "E_VTT_CAPTION","message": "VTT closed caption data is invalid. Couldn't find blank line between header and content or content is empty.","type": "VALIDATION"}] |
HTTP Status Code
Status Code | Description | Possible Error Messages |
---|---|---|
400 | Bad Request | advertiserId not found in request |
403 | Forbidden |
|
404 | Not Found | MediaDetails not found |
429 | Too Many Requests | <Exception Message> |
500 | Internal Server Error | There was an error processing the request |