## Preview Events `client.v1.customers.previewEvents(CustomerPreviewEventsParamsparams, RequestOptionsoptions?): CustomerPreviewEventsResponse` **post** `/v1/customers/{customer_id}/previewEvents` Preview how a set of events will affect a customer's invoice. Generates a draft invoice for a customer using their current contract configuration and the provided events. This is useful for testing how new events will affect the customer's invoice before they are actually processed. ### Parameters - **params:** `CustomerPreviewEventsParams` - **customer\_id:** `string` Path param: - **events:** `Array` Body param: - **event\_type:** `string` - **customer\_id:** `string` This has no effect for preview events, but may be set for consistency with Event objects. They will be processed even if they do not match the customer's ID or ingest aliases. - **properties:** `Record` - **timestamp:** `string` RFC 3339 formatted. If not provided, the current time will be used. - **transaction\_id:** `string` This has no effect for preview events, but may be set for consistency with Event objects. Duplicate transaction_ids are NOT filtered out, even within the same request. - **mode:** `"replace" | "merge"` Body param: If set to "replace", the preview will be generated as if those were the only events for the specified customer. If set to "merge", the events will be merged with any existing events for the specified customer. Defaults to "replace". - `"replace"` - `"merge"` - **skip\_zero\_qty\_line\_items:** `boolean` Body param: If set, all zero quantity line items will be filtered out of the response. ### Returns - `CustomerPreviewEventsResponse` - **data:** `Invoice` ### Example ```node import Metronome from '@metronome/sdk'; const client = new Metronome({ bearerToken: 'My Bearer Token', }); const response = await client.v1.customers.previewEvents({ customer_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc', events: [ { event_type: 'heartbeat', timestamp: '2021-01-01T00:00:00Z', properties: { cpu_hours: 100, memory_gb_hours: 200 }, }, ], }); console.log(response.data); ```