Automatizaciones
Cree, lea, modifique y active automatizaciones de forma programática. Una automatización ejecuta **acciones** (aplicar etiqueta, mover etapa, enviar WhatsApp, crear tarea, llamar a un webhook…) cuando ocurre un **disparador** (lead creado, mensaje recibido, etapa cambiada, fecha, recurrencia…). La lectura exige el permiso `automations:read`; la escritura exige `automations:write`.
https://app.syncro.chat/api/v1AuthX-API-Key: crm_SUA_CHAVE_AQUIConceptos importantes
- Dos formatos de escritura. Puede enviar la automatización en flat (recomendado) —
{name, trigger_type, trigger_config, conditions, actions}— y el servidor genera el grafo; o en graph —{name, nodes, edges}— fiel al editor visual.GET /automations/{id}siempre devuelve ambos dentro despec, y ese mismo objeto se acepta de vuelta en POST/PUT. - Nace inactiva. Toda automatización creada por la API comienza desactivada (
is_active: false). Activarla es un paso aparte (PATCH /automations/{id}/toggle) — activar tiene efecto real (la automatización pasa a enviar mensajes de WhatsApp a los clientes). Confirme con el usuario antes de activar. - Simulación con
validate_only. Envíe"validate_only": trueen cualquier POST/PUT para un dry-run: la API valida y devuelveerrors/warningssin grabar nada (responde siempre200). - Validación estricta. Un spec inválido devuelve 422 con
errors: [{ path, code, message }]señalando el campo exacto a corregir (ej.:actions[0].config.tags).
Listar automatizaciones
/automationsautomations:readPaginado. Filtros mediante query string.
Parámetros de query
is_activebooleanopcionaltrigger_typestringopcionalGET /automations/capabilities)searchstringopcionalpageintegeropcionalper_pageintegeropcional30, máx 100)curl "https://app.syncro.chat/api/v1/automations?is_active=true" \ -H "X-API-Key: crm_SUA_CHAVE_AQUI"
{
"success": true,
"data": [
{
"id": 42,
"name": "Etiquetar novos leads",
"trigger_type": "lead_created",
"is_active": true,
"run_count": 128,
"last_run_at": "2026-07-19T14:03:11-03:00",
"updated_at": "2026-07-18T09:20:00-03:00"
}
],
"meta": {
"total": 1,
"per_page": 30,
"current_page": 1,
"last_page": 1,
"has_more": false
}
}Detallar una automatización
/automations/42automations:readDevuelve el estado + el spec reimportable (flat + graph).
curl "https://app.syncro.chat/api/v1/automations/42" \ -H "X-API-Key: crm_SUA_CHAVE_AQUI"
{
"success": true,
"data": {
"id": 42,
"is_active": true,
"run_count": 128,
"last_run_at": "2026-07-19T14:03:11-03:00",
"updated_at": "2026-07-18T09:20:00-03:00",
"spec": {
"name": "Etiquetar novos leads",
"trigger_type": "lead_created",
"trigger_config": {},
"conditions": [],
"actions": [
{
"type": "add_tag_lead",
"config": {
"tags": [
"Novo"
]
}
}
],
"nodes": [],
"edges": []
}
}
}Crear una automatización
/automationsautomations:writeFormato flat (recomendado). La automatización nace inactiva.
Parámetros del body
namestringobligatoriotrigger_typestringobligatoriolead_created)actionsarrayobligatorio{ "type": "...", "config": { ... } }trigger_configobjectopcionalGET /automations/capabilities)conditionsarrayopcional{ "field": "...", "operator": "...", "value": "..." }validate_onlybooleanopcionalerrors/warnings sin grabar nadaCada acción tiene la forma { "type": "...", "config": { ... } }.
Cada condición (opcional) tiene la forma { "field": "message_body", "operator": "contains", "value": "orçamento" }.
Enviar un name que ya existe devuelve 422 name_conflict — el POST nunca sobrescribe; use el PUT para modificar.
curl -X POST "https://app.syncro.chat/api/v1/automations" \
-H "X-API-Key: crm_SUA_CHAVE_AQUI" \
-H "Content-Type: application/json" \
-d '{
"name": "Etiquetar novos leads",
"trigger_type": "lead_created",
"trigger_config": {},
"conditions": [],
"actions": [
{
"type": "add_tag_lead",
"config": {
"tags": [
"Novo"
]
}
}
]
}'{
"success": true,
"warnings": [],
"data": {
"id": 57,
"is_active": false,
"run_count": 0,
"last_run_at": null,
"updated_at": "2026-07-20T10:00:00-03:00",
"spec": {}
}
}Simular antes de grabar (`validate_only`)
Envíe "validate_only": true en cualquier POST/PUT: la API valida el spec y devuelve errors/warnings sin grabar nada (responde siempre 200).
curl -X POST "https://app.syncro.chat/api/v1/automations" \
-H "X-API-Key: crm_SUA_CHAVE_AQUI" -H "Content-Type: application/json" \
-d '{ "name": "Teste", "trigger_type": "lead_created",
"actions": [ { "type": "add_tag_lead", "config": {} } ],
"validate_only": true }'
{
"success": true,
"valid": false,
"mode": "flat",
"errors": [
{ "path": "actions[0].config.tags", "code": "missing_config_key", "message": "Action \"add_tag_lead\" requires config key \"tags\" (string[])." }
],
"warnings": []
}
Actualizar una automatización
/automations/42automations:writeSustituye el spec entero (envíe el objeto completo; haga un GET antes). No altera el is_active (la activación es solo por el toggle).
curl -X PUT "https://app.syncro.chat/api/v1/automations/42" \
-H "X-API-Key: crm_SUA_CHAVE_AQUI" \
-H "Content-Type: application/json" \
-d '{
"name": "Etiquetar novos leads",
"trigger_type": "lead_created",
"trigger_config": {},
"conditions": [],
"actions": [
{
"type": "add_tag_lead",
"config": {
"tags": [
"Novo"
]
}
}
]
}'Activar / desactivar
/automations/57/toggleautomations:writeBody opcional { "is_active": true } (ausente = invierte el estado actual).
Activar tiene efecto real: la automatización pasa a enviar mensajes a los clientes. Confirme con el usuario antes.
curl -X PATCH "https://app.syncro.chat/api/v1/automations/57/toggle" \
-H "X-API-Key: crm_SUA_CHAVE_AQUI" \
-H "Content-Type: application/json" \
-d '{
"is_active": true
}'{
"success": true,
"id": 57,
"is_active": true
}Eliminar
/automations/57automations:writecurl -X DELETE "https://app.syncro.chat/api/v1/automations/57" \ -H "X-API-Key: crm_SUA_CHAVE_AQUI"
{
"success": true
}Descubrir qué es válido
/automations/capabilitiesautomations:readDevuelve, de forma legible por máquina, todos los disparadores, acciones y claves de config aceptadas (la misma fuente que usa el validador — la doc nunca queda desactualizada). Consulte siempre este endpoint antes de montar una automatización.
curl "https://app.syncro.chat/api/v1/automations/capabilities" \ -H "X-API-Key: crm_SUA_CHAVE_AQUI"
Disparadores y acciones disponibles
Disparadores disponibles (17): message_received, conversation_created, lead_created, lead_stage_changed, lead_won, lead_lost, date_field, recurring, task_created, task_due_soon, calendar_event_created, calendar_event_canceled, calendar_event_starting_soon, appointment_confirmed, appointment_declined, stage_no_reply, stage_recurring.
Acciones disponibles (27): add_tag_lead, remove_tag_lead, add_tag_conversation, move_to_stage, set_lead_source, assign_to_user, assign_random_user, add_note, assign_ai_agent, assign_chatbot_flow, transfer_to_department, close_conversation, set_utm_params, create_task, enroll_sequence, ai_extract_fields, send_webhook, notify_user, send_whatsapp_message, send_whatsapp_group_message, schedule_whatsapp_message, send_whatsapp_notification, transfer_conversation, send_whatsapp_list, send_whatsapp_template (solo API Oficial), send_whatsapp_buttons (solo API Oficial), send_instagram_message.
Listar plantillas listas
/automations/templatesautomations:readLista las plantillas oficiales.
curl "https://app.syncro.chat/api/v1/automations/templates" \ -H "X-API-Key: crm_SUA_CHAVE_AQUI"
Instalar una plantilla
/automations/templates/etiquetar-novos-leads/installautomations:writeInstala una plantilla oficial (idempotente por nombre; instalada inactiva).
curl -X POST "https://app.syncro.chat/api/v1/automations/templates/etiquetar-novos-leads/install" \ -H "X-API-Key: crm_SUA_CHAVE_AQUI"
Formato de error
Toda escritura rechazada devuelve 422 con:
{
"success": false,
"message": "Automation spec failed validation. Fix the errors and retry (or use validate_only:true to iterate).",
"errors": [ { "path": "actions[0].config.tags", "code": "missing_config_key", "message": "…" } ],
"warnings": []
}
Códigos comunes: invalid_trigger, unknown_action, missing_config_key, fk_not_found, name_conflict, duplicate_handle, limit_reached. Warnings (no bloquean): unknown_token, unreachable_node.