Quick start
This guide will help you make your first API call with the Cloudflare TypeScript SDK in under 5 minutes.1
Install the SDK
First, install the Cloudflare SDK using your preferred package manager:
2
Get your API token
You’ll need a Cloudflare API token to authenticate your requests.
- Log in to the Cloudflare Dashboard
- Go to My Profile > API Tokens
- Click Create Token
- Use a template or create a custom token with the permissions you need
- Copy your token and store it securely
3
Set up environment variables
Store your API token in an environment variable:
4
Make your first API call
Create a new TypeScript or JavaScript file and import the SDK:Run your code:
What’s next?
Create a zone
Learn how to create and manage DNS zones
Configure DNS
Add and update DNS records for your zones
Deploy Workers
Deploy serverless functions at the edge
Error handling
Learn how to handle errors gracefully
Complete example
Here’s a more complete example that creates a zone and adds a DNS record:Next steps
Now that you’ve made your first API call, learn more about:- Authentication methods - API tokens, API keys, and user service keys
- Client configuration - Customize timeout, retries, and base URL
- Pagination - Work with paginated API responses
- API Reference - Explore all available resources and methods