Overview
The Documents API stores the metadata of supporting documents — contracts, proof of delivery, proof of payment, communications — and links them to the invoices, payments, receipts and clients they support. The SAT can ask for this evidence to validate an operation (materialidad); keeping it in gigstack, linked to the CFDI, means you can produce it when asked. Base path:https://api.gigstack.io/v2/documents
Documents belong to the team and mode (livemode) of the API key that created them.
Uploading a file for a specific invoice, payment or client? The POST /invoices/{id}/support-documents (and the equivalent client and payment endpoints) accept the file itself and link it in one call — see Invoices. The Documents API below records documents whose file is already in storage, and manages all of them in one place.
Key Features
- Link one document to many entities - invoices, payments, receipts, clients
- Compliance review state -
pending_review,valid,requires_update,expired,rejected - Validity window -
validFrom/validUntilfor contracts and other time-bound evidence - AI extraction - pull structured data out of a PDF or image
- Soft delete - deleted documents disappear from the API but are not destroyed
Endpoints
List Documents
Newest first; soft-deleted documents are excluded.
Note the nested shape and the pagination names, which differ from other list endpoints: the array is at
data.data, and the cursor for the next page is data.next_cursor (pass it back as cursor).
entity_id is applied after the page is fetched, so it only narrows that page. If matches are sparse, use a larger limit.
Create Document
Request fields are camelCase; response fields are snake_case — including the link objects, which you send as
{ "entityType", "entityId" } and read back as { "entity_type", "entity_id", "linked_at" }. Unknown top-level keys are rejected with 400. complianceStatus cannot be set here — it always starts as pending_review.
201 with the document in data.
The file_url you read back is not necessarily the one you sent: gigstack re-mints it as a Firebase download-token URL for the same object when it answers, so links no longer depend on a public storage ACL. It does not expire — but treat it as opaque and re-read the document rather than constructing or caching the link.
Get Document
404.
Update Document
name, description, complianceStatus, complianceNotes, validFrom, validUntil, tags, metadata. The file itself (fileUrl, storagePath, fileName, documentType) cannot be changed; sending those keys returns 400.
Link and Unlink
entityType is invoice, payment, receipt or client. Linking twice to the same entity returns 400; linking to an entity that does not exist or belongs to another team returns 404. Unlinking a document that is not linked returns 400; if the entity no longer exists the link is still removed. Note that this DELETE carries a request body.
Analyze with AI
ai_extraction. Only PDFs and PNG/JPEG/WEBP images can be analyzed; a scanned PDF with no text layer returns 400. The request body is ignored.
Delete Document
404.
Errors
All errors use the standardized envelope (success: false, error.code, error.message, timestamp).
Related Resources
- Invoices API - Upload a file for an invoice in one call
- Clients API - Client support documents
- Payments API - Payment support documents