On this page

Electronic invoicing

The ten POST operations of the lynx-einvoicing Edge Function, from transmitting to credit notes.

All operations live under POST /functions/v1/lynx-einvoicing/<route>, take org_id, and use the authentication headers. The adapter-dian key never leaves the server: the browser only talks to this function.

Invoices

Route Body Does
/transmit org_id, invoice_ids[] (≤50), reissue? Transmits invoices to the DIAN. Returns results[].
/refresh org_id, invoice_id Re-queries the DIAN status of a transmitted invoice.
/representation org_id, invoice_id, regenerate? Keeps the graphical representation (PDF) up to date and returns its bucket path.
/deliver org_id, invoice_id, to? Delivers the invoice; to overrides the recipient email.

The PDF lives in a private bucket

/representation returns path, filename, stamped, cached and generated_at. Download the file from the lynx-documentos bucket with your session — the function keeps it current, it doesn’t stream the bytes.

Credit notes

Route Body Does
/credit-notes org_id, invoice_id, concept_code, reason, line_ids? Issues a credit note over an invoice.
/credit-notes/reissue org_id, credit_note_id Reissues a credit note that ended in error.
/credit-notes/representation org_id, credit_note_id, regenerate? Keeps the credit note’s PDF up to date.
/credit-notes/refresh org_id, credit_note_id Re-queries the DIAN status of a credit note.
POST /functions/v1/lynx-einvoicing/credit-notes
curl -X POST "$LYNX_SUPABASE_URL/functions/v1/lynx-einvoicing/credit-notes" \
  -H "Authorization: Bearer $LYNX_TOKEN" \
  -H "apikey: $LYNX_ANON_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "org_id": "3f1c9a2e-…", "invoice_id": "7b2e…", "concept_code": "2", "reason": "Anulación", "line_ids": [] }'

# 200 OK
{ "credit_note_id": "a12f…", "status": "emitida", "message": "Nota crédito emitida" }

Integrations (admin only)

Route Body Does
/integrations/test org_id, company_id, service, environment, api_key? Tests a provider credential.
/integrations/save org_id, company_id, service, environment, api_key?, url?, settings? Saves the credential; a key that doesn’t authenticate returns 422.

service is one of adapter-dian, docsgen, deliver; environment is uat or prd. Both require the admin role.

Not documented on purpose

lynx-reconcile is not part of this API: it’s a scheduled job invoked by pg_cron with its own secret, not by a person.