There are two types of assets:
- Files that are uploaded
- URLs (URL Assets)
We will cover adding “URL Assets” here. For uploading files, view this API page.
Creating URL assets
URL Assets require three fields. To create a URL asset, send a POST request to:
https://app.digital-downloads.com/api/v1/assets/store
Request
JSON
{
"filename": "My new book",
"size": "10MB",
"url": "https://www.my-website.com/download/my-book.pdf"
}
Response
JSON
{
"data": {
"id": "82664d96-6dfd-4343-96b0-05c46f412a5b",
"filename": "My new book",
"size": "10MB",
"is_file": false,
"is_link": true,
"url": "https://www.my-website.com/download/my-book.pdf"
}
}
Using the ID returned, you can link this asset to a product.
Updating URL assets
URL Assets can be updated by sending a PUT request with the ID in the URL
https://app.digital-downloads.com/api/v1/assets/:id
Example PUT URL
https://app.digital-downloads.com/api/v1/assets/82664d96-6dfd-4343-96b0-05c46f412a5b
Request
JSON
{
"filename": "My new book",
"size": "12MB",
"url": "https://www.my-website.com/download/my-new-book.pdf"
}
Response
JSON
{
"data": {
"id": "82664d96-6dfd-4343-96b0-05c46f412a5b",
"filename": "My new book",
"size": "12MB",
"is_file": false,
"is_link": true,
"url": "https://www.my-website.com/download/my-new-book.pdf"
}
}