Policies: API examples

Contract-derived requests, potential responses and API links for policies.

Generated from the public OpenAPI. Examples illustrate the contract and are not live results. Use your assigned gateway, credentials and identifiers. The snippets do not execute automatically.

Use Node.js 22 or later. Copy the setup below into an .mjs file, set QFP_BASE_URL and QFP_ACCESS_TOKEN, then append the operation snippet you need. No repository checkout or downloaded client is required. Keep secrets in your backend and persist each write key and body before sending.

Request setup

const required = name => {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name} before running this example`);
  return value;
};
const baseUrl = required('QFP_BASE_URL').replace(/\/$/, '');
if (!/^https:\/\//.test(baseUrl)) throw new Error('Use your assigned HTTPS gateway');
const token = required('QFP_ACCESS_TOKEN');
const segment = value => encodeURIComponent(value);
async function request(method, path, body, key) {
  const headers = { Authorization: `Bearer ${token}`, 'API-Version': '1.0.0', Accept: 'application/json' };
  if (key) headers['Idempotency-Key'] = key;
  const multipart = body instanceof FormData;
  if (body !== undefined && !multipart) headers['Content-Type'] = 'application/json';
  const response = await fetch(baseUrl + path, {
    method, headers, body: body === undefined ? undefined : multipart ? body : JSON.stringify(body),
    signal: AbortSignal.timeout(30_000), redirect: 'error',
  });
  const text = await response.text();
  const data = text && response.headers.get('content-type')?.includes('json') ? JSON.parse(text) : text || null;
  if (!response.ok) {
    const error = new Error(`HTTP ${response.status}`);
    Object.assign(error, { status: response.status, data, headers: response.headers });
    throw error;
  }
  return { status: response.status, data };
}

listPolicies

List policies. API Reference · Integration guide

GET /api/policies

ParameterLocationRequired
API-VersionheaderYes
statusqueryNo
ruleTypequeryNo
pagequeryNo
sizequeryNo
const body = undefined;
const result = await request('GET', '/api/policies', body, undefined);
console.log(result.status, result.data);

Replace angle-bracket placeholders before calling. Persist any idempotency key with the business instruction.

Potential responses

Documented statuses: 200, 401.

For CSV/download endpoints, the response may be text rather than JSON. The request helper preserves that distinction.

createPolicy

Create a policy. API Reference · Integration guide

POST /api/policies

ParameterLocationRequired
API-VersionheaderYes

Request body: namedApprover

{
  "name": "Named-approver check",
  "description": "Routes every EUR payment over 100 to a named approver",
  "ruleType": "approval",
  "templateKey": "PAYMENT_TIERS",
  "timeToLive": 30,
  "timeToLiveUnit": "D",
  "content": {
    "appliesTo": {
      "action": "FIAT_PAYMENT"
    },
    "hitPolicy": "collect",
    "rules": [
      {
        "id": "needs-approval",
        "when": {
          "amount": ">= 100.00",
          "assetId": "== EUR"
        },
        "emit": {
          "autoApproval": false,
          "step": 0,
          "approver": "#mlro",
          "reason": "Over 100 EUR"
        }
      }
    ],
    "defaults": {
      "unmatched": "AUTO_APPROVE"
    }
  }
}
const body = {
  "name": "Named-approver check",
  "description": "Routes every EUR payment over 100 to a named approver",
  "ruleType": "approval",
  "templateKey": "PAYMENT_TIERS",
  "timeToLive": 30,
  "timeToLiveUnit": "D",
  "content": {
    "appliesTo": {
      "action": "FIAT_PAYMENT"
    },
    "hitPolicy": "collect",
    "rules": [
      {
        "id": "needs-approval",
        "when": {
          "amount": ">= 100.00",
          "assetId": "== EUR"
        },
        "emit": {
          "autoApproval": false,
          "step": 0,
          "approver": "#mlro",
          "reason": "Over 100 EUR"
        }
      }
    ],
    "defaults": {
      "unmatched": "AUTO_APPROVE"
    }
  }
};
const result = await request('POST', '/api/policies', body, undefined);
console.log(result.status, result.data);

Replace angle-bracket placeholders before calling. Persist any idempotency key with the business instruction.

Potential responses

Documented statuses: 201, 400, 401, 404.

For CSV/download endpoints, the response may be text rather than JSON. The request helper preserves that distinction.

getPolicy

Get a policy. API Reference · Integration guide

GET /api/policies/{policyId}

ParameterLocationRequired
policyIdpathYes
API-VersionheaderYes
const body = undefined;
const result = await request('GET', '/api/policies/' + encodeURIComponent('<policyId>') + '', body, undefined);
console.log(result.status, result.data);

Replace angle-bracket placeholders before calling. Persist any idempotency key with the business instruction.

Potential responses

Documented statuses: 200, 401, 404.

For CSV/download endpoints, the response may be text rather than JSON. The request helper preserves that distinction.

updatePolicy

Update policy name and description. API Reference · Integration guide

PATCH /api/policies/{policyId}

ParameterLocationRequired
policyIdpathYes
API-VersionheaderYes

A request body is required. The contract supplies no JSON body example here; use the linked schema. Multipart requests need FormData/file fields, not a JSON body.

const body = requestBody;
const result = await request('PATCH', '/api/policies/' + encodeURIComponent('<policyId>') + '', body, undefined);
console.log(result.status, result.data);

Replace angle-bracket placeholders before calling. Persist any idempotency key with the business instruction.

Potential responses

Documented statuses: 200, 400, 401, 404.

For CSV/download endpoints, the response may be text rather than JSON. The request helper preserves that distinction.

listPolicyVersions

List versions. API Reference · Integration guide

GET /api/policies/{policyId}/versions

ParameterLocationRequired
policyIdpathYes
API-VersionheaderYes
pagequeryNo
sizequeryNo
const body = undefined;
const result = await request('GET', '/api/policies/' + encodeURIComponent('<policyId>') + '/versions', body, undefined);
console.log(result.status, result.data);

Replace angle-bracket placeholders before calling. Persist any idempotency key with the business instruction.

Potential responses

Documented statuses: 200, 401, 404.

For CSV/download endpoints, the response may be text rather than JSON. The request helper preserves that distinction.

createPolicyVersion

Create a new version. API Reference · Integration guide

POST /api/policies/{policyId}/versions

ParameterLocationRequired
policyIdpathYes
API-VersionheaderYes

A request body is required. The contract supplies no JSON body example here; use the linked schema. Multipart requests need FormData/file fields, not a JSON body.

const body = requestBody;
const result = await request('POST', '/api/policies/' + encodeURIComponent('<policyId>') + '/versions', body, undefined);
console.log(result.status, result.data);

Replace angle-bracket placeholders before calling. Persist any idempotency key with the business instruction.

Potential responses

Documented statuses: 201, 400, 401, 404.

For CSV/download endpoints, the response may be text rather than JSON. The request helper preserves that distinction.

activatePolicy

Activate a policy. API Reference · Integration guide

POST /api/policies/{policyId}/activate

ParameterLocationRequired
API-VersionheaderYes
policyIdpathYes
const body = undefined;
const result = await request('POST', '/api/policies/' + encodeURIComponent('<policyId>') + '/activate', body, undefined);
console.log(result.status, result.data);

Replace angle-bracket placeholders before calling. Persist any idempotency key with the business instruction.

Potential responses

Documented statuses: 200, 401, 404, 409.

For CSV/download endpoints, the response may be text rather than JSON. The request helper preserves that distinction.

setCurrentVersion

Set the current version. API Reference · Integration guide

PUT /api/policies/{policyId}/current-version

ParameterLocationRequired
API-VersionheaderYes
policyIdpathYes

A request body is required. The contract supplies no JSON body example here; use the linked schema. Multipart requests need FormData/file fields, not a JSON body.

const body = requestBody;
const result = await request('PUT', '/api/policies/' + encodeURIComponent('<policyId>') + '/current-version', body, undefined);
console.log(result.status, result.data);

Replace angle-bracket placeholders before calling. Persist any idempotency key with the business instruction.

Potential responses

Documented statuses: 200, 400, 401, 404.

For CSV/download endpoints, the response may be text rather than JSON. The request helper preserves that distinction.

archivePolicy

Archive a policy. API Reference · Integration guide

POST /api/policies/{policyId}/archive

ParameterLocationRequired
API-VersionheaderYes
policyIdpathYes
const body = undefined;
const result = await request('POST', '/api/policies/' + encodeURIComponent('<policyId>') + '/archive', body, undefined);
console.log(result.status, result.data);

Replace angle-bracket placeholders before calling. Persist any idempotency key with the business instruction.

Potential responses

Documented statuses: 200, 401, 404.

For CSV/download endpoints, the response may be text rather than JSON. The request helper preserves that distinction.


Did this page help you?