{"id":23497986,"url":"https://github.com/freedomben/cloudflare_api","last_synced_at":"2026-06-08T00:31:42.573Z","repository":{"id":57483613,"uuid":"456307159","full_name":"FreedomBen/cloudflare_api","owner":"FreedomBen","description":null,"archived":false,"fork":false,"pushed_at":"2022-05-17T17:08:51.000Z","size":65,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-03-15T07:49:23.011Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FreedomBen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-02-07T00:13:58.000Z","updated_at":"2024-03-15T07:49:23.011Z","dependencies_parsed_at":"2022-08-27T23:22:04.733Z","dependency_job_id":null,"html_url":"https://github.com/FreedomBen/cloudflare_api","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FreedomBen%2Fcloudflare_api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FreedomBen%2Fcloudflare_api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FreedomBen%2Fcloudflare_api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FreedomBen%2Fcloudflare_api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FreedomBen","download_url":"https://codeload.github.com/FreedomBen/cloudflare_api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250307807,"owners_count":21409149,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-25T05:17:39.086Z","updated_at":"2026-06-08T00:31:42.567Z","avatar_url":"https://github.com/FreedomBen.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CloudflareApi\n\n`cloudflare_api` is a thin Elixir wrapper around the\n[Cloudflare Client API v4](https://api.cloudflare.com/), focused on keeping\nyou close to the underlying REST endpoints while providing a small set of\nergonomic helpers.\n\n## Rate-limit retries\n\nTo automatically retry HTTP `429` responses, build your client with\n`rate_limit_retry: true` (or pass retry options):\n\n```elixir\nclient = CloudflareApi.new(\"api-token\", rate_limit_retry: [max_retries: 2])\n{:ok, zones} = CloudflareApi.Zones.list(client)\n```\n\nYou can also wrap a single request with `CloudflareApi.RateLimitRetry.run/2`\nand customize `max_retries`, `base_backoff`, or the `sleep` callback for tests.\n\nThe library currently includes convenience modules for:\n\n- Zones – listing zones and working with `CloudflareApi.Zone` structs.\n- DNS records – listing, creating, updating, deleting DNS records via\n  `CloudflareApi.DnsRecords` and `CloudflareApi.DnsRecord`.\n- An optional in-memory cache for DNS lookups via `CloudflareApi.Cache`.\n\nRecent work is expanding coverage to additional endpoints using the same\nhand-written approach. Newly added modules include:\n\n- `CloudflareApi.Accounts` – list accounts or fetch an individual account.\n- `CloudflareApi.WorkerRoutes` – list/create/update/delete Workers routes.\n- `CloudflareApi.AiGatewayDatasets` – CRUD for AI Gateway datasets under a\n  given account and gateway.\n- `CloudflareApi.AiGatewayDynamicRoutes` – manage AI Gateway dynamic routes,\n  deployments, and versions.\n- `CloudflareApi.AiGatewayEvaluations` – list evaluation types and manage\n  gateway evaluations.\n- `CloudflareApi.AiGatewayGateways` – create, update, and fetch AI Gateway\n  configurations (including provider URLs).\n- `CloudflareApi.AiGatewayLogs` – list/update/delete log records for a gateway.\n- `CloudflareApi.AiGatewayProviderConfigs` – manage provider configs for a\n  gateway.\n- `CloudflareApi.ApiShieldApiDiscovery` – interact with API Shield discovery\n  results and OpenAPI artifacts.\n- `CloudflareApi.ApiShieldEndpointManagement` – CRUD for API Shield operations\n  and schema exports.\n- `CloudflareApi.ApiShieldSchemaValidation` – zone/operation schema validation\n  settings plus user schema management.\n- `CloudflareApi.ApiShieldSettings` – high-level API Shield configuration\n  getter/setter for a zone.\n- `CloudflareApi.AsnIntelligence` – fetch ASN overview and subnet details.\n- `CloudflareApi.AccessBookmarks` – legacy bookmark application helpers.\n- `CloudflareApi.AccessScimUpdateLogs` – list SCIM update logs.\n- `CloudflareApi.AccessAppPolicies` – manage policies scoped to an Access app.\n- `CloudflareApi.AccessApplications` – create/update/delete Access apps and\n  manage tokens/settings.\n- `CloudflareApi.AccessAuthenticationLogs` – list Access authentication events.\n- `CloudflareApi.AccessCustomPages` – CRUD for custom Access pages.\n- `CloudflareApi.AccessGroups` – manage Access groups.\n- `CloudflareApi.AccessIdentityProviders` – manage identity providers and SCIM\n  resources.\n- `CloudflareApi.AccessKeyConfiguration` – view/update/rotate Access keys.\n- `CloudflareApi.AccessMtlsAuthentication` – manage Access mTLS certificates\n  and settings.\n- `CloudflareApi.AccessPolicyTester` – run and inspect policy tests.\n- `CloudflareApi.AccessReusablePolicies` – account-level reusable policy CRUD.\n- `CloudflareApi.AccessServiceTokens` – manage service tokens (including rotate\n  and refresh).\n- `CloudflareApi.AccessShortLivedCertificateCas` – CRUD helpers for Access\n  short-lived certificate CAs.\n- `CloudflareApi.ApiShieldClientCertificates` – client certificate CRUD plus\n  hostname associations.\n- `CloudflareApi.ApiShieldWafExpressionTemplates` – manage expression\n  templates for API Shield WAF.\n- `CloudflareApi.AccessTags` – Access tag CRUD.\n- `CloudflareApi.Account` / `AccountBillingProfile` – account limits and\n  billing profile helpers.\n- `CloudflareApi.AccountLoadBalancerMonitorGroups` – monitor group CRUD and\n  reference listing.\n- `CloudflareApi.AccountLoadBalancerMonitors` – monitor CRUD, preview, and\n  references.\n- `CloudflareApi.AccountLoadBalancerPools` – pool CRUD, health, previews, and\n  references.\n- `CloudflareApi.AccountLoadBalancerSearch` – search across load balancer\n  resources.\n- `CloudflareApi.AccountMembers` – manage account member invites and roles.\n- `CloudflareApi.AccountOwnedApiTokens` – manage account tokens, permission\n  groups, and verification.\n- `CloudflareApi.AccountPermissionGroups` – inspect IAM permission groups.\n- `CloudflareApi.AccountRequestTracer` – trigger request traces for an account.\n- `CloudflareApi.AccountResourceGroups` – IAM resource group CRUD.\n- `CloudflareApi.AccountRoles` – list account roles and details.\n- `CloudflareApi.AccountRulesets` – full account ruleset CRUD, entrypoint, and\n  version helpers.\n- `CloudflareApi.AccountSubscriptions` – manage account subscriptions.\n- `CloudflareApi.AccountUserGroups` – IAM user group and member management.\n- `CloudflareApi.AccountCustomNameservers` – manage custom nameservers and zone\n  usage metadata.\n- `CloudflareApi.RealtimeKitActiveSession` – manage meeting sessions\n  (kick/mute/polls).\n- `CloudflareApi.RealtimeKitAnalytics` – daywise analytics for Realtime Kit\n  apps.\n- `CloudflareApi.RealtimeKitApps` – list/create Realtime Kit apps.\n- `CloudflareApi.AnalyzeCertificate` – analyze SSL certificates for a zone.\n- `CloudflareApi.ArgoAnalyticsGeolocation` – Argo latency analytics by colo.\n- `CloudflareApi.ArgoAnalyticsZone` – Argo analytics aggregated per zone.\n- `CloudflareApi.ArgoSmartRouting` – get/patch Argo Smart Routing settings.\n- `CloudflareApi.Attacker` – list Cloudforce One attacker events.\n- `CloudflareApi.AuditLogs` – fetch account/user audit logs.\n- `CloudflareApi.AutoragJobs` – inspect AutoRAG jobs and logs.\n- `CloudflareApi.AutoragRags` – manage AutoRAG collections (create/list/update/delete).\n- `CloudflareApi.AutoragRagSearch` – execute AutoRAG search queries.\n- `CloudflareApi.AutomaticSslTls` – inspect or update Automatic SSL/TLS enrollment.\n- `CloudflareApi.AvailablePageRulesSettings` – list Page Rules settings available to a zone.\n- `CloudflareApi.BinDb` – upload binaries to / fetch binaries from Cloudforce One BinDB.\n- `CloudflareApi.BotSettings` – manage zone bot management configuration.\n- `CloudflareApi.BotnetThreatFeed` – read Botnet Threat Feed reports and ASN configs.\n- `CloudflareApi.BuildTokens` – manage Cloudflare Builds tokens.\n- `CloudflareApi.Builds` – inspect builds, logs, and cancel jobs for Workers scripts.\n- `CloudflareApi.Cnis` – manage Cloudflare Network Interconnects.\n- `CloudflareApi.CacheReserveClear` – inspect or trigger Cache Reserve Clear jobs.\n- `CloudflareApi.CallsApps` – manage Cloudflare Calls applications.\n- `CloudflareApi.CallsTurnKeys` – create/update/delete Calls TURN keys.\n- `CloudflareApi.CatalogSync` – orchestrate Magic Cloud catalog syncs.\n- `CloudflareApi.CloudflareIps` – fetch Cloudflare public IP ranges.\n- `CloudflareApi.CloudflareImages` – upload/list/manage Cloudflare Images assets.\n- `CloudflareApi.CloudflareImagesKeys` – manage Cloudflare Images signing keys.\n- `CloudflareApi.CloudflareImagesVariants` – create/update/list Images variants.\n- `CloudflareApi.CloudflareTunnels` – CRUD Cloudflare/Warp tunnels, tokens, and connections.\n- `CloudflareApi.CloudflareTunnelConfiguration` – read/update Zero Trust tunnel configs.\n- `CloudflareApi.ConnectivityServices` – manage Connectivity Services directory entries.\n- `CloudflareApi.ContentScanning` – enable/disable content upload scanning and payloads.\n- `CloudflareApi.Country` – fetch Cloudforce One country data.\n- `CloudflareApi.CustomHostnameFallbackOrigin` – manage fallback origin for custom hostnames.\n- `CloudflareApi.CustomHostnames` – full CRUD and certificate operations for zone custom hostnames.\n- `CloudflareApi.CustomIndicatorFeeds` – manage Cloudforce One custom indicator feeds.\n- `CloudflareApi.CustomOriginTrustStore` – manage ACM custom origin trust store certificates.\n- `CloudflareApi.CustomSsl` – upload/list/prioritize custom SSL certificates for a zone.\n- `CloudflareApi.CredentialManagement` – store R2 data catalog credentials.\n- `CloudflareApi.CustomPagesZone` – list/update custom pages for a zone.\n- `CloudflareApi.CustomPagesAccount` – list/update account-scoped custom pages.\n- `CloudflareApi.D1` – manage Cloudflare D1 databases, imports/exports, and queries.\n\nAn up-to-date OpenAPI schema for the Cloudflare API is cached locally at\n`priv/cloudflare_api/openapi.json` and used to align request/response shapes.\n\n\u003e NOTE: This library is still evolving and does not yet cover every Cloudflare\n\u003e endpoint. It aims to stay close to the official API and avoid heavy\n\u003e abstraction.\n\n## Installation\n\nAdd `cloudflare_api` to your `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:cloudflare_api, \"~\u003e 0.6.0\"}\n  ]\nend\n```\n\nThen fetch dependencies:\n\n```bash\nmix deps.get\n```\n\n### Supported Elixir / OTP\n\nThe project targets Elixir `~\u003e 1.12` and above, and a reasonably recent OTP release.\nIf you are on a newer Elixir (1.13+), it should work as long as your OTP\nversion is supported by that Elixir release.\n\n## Getting Started\n\nConfigure your Cloudflare API token via an environment variable (recommended):\n\n```bash\nexport CLOUDFLARE_API_TOKEN=\"your-cloudflare-api-token\"\n```\n\nCreate a client and list zones:\n\n```elixir\niex\u003e client = CloudflareApi.client(System.fetch_env!(\"CLOUDFLARE_API_TOKEN\"))\niex\u003e {:ok, zones} = CloudflareApi.Zones.list(client, nil)\niex\u003e Enum.map(zones, \u0026 \u00261[\"name\"])\n[\"example.com\", \"another.example.com\"]\n```\n\nWork with DNS records:\n\n```elixir\n# List DNS records for a zone\niex\u003e zone_id = \"your-zone-id\"\niex\u003e {:ok, records} = CloudflareApi.DnsRecords.list(client, zone_id, name: \"www.example.com\")\n\n# Create a new A record\niex\u003e {:ok, record} =\n...\u003e   CloudflareApi.DnsRecords.create(\n...\u003e     client,\n...\u003e     zone_id,\n...\u003e     \"www.example.com\",\n...\u003e     \"203.0.113.10\"\n...\u003e   )\n\n# Update an existing record\niex\u003e {:ok, updated} =\n...\u003e   CloudflareApi.DnsRecords.update(\n...\u003e     client,\n...\u003e     zone_id,\n...\u003e     record.id,\n...\u003e     record.hostname,\n...\u003e     \"203.0.113.11\"\n...\u003e   )\n\n# Delete a record\niex\u003e CloudflareApi.DnsRecords.delete(client, zone_id, record.id)\n{:ok, \"record-id\"}\n```\n\n## Build \u0026 Development\n\nInstall dependencies:\n\n```bash\nmix deps.get\n```\n\nCompile:\n\n```bash\nmix compile\n```\n\nStart an interactive shell with the app loaded:\n\n```bash\niex -S mix\n```\n\n### Working with the OpenAPI spec\n\nTo refresh the vendored OpenAPI schema from the official Cloudflare\nrepository:\n\n```bash\nmix fetch_openapi\n# or explicitly:\nmix cloudflare_api.fetch_openapi\n```\n\nThis writes the schema to `priv/cloudflare_api/openapi.json`.\n\n## Testing \u0026 Quality Checks\n\nRun the test suite:\n\n```bash\nmix test\n```\n\nFormat the code (and verify formatting):\n\n```bash\nmix format\nmix format --check-formatted\n```\n\nRun Credo (static analysis) in dev or test:\n\n```bash\nmix credo\n```\n\nRun Dialyzer (if you have PLT caches set up):\n\n```bash\nmix dialyzer --plt          # If haven't run before or after changes\nmix dialyzer --plt --force  # After changing Elixir/OTP versions or dependencies\nmix dialyzer\n```\n\nGenerate docs:\n\n```bash\nmix docs\n```\n\n## Contributing\n\nContributions are welcome. Before opening a pull request:\n\n- Read `AGENTS.md` for contributor and tooling guidelines.\n- Add or update tests for any new behavior; avoid real Cloudflare network\n  calls in tests (use `Tesla.Mock` instead).\n- Run `mix test` and `mix format` locally.\n- Add a short note under the `[unreleased]` section in `CHANGELOG.md` for any\n  user‑visible change (including new docs or endpoints).\n\n## Publishing to Hex.pm\n\nThese are general steps for publishing `cloudflare_api` to\n[hex.pm](https://hex.pm/). You only need to do this if you are a maintainer\nwith publishing rights.\n\n1. **Ensure Hex tooling is installed**\n\n   ```bash\n   mix local.hex\n   mix local.rebar\n   ```\n\n2. **Bump the version**\n\n   - Update `@version` in `mix.exs`.\n   - Update any version references in `README.md` (Installation section).\n   - Optionally add or update a `CHANGELOG` entry.\n\n3. **Run checks**\n\n   ```bash\n   mix deps.get\n   mix test\n   mix credo\n   MIX_ENV=dev mix dialyzer     # optional but recommended\n   mix docs\n   ```\n\n4. **Build the Hex package**\n\n   ```bash\n   mix hex.build\n   ```\n\n5. **Authenticate with Hex (first time only)**\n\n   ```bash\n   mix hex.user register   # or: mix hex.user auth\n   ```\n\n6. **Publish to Hex**\n\n   ```bash\n   mix hex.publish\n   # Answer the prompts to confirm publishing\n   ```\n\n7. **Tag and push the release (optional but recommended)**\n\n   ```bash\n   git tag v0.2.4          # example\n   git push origin v0.2.4\n   ```\n\nOnce published, docs will be available at:\n\n\u003chttps://hexdocs.pm/cloudflare_api\u003e\n\nand the package page at:\n\n\u003chttps://hex.pm/packages/cloudflare_api\u003e\n\n## Security Notes\n\n- Never commit real API tokens or secrets.\n- Prefer environment variables (for example `CLOUDFLARE_API_TOKEN`) or\n  other secure runtime configuration.\n- When adding examples, use obviously fake tokens and hostnames and keep\n  them out of library business logic.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffreedomben%2Fcloudflare_api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffreedomben%2Fcloudflare_api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffreedomben%2Fcloudflare_api/lists"}