Errors

This guide covers the error responses you may encounter when using the ibakepro API and how to handle them appropriately.

All error responses follow a consistent format, making it easy to handle errors programmatically.


Error response format

Error response

{
  "success": false,
  "error": {
    "code": "validation_error",
    "message": "Name is required",
    "field": "name"
  }
}
  • Name
    success
    Type
    boolean
    Description

    Always false for error responses.

  • Name
    error.code
    Type
    string
    Description

    A machine-readable error code.

  • Name
    error.message
    Type
    string
    Description

    A human-readable description of the error.

  • Name
    error.field
    Type
    string
    Description

    The field that caused the error (for validation errors).


HTTP Status Codes

  • Name
    200 OK
    Description

    The request was successful.

  • Name
    201 Created
    Description

    A new resource was successfully created.

  • Name
    400 Bad Request
    Description

    The request was malformed or contained invalid parameters.

  • Name
    401 Unauthorized
    Description

    Authentication failed. Check your API key.

  • Name
    403 Forbidden
    Description

    Your API key doesn't have permission for this action.

  • Name
    404 Not Found
    Description

    The requested resource doesn't exist.

  • Name
    429 Too Many Requests
    Description

    You've exceeded the rate limit.

  • Name
    500 Internal Server Error
    Description

    Something went wrong on our end.


Error codes

Authentication errors

  • Name
    missing_api_key
    Description

    No API key was provided in the request headers.

  • Name
    invalid_api_key
    Description

    The API key is invalid or has been revoked.

  • Name
    insufficient_scope
    Description

    The API key doesn't have the required scope for this endpoint.

401 Unauthorized

{
  "success": false,
  "error": {
    "code": "invalid_api_key",
    "message": "The API key provided is invalid"
  }
}

Validation errors

  • Name
    validation_error
    Description

    A required field is missing or has an invalid value.

  • Name
    invalid_json
    Description

    The request body contains invalid JSON.

  • Name
    invalid_cursor
    Description

    The pagination cursor is invalid or expired.

400 Bad Request

{
  "success": false,
  "error": {
    "code": "validation_error",
    "message": "Amount is required",
    "field": "amount"
  }
}

Resource errors

  • Name
    not_found
    Description

    The requested resource doesn't exist or has been deleted.

  • Name
    already_exists
    Description

    A resource with this identifier already exists.

404 Not Found

{
  "success": false,
  "error": {
    "code": "not_found",
    "message": "Order not found: ord_abc123"
  }
}

Rate limiting

When you exceed the rate limit, you'll receive a 429 response. The response headers indicate when you can retry.

  • Name
    rate_limit_exceeded
    Description

    Too many requests in the current time window.

429 Too Many Requests

{
  "success": false,
  "error": {
    "code": "rate_limit_exceeded",
    "message": "Rate limit exceeded. Try again in 60 seconds."
  }
}

Handling errors

Here's an example of how to handle errors in your integration:

JavaScript error handling

async function createOrder(orderData) {
  const response = await fetch('https://api.ibakepro.com/api/v1/orders', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${process.env.IBAKEPRO_API_KEY}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify(orderData),
  })

  const result = await response.json()

  if (!result.success) {
    switch (result.error.code) {
      case 'validation_error':
        console.error(`Validation error on field ${result.error.field}: ${result.error.message}`)
        break
      case 'rate_limit_exceeded':
        console.error('Rate limited - implement exponential backoff')
        break
      default:
        console.error(`API error: ${result.error.message}`)
    }
    throw new Error(result.error.message)
  }

  return result.data
}

Was this page helpful?