Skip to main content
Some operations in this guide have Discovery handlers but no public gateway route yet: POST /invoices/{id}/support-documents, GET /documents, POST /documents, GET /documents/{id}, PATCH /documents/{id}, DELETE /documents/{id}, POST /documents/{id}/analyze, DELETE /documents/{id}/link. Check the availability notice on each API reference page before using them.

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 / validUntil for 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

Records a document whose file you have already uploaded to storage. This endpoint does not accept the file. 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.
Answers 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

A document of another team, or a soft-deleted one, answers 404.

Update Document

Updates metadata and the compliance review. Only the fields you send are written. Accepted fields: name, description, complianceStatus, complianceNotes, validFrom, validUntil, tags, metadata. The file itself (fileUrl, storagePath, fileName, documentType) cannot be changed; sending those keys returns 400.
Both take the same body:
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

Runs AI extraction and stores the result on the document under 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

Soft delete: the document stops appearing in list and get responses and is unlinked from every entity. A second delete returns 404.

Errors

All errors use the standardized envelope (success: false, error.code, error.message, timestamp).