Attach Custom Domain To Bucket
client.r2.buckets.domains.custom.create(stringbucketName, CustomCreateParams { account_id, domain, enabled, 4 more } params, RequestOptionsoptions?): CustomCreateResponse { domain, enabled, zoneId, 2 more }
POST/accounts/{account_id}/r2/buckets/{bucket_name}/domains/custom
Register a new custom domain for an existing R2 bucket.
Security
API Token
The preferred authorization scheme for interacting with the Cloudflare API. Create a token.
Example:
Attach Custom Domain To Bucket
import Cloudflare from 'cloudflare';
const client = new Cloudflare({
apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});
const custom = await client.r2.buckets.domains.custom.create('example-bucket', {
account_id: '023e105f4ecef8ad9ca31a8372d0c353',
domain: 'prefix.example-domain.com',
enabled: true,
zoneId: '36ca64a6d92827b8a6b90be344bb1bfd',
});
console.log(custom.domain);{
"errors": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"messages": [
"string"
],
"result": {
"domain": "example-domain.com",
"enabled": true,
"zoneId": "36ca64a6d92827b8a6b90be344bb1bfd",
"ciphers": [
"string"
],
"minTLS": "1.0"
},
"success": true
}Returns Examples
{
"errors": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"messages": [
"string"
],
"result": {
"domain": "example-domain.com",
"enabled": true,
"zoneId": "36ca64a6d92827b8a6b90be344bb1bfd",
"ciphers": [
"string"
],
"minTLS": "1.0"
},
"success": true
}