Constructors
Constructor
new PolicyApi(transport):PolicyApi
Parameters
transport
Transport
Returns
PolicyApi
Methods
inEffect()
inEffect(The policy a request forcapability):Promise<PolicyInEffect>
capability must declare right now, and what
the request must carry: every fact the rules read, their types, the
signals bound to the Intent, and the signals that need a signed
approval. Maps to GET /policies/in-effect. Call it before every
request: an approved new version replaces the old one at once.
Throws AuthorizationError (403, code CAPABILITY_NOT_ALLOWED) when the
key may not invoke the capability, NotFoundError (404, code
CAPABILITY_NOT_BOUND) when no policy governs it, and ConflictError
(409, NO_APPROVED_POLICY_VERSION) or InternalServerError (503,
POLICY_VERSION_UNAVAILABLE) when every request for it is refused right
now. Do not send a request in any of those cases.
Parameters
capability
string
Returns
Promise<PolicyInEffect>
validate()
validate(Confirms that a policy (name + version) is loadable by the Runtime. POST /policies/validate does not accept or check a policy document body — it only checks that policyRepository.load(policyId, policyVersion) succeeds (packages/api/src/routes/policies.ts). POST /policies/validate does not use the sharedpolicyId,policyVersion):Promise<PolicyValidationResult>
{error, code?}
envelope for 400 or 404: both are {valid, errors}, its own shape,
the caller’s answer, not an SDK-level failure — so those two
statuses are exempted from the default throw-on-error behavior. 401
is not exempted: it is generated by caller-auth middleware before
this route’s own handler ever runs, and does use the shared
envelope, identically to every other route. See
/api-reference/error-handling.
Parameters
policyId
string
policyVersion
string
Returns
Promise<PolicyValidationResult>
proposeChange()
proposeChange(Proposes a policy change. Maps to POST /policies///pending-changes. The API key must belong to a verified human (credential holder type USER).name,version,input):Promise<ProposedPolicyChange>
proposedContent.policyId
must equal name. Only one open proposal per name and version is
allowed; a second one fails with ConflictError.
Parameters
name
string
version
string
input
ProposePolicyChangeInput
Returns
Promise<ProposedPolicyChange>
listChanges()
listChanges(Lists policy changes for review, with the content in effect now next to the proposed content. Maps to GET /policies/pending-changes. The API key must belong to a verified human.status?):Promise<PolicyChangeForReview[]>
Parameters
status?
PendingPolicyChangeStatus
Only changes in this state. Omit for all.
Returns
Promise<PolicyChangeForReview[]>
approveChange()
approveChange(Approves a policy change, which then takes effect. Maps to POST /policies/pending-changes//approve. The API key must belong to a verified human with a registered step up key, who is not the proposer. MakependingPolicyChangeId,stepUpAuthorization):Promise<PendingPolicyChange>
stepUpAuthorization with signPolicyChangeStepUp() and action
“approve”; it is valid once, for 120 seconds by default.
Parameters
pendingPolicyChangeId
string
stepUpAuthorization
PolicyChangeStepUpAuthorization
Returns
Promise<PendingPolicyChange>
rejectChange()
rejectChange(Rejects a policy change. Maps to POST /policies/pending-changes//reject. Same caller rules as approveChange(); sign with action “reject”. A reason is required.pendingPolicyChangeId,rejectionReason,stepUpAuthorization):Promise<PendingPolicyChange>
Parameters
pendingPolicyChangeId
string
rejectionReason
string
stepUpAuthorization
PolicyChangeStepUpAuthorization
Returns
Promise<PendingPolicyChange>