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

# Contact and note deletion webhook examples

> Handle contact deletion and independent note deletion events.

> [!NOTE]
>
> For the exhaustive schema-derived catalog, see [all examples](https://docs.ycloud.com/en/api-reference/guides/examples/webhook-examples/webhook-payload-examples).

## What it is

Handle `contact.deleted` and `contact.note.deleted` events.

## Before you begin

* Create a public HTTPS endpoint in your application.
* Configure a YCloud webhook endpoint for the event types you need.
* Store the endpoint signing secret securely.
* Make event processing idempotent.

## How it works

YCloud sends an HTTP `POST` request when the event occurs. Verify the signature, durably record the event, return a `2xx` response, and process slow work asynchronously.

## Request

The scenarios below show requests delivered to your webhook URL. Treat the event `id` as the delivery identifier and use `type` to route the payload.

## Response

Return a `2xx` status after accepting the event.

```http theme={"theme":{"light":"github-light","dark":"github-dark"}}
HTTP/1.1 200 OK
```

> [!NOTE]
>
> For endpoint setup, signature validation, and retry behavior, see [Configure webhooks](https://docs.ycloud.com/en/api-reference/guides/api-fundamentals/configure-webhooks.md).

Prerequisites

* The webhook endpoint URL should be provided by your server instead of YCloud. **Make sure to replace the URL with your actual webhook endpoint URL.**
* **Make sure that your webhook endpoint is listening for the appropriate event types.** See also [Configure Webhooks](https://docs.ycloud.com/en/api-reference/guides/api-fundamentals/configure-webhooks.md), [Retrieve a webhook endpoint API](https://docs.ycloud.com/api-reference/webhook-endpoints/retrieve-a-webhook-endpoint.md).

Occurs when a contact is deleted. The webhook payload contains minimal contact information that was deleted.

## Basic Contact Deleted Example

### Request

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "id": "evt_3456789012",
  "type": "contact.deleted",
  "apiVersion": "v2",
  "createTime": "2024-01-01T12:00:00.000Z",
  "contactDeleted": {
    "id": "1824266594102064128",
    "nickName": "John Doe",
    "phoneNumber": "+16315551111",
    "updateTime": "2024-01-01T12:00:00.000Z"
  }
}
```

### Response

Acknowledge the delivery after durably accepting the event.

```http theme={"theme":{"light":"github-light","dark":"github-dark"}}
HTTP/1.1 200 OK
```

### Explanation

* **Minimal Information**: The `contactDeleted` object contains only essential information: `id`, `nickName`, `phoneNumber`, and `updateTime`.
* **Null Values**: The `nickName` field may be `null` if the contact didn't have a nickname set.
* **Update Time**: The `updateTime` reflects when the contact was last modified before deletion.
* **Contact ID**: The `id` field contains the unique identifier of the deleted contact for reference.
* **Phone Number**: The `phoneNumber` is always present and formatted in E.164 format.

## Contact note deleted

Use `contact.note.deleted` when a contact note is deleted.

### Request

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "id": "evt_3234567890abcdef12345678",
  "type": "contact.note.deleted",
  "apiVersion": "v2",
  "createTime": "2024-01-03T12:00:00.000Z",
  "contactNote": {
    "id": "6a3de646e18f344f743aaa4d",
    "contactId": "1824266594102064128",
    "username": "alice_01",
    "phoneNumber": "+16315551111",
    "content": "Customer now prefers afternoon follow-up.",
    "createTime": "2024-01-01T12:00:00.000Z",
    "updateTime": "2024-01-02T12:00:00.000Z"
  }
}
```

### Response

Acknowledge the delivery after durably accepting the event.

```http theme={"theme":{"light":"github-light","dark":"github-dark"}}
HTTP/1.1 200 OK
```

### Explanation

Use `contactNote.id` to identify the note and `contactId` to identify its owning contact. `username` and `phoneNumber` describe the contact and can be null. The payload contains the customer-facing note snapshot, including `content`, without internal operator identifiers. This event is emitted for an independent note deletion. Deleting a contact does not emit it for each cascaded note.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.