# Message AI Agent

You can interact with this API by sending a `POST` request. This allows you to send messages, receive replies, and more.<br>

**API Endpoint**

The following endpoint/URL should be used in order to access this API:

```
https://app.stammer.ai/en/chatbot/api/v1/message/
```

**Request Headers**

The API must have the following request headers:

```
Content-Type: application/json
Authorization: Token <Your-API-Token>
```

**Request Body**

The API requires the following parameters in the request body:

* **`chatbot_uuid`** (Type: UUID, Required)

  Unique identifier (UUID) of the chatbot. You can find this UUID on the chatbot's detail page.
* **`query`** (Type: String, Required)

  Message or query the user intends to send to the chatbot. Must be under 5000 characters
* **`user_key`** (Type: String, Required)

  A unique identifier/string, used to distinguish users interacting with the chatbot.
* **`custom_base_system_prompt`** (Type: String, Optional)

  Custom Base System Message that is passed to OpenAI instead of Chatbot Base System Message.

<figure><img src="https://1359281993-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkLIQnOFYHkQtdWxUzzFE%2Fuploads%2FT6MefOa22peWIE1AqrEi%2FScreenshot%202025-04-02%20at%2010.05.22%E2%80%AFAM.jpg?alt=media&#x26;token=876ef40c-7ff6-4a30-8bb7-1f613a2111cb" alt=""><figcaption></figcaption></figure>

**Request Example**

Here's an example of the request:

```python
import requests

# Define the API endpoint
url = "https://app.stammer.ai/en/chatbot/api/v1/message/"

# Set up authentication and headers
headers = {
    'Authorization': 'Token <YOUR-API-TOKEN>',
    'Content-Type': 'application/json',
    'Accept': 'application/json'
}



# Data is passed in the request body as JSON
data = {

    "chatbot_uuid": "12345678-1234-5678-1234-567812345678",

    "query": "Your message/string here.",

    "user_key": "Your message/string here.",

    "custom_base_system_prompt": "Your message/string here."

}
response = requests.post(url, headers=headers, json=data)



# Process the response
if response.status_code in (200, 201, 202):
    result = response.json()
    print("Response data:", result)
else:
    try:
        error_data = response.json()
        error_message = error_data.get('message') or error_data.get('error', 'Unknown error')
        print(f"Error: {error_message}")
    except ValueError:
        print(f"Error: Status code {response.status_code}")

```

Learn More - <https://app.stammer.ai/en/api-docs/chatbot/message/>
