HomeDev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunitySubmit a ticketLog In
GitHubNuGetDev CommunitySubmit a ticket


## Approval definitions

### Create an approval definition

This example shows the creation and saving of a definition:



### Update an approval definition

In this example, a definition is updated with a new reviewer in the second step. This reviewer can approve items in all languages using `CultureInfo.InvariantCulture`.



### Add a role to an approval definition (New in CMS UI 10.10.0)

In this example, a definition is updated with a new role reviewer in the first step. This role can approve items in the Swedish language.



### Delete an approval definition

This example deletes a definition using ID:



Note

A definition cannot be deleted if running approvals exist. All approval instances must be completed or aborted before deleting an approval definition.

### Get an approval definition

Gets a definition in a couple of different ways:



## Approvals

`IApprovalRepository` is the base interface for saving, deleting and listing approvals and their decisions. `IApprovalEngine` is built on top of `IApprovalRepository` to streamline the handling of approvals. Use the repository for listing approvals and use the engine for handling approvals. The engine also raises events that can be hooked up in `IApprovalEngineEvents`.

### Hook up events



### Start an approval

A content approval is not started by saving an approval but by saving a content item with `SaveAction.RequestApproval`. This automatically creates and saves a `ContentApproval` for this content item, if a definition can be resolved.



### Abort an approval

This deletes an approval and raises an aborted event:



### Make a decision

Use the engine to decide to approve or reject a step or the whole approval. There is a possibility to add an optional comment to explain the reason for the decision. If the decision finishes the approval (approves the last step or rejects a step), this comment is saved on the approval as `CompletedComment`.



There are also a number of more explicitly named extension methods to the engine that can be used, for example `ApproveStepAsync `and `ForceApproveAsync`.

### List approvals

Use the `GetAsync` / `GetItemsAsync` methods on `IApprovalRepository` to get specific approvals using ID or `ContentReference`:



The ListAsync method takes an `ApprovalQuery` / `ContentApprovalQuery` object which searches the approvals based on the specified query-data and returns a filtered list. This list can be paged.

This example gets all approvals in review for a user based on a specific definition.



This example list decisions made for an approval: