# IPendingApprovalStore

> Tracon documentation. Tracon is a .NET package family that adds a control
> plane on Microsoft Agent Framework, published as NuGet packages that run
> inside your own ASP.NET Core application.
>
> Page: https://tracon.dev/api/tracon.ipendingapprovalstore/
> Summary: IPendingApprovalStore: The store for pending approval requests.

<div class="api-provenance">Namespace Tracon · Assembly <code>Tracon.Abstractions.dll</code></div>

The store for pending approval requests.

```csharp
public interface IPendingApprovalStore
```

## Remarks

[IPendingApprovalStore.ListPendingAsync](/api/tracon.ipendingapprovalstore/#Tracon_IPendingApprovalStore_ListPendingAsync_System_Threading_CancellationToken_), [IPendingApprovalStore.GetAsync](/api/tracon.ipendingapprovalstore/#Tracon_IPendingApprovalStore_GetAsync_System_Guid_System_Threading_CancellationToken_) and [IPendingApprovalStore.DecideAsync](/api/tracon.ipendingapprovalstore/#Tracon_IPendingApprovalStore_DecideAsync_System_Guid_System_Boolean_System_String_System_DateTimeOffset_System_Threading_CancellationToken_)
are limited to the tenant of the caller (`ITenantContext`): the operator of one
tenant can neither see nor decide the approvals of another tenant.
[IPendingApprovalStore.ExpireAsync](/api/tracon.ipendingapprovalstore/#Tracon_IPendingApprovalStore_ExpireAsync_System_DateTimeOffset_System_Int32_System_Threading_CancellationToken_) is a maintenance operation and scans every tenant — the
same reason as `IRunStore.ClaimOrphanedRunsAsync`.

## Methods

### <a id="Tracon_IPendingApprovalStore_CreateAsync_Tracon_PendingApproval_System_Threading_CancellationToken_"></a> CreateAsync\(PendingApproval, CancellationToken\)

Creates a new pending approval request.

```csharp
ValueTask CreateAsync(PendingApproval approval, CancellationToken cancellationToken = default)
```

#### Parameters

`approval` [PendingApproval](/api/tracon.pendingapproval/)

The request to save. [PendingApproval.Status](/api/tracon.pendingapproval/#Tracon_PendingApproval_Status) must be [ApprovalStatus.Pending](/api/tracon.approvalstatus/).

`cancellationToken` [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken)

The cancellation token.

#### Returns

 [ValueTask](https://learn.microsoft.com/dotnet/api/system.threading.tasks.valuetask)

### <a id="Tracon_IPendingApprovalStore_DecideAsync_System_Guid_System_Boolean_System_String_System_DateTimeOffset_System_Threading_CancellationToken_"></a> DecideAsync\(Guid, bool, string, DateTimeOffset, CancellationToken\)

Writes a decision on a pending request.

```csharp
ValueTask<bool> DecideAsync(Guid id, bool approved, string decidedBy, DateTimeOffset decidedAt, CancellationToken cancellationToken = default)
```

#### Parameters

`id` [Guid](https://learn.microsoft.com/dotnet/api/system.guid)

The request id.

`approved` [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

Whether the request is approved.

`decidedBy` [string](https://learn.microsoft.com/dotnet/api/system.string)

The actor that made the decision.

`decidedAt` [DateTimeOffset](https://learn.microsoft.com/dotnet/api/system.datetimeoffset)

The time of the decision.

`cancellationToken` [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken)

The cancellation token.

#### Returns

 [ValueTask](https://learn.microsoft.com/dotnet/api/system.threading.tasks.valuetask\-1)<[bool](https://learn.microsoft.com/dotnet/api/system.boolean)\>

[true](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) when the decision is written; [false](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) when
the request is not found in the caller's tenant or is no longer in the
[ApprovalStatus.Pending](/api/tracon.approvalstatus/) state (a second decision is rejected silently).

### <a id="Tracon_IPendingApprovalStore_ExpireAsync_System_DateTimeOffset_System_Int32_System_Threading_CancellationToken_"></a> ExpireAsync\(DateTimeOffset, int, CancellationToken\)

Closes the requests that expired before `olderThan` and are still
in the [ApprovalStatus.Pending](/api/tracon.approvalstatus/) state, marking them
[ApprovalStatus.Expired](/api/tracon.approvalstatus/).

```csharp
ValueTask<IReadOnlyList<PendingApproval>> ExpireAsync(DateTimeOffset olderThan, int max, CancellationToken cancellationToken = default)
```

#### Parameters

`olderThan` [DateTimeOffset](https://learn.microsoft.com/dotnet/api/system.datetimeoffset)

Requests that expired before this time are closed (UTC).

`max` [int](https://learn.microsoft.com/dotnet/api/system.int32)

The upper number of requests closed in this round.

`cancellationToken` [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken)

The cancellation token.

#### Returns

 [ValueTask](https://learn.microsoft.com/dotnet/api/system.threading.tasks.valuetask\-1)<[IReadOnlyList](https://learn.microsoft.com/dotnet/api/system.collections.generic.ireadonlylist\-1)<[PendingApproval](/api/tracon.pendingapproval/)\>\>

The records of the closed requests.

#### Remarks

`[TenantAgnostic]`: this is maintenance work and scans the expired requests
of every tenant; filtering by the ambient tenant would leave the requests of the
other tenants [ApprovalStatus.Pending](/api/tracon.approvalstatus/) forever.

### <a id="Tracon_IPendingApprovalStore_GetAsync_System_Guid_System_Threading_CancellationToken_"></a> GetAsync\(Guid, CancellationToken\)

Returns a single pending approval request.

```csharp
ValueTask<PendingApproval?> GetAsync(Guid id, CancellationToken cancellationToken = default)
```

#### Parameters

`id` [Guid](https://learn.microsoft.com/dotnet/api/system.guid)

The request id.

`cancellationToken` [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken)

The cancellation token.

#### Returns

 [ValueTask](https://learn.microsoft.com/dotnet/api/system.threading.tasks.valuetask\-1)<[PendingApproval](/api/tracon.pendingapproval/)?\>

The request, or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) when it is not found in the caller's tenant.

### <a id="Tracon_IPendingApprovalStore_ListPendingAsync_System_Threading_CancellationToken_"></a> ListPendingAsync\(CancellationToken\)

Lists the pending requests of the caller's tenant, ordered from oldest to newest.

```csharp
ValueTask<IReadOnlyList<PendingApproval>> ListPendingAsync(CancellationToken cancellationToken = default)
```

#### Parameters

`cancellationToken` [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken)

The cancellation token.

#### Returns

 [ValueTask](https://learn.microsoft.com/dotnet/api/system.threading.tasks.valuetask\-1)<[IReadOnlyList](https://learn.microsoft.com/dotnet/api/system.collections.generic.ireadonlylist\-1)<[PendingApproval](/api/tracon.pendingapproval/)\>\>
