For a complete page index, fetch https://docs.synthflow.ai/llms.txt. For full documentation content, fetch https://docs.synthflow.ai/llms-full.txt.

# Send a message in a chat

POST https://api.synthflow.ai/v2/chat/{chat_id}/messages
Content-Type: application/json

Send a message to an agent within an existing chat session.

Reference: https://docs.synthflow.ai/api-reference/platform-api/chat/send-chat-message

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: Synthflow APIs
  version: 1.0.0
paths:
  /chat/{chat_id}/messages:
    post:
      operationId: send-chat-message
      summary: Send a message in a chat
      description: Send a message to an agent within an existing chat session.
      tags:
        - subpackage_chat
      parameters:
        - name: chat_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
      responses:
        '200':
          description: '200'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Chat_send-chat-message_Response_200'
        '400':
          description: '400'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Send-chat-messageRequestBadRequestError'
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                message:
                  type: string
                  description: The message to send to the agent.
              required:
                - message
servers:
  - url: https://api.synthflow.ai/v2
  - url: https://api.us.synthflow.ai/v2
components:
  schemas:
    status:
      type: string
      description: Whether the request was successful.
      title: status
    ChatMessageResponse:
      type: object
      properties:
        agent_message:
          type: string
          description: The response message from the agent.
        current_state:
          type: string
          description: The current state of the agent.
        timestamp:
          type: string
          format: date-time
          description: ISO 8601 timestamp of when the message was sent.
        turn_number:
          type: integer
          description: The turn number in the conversation.
      required:
        - agent_message
        - current_state
        - timestamp
        - turn_number
      description: Response from sending a message in a chat.
      title: ChatMessageResponse
    Chat_send-chat-message_Response_200:
      type: object
      properties:
        status:
          $ref: '#/components/schemas/status'
        response:
          $ref: '#/components/schemas/ChatMessageResponse'
      title: Chat_send-chat-message_Response_200
    Send-chat-messageRequestBadRequestError:
      type: object
      properties: {}
      title: Send-chat-messageRequestBadRequestError

```

## SDK Code Examples

```python
import requests

url = "https://api.synthflow.ai/v2/chat/fe90071d-fd73-4755-87a4-6aaa0f9bfb25/messages"

payload = { "message": "Hello, I would like to learn more about your services." }
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.synthflow.ai/v2/chat/fe90071d-fd73-4755-87a4-6aaa0f9bfb25/messages"

	payload := strings.NewReader("{\n  \"message\": \"Hello, I would like to learn more about your services.\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.synthflow.ai/v2/chat/fe90071d-fd73-4755-87a4-6aaa0f9bfb25/messages")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"message\": \"Hello, I would like to learn more about your services.\"\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.synthflow.ai/v2/chat/fe90071d-fd73-4755-87a4-6aaa0f9bfb25/messages")
  .header("Content-Type", "application/json")
  .body("{\n  \"message\": \"Hello, I would like to learn more about your services.\"\n}")
  .asString();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.synthflow.ai/v2/chat/fe90071d-fd73-4755-87a4-6aaa0f9bfb25/messages");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"message\": \"Hello, I would like to learn more about your services.\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = ["message": "Hello, I would like to learn more about your services."] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.synthflow.ai/v2/chat/fe90071d-fd73-4755-87a4-6aaa0f9bfb25/messages")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```