> For the complete documentation index, see [llms.txt](https://docs.saleschat.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.saleschat.pro/getting-started/webhooks.md).

# Webhooks

## Contact Assigned

Version 1.0

```json
{
	"type": CONTACT_ASSIGNED,
	"version":<double>,
	"payload": {
		"contact_id": <string>,
		"user_id": <string>,
		"is_handover": <boolean>,
		"is_assigned" : <boolean>
	}
}
```

## Chatroom Creation

Version 1.0 & 1.1

```json
{
	"type": CHATROOM_CREATED,
	"version":<double>,
	"payload": {
		"chatroom_id": <string>,
		"external_ref_id": <string>,
		"chatroom_type": <enum CONTACT | AFFILIATE >,
		"is_inbound" : <boolean>
	}
}
```

## Chatroom Status Update (Active/Deactive/Expired)

Version 1.0 & 1.1

```json
{
	"type": CHATROOM_ACTIVATED | CHATROOM_DEACTIVATED | CHATROOM_EXPIRED,
	"version":<double>,
	"payload": {
		"chatroom_id": <string>,
		"chatroom_type": <enum CONTACT | AFFILIATE >,
		"status_update_ts": timestamp
	}  
}
```

## Contact Expired

Version 1.0 & 1.1

```json
{
	"type": CONTACT_EXPIRED,
	"version":<double>,
	"payload": {
		"contact_id": <string>
	}  
}
```

## Send Template Message

Version 1.0 & 1.1

```json
{
	"type": SEND_TEMPLATE_MESSAGE_STATUS,
	"version":<double>,
	"payload": {
		"request_id": <string>,
		"chatroom_id": <string>,
		"remote_phone_id": <string>,
		"remote_waba_id": <string>,
		"remote_template_id": <string>,
		"status": <enum PERMANENTLY_FAILED | DELIVERED>,
		"err_code": <String>,
		"err_reason": <String>
	}  
}
```

## Media Received

Version 1.0 & 1.1

> This webhook will be retried for a maximum of 3 days before being marked as failed.

```json
{
	"type": MEDIA_FILE,
	"version":<double>,
	"payload": {
		"phone_number": <e164_format string>,
		"file_name": <string>,
		"mime_type": <string>,
		"remote_phone_id": <string>,
		"remote_waba_id": <string>,
		"chatroom_id": <string>,
		"org_id": <string>,
		"media_id": <String>
	}  
}
```

## Media Received with Classification

Version 1.0 & 1.1

```json
{
	"type": MEDIA_FILE_WITH_CLASSIFICATION,
	"version":<double>,
	"payload": {
		"phone_number": <e164_format string>,
		"file_name": <string>,
		"mime_type": <string>,
		"remote_phone_id": <string>,
		"remote_waba_id": <string>,
		"chatroom_id": <string>,
		"org_id": <string>,
		"media_id": <String>,
		"classification": {
			"suggested_labels": list<string>,
			"suggested_labels_status": <enum ACCEPTED | REJECTED>,
			"user_input_labels": list<string>
		}
	}  
}
```

## Contact Opt Out Webhook

Version 1.0 & 1.1

```json
{
    "type": CONTACT_OPT_OUT,
    "version":<double>,
    "payload": {
        "phone_number": <e164_format string>,
        "chatroom_id": <string>,
        "opt_out_ts": <timestamp>,
        "opt_out_source": {
            "type": <enum TEMPLATE_BUTTON>,
            "template_id" : <string>,
            "button_id": <string>
        }
    }
}
```

## Analytics Dump

Version 1.0 & 1.1

Note that the file format may vary based on webhook version.

For more details refer to [Metric Dumps](/application/metric-dumps.md)

```json
{
    "type": ANALYTICS_DUMP_FILE,
    "version" : <double>
    "payload": {
        "metric_type": <string>,
        "granualarity": <enum DAILY | WEEKLY>,
        "start_time": <timestamp>,
        "file_id": <string>
    }
}
```

For downloading the file use the [download signed URL API](/api-documentation/media.md) with the above obtained *file\_id*

Analytics Metric Type:

* MESSAGE\_DUMP
* AGENT\_ANALYTICS
