/
Contents
Media
Resolve a media id to its public URL.
Base URL, authentication and conventions of this API are on the Content Delivery API page.
get
/media/{mediaId}Resolve a media id to its URL
302 redirect to the stable public URL of a media file of this site. Meant for your server to
turn a media id found in blocks/fields into a URL. Never use this endpoint as src of
an <img>/<video>: the browser would need the token. Put the Location URL in your HTML instead.
Read the Location header without following the redirect: most HTTP clients follow it by default
(with Guzzle pass 'allow_redirects' => false, with fetch pass redirect: "manual" — server-side
only, since browsers hide the header of a manual redirect).
GET https://api-brain.nucleoplatform.com/api/delivery/v1/acme/sites/12/media/{mediaId}
Authentication: Bearer token
Rate limit: 120 requests per 1m, per IP
Path parameters
mediaIdintegerrequiredExample:311
Responses
302Redirect to the public file.
HeadersLocation
401Missing or unknown delivery token.application/json
messagestring
404Not found. Also returned when the workspace slug is unknown or when the token belongs to another site (Nucleo never confirms that a site exists to a token that cannot read it). The text of
messagevaries with the case: branch on the404status only. application/jsonmessagestring
429More than 120 requests in a minute from the same IP.application/json
HeadersRetry-AfterX-RateLimit-LimitX-RateLimit-Remaining
messagestring
curl -i -X GET https://api-brain.nucleoplatform.com/api/delivery/v1/acme/sites/12/media/311 \
-H "Authorization: Bearer $NUCLEO_CMS_TOKEN"const res = await fetch("https://api-brain.nucleoplatform.com/api/delivery/v1/acme/sites/12/media/311", {
method: "GET",
headers: {
Authorization: `Bearer ${process.env.NUCLEO_CMS_TOKEN}`,
},
redirect: "manual", // server-side: browsers hide the Location of a manual redirect
});
console.log(res.status, res.headers.get("location"));<?php
require 'vendor/autoload.php';
$client = new GuzzleHttp\Client();
$response = $client->request('GET', 'https://api-brain.nucleoplatform.com/api/delivery/v1/acme/sites/12/media/311', [
'headers' => [
'Authorization' => 'Bearer ' . getenv('NUCLEO_CMS_TOKEN'),
],
'allow_redirects' => false,
'http_errors' => false,
]);
echo $response->getStatusCode(), PHP_EOL;
echo $response->getHeaderLine('Location');{
"message": "Delivery token required (Authorization: Bearer)."
}{
"message": "Invalid delivery token."
}{
"message": "Not found."
}{
"message": "Too Many Attempts."
}Was this page helpful?