export type CreateApiIdentitiesEventsSaveArgs = {body: {identity_type: string, profile_id: string, event_type: string, event_data: Record, timestamp?: number | undefined}}; export type CreateApiIdentitiesEventsSaveOptions = {baseUrl?: string | undefined, apiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Save the identity event. * * POST /identities/events/save */ export const createApiIdentitiesEventsSave = async (args: CreateApiIdentitiesEventsSaveArgs, options?: CreateApiIdentitiesEventsSaveOptions) => { const {baseUrl = "https://api.phantombuster.com/api/v2", fetch: fetchFn = fetch, apiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (apiKeyAuth !== undefined) headers.set("X-Phantombuster-Key", apiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/identities/events/save${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };