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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fastcflare-0.0.1.tar.gz.
File metadata
- Download URL: fastcflare-0.0.1.tar.gz
- Upload date:
- Size: 148.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b0aad993f1a844b1f81719ab69c6cbd2f4eed8e923c482a915230337d86a40ca
|
|
| MD5 |
61b62e658515f21ac3bef385e50e786f
|
|
| BLAKE2b-256 |
5f4f1dbd952a5f3ab11250cdfb9e91258a0da6ef657ee4b6e0f2a5ec170e0e9c
|
File details
Details for the file fastcflare-0.0.1-py3-none-any.whl.
File metadata
- Download URL: fastcflare-0.0.1-py3-none-any.whl
- Upload date:
- Size: 150.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8ef4d86d6f5af166d280c7d1d840ecb88582f9719b08d60bd278a252f58e41bf
|
|
| MD5 |
1954379f505ed326e34c0f20cf2ebaa0
|
|
| BLAKE2b-256 |
b0b9879e524f0794c986bad2d9462603aff829de332d38a4ef571c262e1a58e1
|