Chats¶
chats ¶
Chats resource group.
Wraps three Compliance API endpoints:
GET /v1/compliance/apps/chats— cursor-paginated chat metadata list.user_ids[]is required and must carry 1–10 IDs; the SDK validates the length client-side (a cheap input-shape check) and raisesValueErroroutside that range without touching the network.-
GET /v1/compliance/apps/chats/{claude_chat_id}/messages— the only way to fetch a single chat. Returns the chat metadata alongside one cursor-paginated page of messages. Exposed via two methods: -
getreturns aChatMessagesPagecarrying both the chat and the message page so callers can read either. -
iter_messagesdrives the same endpoint with a custom cursor loop and yieldsMessageobjects one at a time. -
DELETE /v1/compliance/apps/chats/{claude_chat_id}— destructive delete. The chat record persists withdeleted_atpopulated (soft-delete data model) but cannot be undone. ReturnsNone.
Note that the API does not expose a separate
GET /v1/compliance/apps/chats/{id} single-fetch endpoint, so
get uses the messages endpoint and reads the chat fields from
its response.
Chat
dataclass
¶
A single chat's metadata (list shape).
Attributes:
| Name | Type | Description |
|---|---|---|
id |
str
|
Tagged chat identifier ( |
name |
str
|
Display name. |
created_at |
str
|
RFC 3339 creation timestamp. |
updated_at |
str
|
RFC 3339 last-update timestamp. |
organization_id |
str
|
Owning organisation's tagged ID. |
model |
str
|
Model the chat ran against (e.g. |
href |
str
|
Direct claude.ai URL for the chat. |
deleted_at |
str | None
|
RFC 3339 deletion timestamp, or |
organization_uuid |
str | None
|
Organisation UUID (alternate identifier),
or |
project_id |
str | None
|
Owning project's tagged ID, or |
user |
dict[str, Any] | None
|
Creator info ( |
extra |
dict[str, Any]
|
Any additional fields the API adds in a later revision. |
from_dict
classmethod
¶
Build a Chat from one decoded record.
Strips the message-page wrapper keys before delegating to
parse_with_extra so the chat's extra does not
carry pagination cruft when the body comes from the
/messages endpoint.
Message
dataclass
¶
A single message within a chat.
Content blocks, file attachments, and artifact references are stored as raw dicts — typed unions for those nested shapes can land later if they earn their keep.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
str
|
Tagged message identifier ( |
role |
str
|
|
created_at |
str
|
RFC 3339 creation timestamp. |
content |
list[dict[str, Any]]
|
List of content blocks. Each block has at least a
|
files |
list[dict[str, Any]] | None
|
User-uploaded file references attached to the message,
or |
generated_files |
list[dict[str, Any]] | None
|
References to files the assistant produced via
tool use (PDFs, spreadsheets, etc.), or |
artifacts |
list[dict[str, Any]] | None
|
Artifact references generated alongside an
assistant message, or |
extra |
dict[str, Any]
|
Any additional fields the API adds in a later revision. |
from_dict
classmethod
¶
Build a Message from one decoded record.
ChatMessagesPage
dataclass
¶
Result of get — chat metadata plus one page of messages.
The Compliance API returns these together from a single endpoint,
so this wrapper makes the join explicit on the SDK side rather
than scattering pagination fields across Chat.
Attributes:
| Name | Type | Description |
|---|---|---|
chat |
Chat
|
The chat's metadata. |
messages |
CursorPage[Message]
|
One |
from_dict
classmethod
¶
Build a ChatMessagesPage from the /messages response.
Chats ¶
Synchronous client for the Chats endpoints.
list ¶
list(
*,
user_ids: StrList,
organization_ids: StrList | None = None,
project_ids: 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,
updated_at_gte: str | None = None,
updated_at_gt: str | None = None,
updated_at_lte: str | None = None,
updated_at_lt: str | None = None,
after_id: str | None = None,
before_id: str | None = None,
limit: int | None = None
) -> CursorPage[Chat]
Fetch one cursor-paginated page of chats.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_ids
|
StrList
|
Required. 1–10 user IDs to filter on. The
API rejects requests outside this range; the SDK
raises |
required |
organization_ids
|
StrList | None
|
Optional org filter. |
None
|
project_ids
|
StrList | None
|
Optional project filter. |
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
|
updated_at_gte
|
str | None
|
|
None
|
updated_at_gt
|
str | None
|
|
None
|
updated_at_lte
|
str | None
|
|
None
|
updated_at_lt
|
str | None
|
|
None
|
after_id
|
str | None
|
Cursor for forward pagination. |
None
|
before_id
|
str | None
|
Cursor for backward pagination. Mutually
exclusive with |
None
|
limit
|
int | None
|
Maximum results, default 100, max 1000. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
When |
iter ¶
iter(
*,
user_ids: StrList,
organization_ids: StrList | None = None,
project_ids: 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,
updated_at_gte: str | None = None,
updated_at_gt: str | None = None,
updated_at_lte: str | None = None,
updated_at_lt: str | None = None,
limit: int | None = None
) -> Iterator[Chat]
Iterate every matching chat, auto-paginating.
Same filters as list except that after_id /
before_id are managed by the iterator.
Raises:
| Type | Description |
|---|---|
ValueError
|
When |
get ¶
get(
chat_id: str,
*,
after_id: str | None = None,
before_id: str | None = None,
limit: int | None = None
) -> ChatMessagesPage
Fetch one chat's metadata + a page of its messages.
The Compliance API returns chat metadata and a message page
from a single endpoint; the SDK exposes them together via
ChatMessagesPage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chat_id
|
str
|
Tagged chat identifier ( |
required |
after_id
|
str | None
|
Cursor for forward pagination of messages. |
None
|
before_id
|
str | None
|
Cursor for backward pagination of messages. |
None
|
limit
|
int | None
|
Maximum messages on the returned page. When omitted, the server returns the full message set in one response. |
None
|
iter_messages ¶
Iterate every message in a chat, auto-paginating.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chat_id
|
str
|
Tagged chat identifier. |
required |
limit
|
int | None
|
Per-page maximum (max 1000). Omit to let the server return the full set in one response. |
None
|
delete ¶
Delete a chat (marks deleted_at; irreversible).
Returns None on success; the server's confirmation payload
is discarded.
AsyncChats ¶
Asynchronous client for the Chats endpoints.
list
async
¶
list(
*,
user_ids: StrList,
organization_ids: StrList | None = None,
project_ids: 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,
updated_at_gte: str | None = None,
updated_at_gt: str | None = None,
updated_at_lte: str | None = None,
updated_at_lt: str | None = None,
after_id: str | None = None,
before_id: str | None = None,
limit: int | None = None
) -> CursorPage[Chat]
Async analogue of list.
iter
async
¶
iter(
*,
user_ids: StrList,
organization_ids: StrList | None = None,
project_ids: 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,
updated_at_gte: str | None = None,
updated_at_gt: str | None = None,
updated_at_lte: str | None = None,
updated_at_lt: str | None = None,
limit: int | None = None
) -> AsyncIterator[Chat]
Async analogue of iter.
get
async
¶
get(
chat_id: str,
*,
after_id: str | None = None,
before_id: str | None = None,
limit: int | None = None
) -> ChatMessagesPage
Async analogue of get.
iter_messages
async
¶
Async analogue of iter_messages.