Errors and HTTP codes
factura.com.do returns business rules with a simple envelope: { success: false, message }. Authentication responds with 401 and no body, and JSON parsing errors return 400 with the default body emitted by the Minimal API binding. Learn the three shapes and every resource becomes predictable.
Summary
Business rules executed by the handler (inactive supplier, unbalanced payments, amount out of range, etc.) return 400 with { success: false, message } and a human-readable message. Authentication with X-Api-Key responds 401 with no body. JSON parsing errors are handled by the Minimal API binding: 400 with a default body, without ProblemDetails registered in the application. When the handler throws an exception, the response is { error }: 400 for argument validation, 404 for a missing resource and 500 for anything else (for example, when there is no active NCF sequence).
HTTP codes
| Code | When it occurs | Expected action |
|---|---|---|
200 OK | GET with result or POST/PUT/DELETE processed. Void and DELETE also respond 200 when they fail, with success: false | Read success before assuming the operation took effect |
400 Bad Request | Malformed JSON, body validation or failed business rule | Read message and fix the body |
401 Unauthorized | X-Api-Key is missing or invalid | Rotate or renew the key |
403 Forbidden | The key is valid, but the workspace is not on the Corporativo plan | Move to the Corporativo plan |
404 Not Found | id does not exist in your workspace, or the note references a sequence that does not exist | Verify the resource belongs to the tenant |
500 Internal Server Error | Unhandled exception, such as creating a document with no active NCF sequence | Read error; if it is the sequence, set it up in the app. Otherwise retry with backoff and open a ticket if it persists |
Standard envelope
Three examples cover most cases: business rule on the body, authentication with a missing header and conflict on the resource state. The shape differs between the { success, message } envelope and the 401 with no body.
Body rule (400)
{ "success": false, "message": "El cliente está inactivo y no puede ser utilizado en documentos."}Unauthorized (401, no body)
HTTP/1.1 401 UnauthorizedContent-Length: 0State conflict (400)
{ "success": false, "message": "No se puede crear un Comprobante de Compras (E41) para un proveedor registrado en la DGII."}Common errors
| Case | Code | Detail |
|---|---|---|
| Subdomain that matches no workspace | 404 | No body |
| X-Api-Key missing or expired | 401 | No body. Retry with the correct header |
| Workspace without the Corporativo plan | 403 | El acceso a la API REST está disponible solo en el plan Corporativo. |
| No active NCF sequence for the type | 500 | No hay secuencia activa para el tipo de documento N |
| Credit or debit note with a non-existent referenceSequence | 404 | No se encontró un documento con la secuencia 'E310000000001'. |
| DELETE of a customer that does not exist | 200 | success: false · CustomerId with ID … not found. |
| Voiding a document the DGII is still validating | 200 | success: false · Error al anular factura: No se puede anular una factura que está en proceso de validación por la DGII. … |
| customerId or another id does not exist in the workspace | 404 | No body (resource not found) |
| Inactive supplier in the catalog | 400 | El proveedor está inactivo y no puede ser utilizado en documentos. |
| E41 with a DGII-registered supplier | 400 | No se puede crear un Comprobante de Compras (E41) para un proveedor registrado en la DGII. |
| Payments do not balance with the document total | 400 | La suma de los pagos (RD$ X) no coincide con el monto total del documento (RD$ Y). |
| edit-amount with a proposed amount exceeding the original | 400 | El monto propuesto (RD$ X) no puede exceder el total del documento original (RD$ Y). |
| Malformed JSON or unexpected type | 400 | Response from the Minimal API binder; the exact shape depends on the ASP.NET Core version. |