cloudflare_sdk
The base framework for the Cloudflare module suite. It provides named credential sets, resolution of account IDs and API tokens from settings.php, and a shared HTTP client factory that the other Cloudflare modules build on.
You usually install this module because another Cloudflare module (such as the Cloudflare AI Gateway) depends on it. On its own it adds a small admin screen for managing credential sets and the services those modules use; it makes no calls to Cloudflare by itself.
Features
- A credential set configuration entity, identified by a machine name and label only. Nothing account-specific is stored in configuration or the database.
- Account ID and API token resolved from settings.php, keyed by the credential set's machine name (
$settings['cloudflare']['credentials'][<id>]). - Support for multiple named credential sets, for example different tokens for different purposes or accounts.
- A pluggable credential resolver behind an interface, so the secret source can be changed without changing callers.
- A shared HTTP client factory that binds a base URI and default headers over Drupal core's HTTP client, with a typed exception.
Post-Installation
This module has no standalone features beyond credential management; you install it because another Cloudflare module needs it. After enabling it:
- Add a credential set at Configuration > Web services > Cloudflare credentials, giving it a machine name.
- Add its account ID and API token to settings.php, keyed by that machine name:
$settings['cloudflare']['credentials']['my_account'] = [ 'account_id' = 'your-account-id', 'token' = 'your-token', ];
Other Cloudflare modules then reference the credential set by its machine name.
Additional Requirements
This module requires no modules outside of Drupal core. To make a credential set useful you need a Cloudflare account and an API token. Install with Composer:
composer require drupal/cloudflare_sdkWhile the suite is in alpha, require it as drupal/cloudflare_sdk:^1.0@alpha (or set your project's minimum-stability to alpha) so the pre-stable releases resolve.
Recommended modules/libraries
This module exists to support the rest of the Cloudflare suite:
- Cloudflare AI Gateway, a client for the Cloudflare AI Gateway.
- Cloudflare AI Gateway Provider, which connects a gateway to the Drupal AI module.
Similar projects
The existing Cloudflare module integrates CDN and cache management. This module is narrower and reusable: a credential and HTTP foundation that keeps account IDs and tokens in settings.php and gives the other Cloudflare suite modules one shared credential model.
Supporting this Module
Issue reports, patches and feedback are welcome in the project's issue queue.
Community Documentation
For creating a Cloudflare API token, see Cloudflare's documentation at developers.cloudflare.com/fundamentals/api/get-started/create-token.