Skip to content

Get Policy Version History

Retrieve the full version history for a policy identified by its internal policy ID. Each entry in the response represents a distinct version that has been saved, including which version is currently active.

Endpoint

GET /api/v1/policies/{policyId}/versions

Required Role

MEMBER

Path Parameters

ParameterTypeRequiredDescription
policyIdstringYesThe internal UUID of the policy resource. Obtain this value from the policy management API or the Aster dashboard.

Headers

HeaderValueRequired
AuthorizationBearer <token>Yes
X-Tenant-IDTenant identifier stringYes

Request Body

None.

Response Body

An array of version objects ordered by version number in ascending order.

json
[
  {
    "version": 1,
    "active": false,
    "moduleName": "string",
    "functionName": "string",
    "createdAt": "ISO8601",
    "createdBy": "string",
    "notes": "string"
  }
]
FieldTypeDescription
versionnumberMonotonically increasing integer version number. Version 1 is the initial deployment.
activebooleantrue for exactly one entry in the array — the version currently serving evaluation requests.
moduleNamestringThe CNL module name declared in this version of the policy source.
functionNamestringThe primary function name for this version of the policy.
createdAtstringISO 8601 timestamp recording when this version was saved (e.g. "2024-03-15T09:30:00Z").
createdBystringIdentifier (email or user ID) of the principal who created this version.
notesstringOptional human-readable deployment notes attached at the time of version creation. Empty string if no notes were provided.

HTTP Status Codes

StatusMeaning
200 OKVersion history returned. Empty array means the policy exists but has no recorded versions.
401 UnauthorizedMissing or invalid bearer token.
403 ForbiddenToken is valid but the caller lacks the MEMBER role.
404 Not FoundNo policy found for the given policyId within the tenant.
500 Internal Server ErrorUnexpected engine failure.

Examples

bash
curl -X GET \
  "https://policy.aster-lang.dev/api/v1/policies/d4e5f6a7-b8c9-4d0e-1f2a-3b4c5d6e7f8a/versions" \
  -H "Authorization: Bearer <token>" \
  -H "X-Tenant-ID: acme-corp"
js
const policyId = 'd4e5f6a7-b8c9-4d0e-1f2a-3b4c5d6e7f8a';

const response = await fetch(
  `https://policy.aster-lang.dev/api/v1/policies/${policyId}/versions`,
  {
    method: 'GET',
    headers: {
      Authorization: 'Bearer <token>',
      'X-Tenant-ID': 'acme-corp',
    },
  }
);

const versions = await response.json();

const active = versions.find((v) => v.active);
console.log(`Active version: ${active?.version}`);

versions.forEach((v) => {
  const marker = v.active ? ' [ACTIVE]' : '';
  console.log(`v${v.version}${marker} — ${v.createdAt} by ${v.createdBy}`);
});

Example Response

json
[
  {
    "version": 1,
    "active": false,
    "moduleName": "Loan.Approval",
    "functionName": "isEligible",
    "createdAt": "2024-01-10T08:00:00Z",
    "createdBy": "alice@acme-corp.com",
    "notes": "Initial deployment"
  },
  {
    "version": 2,
    "active": false,
    "moduleName": "Loan.Approval",
    "functionName": "isEligible",
    "createdAt": "2024-02-20T14:15:00Z",
    "createdBy": "bob@acme-corp.com",
    "notes": "Raised credit score threshold from 680 to 700"
  },
  {
    "version": 3,
    "active": true,
    "moduleName": "Loan.Approval",
    "functionName": "isEligible",
    "createdAt": "2024-03-15T09:30:00Z",
    "createdBy": "alice@acme-corp.com",
    "notes": "Added income floor requirement per compliance review CR-204"
  }
]

Released under the MIT License.