Create a device settings profile
client.ZeroTrust.Devices.Policies.Custom.New(ctx, params) (*SettingsPolicy, error)
POST/accounts/{account_id}/devices/policy
Creates a device settings profile to be applied to certain devices matching the criteria.
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 a device settings 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"),
)
settingsPolicy, err := client.ZeroTrust.Devices.Policies.Custom.New(context.TODO(), zero_trust.DevicePolicyCustomNewParams{
AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"),
Match: cloudflare.F(`identity.email == "test@cloudflare.com"`),
Name: cloudflare.F("Allow Developers"),
Precedence: cloudflare.F(100.000000),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", settingsPolicy.GatewayUniqueID)
}
{
"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": {
"allow_mode_switch": true,
"allow_updates": true,
"allowed_to_leave": true,
"auto_connect": 0,
"captive_portal": 180,
"default": false,
"description": "Policy for test teams.",
"disable_auto_fallback": true,
"enabled": true,
"exclude": [
{
"address": "192.0.2.0/24",
"description": "Exclude testing domains from the tunnel"
}
],
"exclude_office_ips": true,
"fallback_domains": [
{
"suffix": "example.com",
"description": "Domain bypass for local development",
"dns_server": [
"1.1.1.1"
]
}
],
"gateway_unique_id": "699d98642c564d2e855e9661899b7252",
"include": [
{
"address": "192.0.2.0/24",
"description": "Include testing domains in the tunnel"
}
],
"lan_allow_minutes": 30,
"lan_allow_subnet_size": 24,
"match": "identity.email == \"test@cloudflare.com\"",
"name": "Allow Developers",
"policy_id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415",
"precedence": 100,
"register_interface_ip_with_dns": true,
"sccm_vpn_boundary_support": false,
"service_mode_v2": {
"mode": "proxy",
"port": 3000
},
"support_url": "https://1.1.1.1/help",
"switch_locked": true,
"target_tests": [
{
"id": "id",
"name": "name"
}
],
"tunnel_protocol": "wireguard"
},
"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": {
"allow_mode_switch": true,
"allow_updates": true,
"allowed_to_leave": true,
"auto_connect": 0,
"captive_portal": 180,
"default": false,
"description": "Policy for test teams.",
"disable_auto_fallback": true,
"enabled": true,
"exclude": [
{
"address": "192.0.2.0/24",
"description": "Exclude testing domains from the tunnel"
}
],
"exclude_office_ips": true,
"fallback_domains": [
{
"suffix": "example.com",
"description": "Domain bypass for local development",
"dns_server": [
"1.1.1.1"
]
}
],
"gateway_unique_id": "699d98642c564d2e855e9661899b7252",
"include": [
{
"address": "192.0.2.0/24",
"description": "Include testing domains in the tunnel"
}
],
"lan_allow_minutes": 30,
"lan_allow_subnet_size": 24,
"match": "identity.email == \"test@cloudflare.com\"",
"name": "Allow Developers",
"policy_id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415",
"precedence": 100,
"register_interface_ip_with_dns": true,
"sccm_vpn_boundary_support": false,
"service_mode_v2": {
"mode": "proxy",
"port": 3000
},
"support_url": "https://1.1.1.1/help",
"switch_locked": true,
"target_tests": [
{
"id": "id",
"name": "name"
}
],
"tunnel_protocol": "wireguard"
},
"success": true
}