Handle errors and retries
All errors follow RFC 9457, and the type field is a deep link to the error dictionary.
Recommended pattern
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/invoicesis idempotent viaIdempotency-Keywith 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
| Type | Action |
|---|---|
validation-error | Fix the payload. |
mathematical-discrepancy | Recompute totals with correct rounding. |
dgii-rejected | Read dgii.code and consult the dictionary. |
dgii-unavailable | Wait for the webhook. |
All set! You've issued your first invoice. Continue with the concepts or the full reference.