Errors and other HTTP response codes

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 DigiTax

We 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 statusScenario in DigiTax APIAction
200 OKTypical for successful GET endpoint requestsUse the API response as needed
201 CreatedTypical for successful POST endpoint requestsUse the API response as needed

Client error responses

HTTP statusScenario in DigiTax APIFurther context and possible action
400 Bad RequestTypical for POST endpoint requestsAction: Update the request body, headers, and/or parameters and retry
401 UnauthorizedTypical for POST and GET endpoint requests

For example, if you use an invalid or deactivated API Key, you receive a 401 error:
{"code": "401", "message": "bad credentials"}

Action: Check your API Key or generate one under Integrations.

403 ForbiddenTypical for POST endpoint requestsThe user or token is not permitted to perform this action.
404 Not FoundPossible in any endpointAction: Verify the entity ID and endpoint route
409 ConflictTypical for POST endpoint requests

For example, trader_invoice_number must be unique across all invoices. Reusing an existing value causes a conflict.

Action: Retry with a different, unique trader_invoice_number

412 Precondition FailedTypical 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 RequestsPossible 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 endpointAction:
  • Check whether our team has issued an advisory on service interruption.
    • If so, retry once resolution is communicated.
    • If not, retry once. If a retry still returns a 5XX error, reach out to our support team.