Create Zone
Security
API Token
The preferred authorization scheme for interacting with the Cloudflare API. Create a token.
Example:
API Email + API Key
The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.
Example:
The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.
Example:
Accepted Permissions (at least one required)
Parameters
name: str
The domain name. Per RFC 1035 the overall zone name can be up to 253 characters, with each segment ("label") not exceeding 63 characters.
maxLength253
Create Zone
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)
zone = client.zones.create(
account={},
name="example.com",
)
print(zone.id){
"errors": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"messages": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"success": true,
"result": {
"id": "023e105f4ecef8ad9ca31a8372d0c353",
"account": {
"id": "023e105f4ecef8ad9ca31a8372d0c353",
"name": "Example Account Name"
},
"activated_on": "2014-01-02T00:01:00.12345Z",
"created_on": "2014-01-01T05:20:00.12345Z",
"development_mode": 7200,
"meta": {
"cdn_only": true,
"custom_certificate_quota": 1,
"dns_only": true,
"foundation_dns": true,
"page_rule_quota": 100,
"phishing_detected": false,
"step": 2
},
"modified_on": "2014-01-01T05:20:00.12345Z",
"name": "example.com",
"name_servers": [
"bob.ns.cloudflare.com",
"lola.ns.cloudflare.com"
],
"original_dnshost": "NameCheap",
"original_name_servers": [
"ns1.originaldnshost.com",
"ns2.originaldnshost.com"
],
"original_registrar": "GoDaddy",
"owner": {
"id": "023e105f4ecef8ad9ca31a8372d0c353",
"name": "Example Org",
"type": "organization"
},
"plan": {
"id": "023e105f4ecef8ad9ca31a8372d0c353",
"can_subscribe": false,
"currency": "USD",
"externally_managed": false,
"frequency": "monthly",
"is_subscribed": false,
"legacy_discount": false,
"legacy_id": "free",
"name": "Example Org",
"price": 10.99
},
"cname_suffix": "cdn.cloudflare.com",
"paused": true,
"permissions": [
"#worker:read"
],
"status": "active",
"tenant": {
"id": "023e105f4ecef8ad9ca31a8372d0c353",
"name": "Example Account Name"
},
"tenant_unit": {
"id": "023e105f4ecef8ad9ca31a8372d0c353"
},
"type": "full",
"vanity_name_servers": [
"ns1.example.com",
"ns2.example.com"
],
"verification_key": "284344499-1084221259"
}
}Returns Examples
{
"errors": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"messages": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"success": true,
"result": {
"id": "023e105f4ecef8ad9ca31a8372d0c353",
"account": {
"id": "023e105f4ecef8ad9ca31a8372d0c353",
"name": "Example Account Name"
},
"activated_on": "2014-01-02T00:01:00.12345Z",
"created_on": "2014-01-01T05:20:00.12345Z",
"development_mode": 7200,
"meta": {
"cdn_only": true,
"custom_certificate_quota": 1,
"dns_only": true,
"foundation_dns": true,
"page_rule_quota": 100,
"phishing_detected": false,
"step": 2
},
"modified_on": "2014-01-01T05:20:00.12345Z",
"name": "example.com",
"name_servers": [
"bob.ns.cloudflare.com",
"lola.ns.cloudflare.com"
],
"original_dnshost": "NameCheap",
"original_name_servers": [
"ns1.originaldnshost.com",
"ns2.originaldnshost.com"
],
"original_registrar": "GoDaddy",
"owner": {
"id": "023e105f4ecef8ad9ca31a8372d0c353",
"name": "Example Org",
"type": "organization"
},
"plan": {
"id": "023e105f4ecef8ad9ca31a8372d0c353",
"can_subscribe": false,
"currency": "USD",
"externally_managed": false,
"frequency": "monthly",
"is_subscribed": false,
"legacy_discount": false,
"legacy_id": "free",
"name": "Example Org",
"price": 10.99
},
"cname_suffix": "cdn.cloudflare.com",
"paused": true,
"permissions": [
"#worker:read"
],
"status": "active",
"tenant": {
"id": "023e105f4ecef8ad9ca31a8372d0c353",
"name": "Example Account Name"
},
"tenant_unit": {
"id": "023e105f4ecef8ad9ca31a8372d0c353"
},
"type": "full",
"vanity_name_servers": [
"ns1.example.com",
"ns2.example.com"
],
"verification_key": "284344499-1084221259"
}
}