# API builder

Some API request functions can be run in the Calculator.

Requests are sent via the **POST** or **GET** method to a URL in the following format:

**<https://chatter.mavibot.ai/api/{api\\_key}/{action}>**

Where:

**api\_key** — the API access key generated in the project settings.

<figure><img src="/files/1HjIw6l2WcC8Yq3PIQVg" alt=""><figcaption></figcaption></figure>

{% hint style="success" %}
To use the token in a URL request, you first need to generate an API key.

Instructions for doing this are provided in the "Generating an API Key" section. <mark style="color:red;">**ссылка**</mark>
{% endhint %}

{% hint style="danger" %}
When copying a URL from this page, a space may appear and must be removed.

Example of an incorrect link:&#x20;<https://chatter.mavibot.pro> /api/callback

If the space after .pro remains, the request won’t work.
{% endhint %}

{% hint style="warning" %}
Do not use prohibited characters when sending a GET request.

Make sure you understand the correct format for GET requests.
{% endhint %}

## **How to generate an API key**

{% hint style="success" %}
The old API key generation feature still works as before but is not available for new projects.

If your project already has API keys generated without the access settings described in this section, those existing API keys will continue to function normally.

If you need to generate new keys, use the updated settings.
{% endhint %}

To generate an API key, go to the project settings:

<figure><img src="/files/NxPq3ggLbNfjEbGPPuwQ" alt="" width="301"><figcaption></figcaption></figure>

Next, go to the "Integrations" section:

<figure><img src="/files/brhuwUHCjYD5Ts9Z0tZt" alt="" width="563"><figcaption></figcaption></figure>

You’ll find the “Add API key” button in the "Integrations" section:

<figure><img src="/files/mRh7TIwSHnzHu2m2VOTK" alt=""><figcaption></figcaption></figure>

After clicking the button, a modal window will open with access settings and API key generation options:

<figure><img src="/files/r0edfKG0hrokkxYIL5bi" alt=""><figcaption></figcaption></figure>

Next, you need to select the access permissions for the API key:

<figure><img src="/files/wPxEflMN3fF7QmjTmXO1" alt=""><figcaption></figcaption></figure>

The API function will work according to the access permissions you select.

{% hint style="warning" %}
Please note!

The API function depends on the access permissions you set: if you generate an API key with read-only access to client information and then use it to send a message to a client or modify their variables, the API request will fail.\
The required permission for each API request is specified in the API request card:

<img src="/files/FUzZbPiFxa1U2nxs7oN3" alt="" data-size="original">
{% endhint %}

Next, enter a name for the API key:

<figure><img src="/files/s11snpXzn3L0GguS5ye9" alt=""><figcaption></figcaption></figure>

Generate the API key by clicking the "Generate" button:

<figure><img src="/files/BuVXA7PD09AbhvjJtVi7" alt=""><figcaption></figcaption></figure>

После чего нажмите "Готово" и ключ api добавится в раздел:

<figure><img src="/files/57NjB1IKhUeYXI5R0h4K" alt=""><figcaption></figcaption></figure>

You can add as many API keys as needed, assigning different access permissions to each.

<figure><img src="/files/P9xwUAiTMVqVqDy1zJaH" alt=""><figcaption></figcaption></figure>

Next, you need to set a primary project key. This allows you to use the key in a request URL with the #{api\_key} placeholder.

To do this, click the "{+}" button to the right of the desired API key:

<figure><img src="/files/xemnyN1iniPu3Z17YhNK" alt=""><figcaption></figcaption></figure>

A label will then appear next to the key, indicating that it is the primary project key.

<figure><img src="/files/KtCz5SkbMX2zsKR8BBDk" alt=""><figcaption></figcaption></figure>

You can access the primary project key via api\_key: simply generate the required key, set its permissions, and designate it as the primary project key. Then, in the Calculator, use the request URL with the #{api\_key} placeholder, which will contain the value of the primary project key.

<figure><img src="/files/T2YsdYDAQTIVaMeU2fat" alt=""><figcaption><p>URL запроса</p></figcaption></figure>

<figure><img src="/files/CNBLQvnmQGH2tnlaiE63" alt=""><figcaption></figcaption></figure>

Any other generated keys with access settings will be considered secondary keys. In the request URL, you can use their value instead of #{api\_key}. To do this, copy the value of the secondary key:

<figure><img src="/files/30nvqZYlwv8UwA28gXBu" alt=""><figcaption></figcaption></figure>

and paste it into the request URL in place of #{api\_key}:

<figure><img src="/files/WSE52keHfxWeKXDXUuJ0" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
An API key generated using the old method is set as the primary project key by default and has full permissions.
{% endhint %}

{% hint style="danger" %}
Note!&#x20;

If you delete the key set as the primary project key, you will need to manually designate a new key as the primary.
{% endhint %}

{% hint style="success" %}
Please note!&#x20;

If you have API keys generated using the old method, they will continue to work normally. It is not possible to generate new API keys of the old type.
{% endhint %}

## How to receive messages at the Webhook URL specified in the project settings

![Project settings](/files/-MAzbQGo0OeseVRi1nWV)

Each incoming or outgoing message will be sent as the following JSON POST request:

```
{
    "id": "message ID in the system",
    "client": {
        "id": "client ID in the system",
        "recepient": "client ID in the messenger",
        "client_type": "type of messenger",
        "name": "client's name",
        "avatar": "client's avatar",
        "created_at": "client creation date",
        "tag": "subscription key",
        "group": "bot the client is linked to"
    },
    "message": "message text",
    "attachments": "array containing file links or dictionaries of file links",
    "message_id": "ID of the block from which the message was sent",
    "project_id": "project ID",
    "is_input": "1 if the message is from the client, 0 if from the bot",
    "delivered": "1 if the message was sent successfully, 0 if there was an error",
    "error_message": "text of the message delivery error"
}
```

If a request returns an error, it will not be retried. Even if the server returns errors, notifications will continue to be sent.

### How to create a JSON request

Go to the settings of the block where the data will be recorded in the table.&#x20;

<figure><img src="/files/7pjieYydkBHw03azeiQY" alt=""><figcaption></figcaption></figure>

1. Add an API Request section.
2. Select POST-JSON as the request type.
3. Then proceed to fill in the request fields:

<figure><img src="/files/jFOqkrntx1tIVJcLmsAr" alt=""><figcaption></figcaption></figure>

**Request URL** — the path to the function to be called. In the documentation, this is always shown on the first line next to the request type:

<figure><img src="/files/DNFST1ffYyJzjdItheNx" alt=""><figcaption></figcaption></figure>

**Saved values** — a list of response parameters with the variable names where the results should be stored, in the following format:

> **request\_parameter -> your\_variable**
>
> If the response contains parameters with a complex structure, parse them as follows:
>
> * > "cell\_number":{"row":4,"col":2}\
>   > \
>   > \
>   > cell\_number|row ->String; \
>   > cell\_number|col -> Column<br>

**Request headers** — fill in if needed. This usually includes the data format and/or access token.

**JSON parameters** — the request body, where you specify the data parameters in JSON format. Example:

**{"client\_id": "#{recipient\_id\_in\_builder}", "message":"Hello!"}**

To understand the structure of the response, write #{custom\_answer} in the Message field to output the variable’s value.<br>

<figure><img src="/files/wF8iAhM5eC3edbrkYRrf" alt=""><figcaption><p>Receiving the result of an API request as a message</p></figcaption></figure>

Next, the documentation lists the allowed parameters in the "Body" section:&#x20;

<figure><img src="/files/46MXc86xGhsnI4zIw7aO" alt="" width="551"><figcaption></figcaption></figure>

## How to use a universal webhook

The listed methods can now be executed as either POST or GET requests.

* [callback](#zapusk-bota)
* [whatsapp\_callback](#zapusk-bota)
* [message](#otpravka-soobshenii)
* [whatsapp\_message](#otpravka-soobshenii)

Previously, our methods had fixed parameters (such as **client\_id** and **fb\_id**) for triggering subscriber actions, which imposed certain limitations when integrating with third-party services.

Now you can specify which request parameter SaleBot should use to find the user ID. Use a parameter with the **value\_ prefix**, for example, **value\_user\_id** or **value\_group\_id**.

Additionally, the callback sending method can now be triggered using the client’s email (**client\_email**) or phone number (**client\_phone**).

{% hint style="success" %}
The **callback**, **fb\_callback**, and **whatsapp\_callback** methods are not tied to specific parameter names. You can specify which parameter contains the client’s phone number, email, or ID.
{% endhint %}

This is useful when setting up webhook reception from a website.

**To specify which variable contains the client\_id**, use the value\_client\_id parameter and provide the name of the parameter holding this value.

**To specify which variable contains the phone number**, use value\_phone.

**To specify which variable contains the email,** use value\_email.

**To specify which variable contains the user\_id**, use value\_user\_id.

**To specify which variable contains the group\_id**, use value\_group\_id.

**To specify the variable containing the message itself in the webhook**, use value\_message (passed in the same way as the other parameters).

Example:

In the address, specify value\_client\_id = my\_client.

`https://chatter.mavibot.ai/api/d3f31dabef80ddeb73d43938b4ef8bb0/callback?value_client_id=my_client`\
`{"my_client":49177759, "message":"Hello world"}`

The request will be equivalent to the one below:

`https://chatter.mavibot.pro/api/d3f31dabef80ddeb73d43938b4ef8bb0/callback`\
`{"client_id":49177759, "message":"Hello world"}`

As you can see, the parameter name containing the value is prefixed with **value\_**.

{% hint style="warning" %}
Please note!&#x20;

Some events generate system notifications within the project.

For example, there are system notifications with a message field that are not empty but contain no client text.

At the same time, the project may also generate message hooks with specific content, such as "message: new\_chat\_member".

Therefore, it’s important to check the content: it will either be a system notification or a hook for a specific event.
{% endhint %}

## How to start the bot

### Start the bot

<details>

<summary><mark style="color:green;">POST</mark> https://chatter.mavibot.ai/api/#{api_key}/callback</summary>

URL запроса: <https://chatter.mavibot.ai/api/#{api\\_key}/callback><br>

This method can be used to trigger a funnel for a client or confirm an action on an external resource. The client will not see this message.<br>

**Please note: any parameters you additionally pass will be saved in variable**

The callback method can now also be triggered using the client’s email (client\_email) or phone number (client\_phone).

Access permission when generating a key: **"Permission to modify/delete client information"**.

<img src="/files/cwGN9svUAoEo6lja7m7b" alt="" data-size="original">

Path

api key\* - access token

Body

client\_phone - phone number used to look up the client

client\_email - email used to look up the client

client\_id - client ID in the builder

message - message text

resume\_bot - True (optional parameter). If the bot is paused, this is used to unpause it.&#x20;

Example: resume\_bot = True

time\_shift - number. If specified, the message will be sent after the given number of seconds from the current time.

send\_time - date and time in the format "%Y-%m-%d %H:%M:%S" (e.g., "2024-10-16 13:15:59"). This sets the date and time for sending the message. If both time\_shift and send\_time are specified, time\_shift will take precedence.

```
import requests
import json

params = {"message": "some_text", "client_id": "25554"}
token = 'b551e18c8b8e86bea6f14f38de3f5cc3c31ba1edb4d8'
url = f'https://chatter.salebot.pro/api/{token}/callback'
requests.post(url, json=params)
```

</details>

### Starting the bot using a WhatsApp number

<details>

<summary><mark style="color:green;">POST</mark> https://chatter.mavibot.ai/api/&#x3C;api_key>/whatsapp_callback</summary>

URL request: <https://chatter.mavibot.ai/api/\\>\<api\_key>/whatsapp\_callback

This method can trigger the WhatsApp bot after a client registers on the website or submits a request with their phone number.

**Please note: any parameters you additionally pass will be saved in variable**

Access permission when generating a key: **"Permission to modify or delete client information"**.

<img src="/files/cwGN9svUAoEo6lja7m7b" alt="" data-size="original">

Path

api key\* - access token

Body

name - client name\
message - message text\
phone - client phone number\
bot\_id - bot ID\
resume\_bot - True (optional parameter). If the bot is paused, use this to resume it. Example: resume\_bot = True

time\_shift - number. If specified, the message will be sent after the given number of seconds from the current time.

send\_time - date and time in the format "%Y-%m-%d %H:%M:%S" (e.g., "2024-10-16 13:15:59"). This sets the date and time for sending the message. If both time\_shift and send\_time are specified, time\_shift will take precedence.

</details>

### Starting the bot using a Telegram ID

<details>

<summary><mark style="color:green;">POST</mark> https://chatter.mavibot.pro/api/#{api_key}/tg_callback</summary>

URL request: <https://chatter.mavibot.pro/api/#{api\\_key}/tg\\_callback>

This method can be used to trigger a funnel for a client or confirm an action on an external website. The client will not see this message.

**Please note: any parameters you additionally pass will be saved in variables.**

Access permission when generating a key: **"Permission to modify or delete client information"**.

<img src="/files/cwGN9svUAoEo6lja7m7b" alt="" data-size="original">

Path

api key\* - access token

Body

message - message text\
user\_id - Telegram user ID\
group\_id - bot name (ended as bot)\
resume\_bot - True (optional parameter). If the bot is paused, use this to resume it. Example: resume\_bot = True

time\_shift - number. If specified, the message will be sent after the given number of seconds from the current time.

send\_time - date and time in the format "%Y-%m-%d %H:%M:%S" (e.g., "2024-10-16 13:15:59"). This sets the date and time for sending the message. If both time\_shift and send\_time are specified, time\_shift will take precedence.

</details>

### Sending callback messages to a list of clients by platform\_id

<details>

<summary><mark style="color:green;">POST</mark>  https://chatter.mavibot.ai/api/#{api_key}/send_callback_by_platform_id</summary>

URL request: <https://chatter.mavibot.ai/api/#{api\\_key}/send\\_callback\\_by\\_platform\\_id>

When clients with a platform\_id from the list are found in the project, a callback will be sent with the text from the callback\_text field.\
\ <mark style="color:red;">**Limit: 1 request = maximum 300 sends**</mark>&#x20;

Example of request parameters:\
{"platform\_ids":\[407184121, "79609879898", "2rwewefw"], "callback\_text": "test\_callback"}

Access permission when generating a key: **"Permission to modify or delete client information"**.

<img src="/files/cwGN9svUAoEo6lja7m7b" alt="" data-size="original">

Path

api key\* - access token

Body

platform\_ids - List of client IDs in the messenger\
callback\_text - callback text\
group\_id - bot ID

time\_shift - number. If specified, the message will be sent after the given number of seconds from the current time.

send\_time - date and time in the format "%Y-%m-%d %H:%M:%S" (e.g., "2024-10-16 13:15:59"). This sets the date and time for sending the message. If both time\_shift and send\_time are specified, time\_shift will take precedence.

</details>

### Sending a callback message to a client by email

<details>

<summary><mark style="color:green;">POST</mark> https://chatter.mavibot.ai/api/#{api_key}/email_callback</summary>

URL request: <https://chatter.mavibot.ai/api/#{api\\_key}/email\\_callback>

This method can trigger the email bot after a client registers on the website or submits a request with their email. The method will locate the client’s email or create it if not found.

Access permission when generating a key: **"Permission to modify or delete client information"**.

<img src="/files/cwGN9svUAoEo6lja7m7b" alt="" data-size="original">

**Please note: any parameters you additionally pass will be saved in variable**

Path

api key\* - access token

Body

name - client name\
message - message text\
email - email address\
email\_id\_bot - bot email address\
resume\_bot - True (optional parameter).&#x20;

If the bot is paused, use this to resume it. Example: resume\_bot = True

time\_shift - number. If specified, the message will be sent after the given number of seconds from the current time.

send\_time - date and time in the format "%Y-%m-%d %H:%M:%S" (e.g., "2024-10-16 13:15:59"). This sets the date and time for sending the message. If both time\_shift and send\_time are specified, time\_shift will take precedence.

</details>

## How to work with messages

### Message sending parameters

**attachment\_type** — can be: **image, video, link, file, or audio**.\
When sending an attachment, the message parameter is optional.

**buttons** — defines the buttons to be attached to the message. The button format matches the advanced button settings.

Buttons can be passed in two ways: with a hint for messengers that don’t support buttons, or without it.

Example of the buttons parameter:

```
"buttons": {
  "hint": "This text will be displayed in WhatsApp",
  "buttons": [
    {
      "type": "reply",
      "text": "Tell me about the services",
      "line": 0,
      "index_in_line": 0
    },
    {
      "type": "reply",
      "text": "Service prices",
      "line": 0,
      "index_in_line": 1
    },
    {
      "type": "reply",
      "text": "Contacts",
      "line": 1,
      "index_in_line": 0
    },
    {
      "type": "reply",
      "text": "Submit a request",
      "line": 1,
      "index_in_line": 1
    }
  ]
}
```

### Sending a message to a client

<details>

<summary><mark style="color:green;">POST</mark>  https://chatter.mavibot.ai/api/#{api_key}/message</summary>

URL запроса: <https://chatter.mavibot.ai/api/#{api\\_key}/message>

This method can be used to send notification messages. The message parameter is required unless you are sending a file. If you are sending a file, the text is optional.

Access permission when generating a key: **"Permission to modify or delete client information"**.

<img src="/files/cwGN9svUAoEo6lja7m7b" alt="" data-size="original">

Path

api key\* - access token

Body

message\_id - block number for sending\
message - message text\
client\_id - client ID in the builder\
attachment\_type - file display type. Required if attachment\_url is provided.\
attachment\_url - file URL\
buttons - buttons

time\_shift - number. If specified, the message will be sent after the given number of seconds from the current time.

send\_time - date and time in the format "%Y-%m-%d %H:%M:%S" (e.g., "2024-10-16 13:15:59"). This sets the date and time for sending the message. If both time\_shift and send\_time are specified, time\_shift will take precedence.

```
import requests
import json

# Sending a text message
params = {"message": "some_text", "client_id": "25554"}
token = 'b551e18c8b8e86bea6f14f38de3f5cc3c31ba1edb4d8'
url = f'https://chatter.mavibot.ai/api/{token}/message'
requests.post(url, json=params)

# Sending an attachment
params = {
    "message": "some message",
    "client_id": "1234565",
    "attachment_type": "video/image/file",
    "attachment_url": "https://qwreqw"
}
token = 'b551e18c8b8e86bea6f14f38de3f5cc3c31ba1edb4d8'
url = f'https://chatter.mavibot.ai/api/{token}/message'
requests.post(url, json=params)

# In 'attachment_type', specify either 'video', 'image', or 'file'
# depending on the type of attachment: video, image, or document.
```

</details>

### Sending a message in WhatsApp

<details>

<summary><mark style="color:green;">POST</mark> https://chatter.salebot.pro/api/&#x3C;api_key>/whatsapp_message</summary>

URL запроса: <https://chatter.mavibot.pro/api/\\>\<api\_key>/whatsapp\_message

Allows you to send a message on behalf of the connected bot to the specified number. The whatsapp\_bot\_id must be taken from the "Messengers and chats" section. Each connected WhatsApp account is assigned a unique identifier by the builder.

Access permission when generating a key: **"Permission to modify or delete client information"**.

<img src="/files/cwGN9svUAoEo6lja7m7b" alt="" data-size="original">

Path

api key\* - access token

Body

message\_id - block number for sending\
whatsapp\_bot\_id - WhatsApp bot ID from which the message should be sent\
attachment\_url - file URL\
attachment\_type - file display type. Required if attachment\_url is provided.\
message - message text\
phone - recipient phone number

time\_shift - number. If specified, the message will be sent after the given number of seconds from the current time.

send\_time - date and time in the format "%Y-%m-%d %H:%M:%S" (e.g., "2024-10-16 13:15:59"). This sets the date and time for sending the message. If both time\_shift and send\_time are specified, time\_shift will take precedence.

```
import requests
import json

params = {"message": "some_text", "phone": "79875146788"}
token = 'b551e18c8b8e86bea6f14f38de3f5cc3c31ba1edb4d8'
url = f'https://chatter.mavibot.ai/api/{token}/whatsapp_message'
requests.post(url, json=params)
```

</details>

### Bulk message sending

<details>

<summary><mark style="color:green;">POST</mark> https://chatter.mavibot.ai/api/#{api_key}/broadcast</summary>

URL request: <https://chatter.mavibot.ai/api/#{api\\_key}/broadcast>

This method allows you to start a broadcast.

You can use <mark style="color:red;">**one of the following mutually exclusive options**</mark>:

1. list parameter — the broadcast will be sent to the specified list of clients.
2. clients parameter — the broadcast will be sent to an array of client IDs.
3. platform\_ids and group\_id parameters — the broadcast will be sent to an array of platform\_ids (messenger IDs) for the specified bot (group\_id).
4. If none of the above parameters are provided, the broadcast will not be sent.

Required parameters: message (and/or attachment\_type and attachment\_url) or message\_id.

Access permission when generating a key: **"Permission to modify or delete client information"**.

<img src="/files/cwGN9svUAoEo6lja7m7b" alt="" data-size="original">

**Path**

api key\* - access token

**Body**

**list** - list number to which the broadcast should be sent

clients - client IDs in the builder

message - message text

platform\_ids - recipient IDs in the messenger. Must be used together with the required group\_id parameter

group\_id - required only when using platform\_ids. Ignored with other options. Specifies the bot for sending to the given platform\_ids

attachment\_url - file URL

attachment\_type - file display type. Required if attachment\_url is provided.

buttons - buttons

message\_id - block number for sending

shift — number of seconds between messages. The default is 0.2.

time\_shift - number. If specified, the message will be sent after the given number of seconds from the current time.

send\_time - date and time in the format "%Y-%m-%d %H:%M:%S" (e.g., "2024-10-16 13:15:59"). This sets the date and time for sending the message. If both time\_shift and send\_time are specified, time\_shift will take precedence.

```
import requests
import json

params = {"message": "some_text", "clients": ["5", "58", "110"]}
token = 'b551e18c8b8e86bea6f14f38de3f5cc3c31ba1edb4d8'
url = f'https://chatter.mavibot.ai/api/{token}/broadcast'
requests.post(url, json=params)
```

</details>

### Retrieving message history

<details>

<summary><mark style="color:blue;">GET</mark> https://chatter.mavibot.ai/api/#{api_key}/get_history?client_id=</summary>

URL request: <https://chatter.mavibot.ai/api/#{api\\_key}/get\\_history?client\\_id=>

The client\_id parameter can be obtained here. <mark style="color:red;">**ссылка**</mark>

Access permission when generating the key: **"Permission to read client information"**.

<img src="/files/1nDbUDyZTyibF5Jcpts5" alt="" data-size="original">

**Path**

api key\* - access token

**Body**

client\_id - client ID

limit - number of items in the response. Default: 2000, maximum: 2000

start\_date - start date of the selection period (required if stop\_date is specified), format: dd.mm.yyyy&#x20;

stop\_date - end date of the selection period (required if start\_date is specified), format: dd.mm.yyyy

```
{
  "status": "success",
  "result": [
    {
      "id": 104500,
      "answered": true,
      "client_replica": false,
      "message_id": 390,
      "message_from_outside": 0,
      "created_at": 1587895014,
      "text": "Meow meow",
      "attachments": {
        
      },
      "delivered": true,
      "error_message": "true",
      "manager_id": 12486,
      "manager_email": "example@mail.com"
    },
  ]
}
```

</details>

### Clear message history

<details>

<summary><mark style="color:blue;">GET</mark> https://chatter.mavibot.ai/api/#{api_key}/clear_history?client_id=</summary>

URL запроса: <https://chatter.mavibot.ai/api/#{api\\_key}/clear\\_history?client\\_id=>

Deletes chat history&#x20;

Access permission when generating a key: **"Permission to modify/delete client information"**.

<img src="/files/cwGN9svUAoEo6lja7m7b" alt="" data-size="original">

**Path**

api key\* - access token

**Body**

client\_id - client ID

```
import requests
import json


token = 'b551e18c8b8e86bea6f14f38de3f5cc3c31ba1edb4d8'
url = f'https://chatter.mavibot.ai/api/{token}/clear_history?client_id=85856'
requests.get(url)
```

</details>

## How to assign clients

### Assigning a client to an employee

<details>

<summary><mark style="color:green;">POST</mark>  https://chatter.mavibot.ai/api/#{api_key}/assign_to_user</summary>

URL request: <https://chatter.mavibot.ai/api/#{api\\_key}/assign\\_to\\_user>

This method allows you to assign a client to an employee. The email parameter is optional. If no email is provided, the system will assign the client according to its algorithm.

Access permission when generating a key: **"Permission to modify/delete client information"**.

<img src="/files/cwGN9svUAoEo6lja7m7b" alt="" data-size="original">

**Path**

api key\* - access token

**Body**

client\_id - client ID\
email - employee email (optional)

```
import requests
import json

params = {"client_id":"#{client_id}","email":"xxxxx@mail.ru"}
token = 'b551e18c8b8e86bea6f14f38de3f5cc3c31ba1edb4d8'
url = f'https://chatter.mavibot.ai/api/{token}/broadcast'
requests.post(url, json=params)
```

</details>

### Importing clients into the system

<details>

<summary><mark style="color:green;">POST</mark> https://chatter.mavibot.ai/api/#{api_key}/load_clients</summary>

URL request: <https://chatter.mavibot.pro/api/#{api\\_key}/load\\_clients>

This method allows you to import clients into the system. When uploading WhatsApp clients, you can provide the number in any format, either with the ending @s.whatsapp.net or without it.

The group ID (group\_id) can be obtained HERE via /api/\<api\_key>/connected\_channels. (If client\_type = 13 (telephony), then group\_id is an empty string: ""). <mark style="color:red;">**ссылка**</mark>

The messenger type from which the client came (client\_type) can be found HERE. <mark style="color:red;">**ссылка**</mark>

Example: \[{"platform\_id":"79875555555","group\_id":34810,"client\_type":6}]

Access permission when generating a key: **"Permission to modify or delete client information"**.

<img src="/files/cwGN9svUAoEo6lja7m7b" alt="" data-size="original">

**Path**

api key\* - access token

**Body**

platform\_id - phone number\
group\_id - group ID\
client\_type - the messenger type a client came from

```
import requests
import json
token = 'b551e18c8b8e86bea6f14f38de3f5cc3c31ba1edb4d8'
url = f'https://chatter.mavibot.ai/api/{token}/load_clients'
params = [{ "platform_id": 274827917, "group_id": 169166236, "client_type":0},
{"platform_id":"79538550785@s.whatsapp.net", "group_id": "1hwF7lwEjv4SKYIGFhQnBw==", "client_type": 6}]
requests.post(url, json=params)
# if successful, the function will return an ID and an addition status for each item
# response example
# {"status":"success","items":[{"platform_id":"700000000@s.whatsapp.net","group_id":"5kqchxwyvdvFZOsp80q2qw==","client_type":6,"status":"success","id":1469409}]}
```

</details>

### Add clients to a list

<details>

<summary><mark style="color:green;">POST</mark> https://chatter.mavibot.ai/api/&#x3C;api_key>/add_to_list</summary>

URL request: <https://chatter.mavibot.ai/api/\\>\<api\_key>/add\_to\_list

Adds clients to a list

Access permission when generating a key: **"Permission to modify or delete client information"**.

<img src="/files/cwGN9svUAoEo6lja7m7b" alt="" data-size="original">

**Path**

api key\* - access token

**Body**

list\_id - list number\
clients - client ID array

Example:\
JSON parameters\
{"list\_id":1170282, "clients":\[411262772, 646410963]}

</details>

### Remove clients from a list

<details>

<summary><mark style="color:green;">POST</mark> https://chatter.mavibot.ai/api/#{api_key}/remove_from_list</summary>

URL request: <https://chatter.mavibot.ai/api/#{api\\_key}/remove\\_from\\_list>

Removes clients from a list

Access permission when generating a key: **"Permission to modify or delete client information"**.

<img src="/files/cwGN9svUAoEo6lja7m7b" alt="" data-size="original">

**Path**

api key\* - access token

**Body**

list\_id - list number\
clients - client numbers array in the Mavibot builder (values of client\_id)

</details>

### Retrieve client list

<details>

<summary><mark style="color:blue;">GET</mark> https://chatter.mavibot.ai/api/&#x3C;api_key>/get_clients</summary>

**URL request:** <https://chatter.mavibot.a/aipi/\\>\<api\_key>/get\_clients

Access permission when generating a key: **"Permission to modify or delete client information"**.

<img src="/files/1nDbUDyZTyibF5Jcpts5" alt="" data-size="original">

**Path**

api key\* - access token

**Body**

offset – Offset from the first element

limit – Number of items in the response / Default: 500, Maximum: 500

list – List number

reverse – Indicates reverse sorting (from the oldest record to the newest). This parameter works only if the list is not specified.

Returns the status and an array of items.

```
{
"status":"success",
"clients":[{
    "id":44483,
    "platform_id":"146467928",
    "client_type":0,
    "name":null,
    "avatar":null,
    "message_id":null,
    "project_id":1,
    "created_at":1588248599,
    "updated_at":1588248599,
    "custom_answer":null,
    "tag":null,
    "group":"143414131",
    "operator_start_dialog":null
    }
]
}
```

</details>

### Retrieve the list of bot subscribers in any messenger

<details>

<summary><mark style="color:blue;">GET</mark> https://chatter.mavibot.ai/api/#{api_key}/subscribers</summary>

URL request: <https://chatter.mavibot.ai/api/#{api\\_key}/subscribers>

Retrieves client information from a selected messenger.

*<mark style="color:red;">Note!</mark>* This method does not return variables.

Access permission when generating a key: **"Permission to modify or delete client information"**.

<img src="/files/1nDbUDyZTyibF5Jcpts5" alt="" data-size="original">

**Path**

api key\* - access token

**Body**

page\
tag – Tag specified on the subscription page\
group – VK group ID the subscriber is linked to\
date\_from – Subscribed after this date (timestamp)\
date\_to – Subscribed before this date (timestamp)\
client\_type – Messenger ID for which to retrieve the subscriber list. If not specified, all clients will be returned

```
[  
  {
    "id": 44886,
    "tag": null,
    "created_at": 1609867984,
    "name": "John Smith",
    "vk_id": "146467928",
    "group": "155824294",
    "variables": null
  },
  {
    "id": 44889,
    "tag": null,
    "created_at": 1609867984,
    "name": "Anna Smith",
    "vk_id": "1609867984",
    "group": "155824294",
    "variables": {
      "utm_source": "some_value"
    }
  }
]
```

</details>

## How to work with variables

### Assigning variables

<details>

<summary><mark style="color:green;">POST</mark> https://chatter.mavibot.ai/api/#{api_key}/save_variables</summary>

URL request: <https://chatter.mavibot.ai/api/#{api\\_key}/save\\_variables>

&#x20;<mark style="color:green;">**!**</mark>**&#x20;**<mark style="color:$success;">**No limit applies to this request.**</mark>&#x20;

Allows you to save variables in both the lead and the client.&#x20;By default, the variable assignment request adds them to deal variables.&#x20;To update variables in the client profile, use the client. prefix. For example, for a phone: client.phone.

Access permission when generating a key: **"Permission to modify or delete client information"**.

<img src="/files/1nDbUDyZTyibF5Jcpts5" alt="" data-size="original">

**Update**: The clients parameter allows assigning variables in bulk.\
Example: {"client\_id":49177759, "variables":{"client.phone":"88888888888"}}

**Path**

api key\* - access token

**Body**

clients – Array of client IDs for variable assignment

client\_id – Client ID

variables – Hash of variables (key-value pairs)

```
import requests
import json

params = {"client_id": "25554", "variables": {"var_name": "var_value"}}
token = 'b551e18c8b8e86bea6f14f38de3f5cc3c31ba1edb4d8'
url = f'https://chatter.mavibot.ai/api/{token}/save_variables'
requests.post(url, json=params)
```

</details>

### Retrieve variables

<details>

<summary><mark style="color:blue;">GET</mark> https://chatter.mavibot.ai/api/#{api_key}/get_variables?client_id=</summary>

URL request: <https://chatter.mavibot.ai/api/#{api\\_key}/get\\_variables?client\\_id=>

Access permission when generating a key: **"Permission to modify or delete client information"**.

<img src="/files/1nDbUDyZTyibF5Jcpts5" alt="" data-size="original">

Example: <https://chatter.mavibot.ai/api/d3f31dabef80ddeb73d43938b4ef8bb0/get\\_variables?client\\_id=49177759>

**Path**

api key\* - access token

**Body**

client\_id - client ID

```
import requests
import json


token = 'b551e18c8b8e86bea6f14f38de3f5cc3c31ba1edb4d8'
url = f'https://chatter.mavibot.ai/api/{token}/get_variables?client_id=85856'
requests.get(url)
```

</details>

## How to retrieve the client ID (client\_id)

### Retrieve client\_id using the platform\_id value

<details>

<summary><mark style="color:green;">POST</mark> https://chatter.mavibot.ai/api/#{api_key}/find_client_id_by_platform_id</summary>

**URL request:** <https://chatter.mavibot.ai/api/#{api\\_key}/find\\_client\\_id\\_by\\_platform\\_id>

Access permission when generating a key: **"Permission to modify or delete client information"**.

<img src="/files/1nDbUDyZTyibF5Jcpts5" alt="" data-size="original">

**Path**

api key\* - access token

**Body**

platform\_ids - ID's array in a messanger\
group\_id - bot ID

```
[{
"id":15099119,
"tag":null,
"created_at":1618815253,
"name":"ОЛЬГА БЕЛИК",
"avatar":"https:\\/\\/files.mavibot.ai\\/uploads\\/avatars\\/256865200.jpg",
"platform_id":"2568652",
"group":"Mavibotai_bot",
"variables":{"tg_username":"@belik"}},

{"id":21087377,
"tag":null,
"created_at":1626275893,
"name":"John Smith",
"avatar":"https:\\/\\/files.mavibot.ai\\/uploads\\/avatars\\/571830542.jpg",
"platform_id":"571830542",
"group":"Mavibotai_bot",
"variables":{"tg_username":"@jsmith61"}
}]
```

</details>

### Retrieve the client ID from the online chat

<details>

<summary><mark style="color:blue;">GET</mark> https://chatter.mavibot.ai/api/#{api_key}/online_chat_client_id?recipient=</summary>

URL request: <https://chatter.mavibot.ai/api/#{api\\_key}/online\\_chat\\_client\\_id?recipient=>

This method allows you to integrate a website with a chat bot. For example, if a user visits a promotion page, you can immediately send a message in the chat with a personalized offer.

Access permission when generating a key: "Permission to modify or delete client information".

<img src="/files/cwGN9svUAoEo6lja7m7b" alt="" data-size="original">

**Path**

api key\* - access tiken

**Body**

tag - tag (client tag)\
name - client name\
recipient - dialog ID on a website

#### Where to get the **recipient?**&#x20;

You can get it on the website with the Mavibot.ai online chat, use JS to get the property **MavibotAi.recipient\_id**.

<img src="/files/-MAzdR8vkdqsPGCrvbPI" alt="" data-size="original">

```
{ "client_id": 36553 }
```

</details>

### Retrieve client\_id by WhatsApp number

<details>

<summary><mark style="color:blue;">GET</mark> https://chatter.mavibot.ai/api/#{api_key}/whatsapp_client_id?phone=</summary>

URL request: <https://chatter.mavibot.ai/api/#{api\\_key}/whatsapp\\_client\\_id?phone=>

This method returns the client ID for making API requests if you know the client’s WhatsApp phone number.\
If no client exists with that number, the method will return a 404 error.

Access permission when generating a key: "Permission to modify or delete client information".

<img src="/files/1nDbUDyZTyibF5Jcpts5" alt="" data-size="original">

**Path**

api key\* - access token

**Body**

phone - phone number\
group\_id - bot ID

</details>

### Retrieve client\_id by phone number

<details>

<summary><mark style="color:blue;">GET</mark> https://chatter.mavibot.ai/api/&#x3C;api_key>/find_client_id_by_phone?phone= </summary>

URL request: <https://chatter.mavibot.ai/api/\\>\<api\_key>/find\_client\_id\_by\_phone?phone=&#x20;

This method returns the client ID for making API requests.

The search is performed both among WhatsApp clients and via variables.

Access permission when generating a key: "Permission to modify or delete client information".

<img src="/files/1nDbUDyZTyibF5Jcpts5" alt="" data-size="original">

**Path**

api key\* - access token

**Body**

phone - phone number

</details>

### Retrieve client\_id by email

<details>

<summary><mark style="color:blue;">GET</mark> https://chatter.mavibot.ai/api/#{api_key}/find_client_id_by_email?email= </summary>

URL request: <https://chatter.mavibot.ai/api/#{api\\_key}/find\\_client\\_id\\_by\\_email?email=&#x20>;

This method returns the client ID for making API requests.\
The search is performed using variables.

Access permission when generating a key: "Permission to modify or delete client information".

<img src="/files/1nDbUDyZTyibF5Jcpts5" alt="" data-size="original">

**Path**

api key\* - access token

**Body**

email - email for search

</details>

### Retrieve client\_id by variable value

<details>

<summary><mark style="color:blue;">GET</mark> https://chatter.mavibot.ai/api/#{api_key}/find_client_id_by_var?var=&#x26;val=</summary>

URL запроса: <https://chatter.mavibot.ai/api/#{api\\_key}/find\\_client\\_id\\_by\\_var?var=\\&val=>

This method returns the client ID for making API requests.

Access permission when generating the key: "Permission to read client information"

<img src="/files/1nDbUDyZTyibF5Jcpts5" alt="" data-size="original">

**Path**

api key\* - access token

**Body**

**var -** variable name to search by\
**val -** variable value\
**group\_id -** group ID\
**search\_in -** pass the value 'order' to search in deal variables; searches up to three variables for project clients and returns a list of clients that have all the specified variables.

</details>

### Retrieve the ID of the most recently created client by variable value

<details>

<summary><mark style="color:blue;">GET</mark> https://chatter.mavibot.ai/api/#{api_key}/find_latest_client_id_by_var?var=&#x26;val=</summary>

URL request: <https://chatter.mavibot.ai/api/#{api\\_key}/find\\_latest\\_client\\_id\\_by\\_var> ?var=\&val=

This method returns the ID of the most recently created client for making API requests. It searches both client and deal variables.

Access permission when generating the key: "Permission to read client information"

<img src="/files/1nDbUDyZTyibF5Jcpts5" alt="" data-size="original">

**Path**

api key\* - access token

**Body**

**var -** variable name to search by\
**val -** variable value

</details>

### Retrieve a list of client\_id values by variable value

<details>

<summary><mark style="color:blue;">GET</mark> https://chatter.mavibot.ai/api/#{api_key}/find_all_client_id_by_var?var=&#x26;val=</summary>

URL request: <https://chatter.mavibot.ai/api/#{api\\_key}/find\\_all\\_client\\_id\\_by\\_var?var=\\&val=>

This method returns a list of client IDs that have the specified variable with the specified value.

Access permission when generating the key: "Permission to read client information"

<img src="/files/1nDbUDyZTyibF5Jcpts5" alt="" data-size="original">

**Path**

api key\* - access token

**Body**

**var -** variable name to search by\
**val -** variable value

```
{
    // Response
}
```

</details>

### Retrieve a list of client\_id values based on multiple variable values

<details>

<summary><mark style="color:blue;">GET</mark> https://chatter.mavibot.ai/api/#{api_key}/find_all_client_id_by_several_vars?var=val</summary>

URL request: <https://chatter.mavibot.ai/api/#{api\\_key}/find\\_all\\_client\\_id\\_by\\_several\\_vars?var=val>

Access permission when generating the key: "Permission to read client information".

<img src="/files/1nDbUDyZTyibF5Jcpts5" alt="" data-size="original">

**Path**

api key\* - acces token

**Body**

variable1 - Value1

variable2 - Value2

variable3 - Value3

```
{
 "status":"success","client_ids":[93891114]
}
```

</details>

### Search by variables

<details>

<summary><mark style="color:green;">POST</mark> https://chatter.mavibot.ai/api/#{api_key}/find_clients</summary>

URL request: <https://chatter.mavibot.ai/api/#{api\\_key}/find\\_clients>

This method searches by variables and returns a list of client IDs that meet the query conditions.

By default, the search is performed on client variables (recommended): {"q": {"result": "ok", "var": "home", "var": "60"}} – the client must have all specified variables

Search in deal variables, at least one of the specified variables must be present: {"q": {"result": "ok", "var": "home", "var": "60"}, "search\_in": "order", "include\_all": False}

Client variable name equals one of the list values: {"q": {"name": {"\_in": \["Joe", "Jane", "Donald"]}}}

Client variable name does NOT equal any of the list values: {"q": {"name": {"\_not\_in": \["Joe", "Jane", "Donald"]}}}

Client variable name does not equal "Joe": {"q": {"name": {"\_not": "Joe"}}}

**Note: Number comparison works only if all clients have numeric values in the searched variable. If even one client has a string, the request will fail.**

Access permission when generating the key: "Permission to read client information"

<img src="/files/1nDbUDyZTyibF5Jcpts5" alt="" data-size="original">

Parameters

**Path**

api key\* - access token

**Body**

q – required parameter, contains the query conditions for searching variables

search\_in – specifies which entity’s variables to search; if not provided, the search is done on client variables. Can take the value order.

include\_all – whether all conditions in q must be met;

False – if at least one condition matches, the entity is selected

```
Success
{"status":"success","client_ids":[41203, 5622354, 785212]} 
{"status":"success","client_ids":[]} 
{"status": "fail", "message": "Parameter "q" required"} {"status": "fail", "message": "Error in parameter format"}
Error
{"status":"fail","message":"Something went wrong"}
```

</details>

## How to work with deals

### Retrieve the current deal ID

<details>

<summary><mark style="color:blue;">GET</mark> https://chatter.mavibot.ai/api/#{api_key}/get_current_order_id</summary>

**URL request:** <https://chatter.mavibot.ai/api/#{api\\_key}/get\\_current\\_order\\_id>

Access permission when generating the key: "Permission to read CRM information".

<img src="/files/53sG0tArwJn2zG4u2tEz" alt="" data-size="original">

**Path**

api key\* - access token

**Body**

client\_id - client ID

```
Successful response: {"status":"success","order_id":40632}, where
order_id - current deal ID
Error response: {"status":"client_not_found"}
```

</details>

### Retrieve the list of deals

<details>

<summary><mark style="color:blue;">GET</mark> https://chatter.mavibot.ai/api/#{api_key}/get_orders</summary>

**URL request:** <https://chatter.mavibot.ai/api/#{api\\_key}/get\\_orders>

Access permission when generating the key: "Permission to read CRM information"

<img src="/files/53sG0tArwJn2zG4u2tEz" alt="" data-size="original">

**Path**

api key\* - access token

**Body**

client\_id - client ID

**order\_status** - deal stage: \
0 - active deals\
1 - successful deals\
2 - unsuccessful deals

```
Successful response: {"status":"success","order_id":[40338,40340,40341]} 
Error response: {"status":"client_not_found"}
```

</details>

### Move a deal to the next stage in the Mavibot funnel

<details>

<summary><mark style="color:green;">POST</mark> https://chatter.mavibot.ai/api/#{api_key}/move_order_to_next_state</summary>

**URL request:** <https://chatter.mavibot.ai/api/#{api\\_key}/move\\_order\\_to\\_next\\_state>

Access permission when generating the key: "Permission to modify/delete CRM information"

<img src="/files/6WnID16BZNJA25d762Bi" alt="" data-size="original">

**Path**

api key\* - access token

**Body**

client\_id - client ID

**order\_id** - deal ID

```
Successful response: 
{"status":"success","state_id":37}, где 
state_id - stage ID in MavibotCRM 
Error response: 
{"status":"client_not_found"}
```

</details>

### Retrieve deal data

<details>

<summary><mark style="color:green;">POST</mark> https://chatter.mavibot.ai/api/#{api_key}/get_order_vars</summary>

**URL request:** <https://chatter.mavibot.ai/api/#{api\\_key}/get\\_order\\_vars>

Access permission when generating the key: "Permission to read CRM information"

<img src="/files/53sG0tArwJn2zG4u2tEz" alt="" data-size="original">

**Path**

api key\* - access token

**Body**

client\_id - client ID

**order\_id** - deal ID

variables - variable array\
(format:\["var\_name1", "var\_name2"])

```
Successful response: 
{"status":"success","result":{"var_name1":"111","var_name2":"13.04.2023"}} 

Error example: 
{"status":"client_not_found"}
```

</details>

### Add deal variables

<details>

<summary><mark style="color:green;">POST</mark> https://chatter.mavibot.ai/api/#{api_key}/set_order_vars</summary>

**URL request:** <https://chatter.mavibot.ai/api/#{api\\_key}/set\\_order\\_vars>

Access permission when generating the key: "Permission to modify/delete CRM information"

<img src="/files/6WnID16BZNJA25d762Bi" alt="" data-size="original">

**Path**

api key\* - access token

**Body**

client\_id - client ID

**order\_id** - deal ID

variables -A dictionary of variables (the key is the variable name, and the value is what should be saved in that variable)\
(format:{"var\_name": "var\_velue"})

```
Successful response: {"status":"success"} 
Error response: {"status":"order 12345 not found"}
```

</details>

### Create a deal

<details>

<summary><mark style="color:green;">POST</mark> https://chatter.mavibot.ai/api/#{api_key}/create_order</summary>

**URL request:** <https://chatter.mavibot.ai/api/#{api\\_key}/create\\_order>

Access permission when generating the key: "Permission to modify/delete CRM information"

<img src="/files/6WnID16BZNJA25d762Bi" alt="" data-size="original">

**Path**

api key\* - access token

**Body**

client\_id - client ID

name - deal name

description - deal description

budget - deal amount

You must specify one of the following parameters in the request: client\_id, email, or phone.\
If multiple parameters are provided, only one will be used. The priority order is: client\_id > phone > email.\
If phone or email is provided and no client exists with that phone number or email, a new client will be created.

```
Successful response: {"status":"success","order_id":40654}, 
where order_id is the ID of the new active deal.
Error response: {"status":"client_not_found"}
```

</details>

### Move a deal to a stage in MavibotCRM

<details>

<summary><mark style="color:green;">POST</mark> https://chatter.mavibot.ai/api/#{api_key}/set_order_state</summary>

**URL request:** <https://chatter.mavibot.ai/api/#{api\\_key}/set\\_order\\_state>

Access permission when generating the key: "Permission to modify/delete CRM information"

<img src="/files/6WnID16BZNJA25d762Bi" alt="" data-size="original">

**Path**

api key\* - access token

**Body**

client\_id - client ID

state\_id - the stage number to which the client’s deal should be moved

</details>

### Retrieve the funnel stage ID in Mavibot CRM

<details>

<summary><mark style="color:blue;">GET</mark> https://chatter.mavibot.ai/api/#{api_key}/get_order_state</summary>

**URL request:** <https://chatter.mavibot.ai/api/#{api\\_key}/get\\_order\\_state>

Access permission when generating the key: "Permission to read CRM information"

<img src="/files/53sG0tArwJn2zG4u2tEz" alt="" data-size="original">

**Path**

api key\* - access token

**Body**

client\_id - client ID

state\_id - deal ID (if not specified, the method will return the stage ID of the current deal)

```
Example of a successful response:
{'status': 'success', 'state_id': 123456}

Example of an unsuccessful response:
{'status': 'order not found'}
```

</details>

## What other capabilities are available?

### Check if a phone number has WhatsApp

<details>

<summary><mark style="color:blue;">GET</mark> https://chatter.mavibot.ai/api/#{api_key}/check_whatsapp</summary>

**URL request:** <https://chatter.mavibot.ai/api/#{api\\_key}/check\\_whatsapp>

**To use this method, WhatsApp must be connected to Mavibot.**

Access permission when generating a key: "Permission to modify or delete client information".

<img src="/files/1nDbUDyZTyibF5Jcpts5" alt="" data-size="original">

Can be called using either GET or POST.\
The phone number can be provided in any format.

**Path**

api key\* - access token

**Body**

phone - phone number to check

</details>

### Get the list of messengers connected to the project

<details>

<summary><mark style="color:blue;">GET</mark> https://chatter.mavibot.ai/api/&#x3C;api_key>/connected_channels</summary>

URL request: <https://chatter.mavibot.ai/api/\\>\<api\_key>/connected\_channels

Access permission when generating a key: "Permission to modify or delete client information".

<img src="/files/1nDbUDyZTyibF5Jcpts5" alt="" data-size="original">

The function returns the group\_id parameter for each messenger, which must be used when importing clients.

For WhatsApp, it also returns a **status** field, which can have the following values:<br>

**NOT\_STARTED = 0**\
**STARTED = 1**\
**ASLEEP = 2**\
**STOPPED = 3**

**Path**

api key\* - access token

```
{'project_id': 1, 
'viber': [{
        'id': 14, 
        'uri': 'mavibotstage', 
        'name': 'mavibotstage', 
        'enabled': true,
        'group_id': 11}], 
'facebook': [], 
'telegram': [{
        'id': 23, 
        'short_name': 'bulls_vs_bears_bot', 
        'name': 'bulls_vs_bears_bot', 
        'enabled': true,
        'group_id': 'bulls_vs_bears_bot'}], 
'whatsapp': [], 
'avito': [], 
'ok': [], 
'vkontakte': [{
        'id': 33, 
        'group': '143414131',
        'group_id': '143414131'}]
}
```

</details>

### Retrieve the list of blocks from the bot’s flow

<details>

<summary><mark style="color:blue;">GET</mark> https://chatter.mavibot.ai/api/&#x3C;api_key>/get_messages</summary>

**URL request:** <https://chatter.mavibot.ai/api/\\>\<api\_key>/get\_messages

Access permission when generating a key: "Permission to modify or delete client information".

<img src="/files/1nDbUDyZTyibF5Jcpts5" alt="" data-size="original">

**Path**

api key\* - access token

</details>

### Retrieve nested client data

<details>

<summary>delimiter</summary>

To retrieve client\_id and/or the client’s phone number from nested dictionaries (not at the first level), use the delimiter parameter.

Add the following to your request URL:

?delimiter=1\&delimiter\_value\_client\_id={key1}1{key2}\&delimiter\_value\_phone={key1}1{key2}&#x20;

where:

?delimiter=1 – the delimiter value that separates keys {key1}1{key2}1{key3}

delimiter\_value\_client\_id={key1}1{key2} – to retrieve the client ID

delimiter\_value\_phone={key1}1{key2} – to retrieve the client phone number

{key1}, {key2}, … – keys containing the values (can include any characters except the delimiter). You can have an unlimited number of keys:\
?delimiter=1\&delimiter\_value\_client\_id={key1}1{key2}1{key3}1{key4}1{key5}1{key6}. \
**Keys are passed without curly braces.**

Use the delimiter between keys. For example, if delimiter=2, then {key1}2{key2}2{key3}; if delimiter=5, then {key1}5{key2}5{key3}. Ensure the key does not contain the delimiter character.

Example:

<https://chatter.mavibot.a/aipi/\\>\<api\_key>/callback<mark style="color:yellow;">**?delimiter=1\&delimiter\_value\_client\_id={key1}1{key2}\&delimiter\_value\_phone={key1}1{key2}**</mark>&#x20;

You can also retrieve only the ID or only the phone number:&#x20;

<https://chatter.salebot.pro/api/\\>\<api\_key>/callback<mark style="color:green;">**?delimiter=1\&delimiter\_value\_client\_id={key1}1{key2} -**</mark> only client ID;

<https://chatter.salebot.pro/api/\\>\<api\_key>/callback<mark style="color:green;">**?delimiter=1delimiter\_value\_phone={key1}1{key2}**</mark> - only phone number;

API methods:

1. Start bot: <https://chatter.mavibotbot.ai/api/\\>\<api\_key>/callback
2. Start bot by WhatsApp number: <https://chatter.mavibotbot.ai/api/\\>\<api\_key>/whatsapp\_callback
3. Start bot by Telegram ID: <https://chatter.mavibotbot.ai/api/\\>\<api\_key>/tg\_callback
4. Send callback message to email client: <https://chatter.mavibotbot.ai/api/\\>\<api\_key>/email\_callback
5. Send message to client: <https://chatter.mavibotbot.ai/api/\\>\<api\_key>/message
6. Send WhatsApp message: <https://chatter.mavibotbot.ai/api/\\>\<api\_key>/whatsapp\_message
7. Bulk messaging: <https://chatter.mavibotbot.ai/api/\\>\<api\_key>/broadcast
8. Assign variables: <https://chatter.mavibotbot.ai/api/\\>\<api\_key>/save\_variables   \\

</details>

{% hint style="success" %}
If you need additional methods, please contact support.
{% endhint %}


---

# 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://docs.mavibot.ai/working-with-api/api-builder.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.
