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
Cria uma nova sessão de chat e começa a construir com IA
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_bodyCria uma nova sessão de chat e inicia o workflow da IA.
Resposta JSON (com
Resposta em streaming (com
Com o streaming ativado, a resposta é um stream de texto:
A primeira linha contém o ID do chat no formato
Requisição
POST /api/chat
Cabeçalhos
| Cabeçalho | Obrigatório | Descrição |
|---|---|---|
Authorization | Sim | Bearer macaly_... |
Content-Type | Sim | application/json |
Parâmetros do corpo
| Campo | Tipo | Obrigatório | Padrão | Descrição |
|---|---|---|---|---|
content | string | Sim | - | A mensagem (prompt) do usuário |
stream | boolean | Não | true | Se false, retorna JSON em vez de stream |
backend | string | Não | "DEFAULT" | Backend a ser usado |
executionMode | "auto" | "planning" | "build" | Não | - | Define como a IA aborda a tarefa |
model | "gpt-5.6-terra" | "gpt-6.1-sol" | "gpt-6-luna" | "grok-4-6" | "kimi-k3" | "sonnet-5-5" | "opus-5-5" | "blueai-glm-5-3" | "blueai-glm-5-3-flash" | Não | - | Modelo de IA a ser usado. Se omitido, vale o modelo configurado no workspace |
reasoningEffort | "medium" | "high" | Não | - | Define o quanto a IA aprofunda o raciocínio sobre a tarefa |
experimental_attachments | array | Não | [] | Anexos de arquivo (formato abaixo) |
Formato dos anexos
Cada item do arrayexperimental_attachments tem a seguinte estrutura:
| Campo | Tipo | Obrigatório | Descrição |
|---|---|---|---|
url | string | Sim | URL do arquivo a ser anexado |
name | string | Não | Nome de exibição do anexo |
contentType | string | Não | Tipo MIME do arquivo |
Exemplo de requisição
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'])
Resposta
Resposta JSON (com stream: false)
{
"chatId": "abc123def456",
"url": "https://www.macaly.com/chat/abc123def456",
"streamId": "stream_xyz789",
"assistantMessageId": "msg_123"
}
| Campo | Tipo | Descrição |
|---|---|---|
chatId | string | Identificador único do chat |
url | string | Link direto para ver o chat |
streamId | string | undefined | Identificador do stream para assinatura. Presente apenas em backends com workflow |
assistantMessageId | string | undefined | ID da mensagem do assistente em geração. Presente apenas em backends com workflow |
Resposta em streaming (com stream: true, o padrão)
Com o streaming ativado, a resposta é um stream de texto:
2:[{"chatId":"abc123def456"}]
0:"Starting to build..."
...
2:[{"chatId":"..."}].
Extraindo o ID do chat do stream
const text = await response.text();
const match = text.match(/2:\[{"chatId":"([^"]+)"/);
const chatId = match?.[1];
Códigos de status
| Código | Descrição |
|---|---|
| 200 | Sucesso: chat criado |
| 400 | Corpo da requisição inválido |
| 401 | Chave de API inválida ou ausente |
| 402 | Créditos insuficientes |
| 403 | Forbidden: sem permissão para o workspace informado |
| 422 | Erro de validação |
| 429 | Limite de requisições excedido |
| 500 | Erro no servidor |
Próximos passos
Depois de criar o chat:- Acompanhe a conclusão com
GET /api/chat/{chatId}/status - Assine o stream com
GET /api/chat/{chatId}/subscribepara receber atualizações em tempo real - Envie mensagens de acompanhamento com
POST /api/chat/{chatId}/publish
Esta página foi útil?