Retrieve a file
Get the download link of a compensation confirmation, a certificate or a project image.
Returns a file attached to a record, such as the compensation confirmation or certificate of a purchase, or an image of a product. Purchases list the IDs of their files in files.
Request
GET /v2/files/{id}
idstringrequiredThe file ID, such as file_34sdfgJH9df4g35.
GET /v2/files/{id} in the API referencecurl "https://api.sandbox.squake.earth/v2/files/file_34sdfgJH9df4g35" \
--header "Authorization: Bearer $SQUAKE_API_KEY"Response
{
"id": "file_34sdfgJH9df4g35",
"filename": "SQUAKE-CompensationConfirmation-euc1XXX.pdf",
"purpose": "confirmation_document",
"size": 48211,
"type": "pdf",
"download_url": "https://squake.s3.eu-central-1.amazonaws.com/..."
}| Field | Type | Description |
|---|---|---|
id | string | The file ID. |
filename | string | The file name. |
purpose | string | confirmation_document, certificate_document or project_image. |
size | integer | Size in bytes. |
type | string | csv, jpg, pdf, png or webp. |
download_url | string | The link to download the file. It expires after one year. |
notification | string | Information about the file, such as when it will be available. |
Waiting for a document
SQUAKE generates documents after the purchase, so a file can exist before its content does. While download_url is empty, the document hasn't been created yet: poll until the link appears, and read notification for when to expect it. To avoid polling, register a confirmation_document_available or certificate_document_available webhook. It sends you the file, including its download_url, as soon as the document is ready.
Errors
| Status | Meaning |
|---|---|
401 | The API key is missing or invalid. |
403 | The request is forbidden for your account. |
404 | No file has this ID. |
Related
- Retrieve a purchase
- Retrieve a File in the API reference