Skip to content
Docs

List policy versions in a policy set version

List policy versions in a policy set version

client.Zones.PolicySets.Versions.ListPolicies(ctx, versionID, params) (*ZonePolicySetVersionListPoliciesResponse, error)
GET/zones/{zone_id}/policy-sets/{policy_set_id}/versions/{version_id}/policies

Returns the policy versions referenced by this policy set version's manifest as a paginated list.

ParametersExpand Collapse
versionID string
params ZonePolicySetVersionListPoliciesParams
ZoneID param.Field[string]

Path param: The zone identifier

PolicySetID param.Field[string]

Path param: The policy set identifier

After param.Field[string]optional

Query param: Cursor for forward pagination. Returned in Pagination.after_cursor. Mutually exclusive with before.

minLength1
maxLength255
Before param.Field[string]optional

Query param: Cursor for backward pagination. Returned in Pagination.before_cursor. Mutually exclusive with after.

minLength1
maxLength255
Expand param.Field[[]string]optional

Query param: Opt-in to additional response fields. Repeatable; matches the expand[] convention used across the Keycard API.

const ZonePolicySetVersionListPoliciesParamsExpandTotalCount ZonePolicySetVersionListPoliciesParamsExpand = "total_count"

Query param: Narrows which Cedar representation the response includes. When omitted, both cedar_json and cedar_raw are populated. Pass json to receive only cedar_json, or cedar to receive only cedar_raw. Callers that don't care about payload size can skip this parameter.

const ZonePolicySetVersionListPoliciesParamsFormatCedar ZonePolicySetVersionListPoliciesParamsFormat = "cedar"
const ZonePolicySetVersionListPoliciesParamsFormatJson ZonePolicySetVersionListPoliciesParamsFormat = "json"
Limit param.Field[int64]optional

Query param: Maximum number of items to return per page.

minimum1
maximum100

Query param: Sort direction. Default is desc (newest first).

const ZonePolicySetVersionListPoliciesParamsOrderAsc ZonePolicySetVersionListPoliciesParamsOrder = "asc"
const ZonePolicySetVersionListPoliciesParamsOrderDesc ZonePolicySetVersionListPoliciesParamsOrder = "desc"

Query param: Field to sort by.

const ZonePolicySetVersionListPoliciesParamsSortCreatedAt ZonePolicySetVersionListPoliciesParamsSort = "created_at"
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 ZonePolicySetVersionListPoliciesResponse 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.

List policy versions in a policy set version

package main

import (
  "context"
  "fmt"

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

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

  )
  response, err := client.Zones.PolicySets.Versions.ListPolicies(
    context.TODO(),
    "version_id",
    keycard.ZonePolicySetVersionListPoliciesParams{
      ZoneID: "zone_id",
      PolicySetID: "policy_set_id",
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", response.Items)
}
{
  "items": [
    {
      "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"
    }
  ],
  "pagination": {
    "after_cursor": "x",
    "before_cursor": "x",
    "total_count": 0
  }
}
Returns Examples
{
  "items": [
    {
      "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"
    }
  ],
  "pagination": {
    "after_cursor": "x",
    "before_cursor": "x",
    "total_count": 0
  }
}