SDK reference · Node SDK

prov.mandate.policies.publishVersion

prov.mandate.policies.publishVersion in Node SDK. S5: make a saved version live now, or (trialDays, 1 to 30, Pro and up; agent, checkout and capture policies) run it as a trial first.

Signature

prov.mandate.policies.publishVersion(version: number, opts?: { trialDays?: number; idempotencyKey?: string } & DomainOpts): Promise<PolicyVersion>

Parameters

versionnumberRequired
opts{ trialDays?: number; idempotencyKey?: string } & DomainOpts

Request fields

Idempotency-Keystringheader
Retry a create safely: the same key + request returns the stored response (24 h, per caller).
versionintegerpathRequired
The version number.
trial_daysinteger
Run the draft silently next to the live version for this many days instead of publishing now.
acknowledge_rate_changeboolean
Publish although this version's latest backtest moves Challenge plus Reject by more than 5 points against the live version. Without it that publish answers 409 policy_rate_change_unacknowledged with the change.

Returns

Promise<PolicyVersion> The live version, or the trial run when trial_days is set.

HTTP operation

POST /v1/mandate/policies/versions/{version}/publish: Publish a policy version

Errors

Example

const step1 = await (await fetch(`${process.env.PROVENANCE_API}/v1/mandate/policies/versions`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({
    "note": "big orders go to admins, then the owner",
    "document": {
      "rules": [
        {
          "id": "notify-finance",
          "label": "Orders over $10,000",
          "when": [
            {
              "fact": "transaction_amount",
              "op": "gt",
              "value": 10000
            }
          ],
          "require": {
            "notify": {
              "to": [
                "role:admins"
              ]
            }
          }
        },
        {
          "id": "big-orders",
          "label": "Orders over $5,000",
          "when": {
            "match": "all",
            "items": [
              {
                "fact": "transaction_amount",
                "op": "gt",
                "value": 5000
              },
              {
                "match": "any",
                "conditions": [
                  {
                    "fact": "action_type",
                    "op": "eq",
                    "value": "wire"
                  },
                  {
                    "fact": "field",
                    "path": "metadata.cost_center",
                    "op": "eq",
                    "value": "research"
                  }
                ]
              }
            ]
          },
          "require": {
            "approval": true,
            "route": {
              "steps": [
                {
                  "to": [
                    "role:admins"
                  ],
                  "after": "2h"
                },
                {
                  "to": [
                    "role:owners"
                  ],
                  "after": "1d"
                }
              ]
            }
          }
        }
      ]
    }
  }),
})).json();
const policyVersion = step1.version;
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/mandate/policies/versions/${policyVersion}/publish`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5" },
})).json();

Was this page helpful? Send us feedback

LLM? Read llms.txt.