Skip to content

Validate Policy Exists

Check whether a policy identified by module and function name is deployed and callable. This endpoint does not execute any policy logic; it only confirms that the policy is registered and in a runnable state.

Use this endpoint to pre-flight an evaluation request, to verify a deployment succeeded, or to implement health checks for critical policies.

Endpoint

POST /api/v1/policies/validate

Required Role

MEMBER

Headers

HeaderValueRequired
AuthorizationBearer <token>Yes
Content-Typeapplication/jsonYes
X-Tenant-IDTenant identifier stringYes

Request Body

json
{
  "policyModule": "string",
  "policyFunction": "string"
}
FieldTypeRequiredDescription
policyModulestringYesFully-qualified module name to look up (e.g. "Loan.Approval").
policyFunctionstringYesFunction name within the module to validate (e.g. "isEligible").

Response Body

json
{
  "valid": true,
  "error": null
}
FieldTypeDescription
validbooleantrue if the policy exists, is deployed, and can be called. false if it is not found, is in a failed deployment state, or is otherwise uncallable.
errorstring | nullDescriptive reason why valid is false; null when valid is true.

HTTP Status Codes

StatusMeaning
200 OKValidation check completed. A 200 response with valid: false means the policy does not exist or is not callable — this is a successful check, not an HTTP error.
400 Bad RequestMalformed request body or missing required fields.
401 UnauthorizedMissing or invalid bearer token.
403 ForbiddenToken is valid but the caller lacks the MEMBER role.
500 Internal Server ErrorUnexpected engine failure prevented the check from completing.

Examples

bash
curl -X POST https://policy.aster-lang.dev/api/v1/policies/validate \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -H "X-Tenant-ID: acme-corp" \
  -d '{
    "policyModule": "Loan.Approval",
    "policyFunction": "isEligible"
  }'
js
const response = await fetch(
  'https://policy.aster-lang.dev/api/v1/policies/validate',
  {
    method: 'POST',
    headers: {
      Authorization: 'Bearer <token>',
      'Content-Type': 'application/json',
      'X-Tenant-ID': 'acme-corp',
    },
    body: JSON.stringify({
      policyModule: 'Loan.Approval',
      policyFunction: 'isEligible',
    }),
  }
);

const data = await response.json();

if (!data.valid) {
  console.error('Policy is not callable:', data.error);
} else {
  console.log('Policy is ready for evaluation.');
}

Example Response (Policy Found)

json
{
  "valid": true,
  "error": null
}

Example Response (Policy Not Found)

json
{
  "valid": false,
  "error": "No deployed policy found for module 'Loan.Approval', function 'isEligible'"
}

Example Response (Policy in Failed State)

json
{
  "valid": false,
  "error": "Policy 'Loan.Approval.isEligible' exists but failed to load: compilation error in version 3"
}

Released under the MIT License.