Skip to content
Docs

List policy versions in a policy set version

List policy versions in a policy set version

zones.policy_sets.versions.list_policies(strversion_id, VersionListPoliciesParams**kwargs) -> VersionListPoliciesResponse
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
zone_id: str
policy_set_id: str
version_id: str
after: Optional[str]

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

minLength1
maxLength255
before: Optional[str]

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

minLength1
maxLength255
expand: Optional[List[Literal["total_count"]]]

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

format: Optional[Literal["cedar", "json"]]

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.

Accepts one of the following:
"cedar"
"json"
limit: Optional[int]

Maximum number of items to return per page.

minimum1
maximum100
order: Optional[Literal["asc", "desc"]]

Sort direction. Default is desc (newest first).

Accepts one of the following:
"asc"
"desc"
sort: Optional[Literal["created_at"]]

Field to sort by.

x_api_version: Optional[str]
x_client_request_id: Optional[str]
formatuuid
ReturnsExpand Collapse
class VersionListPoliciesResponse:
items: List[PolicyVersion]
id: str
created_at: datetime
formatdate-time
created_by: str
owner_type: Literal["platform", "customer"]

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:
"platform"
"customer"
policy_id: str
schema_version: str

Schema version this policy was validated against when created.

sha: str

Hex-encoded content hash

version: int
zone_id: str
archived_at: Optional[datetime]
formatdate-time
archived_by: Optional[str]
cedar_json: Optional[object]

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.

cedar_raw: Optional[str]

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

from keycardai_api import KeycardAPI

client = KeycardAPI()
response = client.zones.policy_sets.versions.list_policies(
    version_id="version_id",
    zone_id="zone_id",
    policy_set_id="policy_set_id",
)
print(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
  }
}