Skip to main content
await sdk.conversation.record_messages_batch(
    messages: List[Dict[str, Any]],
) -> Dict[str, Any]
Records many messages in one call. Use this when backfilling an existing transcript, syncing a buffered queue, or recording a multi-turn exchange after it completes. Each entry in messages follows the same shape as the arguments to record_message.

Parameters

messages
List[Dict[str, Any]]
required
List of message dicts. Each dict supports the following keys:
  • conversation_id (str, required) — conversation identifier; must be a valid UUID registered via record_message
  • role (str, required) — must be "user" or "assistant"
  • content (str, required) — message text
  • user_id (str, optional) — external user id
  • customer_id (str, optional) — external customer id; required on B2B, auto-resolved on B2C (B2C vs B2B)
  • session_id (str, optional) — session identifier
  • metadata (dict, optional) — free-form metadata
Unlike record_message, user_id and customer_id are optional in batch mode. If omitted, the entry is recorded without explicit user/customer attribution.

Returns

A dict summarising the batch outcome.
total
int
Number of messages submitted.
succeeded
int
Number of messages accepted.
failed
int
Number of messages rejected.
results
List[Dict[str, Any]]
Per-message results in submission order. Successful entries include message_id and recorded_at; failed entries include an error field.

Example

import uuid
from maximem_synap import MaximemSynapSDK

sdk = MaximemSynapSDK(api_key="synap_your_key_here")
await sdk.initialize()

# conversation_id must be a valid UUID; reuse one id across the whole transcript
conversation_id = str(uuid.uuid4())

result = await sdk.conversation.record_messages_batch(
    messages=[
        {
            "conversation_id": conversation_id,
            "role": "user",
            "content": "What's on my calendar today?",
            "user_id": "user_alice",
            "customer_id": "customer_acme",
        },
        {
            "conversation_id": conversation_id,
            "role": "assistant",
            "content": "You have two meetings and a dentist appointment.",
            "user_id": "user_alice",
            "customer_id": "customer_acme",
        },
    ]
)

print(f"Recorded {result['succeeded']} of {result['total']} messages")

Raises

  • InvalidInputError — when an entry is missing required keys or role is invalid.
  • AuthenticationError — when the API key is missing or invalid.
  • NetworkError — when the SDK cannot reach Synap.

See also