Skip to main content

Overview

This guide covers how to handle errors from the Cred Protocol API, including common error codes, error response formats, and best practices for building resilient applications.

Error Response Format

All API errors return a JSON response with a detail field:
Some errors may include additional fields:

HTTP Status Codes

Client Errors (4xx)

Server Errors (5xx)

Common Errors and Solutions

Causes:
  • Malformed Ethereum address
  • Invalid ENS name
  • Missing required parameters
Solutions:
  • Validate addresses before making requests
  • Use checksummed addresses when possible
  • Verify ENS names resolve correctly
Causes:
  • Missing Authorization header
  • Invalid API key format
  • Revoked API key
Solutions:
  • Ensure header format is Bearer YOUR_API_KEY
  • Check for typos in the API key
  • Verify the key hasn’t been revoked
  • Generate a new key if needed
Causes:
  • No Authorization header or X-PAYMENT header provided
  • This is an informational response, not an error
Response Headers:
  • X-PAYMENT-REQUIRED: Base64-encoded payment requirements for x402-compatible clients (includes options for all enabled networks)
Solutions:
  • Add an API key: Authorization: Bearer YOUR_API_KEY
  • Or use x402 payment: Sign a USDC transfer and include in X-PAYMENT header
  • Supported networks: Base, Base Sepolia, SKALE Base, SKALE Base Sepolia
  • See Authentication Guide for details
Causes:
  • Accessing a feature not in your plan
  • Account restrictions
Solutions:
  • Check your plan features in the Dashboard
  • Upgrade your plan if needed
  • Contact support for account issues
Causes:
  • Address has never been used on-chain
  • ENS name doesn’t exist
  • Incorrect endpoint path
Solutions:
  • Verify the address exists on Etherscan
  • Check ENS name resolution
  • Verify the endpoint URL
Causes:
  • Exceeded requests per minute limit
Solutions:
  • Implement exponential backoff
  • Cache responses where possible
  • Wait for the retry_after period
See Rate Limiting below.
Causes:
  • Exceeded monthly Cred Unit allocation
Response Fields:Solutions:
  • Wait until period_end for credits to reset
  • Upgrade your plan for more Cred Units
  • Optimize API usage by caching responses
  • Use summary endpoints (lower CU cost) where possible
Causes:
  • Unexpected server-side error
  • Temporary system issue
Solutions:
  • Retry with exponential backoff
  • Contact support if the issue persists
  • Check status page for outages

Implementing Error Handling

Basic Error Handling

With Retry Logic

Python Example

Rate Limiting

Understanding Usage Limits

API usage is measured in Cred Units (CUs) based on your plan:

Handling Rate Limits

Best Practices

Validate Input

Validate addresses and parameters before making API calls

Use Retries

Implement exponential backoff for transient errors

Cache Responses

Cache successful responses to reduce API calls

Log Errors

Log errors with context for debugging

Logging Example