---
title: Create Zero Trust account
---

[Skip to content](#_top)

[API Reference](https://developers.cloudflare.com/api/go)

[Zero Trust](https://developers.cloudflare.com/api/go/resources/zero_trust)

[Gateway](https://developers.cloudflare.com/api/go/resources/zero_trust/subresources/gateway)

Copy Markdown

Open in **Claude**Open in **ChatGPT**Open in **Cursor**

---

**Copy Markdown****View as Markdown**

# Create Zero Trust account

client.ZeroTrust.Gateway.New(ctx, body) (\*[GatewayNewResponse](<https://developers.cloudflare.com/api/go/resources/zero_trust#(resource)%20zero_trust.gateway%20%3E%20(model)%20GatewayNewResponse%20%3E%20(schema)>), error)

POST/accounts/{account\_id}/gateway

Create a Zero Trust account for an existing Cloudflare account.

##### Security

<details>

<summary>API Token</summary>



The preferred authorization scheme for interacting with the Cloudflare API. <a href="https://developers.cloudflare.com/fundamentals/api/get-started/create-token/">Create a token</a>.

**Example:**<code>Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY</code>

</details>

<details>

<summary>API Email + API Key</summary>



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

**Example:**<code>X-Auth-Email: user@example.com</code>

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

**Example:**<code>X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194</code>

</details>

##### Accepted Permissions (at least one required)

`Zero Trust Write`

##### ParametersExpand Collapse

<details>

<summary>

body GatewayNewParams

</summary>

AccountID param.Field\[string]

Specify the Cloudflare account identifier.

<a href="#(resource)%20zero_trust.gateway%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20account_id">Link to this property</a>

</details>

[Link to this property](<#(resource)%20zero_trust.gateway%20%3E%20(method)%20create%20%3E%20(params)%20default>)

##### ReturnsExpand Collapse

<details>

<summary>

type GatewayNewResponse struct{…}

</summary>

ID stringOptional

Specify the Cloudflare account ID.

maxLength32

<a href="#(resource)%20zero_trust.gateway%20%3E%20(model)%20GatewayNewResponse%20%3E%20(schema)%20%3E%20(property)%20id">Link to this property</a>

GatewayTag stringOptional

Specify the gateway internal ID.

maxLength32

<a href="#(resource)%20zero_trust.gateway%20%3E%20(model)%20GatewayNewResponse%20%3E%20(schema)%20%3E%20(property)%20gateway_tag">Link to this property</a>

ProviderName stringOptional

Specify the provider name (usually Cloudflare).

<a href="#(resource)%20zero_trust.gateway%20%3E%20(model)%20GatewayNewResponse%20%3E%20(schema)%20%3E%20(property)%20provider_name">Link to this property</a>

</details>

[Link to this property](<#(resource)%20zero_trust.gateway%20%3E%20(model)%20GatewayNewResponse%20%3E%20(schema)>)

### Create Zero Trust account

Go

HTTPTypeScriptPythonGoTerraform

```
package main

import (
  "context"
  "fmt"

  "github.com/cloudflare/cloudflare-go"
  "github.com/cloudflare/cloudflare-go/option"
  "github.com/cloudflare/cloudflare-go/zero_trust"
)

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  gateway, err := client.ZeroTrust.Gateway.New(context.TODO(), zero_trust.GatewayNewParams{
    AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"),
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", gateway.ID)
}
```

200 example

```
{
  "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": "699d98642c564d2e855e9661899b7252",
    "gateway_tag": "f174e90afafe4643bbbc4a0ed4fc8415",
    "provider_name": "Cloudflare"
  }
}
```

##### Returns Examples

200 example

```
{
  "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": "699d98642c564d2e855e9661899b7252",
    "gateway_tag": "f174e90afafe4643bbbc4a0ed4fc8415",
    "provider_name": "Cloudflare"
  }
}
```