← Volver al lienzo

API OpenClaw

Todas las peticiones requieren la cabecera x-api-key con el valor del secret OPENCLAW_API_KEY. Base URL: https://tu-app.lovable.app/api/public/openclaw

GET/agents

Listar agentes

curl https://tu-app.lovable.app/api/public/openclaw/agents \
  -H "x-api-key: $OPENCLAW_API_KEY"
GET/agents/:id

Leer un agente (con actividad)

curl https://tu-app.lovable.app/api/public/openclaw/agents/gmail \
  -H "x-api-key: $OPENCLAW_API_KEY"
PATCH/agents/:id

Actualizar estado, prioridad, herramientas o posición

Campos opcionales: state (working · meeting · review · paused · coordinating), priority (Alta · Media · Baja), tools, position, name, role, hue.

curl -X PATCH https://tu-app.lovable.app/api/public/openclaw/agents/gmail \
  -H "x-api-key: $OPENCLAW_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"state":"meeting","priority":"Alta","tools":["Gmail","CRM"],"position":2}'
POST/agents/:id/activity

Añadir entrada de actividad

curl -X POST https://tu-app.lovable.app/api/public/openclaw/agents/gmail/activity \
  -H "x-api-key: $OPENCLAW_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"title":"Respuesta enviada","copy":"Confirmación de pedido #4821."}'
GET / POST/agents/:id/status

Atajo: leer / cambiar estado

curl -X POST https://tu-app.lovable.app/api/public/openclaw/agents/gmail/status \
  -H "x-api-key: $OPENCLAW_API_KEY" -H "Content-Type: application/json" \
  -d '{"state":"working"}'
GET/office/state

Snapshot completo de la oficina

Devuelve agentes + últimas tareas, eventos y comandos.

curl https://tu-app.lovable.app/api/public/openclaw/office/state -H "x-api-key: $OPENCLAW_API_KEY"
POST/office/event

Registrar un evento de oficina

curl -X POST https://tu-app.lovable.app/api/public/openclaw/office/event \
  -H "x-api-key: $OPENCLAW_API_KEY" -H "Content-Type: application/json" \
  -d '{"type":"email_received","agent_id":"gmail","payload":{"from":"x@y.com"}}'
GET / POST/tasks

Listar / crear tareas

Filtros GET: ?status=, ?agent_id=.

curl -X POST https://tu-app.lovable.app/api/public/openclaw/tasks \
  -H "x-api-key: $OPENCLAW_API_KEY" -H "Content-Type: application/json" \
  -d '{"title":"Revisar contrato","agent_id":"documentos","priority":"Alta"}'
PATCH/tasks/:id

Actualizar tarea

curl -X PATCH https://tu-app.lovable.app/api/public/openclaw/tasks/<uuid> \
  -H "x-api-key: $OPENCLAW_API_KEY" -H "Content-Type: application/json" \
  -d '{"status":"done"}'
GET / POST/commands

Listar / encolar comandos (app → OpenClaw)

La app crea comandos vía POST cuando el usuario pulsa un botón. OpenClaw hace polling con ?status=pending, ejecuta y cierra con PATCH al endpoint de abajo.

curl https://tu-app.lovable.app/api/public/openclaw/commands?status=pending \
  -H "x-api-key: $OPENCLAW_API_KEY"
GET / PATCH/commands/:id

Consultar / cerrar un comando

curl -X PATCH https://tu-app.lovable.app/api/public/openclaw/commands/<uuid> \
  -H "x-api-key: $OPENCLAW_API_KEY" -H "Content-Type: application/json" \
  -d '{"status":"done","result":{"ok":true}}'
POST/agent-message

Mensaje rápido a un agente (atajo)

Crea entrada en la actividad del agente y un evento global.

curl -X POST https://tu-app.lovable.app/api/public/openclaw/agent-message \
  -H "x-api-key: $OPENCLAW_API_KEY" -H "Content-Type: application/json" \
  -d '{"agent_id":"zac","title":"Aviso","copy":"Reunión a las 17:00."}'
GET/activity

Feed de actividad de la oficina

curl https://tu-app.lovable.app/api/public/openclaw/activity?limit=20 \
  -H "x-api-key: $OPENCLAW_API_KEY"

IDs disponibles: gmail, whatsapp, crm, calendario, reuniones, documentos, zac.