> For the complete documentation index, see [llms.txt](https://api.direct.revicom.ltd/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://api.direct.revicom.ltd/messages/stopping.md).

# Stopping Messages

## Stopping messages by uuid

<mark style="color:green;">`POST`</mark> `https://direct.revicom.ltd/api/v1/message/stop`

The method allows for permanent cancelation of single messages with identifiers transmitted

#### Headers

| Name                                            | Type   | Description        |
| ----------------------------------------------- | ------ | ------------------ |
| Authorization<mark style="color:red;">\*</mark> | string | `Basic {TOKEN_1}`  |
| Content-Type<mark style="color:red;">\*</mark>  | string | `application/json` |

#### Request Body

| Name                                    | Type  | Description                                                      |
| --------------------------------------- | ----- | ---------------------------------------------------------------- |
| uuids<mark style="color:red;">\*</mark> | array | Array of message identifiers; at most 10,000 values are allowed. |

{% tabs %}
{% tab title="200" %}
If the request is correct, a response will list the message stopping statuses.

```
{
  "errors": true,
  "items": [
    {
      "messageUuid": "2a28d557-22a1-4be6-8908-1481723043dd",
      "code": 201
    },
    {
      "messageUuid": "811c27e3-3bc4-406a-9fcd-44435a8208da",
      "code": 403
    },
    {
      "messageUuid": "cc46e6b6-2d77-4457-aa81-c17a027721d3",
      "code": 404
    }
  ]
}
```

{% endtab %}

{% tab title="401" %}
Invalid token used/ authorization header missing.

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

```
{
    "error": {
        "code": 4012,
        "msg": "Bad credentials"
    }
}
```

{% endtab %}

{% tab title="4010" %}

```
{
    "error": {
        "code": 4010,
        "msg": "Not Authenticated"
    }
}
```

{% endtab %}
{% endtabs %}
{% endtab %}

{% tab title="403" %}
Token of wrong type used.

```
{
    "error": {
        "code": 4030,
        "msg": "Access Denied"
    }
}
```

{% endtab %}
{% endtabs %}

{% hint style="warning" %}
Changing the status of messages is asynchronous: it can take a few seconds between successful completion of the request and the status of messages being set to unsent.
{% endhint %}

{% hint style="info" %}

* This request can be performed for both single messages and dispatch messages
* When a root cascade message is successfully stopped, the entire cascade from that message will be stopped
  {% endhint %}

## **Response object description** <a href="#response-description" id="response-description"></a>

```
{
  "errors": true,
  "items": [
    {
      "messageUuid": "2a28d557-22a1-4be6-8908-1481723043dd",
      "code": 200
    },
    {
      "messageUuid": "063464ec-a34f-4558-90c5-984395000001",
      "code": 202
    },
    {
      "messageUuid": "811c27e3-3bc4-406a-9fcd-44435a8208da",
      "code": 403
    },
    {
      "messageUuid": "cc46e6b6-2d77-4457-aa81-c17a027721d3",
      "code": 404
    }
  ]
}
```

| Parameter         | Type    | Description                                                                                                                                                                                                                                                                                                                                                                                    |
| ----------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| errors            | boolean | Unsuccessful message stops (codes 403, 404 in the response)                                                                                                                                                                                                                                                                                                                                    |
| items             | array   | Array with message stop result objects                                                                                                                                                                                                                                                                                                                                                         |
| items.messageUuid | string  | Message ID                                                                                                                                                                                                                                                                                                                                                                                     |
| items.code        | integer | <p>Message stop result:</p><ul><li>200 — the message will be stopped for sure</li><li>202 — the message will be stopped <strong>not</strong> for sure, because it enters the stage of sending or generating a cascade message</li><li>403 — the message cannot be stopped because it is being sentor already sent</li><li>404 — the message was not stopped because it was not found</li></ul> |

## Request example <a href="#example" id="example"></a>

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

```
POST https://direct.revicom.ltd/api/v1/message/stop
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Content-Type: application/json
{
  "uuids": [
    "2a28d557-22a1-4be6-8908-1481723043dd",
    "811c27e3-3bc4-406a-9fcd-44435a8208da",
    "cc46e6b6-2d77-4457-aa81-c17a027721d3"
  ]
}
```

{% endtab %}

{% tab title="cURL" %}

```
curl -X POST 'https://direct.revicom.ltd/api/v1/message/stop' \
-H 'Content-Type: application/json' \
-H 'Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==' \
-d '{"uuids":["2a28d557-22a1-4be6-8908-1481723043dd","811c27e3-3bc4-406a-9fcd-44435a8208da","cc46e6b6-2d77-4457-aa81-c17a027721d3"]}'
```

{% endtab %}
{% endtabs %}
