mv.events
The event log behind webhooks. These methods are on mv.events, where mv is your client (see the Node.js SDK). Each one returns the response object and throws when the API answers with an error.
list()
Section titled “list()”List events. Events in this mode, newest first, for the last 30 days. Filter by type (type=call.*, or several with types[]) and creation time (created[gte]…).
mv.events.list(query?: NonNullable<EventsListData["query"]>, options?: RequestOptions): PagedList<EventsListResponse["data"][number], NonNullable<EventsListData["query"]>>GET /events · API reference
Parameters
Section titled “Parameters”| Name | Type | Required | Description |
|---|---|---|---|
query.limit |
integer |
no | How many objects to return, 1–100 (default 20). |
query.starting_after |
string |
no | A cursor (next_cursor) or object ID: return the objects after it (older). |
query.ending_before |
string |
no | A cursor or object ID: return the objects before it (newer). |
query.type |
string |
no | Only events of this type. An event type (call.ended), a group (call.*) or "*" for every event. |
query.types |
array |
no | Only events of these types (types[]=call.ended&types[]=qa.*). |
query.created |
object |
no | Filter on the creation time: created[gte], created[gt], created[lte], created[lt] (ISO-8601). |
options.headers["MoreVoice-Version"] |
string |
no | The API version to use for this request. Defaults to the version the API key is pinned to. |
options |
RequestOptions |
no | idempotencyKey, extra headers and an abort signal: see retries and idempotency. |
Returns
Section titled “Returns”A PagedList: await it for the first page, for await it for every item.
Example
Section titled “Example”import MoreVoice from "@morevoice/sdk";
const mv = new MoreVoice(); // MOREVOICE_API_KEY from the environment
for await (const event of mv.events.list()) { console.log(event);}retrieve()
Section titled “retrieve()”Retrieve an event. Returns one event: its type, the API version it was rendered in, and its payload (data.object), exactly as webhooks deliver it. Events are kept for 30 days.
mv.events.retrieve(id: EventsRetrieveData["path"]["id"], options?: RequestOptions): Promise<EventsRetrieveResponse>GET /events/{id} · API reference
Parameters
Section titled “Parameters”| Name | Type | Required | Description |
|---|---|---|---|
id |
string |
yes | A event ID (evt_…). |
options.headers["MoreVoice-Version"] |
string |
no | The API version to use for this request. Defaults to the version the API key is pinned to. |
options |
RequestOptions |
no | idempotencyKey, extra headers and an abort signal: see retries and idempotency. |
Returns
Section titled “Returns”Event:
| Field | Type | Description |
|---|---|---|
id |
string |
The event ID (also the webhook-id header of its deliveries). |
object |
"event" |
Always event. |
type |
"call.created" | "call.started" | "call.ringing" | "call.answered" | "call.transferred" | "call.ended" | "call.analyzed" | "call.cost_finalized" | … |
— |
created |
string |
An ISO-8601 timestamp in UTC. |
api_version |
string |
— |
livemode |
boolean |
true in live mode, false in test mode. |
org_id |
string |
A org ID (prefix org_). |
data |
object |
— |
request |
object |
— |
Example
Section titled “Example”import MoreVoice from "@morevoice/sdk";
const mv = new MoreVoice(); // MOREVOICE_API_KEY from the environment
const event = await mv.events.retrieve("evt_7Hk2Lm9Qp");console.log(event);stream()
Section titled “stream()”Stream events as they happen. Server-Sent Events: the same event envelopes as GET /v1/events and webhooks, live, for this key’s mode. Filter with types (call.*, campaign.completed, …). Reconnect with Last-Event-ID (EventSource does it for you) to replay what you missed, up to 24 hours back; delivery is at-least-once, so dedupe on id. Counts against the key’s stream limit (concurrency_limit, limit_type: api_streams).
mv.events.stream<T extends EventEnvelope = EventEnvelope>(options?: EventsStreamOptions): EventStream<T>GET /events/stream · API reference
Parameters
Section titled “Parameters”| Name | Type | Required | Description |
|---|---|---|---|
query.types |
string |
no | Only these event types: a type (call.ended), a group (call.*) or "*"; comma-separated or repeated. Default: every event. |
query.last_event_id |
string |
no | Resume after this event, for clients that cannot send the Last-Event-ID header (the header wins when both are sent). |
options.headers["MoreVoice-Version"] |
string |
no | The API version to use for this request. Defaults to the version the API key is pinned to. |
options |
RequestOptions |
no | idempotencyKey, extra headers and an abort signal: see retries and idempotency. |
Returns
Section titled “Returns”An EventStream of events.
Example
Section titled “Example”import MoreVoice from "@morevoice/sdk";
const mv = new MoreVoice(); // MOREVOICE_API_KEY from the environment
for await (const event of mv.events.stream()) { console.log(event.type, event.data.object);}