Skip to main content

Handle errors and retries

All errors follow RFC 9457, and the type field is a deep link to the error dictionary.

resp = requests.post(...)
if resp.status_code >= 400:
problem = resp.json()
print("Error:", problem["type"], problem["title"])
print("Correlation:", problem.get("correlationId"))
if problem.get("dgii"):
print("DGII code:", problem["dgii"]["code"], "track:", problem["dgii"].get("trackId"))
# Decide reintento según problem["type"]:
if problem["type"].endswith("/dgii-unavailable"):
# ERPly Pro ya reintentará — registra y sal.
return
if problem["type"].endswith("/validation-error"):
raise ValueError(problem["detail"])

Safe retries

  • POST /v1/invoices is idempotent via Idempotency-Key with a 24 h TTL. Reusing the same key returns the original result with HTTP 200 (instead of 202).
  • dgii-unavailable (504) → ERPly Pro retries on its own. No action required.
  • dgii-rejected (422) → DO NOT retry with the same eNCF; that number has already been consumed.

Common errors

TypeAction
validation-errorFix the payload.
mathematical-discrepancyRecompute totals with correct rounding.
dgii-rejectedRead dgii.code and consult the dictionary.
dgii-unavailableWait for the webhook.

All set! You've issued your first invoice. Continue with the concepts or the full reference.