Skip to content
API Reference

Create a new policy

client.zones.policies.create(stringzoneID, PolicyCreateParams { name, description, xAPIVersion, xClientRequestID } params, RequestOptionsoptions?): Policy { id, created_at, created_by, 9 more }
POST/zones/{zone_id}/policies

Create a new policy

ParametersExpand Collapse
zoneID: string
params: PolicyCreateParams { name, description, xAPIVersion, xClientRequestID }
name: string

Body param

description?: string

Body param

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
Policy { id, created_at, created_by, 9 more }
id: string
created_at: string
formatdate-time
created_by: string
name: string
owner_type: "platform" | "customer"

Who manages this policy:

  • "platform" — managed by the Keycard platform (system policies).
  • "customer" — managed by the tenant (custom policies).
Accepts one of the following:
"platform"
"customer"
updated_at: string
formatdate-time
zone_id: string
archived_at?: string | null
formatdate-time
description?: string | null
latest_version?: number | null

Human-readable version number of the latest version (e.g., 1, 2, 3)

latest_version_id?: string | null
updated_by?: string | null

Create a new policy

import KeycardAPI from '@keycardai/api';

const client = new KeycardAPI();

const policy = await client.zones.policies.create('zone_id', { name: 'name' });

console.log(policy.id);
{
  "id": "id",
  "created_at": "2019-12-27T18:11:19.117Z",
  "created_by": "created_by",
  "name": "name",
  "owner_type": "platform",
  "updated_at": "2019-12-27T18:11:19.117Z",
  "zone_id": "zone_id",
  "archived_at": "2019-12-27T18:11:19.117Z",
  "description": "description",
  "latest_version": 0,
  "latest_version_id": "latest_version_id",
  "updated_by": "updated_by"
}
Returns Examples
{
  "id": "id",
  "created_at": "2019-12-27T18:11:19.117Z",
  "created_by": "created_by",
  "name": "name",
  "owner_type": "platform",
  "updated_at": "2019-12-27T18:11:19.117Z",
  "zone_id": "zone_id",
  "archived_at": "2019-12-27T18:11:19.117Z",
  "description": "description",
  "latest_version": 0,
  "latest_version_id": "latest_version_id",
  "updated_by": "updated_by"
}