Create Chat
curl --request POST \
--url https://macaly.com/api/chat \
--header 'Authorization: Bearer <token>'import requests
url = "https://macaly.com/api/chat"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://macaly.com/api/chat', 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://macaly.com/api/chat",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://macaly.com/api/chat"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://macaly.com/api/chat")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://macaly.com/api/chat")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_bodyEndpoints
Create chat
Create a new chat session and start building with AI
POST
/
api
/
chat
Create Chat
curl --request POST \
--url https://macaly.com/api/chat \
--header 'Authorization: Bearer <token>'import requests
url = "https://macaly.com/api/chat"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://macaly.com/api/chat', 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://macaly.com/api/chat",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://macaly.com/api/chat"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://macaly.com/api/chat")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://macaly.com/api/chat")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_bodyCreates a new chat session and starts the AI workflow.
JSON Response (when
Streaming Response (when
When streaming is enabled, the response is a text stream:
The first line contains the chat ID in the format
Request
POST /api/chat
Headers
| Header | Required | Description |
|---|---|---|
Authorization | Yes | Bearer macaly_... |
Content-Type | Yes | application/json |
Body Parameters
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
content | string | Yes | - | The user’s message/prompt |
stream | boolean | No | true | If false, returns JSON instead of stream |
backend | string | No | "DEFAULT" | Backend to use |
executionMode | "auto" | "planning" | "build" | No | - | Controls how the AI approaches the task |
model | "sonnet-4-5" | "sonnet-4-6" | "opus-4-5" | "opus-4-6" | No | - | AI model to use. Defaults to team’s configured model |
reasoningEffort | "medium" | "high" | No | - | Controls how deeply the AI reasons about the task |
experimental_attachments | array | No | [] | File attachments (see format below) |
Attachment Format
Each item in theexperimental_attachments array has the following structure:
| Field | Type | Required | Description |
|---|---|---|---|
url | string | Yes | URL of the file to attach |
name | string | No | Display name for the attachment |
contentType | string | No | MIME type of the file |
Example Request
curl -X POST https://www.macaly.com/api/chat \
-H "Authorization: Bearer macaly_abc123..." \
-H "Content-Type: application/json" \
-d '{
"content": "Create a landing page for a coffee shop",
"stream": false
}'
const response = await fetch('https://www.macaly.com/api/chat', {
method: 'POST',
headers: {
'Authorization': 'Bearer macaly_abc123...',
'Content-Type': 'application/json',
},
body: JSON.stringify({
content: 'Create a landing page for a coffee shop',
stream: false,
}),
});
const data = await response.json();
console.log(data.chatId);
import requests
response = requests.post(
'https://www.macaly.com/api/chat',
headers={
'Authorization': 'Bearer macaly_abc123...',
'Content-Type': 'application/json',
},
json={
'content': 'Create a landing page for a coffee shop',
'stream': False,
},
)
data = response.json()
print(data['chatId'])
Response
JSON Response (when stream: false)
{
"chatId": "abc123def456",
"url": "https://www.macaly.com/chat/abc123def456",
"streamId": "stream_xyz789",
"assistantMessageId": "msg_123"
}
| Field | Type | Description |
|---|---|---|
chatId | string | The unique chat identifier |
url | string | Direct URL to view the chat |
streamId | string | undefined | Stream identifier for subscribing. Only present for workflow backends |
assistantMessageId | string | undefined | ID of the assistant message being generated. Only present for workflow backends |
Streaming Response (when stream: true, default)
When streaming is enabled, the response is a text stream:
2:[{"chatId":"abc123def456"}]
0:"Starting to build..."
...
2:[{"chatId":"..."}].
Parsing the Chat ID from Stream
const text = await response.text();
const match = text.match(/2:\[{"chatId":"([^"]+)"/);
const chatId = match?.[1];
Status Codes
| Status | Description |
|---|---|
| 200 | Success - Chat created |
| 400 | Invalid request body |
| 401 | Invalid or missing API key |
| 402 | Insufficient credits |
| 403 | Forbidden - No permission for the specified team |
| 422 | Validation error |
| 429 | Rate limited |
| 500 | Server error |
Next Steps
After creating a chat:- Poll for completion using
GET /api/chat/{chatId}/status - Subscribe to stream using
GET /api/chat/{chatId}/subscribefor real-time updates - Send follow-up messages using
POST /api/chat/{chatId}/publish
⌘I