Skip to content
Start here

Add domain

POST/accounts/{account_id}/pages/projects/{project_name}/domains

Add a new domain for the Pages project.

Security
API Token

The preferred authorization scheme for interacting with the Cloudflare API. Create a token.

Example:Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY
API Email + API Key

The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.

Example:X-Auth-Email: user@example.com

The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.

Example:X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194
Accepted Permissions (at least one required)
Pages Write
Path ParametersExpand Collapse
account_id: string

Identifier.

maxLength32
project_name: string

Name of the project.

Body ParametersJSONExpand Collapse
name: string

The domain name.

ReturnsExpand Collapse
errors: array of { code, message, documentation_url, source }
code: number
minimum1000
message: string
documentation_url: optional string
source: optional { pointer }
pointer: optional string
messages: array of { code, message, documentation_url, source }
code: number
minimum1000
message: string
documentation_url: optional string
source: optional { pointer }
pointer: optional string
result: { id, certificate_authority, created_on, 6 more }
id: string
certificate_authority: "google" or "lets_encrypt"
One of the following:
"google"
"lets_encrypt"
created_on: string
domain_id: string
name: string

The domain name.

status: "initializing" or "pending" or "active" or 3 more
One of the following:
"initializing"
"pending"
"active"
"deactivated"
"blocked"
"error"
validation_data: { method, status, error_message, 2 more }
method: "http" or "txt"
One of the following:
"http"
"txt"
status: "initializing" or "pending" or "active" or 2 more
One of the following:
"initializing"
"pending"
"active"
"deactivated"
"error"
error_message: optional string
txt_name: optional string
txt_value: optional string
verification_data: { status, error_message }
status: "pending" or "active" or "deactivated" or 2 more
One of the following:
"pending"
"active"
"deactivated"
"blocked"
"error"
error_message: optional string
zone_tag: string
success: true

Whether the API call was successful.

Add domain

curl https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/pages/projects/$PROJECT_NAME/domains \
    -H 'Content-Type: application/json' \
    -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
    -d '{
          "name": "this-is-my-domain-01.com"
        }'
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "result": {
    "id": "id",
    "certificate_authority": "lets_encrypt",
    "created_on": "created_on",
    "domain_id": "domain_id",
    "name": "this-is-my-domain-01.com",
    "status": "initializing",
    "validation_data": {
      "method": "http",
      "status": "initializing",
      "error_message": "error_message",
      "txt_name": "txt_name",
      "txt_value": "txt_value"
    },
    "verification_data": {
      "status": "pending",
      "error_message": "error_message"
    },
    "zone_tag": "zone_tag"
  },
  "success": true
}
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"
      }
    }
  ],
  "result": {
    "id": "id",
    "certificate_authority": "lets_encrypt",
    "created_on": "created_on",
    "domain_id": "domain_id",
    "name": "this-is-my-domain-01.com",
    "status": "initializing",
    "validation_data": {
      "method": "http",
      "status": "initializing",
      "error_message": "error_message",
      "txt_name": "txt_name",
      "txt_value": "txt_value"
    },
    "verification_data": {
      "status": "pending",
      "error_message": "error_message"
    },
    "zone_tag": "zone_tag"
  },
  "success": true
}