HTTP response codes for troubleshooting: declines, invalid data, network problems, and more.
Overview
Conventional HTTP response codes are used to indicate the success or failure of an API request.
Responses are grouped in five classes:
- Informational responses (100-199)
- Successful responses (200-299)
- Redirection messages (300-399)
- Client error responses (400-499)
- Server error responses (500-599)
Standard Error Response Envelope
When an error occurs, DigiTax returns a structured JSON payload conforming to the following model:
{
"code": "400",
"message": "Invalid customer Tax Identification Number",
"metadata": {
"field": "identification_number"
}
}code: Machine-readable error code or HTTP status string.message: Human-readable explanation of why the request failed.metadata: Optional key-value object containing contextual diagnostic details (e.g. invalid field names).
DigiTax Tanzania API HTTP response status codes
For our interactive API, these are the main HTTP response status codes:
- 200 OK
- 201 Created
- 400 Bad Request
- 401 Unauthorized
- 403 Forbidden
- 404 Not Found
- 409 Conflict
- 412 Precondition Failed
- 429 Too Many Requests
- 500 Internal Server Error
- 502 Bad Gateway
- 503 Service Unavailable
503 is unlikely for DigiTaxWe pride ourselves to provide 99.99% uptime!
Head over to the MDN reference on HTTP Status codes for details on the complete list of HTTP response status codes.
Further context and possible action points
Successful responses
| HTTP status | Scenario in DigiTax API | Action |
|---|---|---|
| 200 OK | Typical for successful GET endpoint requests | Use the API response as needed |
| 201 Created | Typical for successful POST endpoint requests | Use the API response as needed |
Client error responses
| HTTP status | Scenario in DigiTax API | Further context and possible action |
|---|---|---|
| 400 Bad Request | Typical for POST endpoint requests | Action: Update the request body, headers, and/or parameters and retry |
| 401 Unauthorized | Typical for POST and GET endpoint requests | For example, if you use an invalid or deactivated API Key, you receive a 401 error: Action: Check your API Key or generate one under Integrations. |
| 403 Forbidden | Typical for POST endpoint requests | The user or token is not permitted to perform this action. |
| 404 Not Found | Possible in any endpoint | Action: Verify the entity ID and endpoint route |
| 409 Conflict | Typical for POST endpoint requests | For example, Action: Retry with a different, unique |
| 412 Precondition Failed | Typical for POST endpoint requests | A required precondition has not been met. The accompanying message will advise. Action: Update the request body and retry |
| 429 Too Many Requests | Possible in any endpoint | All endpoints are rate-limited. You have exceeded the quota. Action: Retry later at a slower cadence |
| 5XX (500, 501, 502, 503 ...) | Possible in any endpoint | Action:
|