Policies API
This REST API documentation outlines methods for managing policies on the Aporia Policies Catalog. It includes detailed descriptions of endpoints for creating, updating, and deleting policies, complete with example requests and responses.
Get All Policy Templates
Endpoint: GET https://guardrails.aporia.com/api/v1/policies
Headers:
Content-Type
:application/json
Authorization
:Bearer
+ Your copied Aporia API key
Response Fields:
The response type is a list
. each object in the list contains the following fields:
The policy type.
The policy category.
The policy default_name.
Description of the policy.
Response JSON Example:
Get Specific Policy Template
Endpoint: GET https://guardrails.aporia.com/api/v1/policies/{template_type}
Headers:
Content-Type
:application/json
Authorization
:Bearer
+ Your copied Aporia API key
Path Parameters::
The type identifier of the policy template to retrieve.
Response Fields:
The policy type.
The policy category.
The policy default name.
Description of the policy.
Response JSON Example:
Create Custom Policy
Endpoint: POST https://guardrails.aporia.com/api/v1/policies/custom_policy
Headers:
Content-Type
:application/json
Authorization
:Bearer
+ Your copied Aporia API key
Request Fields:
The name of the custom policy.
The target of the policy - either prompt
or response
.
There are 2 configuration modes for custom policy - simple
and advanced
, each with it’s own condition config.
For simple mode, the following parameters must be passed:
- evaluation_instructions - Instructions that define how the policy should evaluate inputs.
- modality - Defines whether instructions trigger a violation if they evaluate to
TRUE
orFALSE
.
For advanced mode, the following parameters must be passed:
- system_prompt - The system prompt that will be passed to the LLM
- top_p - Top-P sampling probability, between 0 and 1. Defaults to 1.
- temperature - Sampling temperature to use, between 0 and 2. Defaults to 1.
- modality - Defines whether instructions trigger a violation if they evaluate to
TRUE
orFALSE
.
Response Fields:
The custom policy type identifier.
The policy category, typically ‘custom’ for user-defined policies.
The default name for the policy template, as provided in the request.
A description of the policy based on the evaluation instructions.
Response JSON Example:
Edit Custom Policy
Endpoint: PUT https://guardrails.aporia.com/api/v1/policies/custom_policy/{custom_policy_type}
Headers:
Content-Type
:application/json
Authorization
:Bearer
+ Your copied Aporia API key
Path Parameters:
The custom policy type identifier to update. Returned from Create Custom Policy
endpoint.
Request Fields:
The name of the custom policy.
The target of the policy - either prompt
or response
.
There are 2 configuration modes for custom policy - simple
and advanced
, each with it’s own condition config.
For simple mode, the following parameters must be passed:
- evaluation_instructions - Instructions that define how the policy should evaluate inputs.
- modality - Defines whether instructions trigger a violation if they evaluate to
TRUE
orFALSE
.
For advanced mode, the following parameters must be passed:
- system_prompt - The system prompt that will be passed to the LLM
- top_p - Top-P sampling probability, between 0 and 1. Defaults to 1.
- temperature - Sampling temperature to use, between 0 and 2. Defaults to 1.
- modality - Defines whether instructions trigger a violation if they evaluate to
TRUE
orFALSE
.
Response Fields:
The custom policy type identifier.
The policy category, typically ‘custom’ for user-defined policies.
The default name for the policy template.
Updated description of the policy based on the new evaluation instructions.
Response JSON Example:
Delete Custom Policy
Endpoint: DELETE https://guardrails.aporia.com/api/v1/policies/custom_policy/{custom_policy_type}
Headers:
Content-Type
:application/json
Authorization
:Bearer
+ Your copied Aporia API key
Path Parameters:
The custom policy type identifier to delete. Returned from Create Custom Policy
endpoint.
Response:
200
OK
Create policies for multiple projects
Endpoint: PUT https://guardrails.aporia.com/api/v1/policies/
Headers:
Content-Type
:application/json
Authorization
:Bearer
+ Your copied Aporia API key
Request Fields:
The project ids to create the policies in
A list of policies to create. List of policies, each Policy has the following attributes: policy_type
(string), priority
(int), condition
(dict), action
(dict).