Skip to content
API Reference

Create a new policy set

client.Zones.PolicySets.New(ctx, zoneID, params) (*PolicySetWithBinding, error)
POST/zones/{zone_id}/policy-sets

Creates an unbound policy set. Use updatePolicySet to bind after creating a version.

ParametersExpand Collapse
zoneID string
params ZonePolicySetNewParams
Name param.Field[string]

Body param

ScopeType param.Field[ZonePolicySetNewParamsScopeType]optional

Body param: The scope at which this policy set applies:

  • "zone" — applies to all requests in the zone.
  • "resource" — scoped to a specific resource.
  • "user" — scoped to a specific user.
  • "session" — scoped to a specific session.
const ZonePolicySetNewParamsScopeTypeZone ZonePolicySetNewParamsScopeType = "zone"
const ZonePolicySetNewParamsScopeTypeResource ZonePolicySetNewParamsScopeType = "resource"
const ZonePolicySetNewParamsScopeTypeUser ZonePolicySetNewParamsScopeType = "user"
const ZonePolicySetNewParamsScopeTypeSession ZonePolicySetNewParamsScopeType = "session"
XAPIVersion param.Field[string]optional

Header param: API version header (date-based, e.g. 2026-02-01)

XClientRequestID param.Field[string]optional

Header param: Unique request identifier specified by the originating caller and passed along by proxies.

formatuuid
ReturnsExpand Collapse
type PolicySetWithBinding struct{…}
Active booloptional

Whether this policy set is currently bound to a scope

ActiveVersion int64optional

Human-readable version number of the active version (e.g., 1, 2, 3)

ActiveVersionID stringoptional

Public ID of the currently active (bound) version

Mode stringoptional
Accepts one of the following:
const PolicySetWithBindingModeActive PolicySetWithBindingMode = "active"
const PolicySetWithBindingModeShadow PolicySetWithBindingMode = "shadow"
ScopeTargetID stringoptional

Create a new policy set

package main

import (
  "context"
  "fmt"

  "github.com/keycardai/keycard-go"
)

func main() {
  client := keycard.NewClient(

  )
  policySetWithBinding, err := client.Zones.PolicySets.New(
    context.TODO(),
    "zone_id",
    keycard.ZonePolicySetNewParams{
      Name: "name",
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", policySetWithBinding)
}
{
  "id": "id",
  "created_at": "2019-12-27T18:11:19.117Z",
  "created_by": "created_by",
  "name": "name",
  "owner_type": "platform",
  "scope_type": "zone",
  "updated_at": "2019-12-27T18:11:19.117Z",
  "zone_id": "zone_id",
  "archived_at": "2019-12-27T18:11:19.117Z",
  "latest_version": 0,
  "latest_version_id": "latest_version_id",
  "updated_by": "updated_by",
  "active": true,
  "active_version": 0,
  "active_version_id": "active_version_id",
  "mode": "active",
  "scope_target_id": "scope_target_id"
}
Returns Examples
{
  "id": "id",
  "created_at": "2019-12-27T18:11:19.117Z",
  "created_by": "created_by",
  "name": "name",
  "owner_type": "platform",
  "scope_type": "zone",
  "updated_at": "2019-12-27T18:11:19.117Z",
  "zone_id": "zone_id",
  "archived_at": "2019-12-27T18:11:19.117Z",
  "latest_version": 0,
  "latest_version_id": "latest_version_id",
  "updated_by": "updated_by",
  "active": true,
  "active_version": 0,
  "active_version_id": "active_version_id",
  "mode": "active",
  "scope_target_id": "scope_target_id"
}