CDN Product Images: Admin API
Create images with a CDN URL via the Admin API: cdnUrl instead of a file upload for product and taxon images, rules and error responses.
CDN Product Images: Admin API
This documentation always describes the latest published version.
Live Demo: Try this and other plugins live — no installation, no risk: demo.markus-michalski.net
Overview
External Admin API clients and automation can create a product or taxon image not only by uploading a file but also by cdnUrl. The image already lives on the CDN and only its URL is stored - exactly like creating it through the Admin form.
| Endpoint | Purpose |
|---|---|
POST /api/v2/admin/products/{code}/images |
Create a product image |
POST /api/v2/admin/taxons/{code}/images |
Create a taxon image |
Both endpoints expect multipart/form-data, so cdnUrl is sent as a form field, not as JSON.
Rules
cdnUrlandfileare mutually exclusive. Sending both returns HTTP 400.cdnUrlmust be a validhttporhttpsURL of at most 255 characters, otherwise HTTP 400.- Leading and trailing whitespace is trimmed, as in the form.
- The URL is only stored and never fetched server-side. There is no reachability check.
- The same rule applies in the Admin form and in the API. It is implemented in a single place.
Example
curl -X POST "https://shop.example.com/api/v2/admin/products/mug-sw/images" \
-H "Authorization: Bearer <JWT>" \
-F "type=main" \
-F "cdnUrl=https://cdn.example.com/original/mug-sw.jpg"
The response has the same image representation as after a regular file upload, with path equal to the submitted URL.
Behaviour
| Request | Result |
|---|---|
file only |
Regular upload, unchanged |
cdnUrl only |
Image is created with path = cdnUrl |
file and cdnUrl |
HTTP 400 |
invalid or too long cdnUrl |
HTTP 400 |
neither file nor cdnUrl |
HTTP 400 (as before) |
| unknown product/taxon | HTTP 404 (as before) |
Limitations
- On the product endpoint,
productVariantstogether withcdnUrlis not supported and is rejected with HTTP 400. Variant assignment remains reserved for file uploads. - The new
cdnUrlfield does not yet appear in the OpenAPI documentation at/api/v2/docs. - The API extension is only active when
SyliusApiBundleis registered.