Skip to main content

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 also accepts a standalone multipart file, or metadata for a file already in storage.

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).
Filters are applied after a bounded page is fetched. An empty data.data can still have has_more: true. Continue with next_cursor until has_more is false; the cursor is bound to the current team, credential mode and filters. Do not substitute a document ID.

Create Document

Upload a standalone file with multipart form data:
This stores the file in the authenticated team and credential mode, then returns HTTP 201 with the document. Multipart optional fields are name and description; use JSON metadata updates or link operations afterward for structured values. PDF and PNG/JPEG/WEBP files up to 10 MiB are accepted. JSON requests can instead register a file already uploaded to storage. fileUrl and storagePath must name the same object in the runtime bucket, under the selected mode’s teams/{team}/{live|test}/support-documents/ namespace. The legacy teams/{team}/sat_documents/ namespace requires a verified Firebase browser user because those objects have no mode-specific storage path. Foreign buckets/teams, private credential paths and mismatched URLs are rejected. User-scoped mutations require a current editor or administrator. 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 credential mode, or a soft-deleted one, answers 404.

Update Document

Updates metadata and the compliance review. Only the fields you send are written. Send null to clear an accepted field; cleared name and compliance_status are returned as null, while cleared tags are returned as []. 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 or credential mode 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 up to 10 MiB 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).