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
Recent Requests
Log in to see full request history
TimeStatusUser Agent
Retrieving recent requests…
LoadingLoading…
Query Params
string

Only as an example of filtering results that have an amount less than $11000.
For more detailed explanation, go to the How to filter results section.

string

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).

string
enum

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

Allowed:
ids[]
array of uuids

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.

ids[]
excluded_ids[]
array of uuids

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.

excluded_ids[]
boolean
Defaults to false

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

Body Params

Control parameters of the export (alternatively, send them in the querystring).

Control parameters of a payable PDF export. They can be sent in this JSON body or in the
querystring. The payable filters themselves always go in the querystring (see the endpoint
description).

company_id and scope are required, but they can be sent either here or in the querystring,
so this body does not require them on its own.

Required (here or in the querystring); the company-id header does not replace it.
Company (or companies) whose payables are exported. In the querystring, send several as a
JSON array, e.g. company_id=["uuid1","uuid2"], as in the payables list. Only companies
where the caller can list payables are considered.

string
enum
  • all: every payable matching the querystring filters, minus excluded_ids.
  • partial: only the payables in ids.
Allowed:
ids
array of uuids

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

ids
excluded_ids
array of uuids

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

excluded_ids
boolean
Defaults to false

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.

Responses

401

Unauthorized

Language
Credentials
Bearer
LoadingLoading…
Response
Click Try It! to start a request and see the response here! Or choose an example:
application/json