MPChatMPChat/Docs

Error Reference

All API errors return a JSON object with a single error field. Use the HTTP status code to categorize the error, and the message to show actionable feedback to users or for debugging.

Error format

JSON
{
  "error": "order not found"
}

HTTP status codes

CodeNameMeaning
200OKRequest succeeded
201CreatedResource created successfully
400Bad RequestInvalid parameters — fix the request before retrying
401UnauthorizedMissing or invalid authentication
403ForbiddenAuthenticated but not authorized for this resource
404Not FoundResource does not exist or you don't have access
409ConflictResource conflict (e.g., duplicate idempotency key)
429Too Many RequestsRate limit exceeded — check Retry-After header
500Internal Server ErrorServer-side error — retry with backoff

Authentication errors

HTTP StatusError messageDescription
401missing authorization headerNo Authorization header was provided.
401invalid authorization formatThe Authorization header format is incorrect.
401api key not foundThe key_id does not match any active API key.
401api key is inactiveThe API key has been revoked.
401invalid signatureThe HMAC signature does not match.
401request timestamp too oldThe timestamp in the Authorization header is more than 5 minutes in the past.

Order errors

POST /v1/orders

HTTP StatusError messageDescription
400invalid amountAmount is not a valid positive decimal.
400unsupported currencyCurrency must be "USDT".
400unsupported networkNetwork must be "TRC20" or "ERC20".
400no available addressNo blockchain address is available for assignment. Retry in a few moments.
409duplicate idempotency keyAn order with this idempotency_key already exists with different parameters.

GET /v1/orders/:id

HTTP StatusError messageDescription
404order not foundThe order ID does not exist or belongs to a different merchant.
403forbiddenThe order belongs to a different merchant account.

Withdrawal errors

POST /v1/withdrawals

HTTP StatusError messageDescription
400insufficient balanceAvailable balance is less than the requested withdrawal amount plus fees.
400invalid destination addressThe destination address is not a valid USDT address for the specified network.
400amount below minimumWithdrawal amount is below the minimum threshold.

Webhook errors

HTTP StatusError messageDescription
400invalid webhook urlURL must be HTTPS.
400invalid event typeOne or more event types in the events array are not recognized.
404webhook not foundThe webhook ID does not exist.

Rate limiting

The API allows 60 requests per minute per API key. When the limit is exceeded:

429 response headers
HTTP/1.1 429 Too Many Requests
Retry-After: 30
Content-Type: application/json

{"error": "rate limit exceeded"}
💡Implement exponential backoff in your client. After receiving a 429, wait at least the number of seconds in the Retry-After header before retrying.

Error handling

JavaScript
async function apiRequest(method, path, body) {
  const response = await fetch(`https://api.mpchat.com${path}`, {
    method,
    headers: {
      "Content-Type": "application/json",
      "Authorization": buildAuthHeader(),
    },
    body: body ? JSON.stringify(body) : undefined,
  });

  if (response.ok) return response.json();

  const error = await response.json().catch(() => ({ error: "Unknown error" }));

  switch (response.status) {
    case 401:
      throw new AuthError(error.error);
    case 429:
      const retryAfter = response.headers.get("Retry-After");
      throw new RateLimitError(error.error, parseInt(retryAfter ?? "60"));
    case 500:
      throw new ServerError(error.error);
    default:
      throw new ApiError(error.error, response.status);
  }
}