Creates a new zone (domain) in your Cloudflare account.
The zone is created in a pending state and must be activated by updating your domain’s nameservers to point to Cloudflare, or by completing the verification process for partial (CNAME) setups.
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)
Create Zone
package main
import (
"context"
"fmt"
"github.com/cloudflare/cloudflare-go"
"github.com/cloudflare/cloudflare-go/option"
"github.com/cloudflare/cloudflare-go/zones"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
)
zone, err := client.Zones.New(context.TODO(), zones.ZoneNewParams{
Account: cloudflare.F(zones.ZoneNewParamsAccount{
}),
Name: cloudflare.F("example.com"),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", 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"
}
}