Cloudflare::API

NAME

Cloudflare::API - Perl client for Cloudflare resource management

SYNOPSIS

use Cloudflare::API;

my $api=Cloudflare::API->new(
    token      => $ENV{'CLOUDFLARE_API_TOKEN'},
    account_id => $ENV{'CLOUDFLARE_ACCOUNT_ID'}
);

my $buckets=$api->r2()->list_buckets();
my $page=$api->r2()->list_buckets(full_response => 1);
my $zone=$api->zones()->get($zone_id);

DESCRIPTION

Cloudflare::API supplies a bearer-authenticated HTTP client and accessors for the resource modules below. It requires Perl 5.10 or later, HTTP::API::Core 1.01 or later, and HTTPS support through IO::Socket::SSL. Resource objects share the same client and transport. The module manages resources through Cloudflare's REST API; it does not build Worker projects or perform R2 object transfers.

An API token is required. Supply token to new() or set CLOUDFLARE_API_TOKEN. Account-scoped methods also need account_id or CLOUDFLARE_ACCOUNT_ID; account and zone lookups work without a default account ID. Use a token with the permissions required by the selected Cloudflare operations.

RESOURCE MODULES

Each accessor creates a resource object. Consult its own man page for arguments, return values, and service-specific limits.

METHODS

RETURN VALUES AND ERRORS

Named resource methods normally return the JSON result. Pass full_response => 1 to retain the full envelope, especially result_info on paginated lists. List filters are named arguments sent as query parameters. Exceptions from HTTP or transport failures remain HTTP::API::Core::Error objects; their decoded Cloudflare body is available through json(). A successful HTTP status with success: false throws Cloudflare::API::Error. Input validation errors throw plain Perl exceptions. No resource write is automatically rolled back.

SEE ALSO

Cloudflare API documentation, HTTP::API::Core, the resource module man pages above, and the cloudflare-api command.

AUTHOR

Andrew Speer andrew.speer@isolutions.com.au

LICENSE and COPYRIGHT

Copyright (c) 2026 Andrew Speer. This software is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.