Skip to main content
The Myaza API uses standard HTTP status codes. Error responses always include a message field and sometimes an error field with more detail.

Error Response Shape

{
  "statusCode": 400,
  "message": "Validation failed: amount must be a positive number",
  "error": "Bad Request"
}

HTTP Status Codes

CodeMeaningCommon Causes
200OKRequest succeeded
201CreatedResource created successfully
204No ContentDeleted successfully
400Bad RequestInvalid input, missing required fields, validation errors
401UnauthorizedMissing or invalid API key / JWT
403ForbiddenValid auth but insufficient permissions
404Not FoundResource doesn’t exist or you don’t have access
409ConflictResource already exists
422Unprocessable EntityRequest understood but business logic rejected it
429Too Many RequestsRate limit exceeded
500Internal Server ErrorUnexpected server error

Common Errors

401 Unauthorized

{
  "statusCode": 401,
  "message": "Unauthorized"
}
Fix: Check that you are sending the correct X-API-Key header or a valid Authorization: Bearer <token> header.

403 Forbidden

{
  "statusCode": 403,
  "message": "Insufficient permissions: crypto:write required"
}
Fix: Your API key or user account does not have the required permission. Either regenerate the key with the correct scope or contact your admin.

400 Validation Error

{
  "statusCode": 400,
  "message": [
    "chain must be a valid chain identifier",
    "amount must be a number string"
  ],
  "error": "Bad Request"
}
Fix: Check the request body against the API reference. All required fields must be present and correctly typed.

404 Not Found

{
  "statusCode": 404,
  "message": "Webhook with id '123e4567-...' not found"
}
Fix: Verify the resource ID. Note that you can only access resources belonging to your own business.

429 Rate Limited

{
  "statusCode": 429,
  "message": "Too many requests, please try again later"
}
Fix: Implement exponential backoff. Default rate limits are:
  • 100 requests/minute per API key
  • Configurable lower limits when creating a key

Handling Errors in Code

const response = await fetch(
  "https://secureapi.gridlog.io/api/v1/crypto/wallets/generate",
  {
    method: "POST",
    headers: {
      "X-API-Key": process.env.MYAZA_API_KEY,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({ chain: "polygon" }),
  },
);

if (!response.ok) {
  const error = await response.json();
  console.error(`API Error ${response.status}:`, error.message);
  throw new Error(error.message);
}

const wallet = await response.json();

Retry Strategy

For 5xx errors and 429 rate limits, use exponential backoff:
async function withRetry(fn, maxRetries = 3) {
  for (let attempt = 0; attempt <= maxRetries; attempt++) {
    try {
      return await fn();
    } catch (err) {
      if (attempt === maxRetries) throw err;
      const isRetryable = [429, 500, 502, 503, 504].includes(err.status);
      if (!isRetryable) throw err;
      const delay = Math.pow(2, attempt) * 1000; // 1s, 2s, 4s
      await new Promise((resolve) => setTimeout(resolve, delay));
    }
  }
}