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_idand
scopeare 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-idheader, and it does not replacecompany_id. scope=allexports every payable matching the filters minusexcluded_ids;
scope=partialexports onlyids(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 (
fetchingorzipping). A second request returns409
with thepdf_export_idof 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| Time | Status | User Agent | |
|---|---|---|---|
Retrieving recent requests… | |||
401Unauthorized
