Skip to content
Docs
Versions

Create a new immutable policy version

Create a new immutable policy version

client.Zones.Policies.Versions.New(ctx, policyID, params) (*PolicyVersion, error)
POST/zones/{zone_id}/policies/{policy_id}/versions

Create a new immutable policy version

ParametersExpand Collapse
policyID string
params ZonePolicyVersionNewParams
ZoneID param.Field[string]

Path param: The zone identifier

SchemaVersion param.Field[string]

Body param: Schema version to validate this policy against. Must not be archived.

CedarJson param.Field[any]optional

Body param: Cedar policy in JSON representation. Mutually exclusive with cedar_raw.

CedarRaw param.Field[string]optional

Body param: Cedar policy in human-readable Cedar syntax. Mutually exclusive with cedar_json.

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 PolicyVersion struct{…}
ID string
CreatedAt Time
formatdate-time
CreatedBy string
OwnerType PolicyVersionOwnerType

Who manages this policy version:

  • "platform" — managed by the Keycard platform (system policy versions).
  • "customer" — managed by the tenant (custom policy versions).
Accepts one of the following:
const PolicyVersionOwnerTypePlatform PolicyVersionOwnerType = "platform"
const PolicyVersionOwnerTypeCustomer PolicyVersionOwnerType = "customer"
PolicyID string
SchemaVersion string

Schema version this policy was validated against when created.

Sha string

Hex-encoded content hash

Version int64
ZoneID string
ArchivedAt Timeoptional
formatdate-time
ArchivedBy stringoptional
CedarJson anyoptional

Cedar policy in JSON representation. Populated by default and when format=json is passed; null when format=cedar narrows the response to the text representation only.

CedarRaw stringoptional

Cedar policy in human-readable syntax. Populated by default and when format=cedar is passed; null when format=json narrows the response to the JSON representation only.

Create a new immutable policy version

package main

import (
  "context"
  "fmt"

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

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

  )
  policyVersion, err := client.Zones.Policies.Versions.New(
    context.TODO(),
    "policy_id",
    keycard.ZonePolicyVersionNewParams{
      ZoneID: "zone_id",
      SchemaVersion: "schema_version",
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", policyVersion.ID)
}
{
  "id": "id",
  "created_at": "2019-12-27T18:11:19.117Z",
  "created_by": "created_by",
  "owner_type": "platform",
  "policy_id": "policy_id",
  "schema_version": "schema_version",
  "sha": "sha",
  "version": 0,
  "zone_id": "zone_id",
  "archived_at": "2019-12-27T18:11:19.117Z",
  "archived_by": "archived_by",
  "cedar_json": {},
  "cedar_raw": "cedar_raw"
}
Returns Examples
{
  "id": "id",
  "created_at": "2019-12-27T18:11:19.117Z",
  "created_by": "created_by",
  "owner_type": "platform",
  "policy_id": "policy_id",
  "schema_version": "schema_version",
  "sha": "sha",
  "version": 0,
  "zone_id": "zone_id",
  "archived_at": "2019-12-27T18:11:19.117Z",
  "archived_by": "archived_by",
  "cedar_json": {},
  "cedar_raw": "cedar_raw"
}