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.4.tar.gz (172.7 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.4-py3-none-any.whl (174.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fastcflare-0.0.4.tar.gz
  • Upload date:
  • Size: 172.7 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.4.tar.gz
Algorithm Hash digest
SHA256 a70d2cbbf7c8e239a3ab860f24683c7a11fb5400c949a82adef19134f3fd2237
MD5 8b0e9af95d6d0b73820c7fd96a3052a5
BLAKE2b-256 b2d73fce2eea2f54d56ca02aebc537807a8a8b977ecc7f9c2b80d7580d63a592

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fastcflare-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 174.2 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 fc1bbd5eda7a73e73819d19ecd4b08e02720b99dbfa0b83fabdf9dab48700e2b
MD5 46c2be973b1c55e2255965370f22a807
BLAKE2b-256 d89cb79859387f10badeb73531aebb95bc924fde314e8a28f8af6836f4c32d6a

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