Api referencePolicies

Set decision rules

Replaces this scope's rules and instructions only when ifVersion matches its current version.

PUT
/v1/policies/{kind}/{id}

Replaces this scope's rules and instructions only when ifVersion matches its current version. A stale version returns a conflict. More specific scopes replace defaults; atLeast floors remain binding. Identical rule matches in one scope are rejected.

Authorization

apiKey
headerx-api-key<token>

Path Parameters

kind*string
Value in"organization""mailbox""apiKey""agent"
id*string
Length1 <= length

Request Body

application/json
  1. body
presets*array<>
rules*array<|>
instructions?string|null
ifVersion*PolicyVersion
Range0 <= value <= 9007199254740991

Response Body

PolicySnapshot

application/json
  1. response
presets*array<>
rules*array<|>
instructions?string|null
version*PolicyVersion
Range0 <= value <= 9007199254740991
Example Request
import { createClient } from "samva";const samva = createClient({ apiKey: process.env.SAMVA_API_KEY! });const result = await samva.policies.setPolicy({  "kind": "organization",  "id": "example",  "presets": [    "example"  ],  "rules": [    {      "match": {},      "decide": "run"    }  ],  "ifVersion": 0});
Example Response
{  "presets": [    "string"  ],  "rules": [    {      "match": {        "kind": "send",        "effect": "read",        "channel": "sms",        "integration": "string",        "tool": "string",        "subject": "agent"      },      "note": "string",      "decide": "run",      "atLeast": null    }  ],  "instructions": "string",  "version": 0}