Send Message
curl --request POST \
--url https://api.example.com/v1/send_message \
--header 'Content-Type: application/json' \
--header 'authorization: <authorization>' \
--data '
{
"text": "<string>",
"user_type": "Patient",
"model_id": "openai"
}
'import requests
url = "https://api.example.com/v1/send_message"
payload = {
"text": "<string>",
"user_type": "Patient",
"model_id": "openai"
}
headers = {
"authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({text: '<string>', user_type: 'Patient', model_id: 'openai'})
};
fetch('https://api.example.com/v1/send_message', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/v1/send_message",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'text' => '<string>',
'user_type' => 'Patient',
'model_id' => 'openai'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"authorization: <authorization>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/v1/send_message"
payload := strings.NewReader("{\n \"text\": \"<string>\",\n \"user_type\": \"Patient\",\n \"model_id\": \"openai\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("authorization", "<authorization>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/v1/send_message")
.header("authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"text\": \"<string>\",\n \"user_type\": \"Patient\",\n \"model_id\": \"openai\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/send_message")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"text\": \"<string>\",\n \"user_type\": \"Patient\",\n \"model_id\": \"openai\"\n}"
response = http.request(request)
puts response.read_body{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}API Reference
Send Message
Sends a message to the chatbot and receives a response.
Args: message: The user message containing text and user_type db: Database session dependency token: Verified API token
Returns: JSON response with user_type and the agent’s response
Raises: HTTPException: If the user_type is invalid or token is invalid
POST
/
v1
/
send_message
Send Message
curl --request POST \
--url https://api.example.com/v1/send_message \
--header 'Content-Type: application/json' \
--header 'authorization: <authorization>' \
--data '
{
"text": "<string>",
"user_type": "Patient",
"model_id": "openai"
}
'import requests
url = "https://api.example.com/v1/send_message"
payload = {
"text": "<string>",
"user_type": "Patient",
"model_id": "openai"
}
headers = {
"authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({text: '<string>', user_type: 'Patient', model_id: 'openai'})
};
fetch('https://api.example.com/v1/send_message', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/v1/send_message",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'text' => '<string>',
'user_type' => 'Patient',
'model_id' => 'openai'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"authorization: <authorization>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/v1/send_message"
payload := strings.NewReader("{\n \"text\": \"<string>\",\n \"user_type\": \"Patient\",\n \"model_id\": \"openai\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("authorization", "<authorization>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/v1/send_message")
.header("authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"text\": \"<string>\",\n \"user_type\": \"Patient\",\n \"model_id\": \"openai\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/send_message")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"text\": \"<string>\",\n \"user_type\": \"Patient\",\n \"model_id\": \"openai\"\n}"
response = http.request(request)
puts response.read_body{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Send Message
Sends a message to the chatbot and receives a response.Headers
| Parameter | Type | Required | Description |
|---|---|---|---|
| authorization | string | Yes | API authorization token |
Request Body
{
"text": "string",
"user_type": "Patient",
"model_id": "openai"
}
| Property | Type | Required | Description |
|---|---|---|---|
| text | string | Yes | The message text to send |
| user_type | string | No | The type of user (Patient, Doctor, Coach). Default: Patient |
| model_id | string | No | The model ID (openai, gemini). Default: openai |
Responses
| Status | Description | Content Type |
|---|---|---|
| 200 | Chatbot response | application/json |
| 422 | Validation Error | application/json |
⌘I