Skip to main content
Organization administrators can perform the same governance and identity tasks through the Python SDK that are available under Settings → Organizations. The calling user or service account must be an administrator of the target organization or a configured deployment-level organization provisioner. A customer-hosted deployment can also designate specific service-account IDs as organization provisioners. A provisioner can create and configure organizations without becoming a member or receiving access to their data.

Bootstrap and account ownership

Deployment-level provisioners must be service accounts, not human users:
  1. A human recovery administrator creates or selects a trusted IT automation organization, then creates a service account with the explicit admin organization role inside it. Resource permission is configured separately.
  2. Add that Docent service-account UUID to the deployment’s Terraform configuration:
    This is not the creator’s user ID, an API key, or an Entra application ID. Listing a human-user ID does not grant provisioner authority.
  3. Apply Terraform and deploy the updated API task definitions. Automation can then authenticate using the service account’s own API key, AWS federated identity, or Microsoft Entra workload identity, without a human login.
The service account remains owned by its original home organization, whose administrators can manage its credentials. The human creator is recorded for attribution; the automation does not borrow their credentials or session. Keep the home organization under trusted IT control and retain a human recovery administrator. Provisioning authority does not automatically grant collection-data access.

Create and update an organization

Creating an organization requires a human identity or a configured provisioner; an ordinary organization-admin service account cannot create organizations.
For repeatable automation, a configured organization provisioner should use a stable customer-owned ID. Repeating the call updates the same organization:

Manage members

Direct membership and Microsoft Entra group membership are independent access sources. Removing a direct grant does not remove access supplied by a mapped Entra group. Pass create_manual_grant=True only when you intentionally want a direct grant to remain after the person leaves that group.

Read and download audit events

List recent events with cursor pagination:
before must be a timezone-aware datetime. To download every event in a half-open time range—start_at is included and end_at is excluded—use:
The download is streamed to a temporary file and atomically moved to output_path after it succeeds.

Investigate collection access

Under Settings → Organizations → Collection access log, administrators can inspect collection permission checks and download matching events as CSV. Use this log to find which identities were allowed to access a collection and which attempts were denied. The same organization-admin and deployment-provisioner permissions apply as for the organization change log. An event records the collection ID and name, user ID and email or service-account name, requested permission, allowed or denied decision, timestamp, request method and route, authentication method, client IP, and user agent. Organization IDs and mapped Microsoft Entra group IDs are snapshots of Docent’s recorded memberships in the organization receiving the event. Unrelated organization memberships and groups are not disclosed. These are not a fresh query of every group in Microsoft Entra. Service-account details include its configured AWS or Entra identity when the account belongs to the organization receiving the event. The actor is the authenticated HTTP caller. If an internal operation checks a different principal’s permission, details.authorization_subject_user_id records whose permission was checked without replacing the caller’s identity. Dashboard navigation permission checks run through the Next.js server, which passes on the browser’s X-Forwarded-For and User-Agent headers, so user_agent is the browser’s. client_ip is the browser’s address when FORWARDED_ALLOW_IPS trusts every proxy between the API and the Next.js server; otherwise it is the address of the nearest hop the API does not trust, such as the Next.js server’s outgoing address. client_ip is the address Docent attributes the request to. Behind a proxy, its accuracy depends on the deployment’s trusted-proxy setting, FORWARDED_ALLOW_IPS. Three fields in details show how the address was worked out:
  • peer_address: the address of the connection the API received, such as a load balancer.
  • x_forwarded_for: the X-Forwarded-For header as received, limited to its last 1,024 characters. The caller can write anything at the start of this value, and each proxy appends the address it received.
  • x_forwarded_for_truncated: true when the start of the header was removed to meet that limit. The Next.js server forwards at most the last 30 entries and 1,024 characters of the header it received, and the API cannot see what it removed.
When the connection comes from a trusted proxy, Docent reads the X-Forwarded-For header from the end, skips the addresses of trusted proxies, and records the first untrusted address as client_ip. If every address is trusted, it records the first one. Otherwise, client_ip is peer_address. Allowed means authorized, not downloaded. Docent saves the event before the permission check returns, so an allowed request can subsequently fail. Denied collection permission checks are saved independently of request rollback. If Docent cannot save the event, the request does not proceed. Request bodies, query strings, credentials, and collection contents are not copied into the log. The log covers collections bound to the organization, created by its service accounts, or shared with it at admin permission after applying the deployment’s sharing policy. Read or write sharing does not grant access to other readers’ history. It records requests that reach a collection permission check, including destination checks when moving runs or copying rubrics. Permission previews that use the shared permission check also produce entries. Browser navigation checks also produce entries, including visits denied before the page loads collection data. Browser sessions and API credentials use the same server-side audit recording. Collection listings, worker processes, and requests rejected before a collection check are outside its scope. HTTP middleware supplies the request context to MonoService.has_permission() and get_readable_collection_ids(). Features using these methods or the require_collection_permission() dependency inherit logging without adding an audit call to each endpoint or page. Repeated checks of the same identity, collection, permission, and decision produce one event per request for each responsible organization. Different decisions and different HTTP requests remain separate events. Work that outlives its HTTP request cannot reuse that request’s audit attribution. Use client.get_collection_access_events(organization_id, ...) to list events. It accepts limit, before, and before_id with the same pagination rules as get_organization_audit_events. Optional collection_id and actor_user_id filters match exact IDs; a service account uses its Docent user ID. Use client.download_collection_access_events(organization_id, ...) to export with start_at, end_at, and output_path, plus the same optional ID filters. The time boundaries must include a timezone offset; start_at is included and end_at is excluded. The UI uses inclusive calendar dates in your timezone. Exports include every matching event, without the list endpoint’s page limit. The server stages the CSV in a temporary file before sending it, so a database failure returns an error rather than a partial download. Allow temporary disk space for concurrent exports; the files are removed when each response finishes. Disconnecting during export cancels staging and closes its database query. Records preserve collection and actor IDs after those objects are deleted. They have no automatic expiry and are deleted with their organization. Apply the collection access migration before deploying the API. Collection reads add audit writes to Postgres, so include this table in storage planning and backups. The records use the application’s database and are not tamper-proof against a database or host administrator. Organizations requiring independent evidence should deliver events to an S3 bucket that administrator cannot modify, or retain exports or database backups outside that administrator’s control. Events wait in the database for up to about an hour before upload.

Deliver collection access events to S3

A deployment can copy these events to an S3 bucket it manages, for retention outside the application database. Set DOCENT_COLLECTION_ACCESS_LOG_S3_BUCKET on every API process to turn this on. The BYOC Terraform module exposes the same setting as collection_access_log_s3_bucket; see Store collection access events in S3 in its README.md for setup, permissions, and monitoring. Collection requests do not wait for S3. Each event is committed to a Postgres queue before the permission check returns, and a background task uploads events in batches. An S3 outage delays delivery without losing events, and a failed write to the queue fails the request. Database history and S3 are switched separately with DOCENT_COLLECTION_ACCESS_LOG_DATABASE_ENABLED and DOCENT_COLLECTION_ACCESS_LOG_S3_ENABLED. The SDK methods on this page, the Collection access log section of the organization’s settings page, and CSV exports read only the database, so they do not return S3-only events. Objects are gzip-compressed JSON Lines files:
Each line is one event, with the fields get_collection_access_events returns, including client_ip and details. Each organization’s events for a UTC hour are uploaded together five minutes after the hour ends. The hour’s folder usually holds one object, and more when the hour is very busy or an event is saved late, so read every object in it. Queued events go to the destination configured when they are uploaded. S3 objects remain when an organization is deleted from Docent, so expire them with the bucket’s retention policy.

Map a Microsoft Entra group

In an Entra-enabled deployment, Docent searches Microsoft Graph using the read-only GroupMember.Read.All and User.ReadBasic.All application permissions approved by the tenant administrator. Mapping by name is convenient, while Docent stores the immutable group object ID:
If no security group has that exact display name, or multiple groups share it, the method raises ValueError without changing the mapping. Call search_entra_groups and then set_entra_group_mapping when you need to select an object ID explicitly. To replace a deleted or renamed group, call either setter again. Replacing the object ID immediately removes access derived from the old mapping and records the transition in the audit log. Members of the replacement group receive access on their next Microsoft sign-in or when an administrator runs a reconciliation. Direct Docent grants remain intact.
Reconciliation asks Microsoft Graph for the mapped group’s complete transitive membership and updates Entra-managed Docent grants. Existing sessions reload organization membership on every request, so additions and removals take effect immediately without forcing a logout. Users who have never signed in are reported as unlinked and receive access after their first Microsoft sign-in. A manual Docent grant is independent and is never removed merely because the user left the Entra group. When the tenant has organization group mappings, Docent retrieves the user’s complete transitive security-group IDs from Graph during Microsoft sign-in. If Graph cannot provide the complete list, the sign-in is rejected and existing group access is not incorrectly retained. Tenants without group mappings do not depend on this Graph lookup for sign-in.

Create a service account

permission caps access to collections and other resources. The independent organization_role controls organization administration and defaults to member. Set organization_role="admin" only when the automation must manage members, identity mappings, service accounts, or audit configuration. Change the organization role later without changing resource access:

API key

Microsoft Entra workload

The enterprise application must have the deployment’s service-account app role.

AWS outbound OIDC workload

The issuer is account-specific and is required for new AWS outbound OIDC bindings. Omitting it creates a legacy signed-request binding. See Authentication for workload setup. Disabling a service account revokes all of its API keys, Entra identity, and AWS identity for subsequent requests: