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

# Claude Compliance

> Sync Claude conversation data into Nebuly via the Claude Compliance API

The Claude Compliance integration is a self-hosted utility script that pulls conversation data from Anthropic's [Claude Compliance API](https://platform.claude.com/docs/en/manage-claude/compliance-api) and ingests each user/assistant turn into Nebuly as an Interaction.

The data flow is:

Compliance API (users → chats → messages) → pair conversion → Nebuly ingestion

The script is incremental and resumable: it tracks a local cache of already-synced data, so you can re-run it safely at any time without creating duplicates.

The source repository is available [here](https://github.com/nebuly-ai/nebuly-integration-examples/tree/main/claude_compliance).

## Prerequisites

* A **Claude Enterprise** organization with the **Compliance API enabled**. Enterprise primary owners can self-enable the Compliance API from the Console; if you are on a Console plan, contact your Anthropic account team.
* **Python ≥ 3.12** and [Poetry](https://python-poetry.org/docs/#installing-with-the-official-installer) installed on the machine that runs the script.

## Install & run

Clone the integration examples repository, install dependencies, configure your `.env` file, and run the sync:

```bash theme={null}
git clone https://github.com/nebuly-ai/nebuly-integration-examples.git
cd nebuly-integration-examples/claude_compliance
poetry install
cp .env.example .env
# Fill in NEBULY_API_KEY, COMPLIANCE_API_KEY, and ORGANIZATION_UUID
poetry run python -m compliance_sync --from-date 2026-01-01
```

Follow the guide below to retrieve the necessary credentials.

For the complete environment variable reference, available CLI flags, payload customization and resumable-cache details, check the project README.

## Get your credentials

The script requires three environment variables. Follow the steps below to obtain each one.

<Steps>
  <Step title="Nebuly secret key → NEBULY_API_KEY">
    In Nebuly, go to **Settings → Projects → View Nebuly keys → Secret keys** and copy the secret key for the project you want to sync.
  </Step>

  <Step title="Compliance Access Key → COMPLIANCE_API_KEY">
    This key is created by the **primary owner** of your Claude Enterprise organization.

    1. Open [claude.ai → Organization settings → API](https://claude.ai/admin-settings/api-access).
    2. Under **Keys**, click **Create key**.
    3. Grant the **`read:compliance_user_data`** scope — this is required to list users and read their chats and messages.
    4. Copy the secret immediately; it is shown only once. It starts with `sk-ant-api01-`.

    <Warning>
      This key can read all chats, files, and projects across every organization linked to your Claude account. Treat it like a root credential and store it in a secrets manager. See Anthropic's [Get access to the Compliance API](https://platform.claude.com/docs/en/manage-claude/compliance-api-access) for full details.
    </Warning>
  </Step>

  <Step title="Organization UUID → ORGANIZATION_UUID">
    Call the List Organizations endpoint to find the `uuid` of the org you want to sync:

    ```bash theme={null}
    curl -sS "https://api.anthropic.com/v1/compliance/organizations" \
      --header "x-api-key: $COMPLIANCE_API_KEY"
    ```

    The response contains records like:

    ```json theme={null}
    { "uuid": "91012d09-...", "name": "Nebuly" }
    ```

    Copy the `uuid` value (not the `name`). See Anthropic's [List organizations, users, roles, groups](https://platform.claude.com/docs/en/manage-claude/compliance-org-data) for the full response schema.
  </Step>
</Steps>

<CardGroup cols={2}>
  <Card title="Claude Compliance Nebuly integration" icon="github" href="https://github.com/nebuly-ai/nebuly-integration-examples/tree/main/claude_compliance">
    Full install guide, env-var table, CLI flags, and customization docs
  </Card>

  <Card title="Claude Compliance API" icon="book" href="https://platform.claude.com/docs/en/manage-claude/compliance-api">
    Anthropic's official Compliance API reference
  </Card>
</CardGroup>

## FAQ

**Where does the synced data appear?**\
Conversations imported by the script show up on the **Interactions** page in your Nebuly project.

**When will my data appear?**\
There can be a delay of up to 30 minutes between the moment data is available in sent and when it becomes visible in Nebuly. Subsequent updates follow the same polling interval.

**Is it safe to re-run the script?**\
Yes. The script maintains a local cache directory (default: `.cache/`) that records which conversations have already been synced. Re-running it will pick up only new data and will not create duplicates.

**How can I see what would be sent without triggering ingestion?**\
Pass the `--dry-run` flag. The script will fetch and convert data but will skip the POST to Nebuly's ingestion endpoint, printing a summary instead.
