Skip to main content
POST
/
v1
/
logs
/
batch
import olira
from olira import LogSpec, OliraLogType

olira.init(api_key="YOUR_API_KEY")
result = olira.log_batch(
    [
        LogSpec(
            log_type=OliraLogType.CONVERSATION_COMPLETED,
            patient_id="8a4fde23-0f1b-4c2a-9d7e-b36c1a5f0e82",
            payload={"channel": "app"},
        ),
    ],
)
print(result.accepted, result.failed, result.errors)
BatchResult(accepted=1, failed=0, errors=[])
olira.log_batch(events: list[LogSpec]) -> BatchResult
Requires scope: sdk:event-log Use for atomic batch semantics or when async_flush is disabled.

Parameters

events
list[LogSpec]
required
Each LogSpec: log_type, patient_id, optional payload, trace, timestamp, idempotency_key, metadata.

Returns

BatchResult
accepted
int
Number of logs accepted.
failed
int
Number of logs rejected.
errors
list[BatchError]
Per-index errors from the API.

Raises

ExceptionWhen
AuthErrorHTTP 401 or 403 — invalid API key or insufficient OAuth scope for this endpoint.
ValidationErrorHTTP 400, 404, or 422 — malformed JSON, unknown patient, or validation failure (message includes response excerpt).
ServerErrorHTTP 409 (e.g. conflicting external identifier) or repeated 5xx after retries; includes status_code when applicable.
RateLimitErrorHTTP 429 — rate limited; check retry_after (seconds).
NetworkErrorConnection timeout, DNS failure, or read error after retries.
import olira
from olira import LogSpec, OliraLogType

olira.init(api_key="YOUR_API_KEY")
result = olira.log_batch(
    [
        LogSpec(
            log_type=OliraLogType.CONVERSATION_COMPLETED,
            patient_id="8a4fde23-0f1b-4c2a-9d7e-b36c1a5f0e82",
            payload={"channel": "app"},
        ),
    ],
)
print(result.accepted, result.failed, result.errors)
BatchResult(accepted=1, failed=0, errors=[])