Skip to content
Start here

Create IP profile

client.ZeroTrust.Devices.IPProfiles.New(ctx, params) (*IPProfile, error)
POST/accounts/{account_id}/devices/ip-profiles

Creates a WARP Device IP profile. Currently, only IPv4 Device subnets can be associated.

Security

API Token

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

Example:Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY
Accepted Permissions (at least one required)
Zero Trust Write
ParametersExpand Collapse
params DeviceIPProfileNewParams
AccountID param.Field[string]

Path param

Match param.Field[string]

Body param: The wirefilter expression to match registrations. Available values: "identity.name", "identity.email", "identity.groups.id", "identity.groups.name", "identity.groups.email", "identity.saml_attributes".

maxLength10000
Name param.Field[string]

Body param: A user-friendly name for the Device IP profile.

Precedence param.Field[int64]

Body param: The precedence of the Device IP profile. Lower values indicate higher precedence. Device IP profile will be evaluated in ascending order of this field.

SubnetID param.Field[string]

Body param: The ID of the Subnet.

Description param.Field[string]optional

Body param: An optional description of the Device IP profile.

Enabled param.Field[bool]optional

Body param: Whether the Device IP profile will be applied to matching devices.

ReturnsExpand Collapse
type IPProfile struct{…}
ID string

The ID of the Device IP profile.

CreatedAt string

The RFC3339Nano timestamp when the Device IP profile was created.

Description string

An optional description of the Device IP profile.

Enabled bool

Whether the Device IP profile is enabled.

Match string

The wirefilter expression to match registrations. Available values: "identity.name", "identity.email", "identity.groups.id", "identity.groups.name", "identity.groups.email", "identity.saml_attributes".

maxLength10000
Name string

A user-friendly name for the Device IP profile.

Precedence int64

The precedence of the Device IP profile. Lower values indicate higher precedence. Device IP profile will be evaluated in ascending order of this field.

SubnetID string

The ID of the Subnet.

UpdatedAt string

The RFC3339Nano timestamp when the Device IP profile was last updated.

Create IP profile

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"),
  )
  ipProfile, err := client.ZeroTrust.Devices.IPProfiles.New(context.TODO(), zero_trust.DeviceIPProfileNewParams{
    AccountID: cloudflare.F("account_id"),
    Match: cloudflare.F(`identity.email == "test@cloudflare.com"`),
    Name: cloudflare.F("IPv4 Cloudflare Source IPs"),
    Precedence: cloudflare.F(int64(100)),
    SubnetID: cloudflare.F("b70ff985-a4ef-4643-bbbc-4a0ed4fc8415"),
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", ipProfile.ID)
}
{
  "errors": [
    {
      "code": 0,
      "message": "message"
    }
  ],
  "messages": [
    {
      "code": 0,
      "message": "message"
    }
  ],
  "result": {
    "id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415",
    "created_at": "2025-02-14T13:17:00.123456789Z",
    "description": "example comment",
    "enabled": true,
    "match": "identity.email == \"test@cloudflare.com\"",
    "name": "IPv4 Cloudflare Source IPs",
    "precedence": 100,
    "subnet_id": "b70ff985-a4ef-4643-bbbc-4a0ed4fc8415",
    "updated_at": "2025-02-14T13:17:00.123456789Z"
  },
  "success": true
}
Returns Examples
{
  "errors": [
    {
      "code": 0,
      "message": "message"
    }
  ],
  "messages": [
    {
      "code": 0,
      "message": "message"
    }
  ],
  "result": {
    "id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415",
    "created_at": "2025-02-14T13:17:00.123456789Z",
    "description": "example comment",
    "enabled": true,
    "match": "identity.email == \"test@cloudflare.com\"",
    "name": "IPv4 Cloudflare Source IPs",
    "precedence": 100,
    "subnet_id": "b70ff985-a4ef-4643-bbbc-4a0ed4fc8415",
    "updated_at": "2025-02-14T13:17:00.123456789Z"
  },
  "success": true
}