Skip to main content

Complete access to the Cloudflare SDK

Project description

FastCF

from fastcore.utils import *
from fastcflare import *

Intro to Account Tokens

Account-owned API tokens (created via /accounts/{id}/tokens) are tied to the account, not a specific user. They act as service principals — ideal for CI/CD pipelines and service-to-service integrations, since they remain valid even if the creating user leaves the organisation.

Creating Account Tokens

You need a token with “Create Additional Tokens” permission at the account level. Use the Cloudflare Python SDK with the Global API Key + email (not a user token):

from cloudflare import Cloudflare
cf = Cloudflare(api_token=your_cf_token, api_email='you@example.com')
accts = cf.accounts.list()
acct_id = accts.result[0].id

Look up available permission groups for your account:

groups = cf.accounts.tokens.permission_groups.list(account_id=acct_id)
{g.name: g.id for g in groups if 'dns' in g.name.lower() or 'zone' in g.name.lower()}

Create the token with nested resource format — zones must be nested under the account:

tok = cf.accounts.tokens.create(account_id=acct_id, name="dns-all-zones", policies=[{
    "effect": "allow",
    "resources": {f"com.cloudflare.api.account.{acct_id}": {"com.cloudflare.api.account.zone.*": "*"}},
    "permission_groups": [
        {"id": "c8fed203ed3043cba015a93ad1616f1f"},  # Zone Read
        ...
    ]
}])
dns_tok = tok.value  # Save this — it's only shown once

⚠️ The resource format {"com.cloudflare.api.account.zone.*": "*"} (without nesting) will fail with: “Must specify a zone for account owned tokens, or nest zone under specific account resource”

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastcflare-0.0.2.tar.gz (149.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fastcflare-0.0.2-py3-none-any.whl (150.4 kB view details)

Uploaded Python 3

File details

Details for the file fastcflare-0.0.2.tar.gz.

File metadata

  • Download URL: fastcflare-0.0.2.tar.gz
  • Upload date:
  • Size: 149.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for fastcflare-0.0.2.tar.gz
Algorithm Hash digest
SHA256 40c9dbaab48810ec7982343b25c717e2665e7d39bee96f640b041696d26fb448
MD5 af4bcef4b46c2de3c630c5f9537fb9df
BLAKE2b-256 00b2d9d55884f2ce7fd6afc02c6d3a8073f7e8b05e1c6e724304c41c33d73a56

See more details on using hashes here.

File details

Details for the file fastcflare-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: fastcflare-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 150.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for fastcflare-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4e9c48871c2eb41b699b6e747f4628638bada7d9bdbd0de523fbf3b50088f160
MD5 713b29f2b88903cac8f984474f3c4dc4
BLAKE2b-256 79158a43568099e3556d5e978e6922d580bf8a57c6eb52365a618b423ecedb1f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page