The Cloudflare SDK provides flexible configuration options for customizing client behavior, authentication, network settings, and more.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/cloudflare/cloudflare-typescript/llms.txt
Use this file to discover all available pages before exploring further.
Basic initialization
Create a new Cloudflare client with your API token:The SDK automatically reads the
CLOUDFLARE_API_TOKEN environment variable if no apiToken is provided.Authentication methods
The SDK supports multiple authentication methods:- API Token (Recommended)
- Global API Key
- User Service Key
Configuration options
TheClientOptions interface provides comprehensive configuration:
API token for authentication (reads from
CLOUDFLARE_API_TOKEN by default)Global API key for legacy authentication
Email address used with Global API key
Service key for Origin CA certificates API
Override the default base URL for the API
Define the API version to target for requests (e.g., “2025-01-01”)
Maximum time in milliseconds to wait for a response (default: 1 minute)
Maximum number of retry attempts for failed requests
Custom HTTP(S) agent for managing connections
Custom
fetch function implementationDefault headers included with every request
Default query parameters included with every request
Custom base URL
Override the API endpoint for testing or alternative environments:CLOUDFLARE_BASE_URL environment variable:
HTTP agent configuration
Configure a custom HTTP agent for proxy support or connection pooling:By default, the SDK uses a stable agent to reuse TCP connections, eliminating handshakes and improving performance.
Custom fetch implementation
Provide a customfetch function for logging, middleware, or alternative implementations:
Fetch shims
The SDK usesnode-fetch in Node.js by default. To use the global web-standards fetch:
Default headers and query parameters
Add custom headers or query parameters to all requests:undefined or null.