# 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 %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://crazyhorse.gitbook.io/crazyhorse/reference/api-reference/webhook.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
