Skip to main content

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.

The Accounts resource provides methods to manage Cloudflare accounts, their members, roles, subscriptions, and API tokens.

Main methods

create

Create a new account (available for tenant admins).
const account = await client.accounts.create({
  name: 'My New Account',
  type: 'standard'
});
name
string
required
Account name
type
'standard' | 'enterprise'
Account type (defaults to ‘standard’)
id
string
Account identifier
name
string
Account name
type
'standard' | 'enterprise'
Account type
created_on
string
Timestamp for the creation of the account

update

Update an existing account.
const account = await client.accounts.update({
  account_id: '023e105f4ecef8ad9ca31a8372d0c353',
  id: '023e105f4ecef8ad9ca31a8372d0c353',
  name: 'Updated Account Name',
  type: 'standard'
});
account_id
string
required
Account identifier tag
id
string
required
Account identifier
name
string
required
Account name
type
'standard' | 'enterprise'
required
Account type
settings
object
Account settings
settings.abuse_contact_email
string
Email to notify for abuse reports
settings.enforce_twofactor
boolean
Whether Two-Factor Authentication is required for account members

list

List all accounts you have ownership or verified access to.
// Automatically fetches more pages as needed
for await (const account of client.accounts.list()) {
  console.log(account.name);
}
direction
'asc' | 'desc'
Direction to order results
name
string
Filter by account name
page
number
Page number of paginated results
per_page
number
Number of items per page (max 50)

delete

Delete a specific account (available for tenant admins). This is a permanent operation that will delete any zones or other resources under the account.
const result = await client.accounts.delete({
  account_id: '023e105f4ecef8ad9ca31a8372d0c353'
});
account_id
string
required
The account ID to delete

get

Get information about a specific account that you are a member of.
const account = await client.accounts.get({
  account_id: '023e105f4ecef8ad9ca31a8372d0c353'
});
account_id
string
required
Account identifier tag

Account type

interface Account {
  id: string;
  name: string;
  type: 'standard' | 'enterprise';
  created_on?: string;
  managed_by?: {
    parent_org_id?: string;
    parent_org_name?: string;
  };
  settings?: {
    abuse_contact_email?: string;
    enforce_twofactor?: boolean;
  };
}

Sub-resources

The Accounts resource provides access to several sub-resources:
  • members - Manage account members and their roles
  • roles - List available roles for an account
  • subscriptions - Manage account subscriptions
  • tokens - Manage API tokens for an account
  • logs - Access account audit logs

Example usage

import Cloudflare from 'cloudflare';

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

// Create a new account
const newAccount = await client.accounts.create({
  name: 'My Company Account',
  type: 'standard'
});

// List all accounts
const accounts = await client.accounts.list();

// Get specific account details
const account = await client.accounts.get({
  account_id: newAccount.id
});

// Update account settings
const updatedAccount = await client.accounts.update({
  account_id: account.id,
  id: account.id,
  name: account.name,
  type: account.type,
  settings: {
    enforce_twofactor: true
  }
});

// Add a member to the account
const member = await client.accounts.members.create({
  account_id: account.id,
  email: 'user@example.com',
  roles: ['Administrator']
});

Build docs developers (and LLMs) love