All documentation
Documentation
When Grade holds a copy of a tracked post's media, you can download that copy instead of fetching the post from the social platform.
downloadUrl on post records
When media downloads are enabled for your organization, post records carry
downloadUrl: an absolute link to the download endpoint below, for example
https://…/sdk/v1/media/campaign/CCMEDIA_123/download.
| Value | Meaning |
|---|---|
| A link | Grade holds a copy. Request it with your usual API key headers. |
null |
Grade holds no copy yet, for example while a video is still being collected, or a video post whose video is not stored. |
| Absent | An account row, a post downloads are not offered for (see below), or downloads are not enabled for your organization. |
Which posts are offered
Downloads can be offered for every post, for campaign posts only, or for
campaign posts whose creator has accepted Grade's Partner Agreement in a version
that licenses their content for your use. Tracked posts outside a campaign are
offered only in the first case. A post that is not offered has no downloadUrl,
and its download endpoint returns 404 download_not_offered.
These responses carry downloadUrl on their post records:
| Endpoint | Where |
|---|---|
GET /campaigns/:campaignId/media |
Each item in data |
GET /campaigns/:campaignId/media/sync |
Each item in data |
GET /campaigns/:campaignId/creators/media |
data.posts and data.groups, not data.accounts |
GET /campaigns/:campaignId/media/discovered-posts |
Each item in data |
GET /campaign-creators/:id/crosspost-groups/:crosspostGroupId/posts |
Each item in data |
GET /content-review |
Each item in data |
GET /campaign-creators/:id/payout-report/data |
resultPosts |
POST /campaign-creators/line-items/query |
rules[].posts |
POST /campaign-creators/payout-previews/query |
payableMedia and nonPayableMedia |
GET /analytics/tracked-media, /:trackedMediaId and /:trackedMediaId/posts |
Post rows |
GET /analytics/tracked-media/sync |
Each post in data |
GET /analytics/collections/:collectionId/members |
Each post member |
GET /analytics/top?type=videos |
Each video |
GET /analytics/media/:source/:mediaId |
data.meta |
Records carry only links your key can open: a campaign post's link needs
campaigns:read and a tracked post's link needs analytics:read. A payout
report read with payouts:read alone carries no links.
GET /sdk/v1/media/campaign/:campaignCreatorMediaId/download
Download a campaign post's media. Requires campaigns:read.
GET /sdk/v1/media/tracked/:trackedMediaId/download
Download a standalone tracked post's media. Requires analytics:read.
What you receive
Both endpoints require X-Application-Id and X-Api-Key, like every SDK call.
They stream Grade's stored copy as an attachment:
- a video post: the video;
- a photo post: the original image;
- a carousel or slideshow: its first slide Grade holds a copy of, as a video or an original image. One file per post; the other slides are not included. Until a slide is stored, the post has no file: its cover image is never sent in place of the slides.
Content-Disposition names the file after the source and ID, for example
campaign-CCMEDIA_123.mp4. Content-Type gives the file's type.
Videos support resuming and caching:
- Send
Range(for examplebytes=1048576-) to get the rest of a file. The answer is206with that range. - The
ETagis the file's checksum. Send it asIf-None-Matchto get304when your copy is current, or asIf-Rangeto resume only an unchanged file.
An image is always sent whole.
Send HEAD instead of GET to read a file's Content-Type and
Content-Length without downloading it.
Example request
curl -sS -OJ "$BASE_URL/sdk/v1/media/campaign/CCMEDIA_123/download" \
-H "X-Application-Id: $APP_ID" \
-H "X-Api-Key: $API_KEY"
-OJ saves the file under the name the response gives. Add -C - to resume an
interrupted video download.
Records from sync feeds
downloadUrl reflects whether Grade held a copy when the record was delivered.
A copy that becomes available later does not by itself send the record again.
When a synced record has downloadUrl: null, read the record again later through
its list or detail endpoint, or request the download link directly: it returns
404 download_unavailable until a copy exists.
Errors
Errors are JSON: { "success": false, "code": "...", "message": "..." }.
| Status | Code | Meaning |
|---|---|---|
401 |
Missing or invalid SDK credentials. | |
403 |
The key lacks the endpoint's scope. | |
404 |
media_not_found |
The post is not in your organization, or the ID is an account. |
404 |
download_not_offered |
Downloads are not offered for this post. |
404 |
download_unavailable |
Grade holds no copy of the post's media yet, or downloads are not enabled for your organization. |
416 |
The requested range is outside the file. | |
503 |
download_temporarily_unavailable |
The stored file cannot be read right now. Retry after the Retry-After seconds. |
