# Webhook

{% hint style="info" %}
**Good to know:** Because image generation takes a long time, when you request image generation, you will need to set up a webhook to listen for the event when the image is generated.
{% endhint %}

## Setup

```
// First create a webhook with method post
// example: https://telegram.crazyhorse.ai/webhook
// payload: {
        "state": "DONE",
        "code": "89e78b15d29165008cbfd61ba3bb679f",
        "image": "ced3e3051c203193952d8b51fe5c9d82/89e78b15d29165008cbfd61ba3bb679f.png",
        "generateImageUrls": [
            "ced3e3051c203193952d8b51fe5c9d82/89e78b15d29165008cbfd61ba3bb679f/generate-1.png"
        ],
        "params": {
            "hair": "red",
            "clothes": "t-shirt, jean",
            "number": 1
        },
        "createdAt": "2023-10-09T11:11:07.174Z"
}
```

## Get result

<mark style="color:green;">`POST`</mark> `https://telegram.crazyhorse.ai/webhook`

Get result when image is generated

#### Request Body

| Name              | Type      | Description                                                                                                                                                                                                                                                                                                                                                                     |
| ----------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| params            | object    | <p><strong>These params</strong></p><p>  <code>hair</code>: string,</p><p>  <code>pose</code>: string,</p><p>  <code>body</code>: string,</p><p>  <code>chest</code>: string,</p><p>  <code>clothes</code>: string,</p><p>  <code>background</code>: string,</p><p>  <code>number</code>: number,</p><p>  <code>loraId</code>: string,</p><p>  <code>debug</code>: boolean,</p> |
| createdAt         | string    |                                                                                                                                                                                                                                                                                                                                                                                 |
| state             | String    | string                                                                                                                                                                                                                                                                                                                                                                          |
| code              | String    | request code                                                                                                                                                                                                                                                                                                                                                                    |
| image             | String    | url origin image                                                                                                                                                                                                                                                                                                                                                                |
| generateImageUrls | String\[] | url generated images                                                                                                                                                                                                                                                                                                                                                            |

{% tabs %}
{% tab title="200 Success" %}

```javascript
"success"
```

{% endtab %}
{% endtabs %}
