Endpoints
Create chat
Create a new chat session and start building with AI
POST
/api/chatCreates a new chat session and starts the AI workflow.
Request
POST /api/chatHeaders
| 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 | "gpt-6.1-sol" | "gpt-6-luna" | "grok-4-6" | "kimi-k3" | "sonnet-5-5" | "opus-5-5" | "haiku-5-5" | "blueai-glm-5-3" | "blueai-glm-5-3-flash" | "blueai-deepseek-v4-1-flash" | "blueai-mistral-large-4" | No | - | AI model to use. Defaults to team’s configured model. Retired IDs such as gpt-5.6-terra still work and run on their successor. |
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 the experimental_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
}'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..."
...The first line contains the chat ID in the format 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