Error Handling

Error responses, status codes, and error codes used by the Snippe API

All API errors follow a consistent format to help you handle them gracefully.


Response Format

{
  "status": "success",
  "code": 200,
  "data": {
    // Response data
  }
}
{
  "status": "error",
  "code": 400,
  "error_code": "validation_error",
  "message": "amount is required"
}

HTTP Status Codes

CodeNameDescription
200OKRequest successful
201CreatedResource created successfully
400Bad RequestInvalid request (validation errors, malformed JSON)
401UnauthorizedAuthentication required or failed
403ForbiddenAuthenticated but not authorized
404Not FoundResource doesn't exist
409ConflictResource already exists or state conflict
422Unprocessable EntityIdempotency key mismatch
429Too Many RequestsRate limit exceeded
500Internal Server ErrorServer-side error
503Service UnavailableExternal service temporarily down

Common Error Scenarios

Invalid API Key (401)

{
  "status": "error",
  "code": 401,
  "error_code": "unauthorized",
  "message": "invalid or missing API key"
}

Fix: Check that your API key is correct and included in the Authorization header.

Insufficient Scope (403)

{
  "status": "error",
  "code": 403,
  "error_code": "insufficient_scope",
  "message": "API key does not have required scope: disbursement:create"
}

Fix: Create a new API key with the required scope from the Dashboard.

Missing Required Fields (400)

{
  "status": "error",
  "code": 400,
  "error_code": "validation_error",
  "message": "amount is required"
}

Invalid Phone Number (400)

{
  "status": "error",
  "code": 400,
  "error_code": "validation_error",
  "message": "phone_number must be a valid phone number"
}

Fix: Use format 255XXXXXXXXX or +255XXXXXXXXX for Tanzanian numbers.

Amount Out of Range (400)

{
  "status": "error",
  "code": 400,
  "error_code": "validation_error",
  "message": "amount 100 is below minimum of 500"
}

Payment Not Found (404)

{
  "status": "error",
  "code": 404,
  "error_code": "not_found",
  "message": "payment not found"
}

Insufficient Balance (500)

{
  "status": "error",
  "code": 500,
  "error_code": "payment_failed",
  "message": "insufficient balance: available 5000, required 6500"
}

Fix: Top up your account balance before creating payouts.

Idempotency Conflict (422)

{
  "status": "error",
  "code": 422,
  "error_code": "validation_error",
  "message": "idempotency key already used with different request body"
}

Fix: Use a unique idempotency key for each unique request.

Rate Limit Exceeded (429)

{
  "status": "error",
  "code": 429,
  "error_code": "rate_limit_exceeded",
  "message": "Too many requests"
}

Fix: Implement exponential backoff and respect the X-Ratelimit-Reset header.


Error Codes Reference

Authentication Errors

CodeDescription
unauthorizedInvalid or missing API key
insufficient_scopeAPI key lacks required scope

Validation Errors

CodeDescription
validation_errorOne or more fields invalid

Resource Errors

CodeDescription
not_foundResource doesn't exist
conflictResource state conflict

Payment Errors

CodeDescription
payment_failedPayment processing error

Validation Rules

RuleValue
Minimum500 TZS (payments), 5,000 TZS (payouts)
MaximumVaries by account type
FormatInteger (smallest currency unit)
FormatExample
With country code+255712345678
Without plus255712345678

Phone numbers must be valid Tanzanian mobile numbers.

  • Must be valid HTTPS URLs
  • Maximum 500 characters
  • Used for: webhook_url, redirect_url, cancel_url

Best Practices

On this page