> ## 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.

# Quick start

> Get up and running with the Cloudflare TypeScript SDK in under 5 minutes

# Quick start

This guide will help you make your first API call with the Cloudflare TypeScript SDK in under 5 minutes.

<Steps>
  <Step title="Install the SDK">
    First, install the Cloudflare SDK using your preferred package manager:

    <CodeGroup>
      ```bash npm theme={null}
      npm install cloudflare
      ```

      ```bash yarn theme={null}
      yarn add cloudflare
      ```

      ```bash pnpm theme={null}
      pnpm add cloudflare
      ```

      ```bash bun theme={null}
      bun add cloudflare
      ```
    </CodeGroup>
  </Step>

  <Step title="Get your API token">
    You'll need a Cloudflare API token to authenticate your requests.

    1. Log in to the [Cloudflare Dashboard](https://dash.cloudflare.com)
    2. Go to **My Profile** > **API Tokens**
    3. Click **Create Token**
    4. Use a template or create a custom token with the permissions you need
    5. Copy your token and store it securely

    <Warning>
      Keep your API token secure! Never commit it to version control or share it publicly.
    </Warning>
  </Step>

  <Step title="Set up environment variables">
    Store your API token in an environment variable:

    <CodeGroup>
      ```bash .env theme={null}
      CLOUDFLARE_API_TOKEN=your_api_token_here
      ```

      ```bash Shell theme={null}
      export CLOUDFLARE_API_TOKEN=your_api_token_here
      ```
    </CodeGroup>
  </Step>

  <Step title="Make your first API call">
    Create a new TypeScript or JavaScript file and import the SDK:

    ```typescript theme={null}
    import Cloudflare from 'cloudflare';

    const client = new Cloudflare({
      apiToken: process.env['CLOUDFLARE_API_TOKEN'],
    });

    // List all accounts
    async function listAccounts() {
      const accounts = await client.accounts.list();
      console.log('Your accounts:');
      for await (const account of accounts) {
        console.log(`- ${account.name} (${account.id})`);
      }
    }

    listAccounts();
    ```

    Run your code:

    <CodeGroup>
      ```bash Node.js theme={null}
      node your-file.js
      ```

      ```bash TypeScript (with tsx) theme={null}
      tsx your-file.ts
      ```

      ```bash Deno theme={null}
      deno run --allow-net --allow-env your-file.ts
      ```

      ```bash Bun theme={null}
      bun run your-file.ts
      ```
    </CodeGroup>
  </Step>
</Steps>

## What's next?

<CardGroup cols={2}>
  <Card title="Create a zone" icon="globe" href="/api-reference/zones">
    Learn how to create and manage DNS zones
  </Card>

  <Card title="Configure DNS" icon="network-wired" href="/api-reference/dns">
    Add and update DNS records for your zones
  </Card>

  <Card title="Deploy Workers" icon="code" href="/api-reference/workers">
    Deploy serverless functions at the edge
  </Card>

  <Card title="Error handling" icon="triangle-exclamation" href="/core-concepts/error-handling">
    Learn how to handle errors gracefully
  </Card>
</CardGroup>

## Complete example

Here's a more complete example that creates a zone and adds a DNS record:

```typescript theme={null}
import Cloudflare from 'cloudflare';

const client = new Cloudflare({
  apiToken: process.env['CLOUDFLARE_API_TOKEN'],
});

async function setupZone() {
  try {
    // Create a new zone
    const zone = await client.zones.create({
      account: { id: 'YOUR_ACCOUNT_ID' },
      name: 'example.com',
      type: 'full',
    });

    console.log(`Created zone: ${zone.name} (${zone.id})`);

    // Add an A record
    const record = await client.dns.records.create({
      zone_id: zone.id,
      type: 'A',
      name: 'www',
      content: '192.0.2.1',
      ttl: 3600,
      proxied: true,
    });

    console.log(`Created DNS record: ${record.name} -> ${record.content}`);
  } catch (error) {
    if (error instanceof Cloudflare.APIError) {
      console.error('API Error:', error.status, error.message);
    } else {
      console.error('Unexpected error:', error);
    }
  }
}

setupZone();
```

<Tip>
  The SDK provides full TypeScript type definitions. Use your editor's autocomplete to explore available methods and parameters!
</Tip>

## Next steps

Now that you've made your first API call, learn more about:

* [Authentication methods](/authentication) - API tokens, API keys, and user service keys
* [Client configuration](/core-concepts/client-configuration) - Customize timeout, retries, and base URL
* [Pagination](/core-concepts/pagination) - Work with paginated API responses
* [API Reference](/api-reference/accounts) - Explore all available resources and methods
