> ## Documentation Index
> Fetch the complete documentation index at: https://docs.endorlabs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Prerequisites for Coding Agent Governance

> Set up the role, API key, and tenant settings an admin needs before any developer machine runs a Coding Agent Governance hook.

Coding Agent Governance is admin-driven. Before a developer machine can send a single event, an admin must turn on the feature and issue an API key with the right role. The admin then rolls hooks out to the supported coding agents in each developer environment.

In-built policies are enabled by default, so basic enforcement starts as soon as hooks run. You review the catalog and add custom rules after deployment.

Complete the following tasks to set up Coding Agent Governance.

1. Confirm Coding Agent Governance is available in your tenant.
2. Create an API key with the **AI Audit User** role to deploy with hooks.
3. Deploy hooks on developer machines. See [Deploy hooks for Cursor](https://docs.endorlabs.com/agent-governance/cursor.md), [Claude Code](https://docs.endorlabs.com/agent-governance/claude-code.md), [Codex](https://docs.endorlabs.com/agent-governance/codex.md), [GitHub Copilot](https://docs.endorlabs.com/agent-governance/copilot.md), and [Snowflake Cortex Code](https://docs.endorlabs.com/agent-governance/cortex-code.md).
4. Review in-built policies and write any custom rules your organization needs. See [Write a policy](https://docs.endorlabs.com/agent-governance/policies.md).
5. Optional: See [Connect the Anthropic Compliance API](https://docs.endorlabs.com/agent-governance/claude-code/compliance-api.md) to let session policies match Claude Code developers by organization role or group.

Skipping any required step delays results. Inventory and policy enforcement both need hooks to run. The in-built policy catalog enforces as soon as hooks are deployed. Custom policies layer on top for organization-specific rules.

## Confirm Coding Agent Governance is available

Select **Agent Governance** from the left sidebar. If the entry is missing, contact your account team to enable Coding Agent Governance for your tenant.

## Create an API key with the AI Audit User role

The **AI Audit User** role is a least-privilege system role for Coding Agent Governance hooks. An API key with this role can submit hook events, read your policy snapshot for local evaluation, read the Coding Agent Governance inventory, and write operational client logs. It cannot read policy violations or any Endor Labs data outside Coding Agent Governance.

> [!WARNING]
>
> Treat the API key and secret as production credentials. Any host with these values can submit hook events as your tenant.

### Create the API key through the user interface

1. Select **User menu** > **Settings** from the left sidebar.
2. Select **Access Control**.
3. Select **API Keys**, then click **Generate API Key**.
4. Enter a name that identifies the key, such as `agent-governance-hooks`.
5. Under **Role**, choose **AI Audit User**.
6. Choose an expiration that matches your rotation policy.
7. Click **Generate**, then copy the key and secret. Store both in your secret manager. Endor Labs shows the secret only once.

See [Manage API keys](https://docs.endorlabs.com/platform-administration/api-keys.md) to manage this key over time.

### Create the API key with endorctl

For MDM-driven rollouts or automated provisioning, create the key with [endorctl](https://docs.endorlabs.com/setup-deployment/cli.md). Replace `<namespace>` with the namespace that owns your Coding Agent Governance policies, `<key-name>` with a descriptive name for the key, and `<YYYY-MM-DDTHH:MM:SSZ>` with the expiration in ISO 8601 UTC format.

```bash theme={null}
endorctl api create -r APIKey -n "<namespace>" --data '{
  "meta": { "name": "<key-name>" },
  "spec": {
    "permissions": { "roles": ["SYSTEM_ROLE_AI_AUDIT"] },
    "expiration_time": "<YYYY-MM-DDTHH:MM:SSZ>"
  },
  "propagate": true
}'
```

The response contains the API key and secret under `spec.key` and `spec.secret`. Capture both before the response scrolls out of your terminal. Endor Labs returns the secret only once.

See [Create an API key through Endor Labs API](https://docs.endorlabs.com/platform-administration/api-keys.md#create-an-api-key-through-endor-labs-api) for the full API reference, including longer expirations and namespace propagation.

## Data collection

Each hook event includes the metadata Endor Labs needs for inventory and policy evaluation:

* Agent name, version, and (where available) model
* Session and sub-session IDs
* Device (endpoint) identifier
* Session configuration, such as permission mode and sandbox state
* User identifier when the agent provides one
* Repository name (not populated for Claude Code sessions) and working directory
* MCP server name, tool name, and call counts
* Shell command line (regex-matched against your policies)
* File path and operation type (read, write, delete, edit)
* Secrets check match (rule, line, column, and fingerprint, never the secret value)
* Policy match outcome and the action applied

### Secret redaction

Endor Labs runs every command line, file path, URL, environment value, and MCP tool input or output through a regex-based redactor before it leaves the developer's machine. Environment variables and keys named like a secret (such as `TOKEN`, `SECRET`, `API_KEY`, `PASSWORD`, or `AUTHORIZATION`) become `[REDACTED]`. The redactor also matches common secret formats in place. These include URL and database-connection credentials, AWS access keys, JWTs, PEM private keys, and provider tokens such as GitHub (`ghp_*`), OpenAI, and Anthropic keys.

Redaction of event payloads uses regex pattern matching that can miss some secrets. A secret that does not match a known pattern or key name can still reach the backend. The [secrets check](https://docs.endorlabs.com/agent-governance/secure-coding.md) is separate from redaction: it detects secrets in file content on the developer's machine, and its violations include the rule and location, never the value. When an enabled secrets policy detects a secret, Endor Labs also scrubs the detected string from the stored event payload. The follow-up event recorded after a permitted file operation includes no file content.

> [!WARNING]
>
> On Cursor, the `sessionStart` hook returns the Endor Labs credential values to Cursor in plaintext under an `AGENT_HOOK_ENDOR_*` prefix, so subsequent hooks in the session inherit them. The values never leave the developer's machine, but anything that captures Cursor hook stdout (such as debug logging or screen recording) can see them.

## Distribute credentials to developer machines

Hooks read credentials from environment variables wherever they run:

* `ENDOR_API`: The Endor Labs API endpoint, for example `https://api.endorlabs.com`.
* `ENDOR_NAMESPACE`: The Endor Labs namespace that owns the policies and receives the events.
* `ENDOR_API_CREDENTIALS_KEY`: The API key value.
* `ENDOR_API_CREDENTIALS_SECRET`: The API secret.

For Cursor, Codex, GitHub Copilot, and Snowflake Cortex Code, set the variables in the environment that launches the agent. For Claude Code, set them in the `env` block of `settings.json`, as shown on [Deploy hooks for Claude Code](https://docs.endorlabs.com/agent-governance/claude-code.md). Use your MDM (Jamf, Intune, Kandji, JumpCloud) to deliver the values, and to ensure endorctl is on `PATH`, on every machine that runs an Endor Labs hook.

Do not distribute `ENDOR_TOKEN` alongside these variables. Hooks authenticate with the API key and secret only, and on older versions of endorctl the extra token triggered a mixed-authentication error that blocked `endorctl ai-audit`.

See [endorctl CLI](https://docs.endorlabs.com/setup-deployment/cli.md) to install endorctl.

## Confirm supported agents and platforms

Coding Agent Governance hooks support Cursor, Claude Code, Codex, GitHub Copilot, and Snowflake Cortex Code on macOS, Linux, and Windows developer machines. Endor Labs has verified Snowflake Cortex Code on macOS only. See [Supported agents and platforms](https://docs.endorlabs.com/agent-governance.md#supported-agents-and-platforms) for the full matrix, including hosted and CLI form factors.

## Next steps

After you complete the prerequisites, proceed to the next steps:

* See [Deploy hooks for Cursor](https://docs.endorlabs.com/agent-governance/cursor.md), [Claude Code](https://docs.endorlabs.com/agent-governance/claude-code.md), [Codex](https://docs.endorlabs.com/agent-governance/codex.md), [GitHub Copilot](https://docs.endorlabs.com/agent-governance/copilot.md), and [Snowflake Cortex Code](https://docs.endorlabs.com/agent-governance/cortex-code.md) to roll hooks out.
* See [Write a policy](https://docs.endorlabs.com/agent-governance/policies.md) to review the in-built catalog and add organization-specific rules.
* See [Connect the Anthropic Compliance API](https://docs.endorlabs.com/agent-governance/claude-code/compliance-api.md) to give Claude Code sessions an organization identity for policies.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.