Skip to main content
The Claude Compliance integration is a self-hosted utility script that pulls conversation data from Anthropic’s Claude Compliance API and ingests each user/assistant turn into Nebuly as an Interaction. The data flow is: Compliance API (chats + local and remote sessions) → interaction cut → Nebuly ingestion The script is incremental and resumable: it tracks a local SQLite cache of already-synced data, so you can re-run it safely at any time without creating duplicates. If your organization signs in with Microsoft Entra, the same script can enrich each interaction with directory data. end_user stays the Claude user id. See Enrich with Microsoft Entra. The source repository is available here.

Prerequisites

  • A Claude Enterprise organization with the Compliance API enabled. The primary owner enables it in claude.ai → Organization settings → API. Standalone Claude Console organizations cannot use this integration: they only get Admin API keys, which reach the Activity Feed and not chats or sessions.
  • Python ≥ 3.12 and Poetry 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:
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.
1

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.
2

Compliance Access Key → COMPLIANCE_API_KEY

Who can create the key:
  • The primary owner of the parent organization can create a key that covers every linked organization.
  • An organization owner can create a key limited to their own organization.
  1. Open claude.ai → Organization settings → API.
  2. Under Keys, click Create key.
  3. Select both scopes:
    • read:compliance_user_data: required to read chats, local sessions, and remote sessions.
    • read:compliance_org_data: required to call List Organizations in the next step.
    Scopes cannot be changed after the key is created. To change them, create a new key.
  4. Copy the secret immediately; it is shown only once. It starts with sk-ant-api01-.
A key scoped to the parent organization can read every chat, file, project, and session transcript across all linked organizations. A key scoped to a single organization is limited to that organization. Treat it like a root credential and store it in a secrets manager. See Anthropic’s Get access to the Compliance API for full details.
3

Organization UUID → ORGANIZATION_UUID

Call the List Organizations endpoint to find the uuid of the org you want to sync:
The organizations are returned in a data array, alongside has_more and next_page for pagination:
Copy the uuid value (not the name). See Anthropic’s List organizations, users, roles, groups for the full response schema.

What is synced

By default the script syncs three sources. Limit a run with --sources (for example chats,local_sessions). end_user is the Claude user id (user.id, or started_by_user.id when a remote session has no owner). It is not the email address. Session interactions carry a product surface tag from Compliance. Use it to tell these products apart: Not included: Claude agents, Claude Design, Claude in Slack, and token or cost fields. Spend can be added later from Anthropic’s Analytics APIs.

Enrich with Microsoft Entra

If Claude users authenticate with Microsoft, you can enrich each interaction from Entra. Compliance itself does not include team, market, or tenure. Those values live in the directory. The sync joins them by email and sets them on the same POST as the interaction. Turn this on before the first sync. A later run does not send an interaction again, so directory fields are not added after the fact. Use one of the two options. ENTRA_FETCH and ENTRA_EXTRACT_PATH cannot both be set.

Fetch users when the sync starts

Set ENTRA_FETCH=true. Each run lists users from Microsoft Graph and keeps them in memory. Install the extra dependency first:
Then set these in .env:
1

Register an app in Microsoft Entra

  1. Open the Microsoft Entra admin center.
  2. Go to App registrations → New registration.
  3. Give the app a name.
  4. Under Supported account types, choose Single tenant only - .
  5. Click Register.
2

Tenant and client IDs

On the app Overview page, copy:
  • Directory (tenant) ID → AZURE_TENANT_ID
  • Application (client) ID → AZURE_CLIENT_ID
3

Client secret

  1. Go to Certificates & secrets → New client secret.
  2. Copy the secret Value immediately. That value is AZURE_CLIENT_SECRET.
Client secrets expire. Rotate the secret before it lapses.
4

Grant User.Read.All

  1. Go to API permissions → Add a permission → Microsoft Graph → Application permissions.
  2. Add User.Read.All.
  3. Click Grant admin consent.
The permission must show Granted before you run the sync. This is an application permission, because the script uses client credentials.

Or point at a JSON file

Leave ENTRA_FETCH unset and set ENTRA_EXTRACT_PATH to a file of Graph user objects ({ "users": [ ... ] } or a bare array). The field names are mail, userPrincipalName, department, jobTitle, officeLocation, city, country, usageLocation, companyName, and employeeHireDate. You can export that file with microsoft_entra in the same repository (poetry run python -m entra_export).

What gets added

The match is case-insensitive. Chats use user.email_address. Sessions use the email on the session listing, because the messages endpoint often returns email_address: null. An email that is missing, or that is not in the directory, is still sent. It just has no directory fields. end_user stays the Claude user id. The same values are also stored as tags (department, job_title, office_location, city, country, company_name, employee_hire_date). Empty values are omitted.

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 the script sends data and when it becomes visible in Nebuly. The script only syncs when you run it, so for ongoing sync schedule it (for example with cron).
Is it safe to re-run the script?
Yes. The script maintains a local SQLite cache at .cache/sync_state.db that records which interactions 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.
Are token and cost included?
No. The Compliance API does not expose per-interaction token or cost fields.
Why do some interactions have no team, market, or tenure?
Entra did not contain that user’s email, or the chat or session listing had no email. end_user is still the Claude user id. Enable enrichment before the first sync. A later run does not update an interaction that was already sent.

Resources

Claude Compliance Nebuly integration

Full install guide, env-var table, CLI flags, and customization docs

Claude Compliance API

Anthropic’s official Compliance API reference

Nebuly Interaction API

API reference for the Interaction ingestion endpoint