Files

In Lemon Squeezy, a file represents a digital good that can be downloaded by a customer after the product has been purchased.

A file belongs to a Variant.


The file object

Attributes


variant_id

The ID of the variant this file belongs to.


identifier

The unique identifier (UUID) for this file.


name

The name of the file (e.g. example.pdf).


extension

The file extension of the file (e.g. pdf).


download_url

The unique URL to download the file. Note: for security reasons, download URLs are signed, expire after 1 hour and are rate-limited to 10 downloads per day per IP address.


size

A positive integer in bytes representing the size of the file.


size_formatted

The human-readable size of the file (e.g. 5.5 MB).


version

The software version of this file (if one exists, e.g. 1.0.0).


sort

An integer representing the order of this file when displayed.


status

The status of the file. Either draft or published.


createdAt

An ISO 8601 formatted date-time string indicating when the object was created.


updatedAt

An ISO 8601 formatted date-time string indicating when the object was last updated.


test_mode

A boolean indicating if the object was created within test mode.

File object

{ "type": "files", "id": "1", "attributes": { "variant_id": 168, "identifier": "6dce5ba7-76f2-481f-ad1e-9c2bec6eb0e2", "name": "my_product.zip", "extension": "zip", "download_url": "https://app.lemonsqueezy.com/download/6dce5ba7-76f2-481f-ad1e-9c2bec6eb0e2?expires=1636383388&signature=886a63faf7215c54011accfa08578b1b687def66f767092629f263061b3a253a", "size": 874694, "size_formatted": "854 KB", "version": "1.0.0", "sort": 1, "status": "published", "createdAt": "2021-11-05T10:22:14.000000Z", "updatedAt": "2021-11-05T16:16:33.000000Z", "test_mode": false } }

Retrieve a file

Retrieves the file with the given ID.

GET /v1/files/:id

curl "https://api.lemonsqueezy.com/v1/files/1" -H 'Accept: application/vnd.api+json' -H 'Content-Type: application/vnd.api+json' -H 'Authorization: Bearer {api_key}'

Returns

Returns a file object.

Response

{ "jsonapi": { "version": "1.0" }, "links": { "self": "https://api.lemonsqueezy.com/v1/files/1" }, "data": { "type": "files", "id": "1", "attributes": { "variant_id": 168, "identifier": "6dce5ba7-76f2-481f-ad1e-9c2bec6eb0e2", "name": "my_product.zip", "extension": "zip", "download_url": "https://app.lemonsqueezy.com/download/6dce5ba7-76f2-481f-ad1e-9c2bec6eb0e2?expires=1636384018&signature=f0a9bdec44ffabf143d4689594491f42a76d773d3cc88ec23ef84d6e903e8f11", "size": 874694, "size_formatted": "854 KB", "version": "1.0.0", "sort": 1, "status": "published", "createdAt": "2021-11-05T10:22:14.000000Z", "updatedAt": "2021-11-05T16:16:33.000000Z", "test_mode": false }, "relationships": { "variant": { "links": { "related": "https://api.lemonsqueezy.com/v1/files/1/variant", "self": "https://api.lemonsqueezy.com/v1/files/1/relationships/variant" } } }, "links": { "self": "https://api.lemonsqueezy.com/v1/files/1" } } }

List all files

Returns a paginated list of files.

Parameters


variant_id

Only return files belonging to the variant with this ID.

GET /v1/files

curl "https://api.lemonsqueezy.com/v1/files" -H 'Accept: application/vnd.api+json' -H 'Content-Type: application/vnd.api+json' -H 'Authorization: Bearer {api_key}'
curl "https://api.lemonsqueezy.com/v1/files?filter[variant_id]=8" -H 'Accept: application/vnd.api+json' -H 'Content-Type: application/vnd.api+json' -H 'Authorization: Bearer {api_key}'

Returns

Returns a paginated list of file objects ordered by sort.

Response

{ "meta": { "page": { "currentPage": 1, "from": 1, "lastPage": 1, "perPage": 10, "to": 10, "total": 10 } }, "jsonapi": { "version": "1.0" }, "links": { "first": "https://api.lemonsqueezy.com/v1/files?page%5Bnumber%5D=1&page%5Bsize%5D=10&sort=sort", "last": "https://api.lemonsqueezy.com/v1/files?page%5Bnumber%5D=1&page%5Bsize%5D=10&sort=sort" }, "data": [ { "type": "files", "id": "1", "attributes": { "variant_id": 168, "identifier": "6dce5ba7-76f2-481f-ad1e-9c2bec6eb0e2", "name": "my_product.zip", "extension": "zip", "download_url": "https://app.lemonsqueezy.com/download/6dce5ba7-76f2-481f-ad1e-9c2bec6eb0e2?expires=1636383388&signature=886a63faf7215c54011accfa08578b1b687def66f767092629f263061b3a253a", "size": 874694, "size_formatted": "854 KB", "version": "1.0.0", "sort": 1, "status": "published", "createdAt": "2021-11-05T10:22:14.000000Z", "updatedAt": "2021-11-05T16:16:33.000000Z", "test_mode": false }, "relationships": { "variant": { "links": { "related": "https://api.lemonsqueezy.com/v1/files/1/variant", "self": "https://api.lemonsqueezy.com/v1/files/1/relationships/variant" } } }, "links": { "self": "https://api.lemonsqueezy.com/v1/files/1" } }, {...}, {...}, ] }