> ## Documentation Index
> Fetch the complete documentation index at: https://docs.userecord.io/llms.txt
> Use this file to discover all available pages before exploring further.

# client.acknowledgeWebhookEvents()

> Remove processed events from the SmartAI queue. Always call this after saving results.

<Info>
  This is a **Backend SDK method**, not an HTTP endpoint.
</Info>

<Warning>
  **Always save first, acknowledge second.** If your database write fails before you acknowledge, the event will be re-delivered on the next poll. That is safe — as long as your save is idempotent (upsert on `eventId`).
</Warning>

## Signature

<CodeGroup>
  ```typescript Node.js theme={null}
  client.acknowledgeWebhookEvents(eventIds: string[]): Promise<AcknowledgeResult>
  ```

  ```python Python theme={null}
  client.acknowledge_webhook_events(event_ids: list)
  ```
</CodeGroup>

***

## Parameters

<ParamField body="eventIds / event_ids" type="string[]" required>
  Array of `eventId` strings to remove from the queue. Get these from `event.eventId` (Node.js) or `event["eventId"]` (Python) inside the `getWebhookEvents` response.
</ParamField>

***

## Return value

<ResponseField name="acknowledged" type="number">
  Number of events successfully removed from the queue.
</ResponseField>

***

<RequestExample>
  ```typescript Standard usage (Node.js) theme={null}
  const { events } = await client.getWebhookEvents({ limit: 50 });

  for (const event of events) {
    await saveToYourDatabase(event);
  }

  await client.acknowledgeWebhookEvents(events.map(e => e.eventId));
  ```

  ```python Standard usage (Python) theme={null}
  result = client.get_webhook_events(limit=50)
  events = result.get("events", [])

  for event in events:
      save_to_your_database(event)

  if events:
      client.acknowledge_webhook_events([e["eventId"] for e in events])
  ```

  ```typescript Safe partial acknowledgement (Node.js) theme={null}
  const processedIds: string[] = [];

  for (const event of events) {
    try {
      await saveToYourDatabase(event);
      processedIds.push(event.eventId);
    } catch (err) {
      console.error('Failed to save', event.eventId, err);
    }
  }

  if (processedIds.length) {
    await client.acknowledgeWebhookEvents(processedIds);
  }
  ```

  ```python Safe partial acknowledgement (Python) theme={null}
  processed_ids = []

  for event in events:
      try:
          save_to_your_database(event)
          processed_ids.append(event["eventId"])
      except Exception as err:
          print(f"Failed to save {event['eventId']}: {err}")
          # Skip — will be re-delivered next poll

  if processed_ids:
      client.acknowledge_webhook_events(processed_ids)
  ```

  ```typescript Idempotent upsert — MongoDB (Node.js) theme={null}
  await db.collection('assessment_results').updateOne(
    { eventId: event.eventId },
    { $setOnInsert: mapEvent(event) },
    { upsert: true }
  );
  ```

  ```python Idempotent upsert — MongoDB (Python) theme={null}
  collection.update_one(
      {"eventId": event["eventId"]},
      {"$setOnInsert": map_event(event)},
      upsert=True,
  )
  ```
</RequestExample>

<ResponseExample>
  ```json Success theme={null}
  {
    "acknowledged": 2
  }
  ```
</ResponseExample>

***

## Error cases

| Condition                                     | Error message                        |
| --------------------------------------------- | ------------------------------------ |
| `eventIds` / `event_ids` is not an array/list | `eventIds must be a non-empty array` |
| `eventIds` / `event_ids` is empty             | `eventIds must be a non-empty array` |
| One or more IDs already acknowledged          | Silently skipped — no error          |
