Skip to content
Docs
Policy Schemas

Get a policy schema by version

Get a policy schema by version

client.zones.policySchemas.retrieve(stringversion, PolicySchemaRetrieveParams { zone_id, format, xAPIVersion, xClientRequestID } params, RequestOptionsoptions?): SchemaVersionWithZoneInfo { is_default }
GET/zones/{zone_id}/policy-schemas/{version}

Get a policy schema by version

ParametersExpand Collapse
version: string
params: PolicySchemaRetrieveParams { zone_id, format, xAPIVersion, xClientRequestID }
zone_id: string

Path param: The zone identifier

format?: "cedar" | "json"

Query param: Schema representation format. cedar returns human-readable Cedar syntax in cedar_schema, json returns Cedar JSON schema object in cedar_schema_json.

Accepts one of the following:
"cedar"
"json"
xAPIVersion?: string

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

xClientRequestID?: string

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

formatuuid
ReturnsExpand Collapse
SchemaVersionWithZoneInfo extends SchemaVersion { created_at, status, updated_at, 5 more } { is_default }

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.

is_default: boolean

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.

Get a policy schema by version

import KeycardAPI from '@keycardai/api';

const client = new KeycardAPI();

const schemaVersionWithZoneInfo = await client.zones.policySchemas.retrieve('version', {
  zone_id: 'zone_id',
});

console.log(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
}