Skip to main content

Errors

PLATFORMA uses conventional HTTP response codes to indicate the success or failure of an API request. Codes in the 2xx range indicate success, 4xx codes indicate client errors, and 5xx codes indicate server errors.

Error Response Format

All error responses follow a consistent structure:

{
  "error": {
    "code": "invalid_request",
    "message": "Human-readable error description",
    "details": [
      {
        "field": "customer_id",
        "message": "is required"
      }
    ]
  }
}

HTTP Status Codes

CodeDescription
200Success
201Created — resource was successfully created
204No Content — request succeeded with no response body
400Bad Request — invalid parameters or malformed request
401Unauthorized — invalid or missing authentication
403Forbidden — insufficient permissions
404Not Found — resource does not exist
409Conflict — request conflicts with current state
422Unprocessable Entity — validation failed
429Too Many Requests — rate limit exceeded
500Internal Server Error — unexpected server error
503Service Unavailable — temporary outage

Error Codes

CodeHTTP StatusDescription
invalid_request400The request body is malformed or missing required fields
authentication_failed401The API key or token is invalid
insufficient_scope403The token lacks required scopes
resource_not_found404The requested resource does not exist
duplicate_resource409A resource with this identifier already exists
validation_error422One or more fields failed validation
rate_limit_exceeded429Rate limit has been exceeded
internal_error500An unexpected error occurred

Handling Errors

Always check the error.code field for programmatic error handling rather than parsing the message string, which may change.

try {
  const order = await client.orders.create({ ... });
} catch (err) {
  if (err.code === "validation_error") {
    console.error("Validation failed:", err.details);
  } else if (err.code === "rate_limit_exceeded") {
    // Retry with exponential backoff
    await sleep(err.retryAfter * 1000);
  } else {
    console.error("Unexpected error:", err.message);
  }
}