Sylius Digital Download: Shop API
Sylius Digital Download and headless: the download endpoint GET /downloads/{token}, response codes and what the plugin does not offer through the Shop API.
Sylius Digital Download: Shop API
This documentation always describes the latest published version.
What the plugin offers via API
The plugin ships no API Platform resource of its own. There is no endpoint that returns the links of an order as JSON, and no fields on the Sylius Shop API resources. The links reach the customer by email, and the download itself is a simple GET route of the shop.
For a headless frontend, this means:
- The download links are in the email. Your frontend does not need to know them and cannot query them via API.
- A link can be called without logging in, the token is the access credential. Guest orders work as well.
- The "Your downloads" list exists only in the Twig storefront (customer account), not as an API.
The download endpoint
| Method | Path | Description |
|---|---|---|
GET |
/downloads/{token} |
Delivers the file for the token. {token} consists of exactly 64 lowercase letters and digits (a-f, 0-9). |
The route is named mmd_digital_download_shop_download. It needs neither a JWT nor a session.
curl -OJ "https://shop.example.com/downloads/3f9c0a7be1d24c58a6b3f1e09d7c4a52b8e6f0139d4a7c25e1b8a06f3d9c7e41"
-O -J saves the file under the name from the Content-Disposition header, that is the original file name.
Responses
| Status | Meaning |
|---|---|
200 |
The file is transferred as an attachment (Content-Type: application/octet-stream, with Content-Length and Content-Disposition: attachment) |
404 |
The token is unknown, or the file is no longer readable in the storage |
410 |
The link is blocked (refund), expired or used up. The body is plain text: This download link is no longer valid. Please contact the shop. |
A token that does not consist of 64 lowercase letters or digits does not match the route at all and ends in a 404 like any unknown URL.
On a successful response, the link counts one download, even if the transfer aborts afterwards. Check the "Downloads per link" limit with some leeway if your customers download large files over unstable connections.
Integrating into the frontend
Your headless shop can use the links from the email unchanged. The route is on the host where the Sylius app runs. After the order, show only a note in the frontend that the links arrive by email, and for a 410 a pointer to your support.