Payable

Create a bulk PDF export

Starts an asynchronous bulk download of the PDFs of the selected payables ("cuentas por pagar"). The response is 202 Accepted with a PdfExport whose status starts as fetching; poll GET /v1/erp/payouts/payables/pdf_exports/{id} until it is completed (or failed/expired) and then download the ZIP files in files[].url.

Selecting payables

  • The payable filters go in the querystring, exactly as in GET /v1/erp/payouts/payables (List all payables) (e.g. amount={"$lt": 11000}). See How to filter results.
  • The control parameters (company_id, scope, ids, excluded_ids, include_attachments) can go in the JSON body or in the querystring. company_id and scope are required in one of the two places (422, payables/pdf_export_scope, if missing). Exports belong to the user, not to a company: these endpoints do not use the company-id header, and it does not replace company_id.
  • scope=all exports every payable matching the filters minus excluded_ids; scope=partial exports only ids (ids from another company or not visible to the caller are ignored).
  • Only payables of companies where the caller can list payables are included.

Limits

  • At most 2.000 payables per export (422, payables/pdf_export_limit). Narrow the filters or split the export.
  • One export in flight per user (fetching or zipping). A second request returns 409 with the pdf_export_id of the running export, so you can resume polling it.
  • The ZIP files are kept for 7 days after completion; then the export becomes expired.

Result

One ZIP per company (<company name>_<date_from>_<date_to>.zip) with one folder per document type that has documents (folders such as Facturas/, Boletas de honorarios/, Reembolsos/, Anticipos/ or Otros/), and an indice.csv (UTF-8 with BOM, ; separator) with the columns Empresa;Fecha emisión;Razón social emisor;RUT emisor;Tipo;Folio;Monto;Estado;Motivo;Archivo. Estado is incluido or falló; failed documents are listed with their Motivo, and are summarized in failures_by_reason. When the export finishes, the user is also notified in-app and by email, according to their notification preferences.

Polling example

# 1. Create the export (filters in the querystring, control params in the body)
created=$(curl -s -X POST 'https://api.cardda.com/v1/erp/payouts/payables/pdf_exports?amount=%7B%22%24lt%22%3A11000%7D' \
  -H 'Authorization: Bearer <api_key>' \
  -H 'Content-Type: application/json' \
  -d '{"company_id": "550e8400-e29b-41d4-a716-446655440000", "scope": "all"}')
# 202 {"id": "0d6f8a52-...", "status": "fetching", ...}: keep its id.
# 409 {"error_code": "payables/pdf_export_in_progress", "pdf_export_id": "..."}: resume that one.
export_id=$(echo "$created" | jq -r '.id // .pdf_export_id // empty')
if [ -z "$export_id" ]; then echo "$created" >&2; exit 1; fi  # 422: see error_code

# 2. Poll every few seconds until status is "completed", "failed" or "expired"
while true; do
  export=$(curl -s "https://api.cardda.com/v1/erp/payouts/payables/pdf_exports/$export_id" \
    -H 'Authorization: Bearer <api_key>')
  status=$(echo "$export" | jq -r .status)
  echo "$status $(echo "$export" | jq -c .progress)"
  case "$status" in completed|failed|expired) break ;; esac
  sleep 5
done

# 3. Download each ZIP. The URLs are signed for 1 hour and re-signed on every GET:
#    if a link expired, GET the export again to get a fresh one.
echo "$export" | jq -r '.files[] | "\(.url)\t\(.filename)"' |
  while IFS=$'\t' read -r url name; do curl -s -o "$name" "$url"; done
post/v1/erp/payouts/payables/pdf_exports

Request

  • Base URL
    https://api.cardda.com
  • URL
    https://api.cardda.com/v1/erp/payouts/payables/pdf_exports
  • Auth
    HTTP bearer

Query parameters

company_idstring

Company UUID, or a JSON array of company UUIDs, whose payables are exported (same format as the payables list). The multi-company form is a single JSON-encoded string (company_id=["<uuid>","<uuid>"], URL-encoded), not a repeated OpenAPI query array. As in the payables list, it is not compared with the company-id header, so it can name several companies; only those where the caller can list payables are exported. Required here or in the body (422, payables/pdf_export_scope, if missing in both).

scope'all' | 'partial'

all or partial. Required, either here or in the body.

ids[]string[]

With scope=partial, the payables to export. Repeat the key with brackets, one UUID each: ids[]=<uuid>&ids[]=<uuid>. Without the brackets (ids=<uuid>&ids=<uuid>) only the last value is read, and a comma-separated list is ignored. May be sent in the body (as ids, a JSON array) instead, which is simpler for long lists.

excluded_ids[]string[]

With scope=all, payables to leave out. Repeat the key with brackets, one UUID each: excluded_ids[]=<uuid>&excluded_ids[]=<uuid>. Without the brackets (excluded_ids=<uuid>&excluded_ids=<uuid>) only the last value is read, and a comma-separated list is ignored. May be sent in the body (as excluded_ids, a JSON array) instead, which is simpler for long lists.

include_attachmentsboolean

Include the attachments of payables that have a PDF. May be sent in the body instead.

Parameters

#/paths/~1v1~1erp~1payouts~1reviews/get/parameters/5 (unresolved $ref)

Request body

scope'all' | 'partial'
  • all: every payable matching the querystring filters, minus excluded_ids.
  • partial: only the payables in ids.
idsstring[]

With scope=partial, the payables to export. Ids from another company or not visible to the caller are ignored.

excluded_idsstring[]

With scope=all, payables to leave out (e.g. rows the user unchecked).

include_attachmentsboolean

Also include the attachments (user documents) of payables that have a PDF. Manual payables without a PDF but with attachments are always included with their attachments, regardless of this flag: they count as included (indice.csv: Estado = incluido, Motivo = "Sin PDF; se incluyó el adjunto."). Only a manual payable with neither a PDF nor attachments fails, with reason manual_without_pdf.

Example request

{
  "company_id": "550e8400-e29b-41d4-a716-446655440000",
  "scope": "all",
  "excluded_ids": [
    "7a1c2e3f-1111-4c4c-9d9d-000000000001"
  ],
  "include_attachments": false
}

Response

Export accepted. Poll GET /v1/erp/payouts/payables/pdf_exports/{id} for its progress.

idstring uuid required
status'fetching' | 'zipping' | 'completed' | 'failed' | 'expired' required
  • fetching: the PDFs are being retrieved (stored documents, attachments and, when needed, the SII).
  • zipping: the ZIP files are being built.
  • completed: the ZIP files are ready in files.
  • failed: the export could not be completed.
  • expired: the ZIP files were purged (7 days after completion); files is empty. Create a new export.
include_attachmentsboolean

Whether the attachments of payables that do have a PDF were included.

company_idsstring[]

Companies covered by the export.

date_fromstring date nullable

Start of the issue-date range of the exported payables (used in the ZIP filename).

date_tostring date nullable

End of the issue-date range of the exported payables (used in the ZIP filename).

created_atstring date-time
completed_atstring date-time nullable
expires_atstring date-time nullable

When the ZIP files will be purged (7 days after completed_at). null until completed.

Example response

{
  "id": "0d6f8a52-3c1e-4b8e-9f3a-2a7f5f6c9b10",
  "status": "completed",
  "progress": {
    "total": 710,
    "processed": 710,
    "included": 573,
    "failed": 137
  },
  "failures_by_reason": [
    {
      "reason": "missing_admin_key",
      "count": 137,
      "message": "la empresa no tiene registrada una clave SII de administrador, Nubox ni BCS. Regístrala en Configuración, en Integraciones y vuelve a generar la descarga."
    }
  ],
  "include_attachments": false,
  "company_ids": [
    "550e8400-e29b-41d4-a716-446655440000"
  ],
  "date_from": "2026-04-01",
  "date_to": "2026-09-30",
  "created_at": "2026-10-26T13:02:11Z",
  "completed_at": "2026-10-26T13:18:47Z",
  "expires_at": "2026-11-02T13:18:47Z",
  "files": [
    {
      "company_id": "550e8400-e29b-41d4-a716-446655440000",
      "company_name": "FI WEG 1",
      "filename": "FI WEG 1_2026-04-01_2026-09-30.zip",
      "byte_size": 41231234,
      "url": "https://storage.example.com/pdf_exports/FI%20WEG%201_2026-04-01_2026-09-30.zip?signature=..."
    }
  ]
}

Changes

No recorded changes to this operation across all 1 revision of this API.