Policy v2 (experimental)
Record a policy version 2 decision
Evaluates the approved policy version 2 for the capability and records the decision as evidence.
POST
/
v2
/
decisions
cURL
# EXPERIMENTAL Policy version 2. Available only where the deployment enables it.
# Record a decision
curl -X POST "https://parmana-api-real.vercel.app/v2/decisions" \
-H "Authorization: Bearer $PARMANA_API_KEY" \
-H "Content-Type: application/json" \
-d '{"capability":"erp:pay-invoice","transactionId":"txn-1001","target":"invoice-7781","parameters":{"amount":1200},"signals":{"vendorVerified":true}}'// EXPERIMENTAL Policy version 2. Available only where the deployment enables it.
// Record a decision
const response = await fetch(
"https://parmana-api-real.vercel.app/v2/decisions",
{
method: "POST",
headers: {
Authorization: `Bearer ${process.env.PARMANA_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
capability: "erp:pay-invoice",
transactionId: "txn-1001",
target: "invoice-7781",
parameters: { amount: 1200 },
signals: { vendorVerified: true },
}),
},
);
console.log(response.status, await response.text());# EXPERIMENTAL Policy version 2. Available only where the deployment enables it.
# Record a decision
import json
import os
import urllib.request
BODY = r'{"capability":"erp:pay-invoice","transactionId":"txn-1001","target":"invoice-7781","parameters":{"amount":1200},"signals":{"vendorVerified":true}}'
def main() -> None:
request = urllib.request.Request(
"https://parmana-api-real.vercel.app/v2/decisions",
data=json.dumps(json.loads(BODY)).encode("utf-8"),
method="POST",
headers={
"Authorization": "Bearer " + os.environ.get("PARMANA_API_KEY", ""),
"Content-Type": "application/json",
},
)
with urllib.request.urlopen(request) as response:
print(response.status, response.read().decode("utf-8"))
if __name__ == "__main__":
main()const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
capability: 'erp:pay-invoice',
transactionId: '<string>',
target: '<string>',
parameters: {},
signals: {},
approvals: {}
})
};
fetch('https://parmana-api-real.vercel.app/v2/decisions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://parmana-api-real.vercel.app/v2/decisions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'capability' => 'erp:pay-invoice',
'transactionId' => '<string>',
'target' => '<string>',
'parameters' => [
],
'signals' => [
],
'approvals' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://parmana-api-real.vercel.app/v2/decisions"
payload := strings.NewReader("{\n \"capability\": \"erp:pay-invoice\",\n \"transactionId\": \"<string>\",\n \"target\": \"<string>\",\n \"parameters\": {},\n \"signals\": {},\n \"approvals\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://parmana-api-real.vercel.app/v2/decisions")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"capability\": \"erp:pay-invoice\",\n \"transactionId\": \"<string>\",\n \"target\": \"<string>\",\n \"parameters\": {},\n \"signals\": {},\n \"approvals\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://parmana-api-real.vercel.app/v2/decisions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"capability\": \"erp:pay-invoice\",\n \"transactionId\": \"<string>\",\n \"target\": \"<string>\",\n \"parameters\": {},\n \"signals\": {},\n \"approvals\": {}\n}"
response = http.request(request)
puts response.read_body{
"outcome": "APPROVE",
"reason": "The policy approves this request.",
"tier": "tier-1",
"recordId": "record-123",
"released": false
}Authorizations
Caller API key issued by scripts/generate-api-key.ts. Sent as Authorization: Bearer . Verified against a stored SHA-256 hash in constant time by packages/api/src/auth/StaticKeyAuthenticator.ts. Required on every route not listed as exempt in this document's top-level description. See /api-reference/authentication.
Body
application/json
Response
The recorded decision.
⌘I
cURL
# EXPERIMENTAL Policy version 2. Available only where the deployment enables it.
# Record a decision
curl -X POST "https://parmana-api-real.vercel.app/v2/decisions" \
-H "Authorization: Bearer $PARMANA_API_KEY" \
-H "Content-Type: application/json" \
-d '{"capability":"erp:pay-invoice","transactionId":"txn-1001","target":"invoice-7781","parameters":{"amount":1200},"signals":{"vendorVerified":true}}'// EXPERIMENTAL Policy version 2. Available only where the deployment enables it.
// Record a decision
const response = await fetch(
"https://parmana-api-real.vercel.app/v2/decisions",
{
method: "POST",
headers: {
Authorization: `Bearer ${process.env.PARMANA_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
capability: "erp:pay-invoice",
transactionId: "txn-1001",
target: "invoice-7781",
parameters: { amount: 1200 },
signals: { vendorVerified: true },
}),
},
);
console.log(response.status, await response.text());# EXPERIMENTAL Policy version 2. Available only where the deployment enables it.
# Record a decision
import json
import os
import urllib.request
BODY = r'{"capability":"erp:pay-invoice","transactionId":"txn-1001","target":"invoice-7781","parameters":{"amount":1200},"signals":{"vendorVerified":true}}'
def main() -> None:
request = urllib.request.Request(
"https://parmana-api-real.vercel.app/v2/decisions",
data=json.dumps(json.loads(BODY)).encode("utf-8"),
method="POST",
headers={
"Authorization": "Bearer " + os.environ.get("PARMANA_API_KEY", ""),
"Content-Type": "application/json",
},
)
with urllib.request.urlopen(request) as response:
print(response.status, response.read().decode("utf-8"))
if __name__ == "__main__":
main()const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
capability: 'erp:pay-invoice',
transactionId: '<string>',
target: '<string>',
parameters: {},
signals: {},
approvals: {}
})
};
fetch('https://parmana-api-real.vercel.app/v2/decisions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://parmana-api-real.vercel.app/v2/decisions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'capability' => 'erp:pay-invoice',
'transactionId' => '<string>',
'target' => '<string>',
'parameters' => [
],
'signals' => [
],
'approvals' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://parmana-api-real.vercel.app/v2/decisions"
payload := strings.NewReader("{\n \"capability\": \"erp:pay-invoice\",\n \"transactionId\": \"<string>\",\n \"target\": \"<string>\",\n \"parameters\": {},\n \"signals\": {},\n \"approvals\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://parmana-api-real.vercel.app/v2/decisions")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"capability\": \"erp:pay-invoice\",\n \"transactionId\": \"<string>\",\n \"target\": \"<string>\",\n \"parameters\": {},\n \"signals\": {},\n \"approvals\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://parmana-api-real.vercel.app/v2/decisions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"capability\": \"erp:pay-invoice\",\n \"transactionId\": \"<string>\",\n \"target\": \"<string>\",\n \"parameters\": {},\n \"signals\": {},\n \"approvals\": {}\n}"
response = http.request(request)
puts response.read_body{
"outcome": "APPROVE",
"reason": "The policy approves this request.",
"tier": "tier-1",
"recordId": "record-123",
"released": false
}