Skip to content
API Reference

Set the default policy schema for a zone

client.Zones.PolicySchemas.SetDefault(ctx, version, params) (*SchemaVersionWithZoneInfo, error)
PATCH/zones/{zone_id}/policy-schemas/{version}

Set the default policy schema for a zone

ParametersExpand Collapse
version string
params ZonePolicySchemaSetDefaultParams
ZoneID param.Field[string]

Path param: The zone identifier

Body param.Field[any]optional

Body param

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 SchemaVersionWithZoneInfo struct{…}

A versioned Cedar schema that defines the entity model, actions, and context shape used for policy evaluation. The schema contains the valid entity types (User, Application, Resource), their attributes, and the allowed attribute values. See the Credentials API spec for a full reference of entity attributes and valid values.

IsDefault bool

Whether this is the zone's default schema. Clients use this to pre-select which schema to write policies against. Has no effect on evaluation.

Set the default policy schema for a zone

package main

import (
  "context"
  "fmt"

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

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

  )
  schemaVersionWithZoneInfo, err := client.Zones.PolicySchemas.SetDefault(
    context.TODO(),
    "version",
    keycard.ZonePolicySchemaSetDefaultParams{
      ZoneID: "zone_id",
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", schemaVersionWithZoneInfo)
}
{
  "created_at": "2019-12-27T18:11:19.117Z",
  "status": "active",
  "updated_at": "2019-12-27T18:11:19.117Z",
  "version": "version",
  "archived_at": "2019-12-27T18:11:19.117Z",
  "cedar_schema": "cedar_schema",
  "cedar_schema_json": {},
  "deprecated_at": "2019-12-27T18:11:19.117Z",
  "is_default": true
}
Returns Examples
{
  "created_at": "2019-12-27T18:11:19.117Z",
  "status": "active",
  "updated_at": "2019-12-27T18:11:19.117Z",
  "version": "version",
  "archived_at": "2019-12-27T18:11:19.117Z",
  "cedar_schema": "cedar_schema",
  "cedar_schema_json": {},
  "deprecated_at": "2019-12-27T18:11:19.117Z",
  "is_default": true
}