About Custom Policies
What is a custom policy?
Policies are used to define values that can be consumed by different services. Ledger has built-in policies
like access, labels or
status, for these policies the values will be validated and consumed by the ledger.
If you create a new schema that targets record policy you can create custom policies to store values which format won't be
validated by the ledger's API Schema.
Data validation will still be performed based on the schema you define, see About Schemas for more details
on how to create your schema.
POST /v2/policies
{
...,
data: {
handle: '...',
schema: 'my-schema',
values: [ ... ]
}
}These custom policies will exposed on the same endpoint as other policies, such as status or access. If you want to read only your policies, you can use a filter.
GET /v2/policies?data.schema=my-schemaExample use case
As policies with custom schemas can store data with defined structure in its values, they are useful for storing
ledger-level configuration. For example, studio uses a custom navigation schema defined for policies to configure
how the navigation menu will be rendered, this is how a navigation policy looks:
{
handle: 'my-custom-navigation',
schema: 'navigation',
values: [
{
header: 'Movements',
screen: 'intents',
},
{
header: 'Connections',
screen: 'bridges',
},
{
header: 'Security',
items: [
{
header: 'Members',
screen: 'members',
},
{
header: 'Security Policies',
screen: 'policies',
params: {
query: '?schema=access',
}
},
{
header: 'roles',
screen: 'circles',
}
],
}
],
}