> For the complete documentation index, see [llms.txt](https://mipos.gitbook.io/public-api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mipos.gitbook.io/public-api/delivery-orders/webhook-management.md).

# Webhook management

This public API includes webhook for the following cases:\
1.Incoming orders(type="ORDER"), is the webhook where our service will send new orders.

2.Get Menu(type="Menu"), is the webhook where our service will get POS menu.

The URLs that will receive the requests must be configured with the following endpoint.

{% hint style="info" %}
When you set a Menu type webhook, our service will send to you the store\_id as a body parameter.
{% endhint %}

## Set up webhook

<mark style="color:green;">`POST`</mark> `https://integrations.mipos.shop/api/v1/integration/webhook/create`

#### Headers

| Name          | Type   | Description            |
| ------------- | ------ | ---------------------- |
| Authorization | string | Bearer {access\_token} |
| Content-Type  | string | application/json       |

#### Request Body

| Name | Type   | Description                         |
| ---- | ------ | ----------------------------------- |
| type | string | Webhook type, by default is "ORDER" |
| url  | string | Webhook URL                         |

{% tabs %}
{% tab title="201 " %}

```javascript
{
    "message": "Webhook successfully created",
    "data": null
}
```

{% endtab %}

{% tab title="401 " %}

```
"Unauthorized."
```

{% endtab %}

{% tab title="409 " %}

```javascript
{
    "message": [
        "User not authenticated.",
        "User not found.",
        "This webhook already exists",
        "Unable to set up the webhook URL."
    ],
    "data": null
}
```

{% endtab %}

{% tab title="422 " %}

```javascript
{
    "url": [
        "The url field is required."
    ]
}
```

{% endtab %}
{% endtabs %}

## Update webhook

<mark style="color:green;">`POST`</mark> `https://integrations.mipos.shop/api/v1/integration/webhook/update`

#### Headers

| Name          | Type   | Description            |
| ------------- | ------ | ---------------------- |
| Authorization | string | Bearer {access\_token} |
| Content-Type  | string | application/jsonc      |

#### Request Body

| Name         | Type   | Description         |
| ------------ | ------ | ------------------- |
| current\_url | string | Current webhook URL |
| new\_url     | string | New webhook URL     |

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

```javascript
{
    "message": "Webhook successfully updated",
    "data": null
}
```

{% endtab %}

{% tab title="401 " %}

```
"Unauthorized."
```

{% endtab %}

{% tab title="409 " %}

```javascript
{
    "message": [
        "User not authenticated.",
        "User not found.",
        "This webhook does not exist",
        "This new webhook already exists",
        "Unable to update the webhook URL."
    ],
    "data": null
}
```

{% endtab %}

{% tab title="422 " %}

```javascript
{
    "current_url": [
        "The current url field is required."
    ],
    "new_url": [
        "The new url field is required."
    ]
}
```

{% endtab %}
{% endtabs %}

## Delete webhook

<mark style="color:green;">`POST`</mark> `https://integrations.mipos.shop/api/v1/integration/webhook/delete`

#### Headers

| Name          | Type   | Description            |
| ------------- | ------ | ---------------------- |
| Authorization | string | Bearer {access\_token} |
| Content-Type  | string | application/json       |

#### Request Body

| Name | Type   | Description |
| ---- | ------ | ----------- |
| url  | string | Webhook URL |

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

```javascript
{
    "message": "Webhook successfully removed",
    "data": null
}
```

{% endtab %}

{% tab title="401 " %}

```
"Unauthorized."
```

{% endtab %}

{% tab title="409 " %}

```javascript
{
    "message": [
        "User not authenticated.",
        "User not found.",
        "This webhook does not exist",
        "Unable to remove the webhook URL."
    ],
    "data": null
}
```

{% endtab %}

{% tab title="422 " %}

```javascript
{
    "url": [
        "The url field is required."
    ]
}
```

{% endtab %}
{% endtabs %}

## Get user webhooks

<mark style="color:blue;">`GET`</mark> `https://integrations.mipos.shop/api/v1/integration/webhooks`

#### Headers

| Name          | Type   | Description    |
| ------------- | ------ | -------------- |
| Authorization | string | Bearer {token} |

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

```javascript
[
    {
        "url": "https://urlwebhook1.test"
    },
    {
        "url": "https://urlwebhook2.test"
    },
    {
        "url": "https://urlwebhook3.test"
    }
]
```

{% endtab %}

{% tab title="401 " %}

```
"Unauthorized."
```

{% endtab %}

{% tab title="409 " %}

```javascript
{
    "message": [
        "User not authenticated.",
        "User not found."
    ],
    "data": null
}
```

{% endtab %}
{% endtabs %}
