Learn how to:
- Enable and disable Basin Catalog on your buckets.
- Enable and disable table maintenance features like compaction and snapshot expiration.
- Authenticate Iceberg engines using API tokens.
Enabling the catalog on a bucket turns on the REST catalog interface and provides a Catalog URI and Warehouse name required by Iceberg clients. Once enabled, you can create and manage Iceberg tables in that bucket.
-
In the Cloudflare dashboard, go to the Basin Catalog page.
Go to Basin Catalog ↗ -
Select Create catalog.
-
Enter an R2 bucket name. You can select an existing bucket or enter a new bucket name to create one. If creating a new bucket, optionally select a location hint.
-
Select Next to configure table maintenance. Optionally enable compaction and snapshot expiration during setup.
-
Review your configuration and select Create catalog.
-
Once created, the catalog detail page displays your Catalog URI and Warehouse name.
To enable the catalog on your bucket, run the basin catalog enable command:
npx wrangler basin catalog enable <BUCKET_NAME>yarn wrangler basin catalog enable <BUCKET_NAME>pnpm wrangler basin catalog enable <BUCKET_NAME>After enabling, Wrangler will return your catalog URI and warehouse name.
When you disable the catalog on a bucket, it immediately stops serving requests from the catalog interface. Any Iceberg table references stored in that catalog become inaccessible until you re-enable it.
-
In the Cloudflare dashboard, go to the Basin Catalog page.
Go to Basin Catalog ↗ -
Select the catalog you want to disable.
-
Go to the Settings tab and scroll to the Disable section.
-
Select Disable and confirm.
To disable the catalog on your bucket, run the basin catalog disable command:
npx wrangler basin catalog disable <BUCKET_NAME>yarn wrangler basin catalog disable <BUCKET_NAME>pnpm wrangler basin catalog disable <BUCKET_NAME>Compaction improves query performance by combining the many small files created during data ingestion into fewer, larger files according to the set target file size. For more information about compaction and why it is valuable, refer to About compaction.
-
In the Cloudflare dashboard, go to the Basin Catalog page.
Go to Basin Catalog ↗ -
Select the catalog you want to enable compaction on.
-
Go to the Settings tab and scroll to the Table Maintenance section.
-
Select Enable or Edit next to compaction.
-
Toggle compaction on and optionally set a target file size. The default is 128 MB.
-
Select Save.
To enable the compaction on your catalog, run the basin catalog compaction enable command:
Enable catalog-level compaction:
npx wrangler basin catalog compaction enable <BUCKET_NAME> --target-size 128 --token <API_TOKEN>yarn wrangler basin catalog compaction enable <BUCKET_NAME> --target-size 128 --token <API_TOKEN>pnpm wrangler basin catalog compaction enable <BUCKET_NAME> --target-size 128 --token <API_TOKEN>Enable compaction for a specific table:
npx wrangler basin catalog compaction enable <BUCKET_NAME> <NAMESPACE> <TABLE> --target-size 128yarn wrangler basin catalog compaction enable <BUCKET_NAME> <NAMESPACE> <TABLE> --target-size 128pnpm wrangler basin catalog compaction enable <BUCKET_NAME> <NAMESPACE> <TABLE> --target-size 128Once enabled, compaction applies retroactively to all existing tables (for catalog-level compaction) or the specified table (for table-level compaction).
Disabling compaction will prevent the process from running for all tables (catalog level) or a specific table (table level). You can re-enable it at any time.
-
In the Cloudflare dashboard, go to the Basin Catalog page.
Go to Basin Catalog ↗ -
Select the catalog you want to disable compaction on.
-
Go to the Settings tab and scroll to the Table Maintenance section.
-
Select Edit next to compaction.
-
Toggle compaction off.
-
Select Save.
To disable the compaction on your catalog, run the basin catalog compaction disable command:
Disable catalog-level compaction:
npx wrangler basin catalog compaction disable <BUCKET_NAME>yarn wrangler basin catalog compaction disable <BUCKET_NAME>pnpm wrangler basin catalog compaction disable <BUCKET_NAME>Disable compaction for a specific table:
npx wrangler basin catalog compaction disable <BUCKET_NAME> <NAMESPACE> <TABLE>yarn wrangler basin catalog compaction disable <BUCKET_NAME> <NAMESPACE> <TABLE>pnpm wrangler basin catalog compaction disable <BUCKET_NAME> <NAMESPACE> <TABLE>Snapshot expiration automatically removes old table snapshots and any unreferenced data files to reduce metadata overhead and storage costs. You can configure:
- Max snapshot age - Snapshots older than this duration are expired. Specify a value followed by a unit (
dfor days,hfor hours,mfor minutes,sfor seconds). For example,7dexpires snapshots older than 7 days. - Min snapshots to keep - The minimum number of snapshots to retain, regardless of age.
-
In the Cloudflare dashboard, go to the Basin Catalog page.
Go to Basin Catalog ↗ -
Select the catalog you want to enable snapshot expiration on.
-
Go to the Settings tab and scroll to the Table Maintenance section.
-
Select Enable or Edit next to snapshot expiration.
-
Toggle snapshot expiration on.
-
Set the Max snapshot age and Min snapshots to keep values.
-
Select Save.
To enable snapshot expiration on your catalog, run the basin catalog snapshot-expiration enable command:
Enable catalog-level snapshot expiration:
npx wrangler basin catalog snapshot-expiration enable <BUCKET_NAME> --token <API_TOKEN> --older-than-days 7 --retain-last 10yarn wrangler basin catalog snapshot-expiration enable <BUCKET_NAME> --token <API_TOKEN> --older-than-days 7 --retain-last 10pnpm wrangler basin catalog snapshot-expiration enable <BUCKET_NAME> --token <API_TOKEN> --older-than-days 7 --retain-last 10Enable snapshot expiration for a specific table:
npx wrangler basin catalog snapshot-expiration enable <BUCKET_NAME> <NAMESPACE> <TABLE> --older-than-days 2 --retain-last 5yarn wrangler basin catalog snapshot-expiration enable <BUCKET_NAME> <NAMESPACE> <TABLE> --older-than-days 2 --retain-last 5pnpm wrangler basin catalog snapshot-expiration enable <BUCKET_NAME> <NAMESPACE> <TABLE> --older-than-days 2 --retain-last 5Disabling snapshot expiration prevents the process from running for all tables (catalog level) or a specific table (table level). You can re-enable snapshot expiration at any time.
-
In the Cloudflare dashboard, go to the Basin Catalog page.
Go to Basin Catalog ↗ -
Select the catalog you want to disable snapshot expiration on.
-
Go to the Settings tab and scroll to the Table Maintenance section.
-
Select Edit next to snapshot expiration.
-
Toggle snapshot expiration off.
-
Select Save.
Disable catalog-level snapshot expiration:
npx wrangler basin catalog snapshot-expiration disable <BUCKET_NAME>yarn wrangler basin catalog snapshot-expiration disable <BUCKET_NAME>pnpm wrangler basin catalog snapshot-expiration disable <BUCKET_NAME>Disable snapshot expiration for a specific table:
npx wrangler basin catalog snapshot-expiration disable <BUCKET_NAME> <NAMESPACE> <TABLE>yarn wrangler basin catalog snapshot-expiration disable <BUCKET_NAME> <NAMESPACE> <TABLE>pnpm wrangler basin catalog snapshot-expiration disable <BUCKET_NAME> <NAMESPACE> <TABLE>To connect your Iceberg engine to Basin Catalog, you must provide a Cloudflare API token with both Basin Catalog permissions and R2 storage permissions. Iceberg engines interact with Basin Catalog to perform table operations. The catalog also provides engines with SigV4 credentials, which are required to access the underlying data files stored in R2.
Basin Catalog supports both read-only and read-write tokens:
- Read-only operations (for example, listing namespaces, loading tables, and querying data) require a token with read access to Basin Catalog and R2 storage.
- Write operations (for example, creating or dropping tables and committing transactions) require a token with read and write access to Basin Catalog and R2 storage.
Use a read-only token for query engines and clients that only read data (such as Basin SQL, DuckDB, or PyIceberg readers), and a read-write token for engines and pipelines that create tables or write data.
Create an R2 API token with the permissions matching your workload:
- Admin Read & Write — for engines and pipelines that read and write data. Includes read and write access to both Basin Catalog and R2 storage.
- Admin Read only — for query engines and clients that only read data. Includes read access to both Basin Catalog and R2 storage.
Providing the resulting token value to your Iceberg engine gives it the ability to manage catalog metadata and handle data operations (reads or writes to R2).
To create an API token programmatically for use with Basin Catalog, you need to specify both Basin Catalog and R2 storage permission groups in your Access Policy.
Use read and write permission groups for engines and pipelines that create tables or write data:
[
{
"id": "f267e341f3dd4697bd3b9f71dd96247f",
"effect": "allow",
"resources": {
"com.cloudflare.edge.r2.bucket.4793d734c0b8e484dfc37ec392b5fa8a_default_my-bucket": "*",
"com.cloudflare.edge.r2.bucket.4793d734c0b8e484dfc37ec392b5fa8a_eu_my-eu-bucket": "*"
},
"permission_groups": [
{
"id": "d229766a2f7f4d299f20eaa8c9b1fde9",
"name": "Workers R2 Data Catalog Write"
},
{
"id": "2efd5506f9c8494dacb1fa10a3e7d5b6",
"name": "Workers R2 Storage Bucket Item Write"
}
]
}
]Use read permission groups for query engines and clients that only read data:
[
{
"id": "f267e341f3dd4697bd3b9f71dd96247f",
"effect": "allow",
"resources": {
"com.cloudflare.edge.r2.bucket.4793d734c0b8e484dfc37ec392b5fa8a_default_my-bucket": "*",
"com.cloudflare.edge.r2.bucket.4793d734c0b8e484dfc37ec392b5fa8a_eu_my-eu-bucket": "*"
},
"permission_groups": [
{
"id": "45db74139a62490b9b60eb7c4f34994b",
"name": "Workers R2 Data Catalog Read"
},
{
"id": "6a018a9f2fc74eb6b293b0c548f38b39",
"name": "Workers R2 Storage Bucket Item Read"
}
]
}
]To learn more about how to create API tokens for Basin Catalog using the API, including required permission groups and usage examples, refer to the Create API tokens via API documentation.
Local Uploads writes object data to a nearby location, then asynchronously copies it to your bucket. Data is queryable immediately and remains strongly consistent. This can significantly improve latency of writes from Apache Iceberg clients outside of the region of the respective Basin Catalog bucket.
To enable R2 Local Uploads, you can use the following Wrangler command:
npx wrangler r2 bucket local-uploads enable <BUCKET_NAME>yarn wrangler r2 bucket local-uploads enable <BUCKET_NAME>pnpm wrangler r2 bucket local-uploads enable <BUCKET_NAME>- Basin Catalog does not currently support R2 buckets in a non-default jurisdiction.