API REFERENCE

Documents API

Documents are the files stored against records in your AlgaPSA instance. Use this API to attach a file to a ticket, project task, client, contact, or asset. Attached documents are then read through the resource they belong to, such as the ticket and asset APIs.

Attach a document

POST /api/v1/documents stores a file and attaches it to one record. The JSON body names the target with entity_type (one of ticket, project_task, client, contact, or asset) and entity_id (the record's UUID), and supplies the content in a source object of one of two shapes:

  • { "type": "url", "url": "https://…" } — AlgaPSA fetches the file from the URL and stores it.
  • { "type": "base64", "content": "…" } — the file content, base64-encoded, inline in the request.

file_name and mime_type are optional. The endpoint accepts JSON only; there is no multipart upload. On success it returns 201 with the new document record.

curl
curl https://algapsa.com/api/v1/documents \
  -H "X-API-Key: $ALGA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "entity_type": "ticket",
    "entity_id": "7c1b1b7e-0f0a-4c43-9c6b-2d6e3f8a9b10",
    "source": { "type": "url", "url": "https://files.example.com/network-diagram.pdf" },
    "file_name": "network-diagram.pdf"
  }'

Size limits

Every attached file is held to the same per-file limit as uploads in the AlgaPSA UI: the storage provider's maximum file size (500 MiB by default; self-hosted instances can change it). How the limit applies depends on the source:

  • url — AlgaPSA streams the download straight into storage rather than buffering it, so a URL source can be as large as the per-file limit. The download stops as soon as it passes the limit and the request fails with 413. Each connection attempt must succeed within 15 seconds and the whole download must finish within 10 minutes; a download that times out is rejected with 400.
  • base64 — the whole request is held in memory, so inline content is capped at 25 MiB of decoded file data (or the per-file limit, if that is lower). A larger payload is rejected with 413 before it is decoded. Use a url source for larger files.

Because the JSON body is size-checked before it is read, the request must declare a Content-Length header. A request without one (for example, a chunked request) is rejected with 411 and the error code LENGTH_REQUIRED. Size refusals use the error code PAYLOAD_TOO_LARGE, and their message names the limit that applied and the alternatives for larger files.

Download host allowlist

For a url source, the hostname must appear in the tenant's Allowed download hosts list, configured under Settings → MCP Server → Allowed download hosts. A URL on an unlisted host (including one reached through a redirect) is rejected with 400 and the error code FETCH_HOST_NOT_ALLOWED. The allowlist does not apply to base64 sources.

Requires document:create plus the update permission for the entity being attached to — for example, ticket:update when attaching to a ticket.

No list endpoint

This resource has no list operation: GET /api/v1/documents returns 404. Read a record's documents through the resource that owns it, such as GET /api/v1/tickets/{id}/documents or GET /api/v1/assets/{id}/documents.

Endpoints

Every endpoint links through to its full parameters, request and response schemas, and code samples.

GET/api/documents/{documentId}/downloadAlgaPSADownload document attachmentGET/api/documents/download/{fileId}AlgaPSADownload or export document fileGET/api/documents/view/{fileId}AlgaPSAView document file inlineGET/api/v1/documentsAlgaPSAAlgaDeskDocuments API namespace rootPOST/api/v1/documentsAlgaPSAAlgaDeskAttach a file to a ticket, project task, client, contact or asset