Skip to main content

File Uploads

Files (attachments, images, documents) are managed through a dedicated upload endpoint and are linked to a specific document via its doctype and name.

Upload a file

POST /api/method/upload_file

Send as multipart/form-data.

FieldRequiredDescription
fileYesThe file contents.
doctypeNoDoctype of the document to attach the file to.
docnameNoName of the document to attach the file to.
is_privateNo1 to restrict access to permitted users only, 0 for a public URL. Default 0.
folderNoTarget folder in the file manager. Defaults to Home.
curl -X POST "https://app.smarty.tel/api/method/upload_file" \
-H "Authorization: token <api_key>:<api_secret>" \
-F "file=@/path/to/id-scan.pdf" \
-F "doctype=Customer" \
-F "docname=CUST-2026-0091" \
-F "is_private=1"
{
"message": {
"name": "a1b2c3d4e5",
"file_name": "id-scan.pdf",
"file_url": "/private/files/id-scan.pdf",
"is_private": 1
}
}

Download a file

Public files (is_private=0) can be fetched directly from their file_url. Private files require an authenticated request to the same path:

curl -X GET "https://app.smarty.tel/private/files/id-scan.pdf" \
-H "Authorization: token <api_key>:<api_secret>" \
-o id-scan.pdf

Listing files attached to a document

Files are themselves documents of doctype File, so you can query them through the standard Resource API:

curl -G "https://app.smarty.tel/api/resource/File" \
-H "Authorization: token <api_key>:<api_secret>" \
--data-urlencode 'filters=[["attached_to_doctype","=","Customer"],["attached_to_name","=","CUST-2026-0091"]]'

Deleting a file

curl -X DELETE "https://app.smarty.tel/api/resource/File/a1b2c3d4e5" \
-H "Authorization: token <api_key>:<api_secret>"

Next: Webhooks.