> ## Documentation Index
> Fetch the complete documentation index at: https://controlplanecorporation-jakob-ess-2-0-0.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Audit Context

> Create and manage audit contexts that enable workloads and third-party systems to write tamper-proof audit trail entries alongside Control Plane platform events.

## Overview

Control Plane provides a tamper-proof audit trail service for both Control Plane and custom workload actions.

To use this feature, create a unique **audit context** for your workload.

The `cpln` audit context is pre-provisioned and captures all native Control Plane platform activity.

See the [audit trail](/core/audittrail) reference page for details on how to query the audit trail and securely capture actions for your workloads.

## Create an Audit Context

See the [Create an Audit Context](/guides/create-audit-context) guide for setup instructions.

## Permissions

The following permissions can be assigned through [policies](/reference/policy) to supported [principal types](/concepts/access-control):

| Permission | Description              | Implies                                           |
| :--------- | :----------------------- | :------------------------------------------------ |
| create     | Create new contexts      |                                                   |
| edit       | Modify existing contexts | view                                              |
| manage     | Full access              | create, edit, manage, readAudit, view, writeAudit |
| readAudit  | Read from this context   | view                                              |
| view       | Read-only view           |                                                   |
| writeAudit | Write to this context    | view                                              |

## Access Report

Displays the permissions granted to principals for the audit context.

## Writing Audit Records from a Workload

1. Make sure the workload is assigned an identity that is granted `writeAudit` permission on the target audit context.
2. Write events using the internal audit endpoint:

   ```bash theme={null}
   # Minimal example
   curl -H "Content-Type: application/json" -X POST http://127.0.0.1:43000/audit/org/${CPLN_ORG}/auditctx/custom-audit-context?async=true -d '{"resource": {"id": "anyid123", "type": "anytype"}}'
   ```

## CLI

To view the CLI documentation for audit contexts, see the [Audit Context CLI reference](/cli-reference/commands/auditctx).
