Errors & Response Format

Tsara APIs use standard HTTP response codes and structured JSON error messages to indicate success or failure.
Every response — whether successful or failed — follows a consistent format for easy parsing and debugging.


✅ Success Response Format

Successful responses always include:

  • success: Boolean value (true)
  • data: The requested resource or object
  • request_id: Unique identifier for tracking each API call

Example

{
  "success": true,
  "data": {
    "id": "wal_123",
    "type": "stablecoin",
    "network": "solana",
    "asset": "USDC",
    "balance": "250.00"
  },
  "request_id": "req_abc123"
}

❌ Error Response Format

When an error occurs, Tsara returns an HTTP status code in the 4xx or 5xx range.
The response body includes details that help identify and fix the issue.

Structure

{
  "success": false,
  "error": {
    "code": "invalid_request",
    "message": "The provided wallet ID is invalid.",
    "hint": "Ensure that the wallet ID exists and is active."
  },
  "request_id": "req_xyz123"
}

📘 Common HTTP Status Codes

StatusMeaningExample
200✅ SuccessRequest completed successfully.
201✅ CreatedResource successfully created (e.g., wallet, customer).
400❌ Bad RequestInvalid or missing parameters.
401🔒 UnauthorizedMissing or invalid API key or token.
403🚫 ForbiddenAction not allowed for your API key.
404❓ Not FoundResource doesn’t exist or has been deleted.
409⚠️ ConflictDuplicate request or non-idempotent action.
422🧩 Unprocessable EntityValidation failed for input fields.
429🕒 Rate Limit ExceededToo many requests — wait before retrying.
500💥 Internal Server ErrorUnexpected error on Tsara’s servers.
503🧱 Service UnavailableTemporary outage or scheduled maintenance.

🧾 Example: Invalid Request

HTTP 400

{
  "success": false,
  "error": {
    "code": "invalid_request",
    "message": "The 'amount' field is required.",
    "hint": "Include 'amount' in your JSON body and retry."
  },
  "request_id": "req_abc789"
}

🔐 Example: Invalid API Key

HTTP 401

{
  "success": false,
  "error": {
    "code": "unauthorized",
    "message": "Invalid API key provided.",
    "hint": "Check that your Authorization header uses the correct Bearer token."
  },
  "request_id": "req_def456"
}

⚡ Example: Rate Limiting

If your application exceeds the allowed number of requests, Tsara returns a rate-limit error.

HTTP 429

{
  "success": false,
  "error": {
    "code": "rate_limit_exceeded",
    "message": "Too many requests. Please wait before retrying.",
    "hint": "Retry after 30 seconds."
  },
  "request_id": "req_lim001"
}

🧠 Best Practices

  1. Always log the request_id for support or debugging.
  2. Handle 422 and 429 gracefully — prompt users to fix input or wait.
  3. Avoid retrying 4xx errors except 429 (rate limits).
  4. Implement exponential backoff for retries on 5xx responses.
  5. Use sandbox mode to test error handling before going live.

🔗 Related Pages

  • Authentication — Learn how to use Bearer tokens with every request.
  • Webhooks — Securely validate webhook signatures.
  • Pagination — Handle list responses with multiple pages of data.