Manage resources from the command line
Last updated Sep 29, 2026
cf manages Cloudflare resources directly, without a Workers project. This guide uses DNS records to show a pattern that most resource commands follow: find a resource, list what it contains, preview a change, make the change, and clean up.
Before you begin
- Install
cfand sign in. If you use an API token, it needs permission to edit DNS records in the zone. - Add a domain to your Cloudflare account. This guide uses
example.com. - (Optional) Install
jq↗︎ to filter JSON output.
1. Find a zone
List the zones you can access:
cf zones list
The result is a JSON array. To look up one domain, filter by name:
cf zones list --name example.com
Note the id of the zone. Zone-scoped commands accept the zone ID or the domain name. For details, refer to Select a zone.
2. List DNS records
List the DNS records in the zone:
cf dns records list --zone example.com
Options narrow the results. For example, list only A records:
cf dns records list --zone example.com --type A
cf dns records list returns one page of results. To get more, use --page and --per-page.
3. Preview a change
Add --dry-run to see the request a command would send. A dry run prints the method, URL, and body as JSON, and exits without sending anything. It does not need credentials.
cf dns records create --zone <ZONE_ID> --body '{"type":"A","name":"test","content":"192.0.2.1","proxied":true}' --dry-run
{
"command": "cf dns records create",
"method": "POST",
"url": "https://api.cloudflare.com/client/v4/zones/<ZONE_ID>/dns_records",
"pathParams": {
"zone-id": "<ZONE_ID>"
},
"query": {},
"bodyKind": "json",
"body": {
"type": "A",
"name": "test",
"content": "192.0.2.1",
"proxied": true
}
}
Use the zone ID in a dry run. A dry run does not look up domain names, so the preview would show the domain name where the ID belongs.
--body takes the JSON request body. Some operations, including this one, accept their input only through --body. For the fields the body accepts, refer to the Create DNS Record API reference.
4. Create the record
Run the same command without --dry-run:
cf dns records create --zone example.com --body '{"type":"A","name":"test","content":"192.0.2.1","proxied":true}'
cf prints the new record as JSON, including its id.
5. Filter the output
Because results are JSON on standard output, you can pipe them to jq. Print the name and content of each A record:
cf dns records list --zone example.com --type A | jq -r '.[] | "\(.name) \(.content)"'
Get the ID of the record you created:
cf dns records list --zone example.com --name test.example.com | jq -r '.[0].id'
6. Delete the record
Delete the record by its ID:
cf dns records delete <RECORD_ID> --zone example.com
cf asks you to confirm before it deletes anything. The default answer is no.
In a non-interactive session, such as a script or CI job, cf cannot ask. It prints the question and Aborted., makes no change, and exits with status 0. To delete without confirmation, pass --force:
cf dns records delete <RECORD_ID> --zone example.com --force
Caution
Because a skipped deletion exits with status 0, a script cannot tell from the exit status that nothing was deleted. On some commands, --force also changes what the API operation does. Read the --help output of a command before you pass --force in a script.
7. Find other commands
Describe a task to find the command for it:
cf cli search "purge cached files for a URL"
cf cli search prints up to five matching commands as JSON, best match first. Each match includes the command and a short summary. It runs locally and does not need credentials.
To see the arguments and options a command accepts, add --help:
cf cache purge --help
To see the API request a generated command sends, including its method, path, parameters, and body fields, pass it to cf schema:
cf schema zones create
To browse commands by product, add --help to cf, to a product such as cf dns, or to any command.
Next steps
- Run
cffrom scripts and pipelines with Usecfin CI. - Give a coding agent access to the same commands with Use
cfwith coding agents.
Was this helpful?
YesNo
On this page
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/cf/get-started/resources/#page","headline":"Manage resources from the command line","description":"Find a zone, list, create, and delete DNS records, and find other commands with the Cloudflare CLI.","url":"https://developers.cloudflare.com/cf/get-started/resources/","inLanguage":"en","image":"https://developers.cloudflare.com/cf/get-started/resources/og.png?v=bacce884889204ff","dateModified":"2026-09-29","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
description: Learn what stays the same and what changes when you move from Wrangler to cf, and decide when to migrate a project. title: cf for Wrangler users image: https://developers.cloudflare.com/cf/wrangler/og.png?v=ddbb6038a85893fe
Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/cf/llms.txt
Use this file to discover all available pages before exploring further.
Docs