Automatizaciones
Reglas automáticas con triggers, condiciones y acciones
curl https://app.getplea.com/api/automations \
-H "Authorization: Bearer TOKEN" \
-H "x-organization-id: ORG_ID"
const automations = await fetch('/api/automations', {
headers: {
'Authorization': 'Bearer TOKEN',
'x-organization-id': 'ORG_ID'
}
}).then(r => r.json());
[
{
"id": "auto-uuid-1",
"name": "Asignar tareas al crear expediente laboral",
"isActive": true,
"trigger": {
"event": "case.created",
"conditions": [
{"field": "caseType", "operator": "equals", "value": "laboral"}
]
},
"actions": [
{
"type": "create_task",
"params": {
"title": "Solicitar documentación al cliente",
"priority": "high",
"dueDays": 3
}
},
{
"type": "create_task",
"params": {
"title": "Presentar papeleta de conciliación",
"priority": "medium",
"dueDays": 10
}
}
],
"executionCount": 15,
"lastExecuted": "2026-03-05T10:00:00Z"
}
]
curl -X POST https://app.getplea.com/api/automations \
-H "Authorization: Bearer TOKEN" \
-H "Content-Type: application/json" \
-H "x-organization-id: ORG_ID" \
-d '{
"name": "Notificar al crear factura",
"trigger": {
"event": "invoice.created",
"conditions": []
},
"actions": [
{
"type": "send_notification",
"params": {
"message": "Se ha creado una nueva factura",
"channel": "email"
}
}
]
}'
const automation = await fetch('/api/automations', {
method: 'POST',
headers: {
'Authorization': 'Bearer TOKEN',
'Content-Type': 'application/json',
'x-organization-id': 'ORG_ID'
},
body: JSON.stringify({
name: 'Notificar al crear factura',
trigger: {
event: 'invoice.created',
conditions: []
},
actions: [
{
type: 'send_notification',
params: { message: 'Se ha creado una nueva factura', channel: 'email' }
}
]
})
}).then(r => r.json());
{
"id": "auto-uuid-new",
"name": "Notificar al crear factura",
"isActive": true,
"trigger": {
"event": "invoice.created",
"conditions": []
},
"actions": [
{
"type": "send_notification",
"params": {
"message": "Se ha creado una nueva factura",
"channel": "email"
}
}
],
"createdAt": "2026-03-07T12:00:00Z"
}
curl -X PATCH https://app.getplea.com/api/automations/auto-uuid-1 \
-H "Authorization: Bearer TOKEN" \
-H "Content-Type: application/json" \
-H "x-organization-id: ORG_ID" \
-d '{"isActive": false}'
await fetch('/api/automations/auto-uuid-1', {
method: 'PATCH',
headers: {
'Authorization': 'Bearer TOKEN',
'Content-Type': 'application/json',
'x-organization-id': 'ORG_ID'
},
body: JSON.stringify({ isActive: false })
});
{
"id": "auto-uuid-1",
"name": "Asignar tareas al crear expediente laboral",
"isActive": false,
"updatedAt": "2026-03-07T12:00:00Z"
}
curl -X DELETE https://app.getplea.com/api/automations/auto-uuid-1 \
-H "Authorization: Bearer TOKEN" \
-H "x-organization-id: ORG_ID"
await fetch('/api/automations/auto-uuid-1', {
method: 'DELETE',
headers: {
'Authorization': 'Bearer TOKEN',
'x-organization-id': 'ORG_ID'
}
});
{
"message": "Automatización eliminada correctamente"
}
curl https://app.getplea.com/api/automations/auto-uuid-1/executions \
-H "Authorization: Bearer TOKEN" \
-H "x-organization-id: ORG_ID"
const executions = await fetch('/api/automations/auto-uuid-1/executions', {
headers: {
'Authorization': 'Bearer TOKEN',
'x-organization-id': 'ORG_ID'
}
}).then(r => r.json());
[
{
"id": "exec-uuid-1",
"automationId": "auto-uuid-1",
"triggerData": {
"caseId": "case-uuid-new",
"caseNumber": "2026/0100",
"caseType": "laboral"
},
"status": "success",
"actionsExecuted": 2,
"executedAt": "2026-03-05T10:00:00Z"
},
{
"id": "exec-uuid-2",
"automationId": "auto-uuid-1",
"triggerData": {
"caseId": "case-uuid-prev",
"caseNumber": "2026/0080",
"caseType": "laboral"
},
"status": "success",
"actionsExecuted": 2,
"executedAt": "2026-02-20T14:30:00Z"
}
]
Endpoints para crear y gestionar reglas de automatización. Las automatizaciones ejecutan acciones automáticas cuando se cumplen determinadas condiciones (ej: cuando se crea un expediente, asignar tareas automáticamente).
GET /api/automations
Lista las automatizaciones configuradas.
POST /api/automations
Crea una nueva automatización.
Nombre descriptivo.
Evento que dispara la automatización. Incluye event y conditions.
Acciones a ejecutar. Cada acción tiene type y params.
Activar inmediatamente. Default: true.
Eventos disponibles: case.created, case.updated, case.closed, task.created, task.completed, invoice.created, invoice.paid, client.created, document.uploaded, booking.created.
Tipos de acción: create_task, send_notification, send_email, update_field, assign_user, create_calendar_event.
PATCH /api/automations/:id
Actualiza una automatización existente.
UUID de la automatización.
DELETE /api/automations/:id
Elimina una automatización.
UUID de la automatización.
GET /api/automations/:id/executions
Lista el historial de ejecuciones de una automatización.
UUID de la automatización.
Last updated today