Skip to content

Downloadable Products API

A downloadable product gives the client a file to download after the order is active. Each order keeps its own copy of the file name, so a new product file reaches existing orders only with Keep Orders Updated on, or one order at a time with update. See Downloads.

Admin calls need Module access on the Servicedownloadable card of the staff group’s Permissions tab, plus each call’s own permission below (Super Administrators have all). See Authentication.

POST /api/admin/servicedownloadable/upload

Uploads a new file for a downloadable product. With Keep Orders Updated set to Yes, every order of the product gets the new file too.

Permission: Manage downloadable products (servicedownloadable.manage)

Parameter Type Description
id integer, required The product id.
file_data file, required The file, sent as a multipart form upload. Allowed extensions include archives (zip, tar, gz, 7z and more), documents (pdf, docx, txt, csv), images, audio and video, and installers (exe, msi, dmg, deb, apk, iso).

Returns: true.

Errors:

  • Product not found (code 9999)
  • File was not uploaded. (code 9999)
  • File upload failed: The uploaded file exceeds the upload_max_filesize directive in php.ini (code 9999)
  • File extension exe2 is not allowed. Allowed extensions: … (code 9999)

The old file is deleted once no product or order uses it.

POST /api/admin/servicedownloadable/update

Changes the file of one order. With a file_data upload, the order gets that file; without one, the order’s service is set again to the file name saved on the order.

Permission: Manage downloadable products (servicedownloadable.manage)

Parameter Type Description
order_id integer, required The order.
file_data file A new file for this order only, sent as a multipart form upload. The same extensions as upload.

Returns: true.

Errors:

  • Order not found (code 9999)
  • Order is not activated (code 9999) when the order has no downloadable service yet
  • No filename available for order file update (code 9999)
  • File extension exe2 is not allowed. Allowed extensions: … (code 9999)

POST /api/admin/servicedownloadable/config_save

Saves the product’s download settings: Keep Orders Updated.

Permission: Manage downloadable products (servicedownloadable.manage)

Parameter Type Description
id integer, required The product id.
update_orders boolean Keep Orders Updated: a new upload also goes to every order of the product. Default false.

Returns: true.

Errors:

  • Product not found (code 9999)
Example

Request parameters:

{
"id": 12,
"update_orders": true
}

result:

true

POST /api/admin/servicedownloadable/send_file

Downloads the product’s current file.

Permission: Manage downloadable products (servicedownloadable.manage)

Parameter Type Description
id integer, required The product id.

Returns: The file as a download (application/octet-stream, with its original name), not JSON.

Errors:

  • Product not found (code 9999)
  • No file associated with this product. (code 404)
  • File cannot be downloaded at the moment. Please contact support. (code 404) when the stored file is missing

POST /api/client/servicedownloadable/send_file

Downloads the file of one of the client’s active downloadable services. Each download adds one to the service’s download count.

Parameter Type Description
order_id integer, required The client’s order.

Returns: The file as a download (application/octet-stream, with its original name), not JSON.

Errors:

  • Order not found (code 404) for an order of another client
  • Subscription expired (code 9999) when the order’s expiry date has passed
  • Order is not activated (code 404) when the order is not active
  • File cannot be downloaded at the moment. Please contact support. (code 404)

Authorized users need the View services permission.