Skip to content

Activities

activities

Activities resource group.

Wraps GET /v1/compliance/activities. The Activity Feed is the cursor-paginated audit log for an organisation; both Compliance Access Keys (with read:compliance_activities scope) and Admin keys can call it. The server is the source of truth on the scope check — the client never inspects the API key prefix.

Example
from claude_compliance_sdk import ComplianceClient

with ComplianceClient(api_key="sk-ant-admin01-...") as client:
    for activity in client.activities.iter(
        created_at_gte="2025-06-01T00:00:00Z",
        activity_types=["claude_chat_created", "api_key_created"],
    ):
        print(activity.id, activity.type)

Activity dataclass

A single audit event from the Compliance API activity feed.

Per-type fields (for example claude_chat_id on a claude_chat_created activity) land in extra rather than on the dataclass so the SDK does not have to track the full list of activity types — that set grows over time.

Attributes:

Name Type Description
id str

Unique identifier (activity_...).

created_at str

When the activity occurred, RFC 3339.

type str

Activity type string (claude_chat_created, api_key_created, etc.). Named type to match the wire format.

organization_id str | None

Owning organisation's tagged ID, or None for activities not tied to an organisation (login, logout, Compliance API access).

organization_uuid str | None

Owning organisation's UUID, or None as above.

actor dict[str, Any] | None

Raw actor payload (UserActor, ApiActor, AdminApiKeyActor, UnauthenticatedUserActor, AnthropicActor, ScimDirectorySyncActor). Discriminate on actor["type"]. Kept as a dict because the union grows over time.

extra dict[str, Any]

Activity-type-specific fields preserved verbatim from the response, plus any new top-level fields the API adds later.

from_dict classmethod

from_dict(body: Mapping[str, Any]) -> 'Activity'

Build an Activity from one decoded JSON record.

Activities

Synchronous client for the Compliance API activity feed.

list

list(
    *,
    organization_ids: StrList | None = None,
    actor_ids: StrList | None = None,
    activity_types: StrList | None = None,
    created_at_gte: str | None = None,
    created_at_gt: str | None = None,
    created_at_lte: str | None = None,
    created_at_lt: str | None = None,
    after_id: str | None = None,
    before_id: str | None = None,
    limit: int | None = None
) -> CursorPage[Activity]

Fetch a single page of activities.

Parameters:

Name Type Description Default
organization_ids StrList | None

Filter to activities in any of these organisations.

None
actor_ids StrList | None

Filter to activities by any of these actor user IDs.

None
activity_types StrList | None

Filter to activities of any of these types.

None
created_at_gte str | None

created_at >= value (RFC 3339).

None
created_at_gt str | None

created_at > value (RFC 3339).

None
created_at_lte str | None

created_at <= value (RFC 3339).

None
created_at_lt str | None

created_at < value (RFC 3339).

None
after_id str | None

Cursor for forward pagination (newer items).

None
before_id str | None

Cursor for backward pagination (older items). Mutually exclusive with after_id.

None
limit int | None

Maximum results, default 100, max 5000.

None

Returns:

Type Description
CursorPage[Activity]

One CursorPage of Activity objects.

Raises:

Type Description
InsufficientScopeError

When the API key lacks read:compliance_activities.

APIError

For any other non-2xx response.

iter

iter(
    *,
    organization_ids: StrList | None = None,
    actor_ids: StrList | None = None,
    activity_types: StrList | None = None,
    created_at_gte: str | None = None,
    created_at_gt: str | None = None,
    created_at_lte: str | None = None,
    created_at_lt: str | None = None,
    limit: int | None = None
) -> Iterator[Activity]

Iterate every matching activity, auto-paginating.

Same filters as list except that after_id / before_id are managed by the iterator and therefore not accepted here.

AsyncActivities

Asynchronous client for the Compliance API activity feed.

list async

list(
    *,
    organization_ids: StrList | None = None,
    actor_ids: StrList | None = None,
    activity_types: StrList | None = None,
    created_at_gte: str | None = None,
    created_at_gt: str | None = None,
    created_at_lte: str | None = None,
    created_at_lt: str | None = None,
    after_id: str | None = None,
    before_id: str | None = None,
    limit: int | None = None
) -> CursorPage[Activity]

Async analogue of list.

iter

iter(
    *,
    organization_ids: StrList | None = None,
    actor_ids: StrList | None = None,
    activity_types: StrList | None = None,
    created_at_gte: str | None = None,
    created_at_gt: str | None = None,
    created_at_lte: str | None = None,
    created_at_lt: str | None = None,
    limit: int | None = None
) -> AsyncIterator[Activity]

Async analogue of iter.