> ## Documentation Index
> Fetch the complete documentation index at: https://docs.horneross.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Actualizar task

> Actualizar configuración de una tarea existente.

## Endpoint

```
PUT /api/tasks/{id}
```

## Headers

<ParamField header="Authorization" type="string" required>
  Bearer token con tu API key. Formato: `Bearer sk_live_xxx`
</ParamField>

<ParamField header="Content-Type" type="string" required>
  `application/json`
</ParamField>

## Path Parameters

<ParamField path="id" type="string" required>
  ID de la tarea
</ParamField>

## Request Body

<ParamField body="name" type="string">
  Nuevo nombre (máx 100 caracteres)
</ParamField>

<ParamField body="description" type="string">
  Nueva descripción (máx 500 caracteres)
</ParamField>

<ParamField body="prompt" type="string">
  Nuevas instrucciones para el agente
</ParamField>

<ParamField body="config" type="object">
  Nueva configuración del trigger
</ParamField>

<ParamField body="isEnabled" type="boolean">
  Activar o desactivar la tarea
</ParamField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X PUT "https://app.horneross.com/api/tasks/trigger_abc123" \
    -H "Authorization: Bearer sk_live_xxx" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "Resumen semanal",
      "prompt": "Genera un resumen semanal de las conversaciones",
      "config": {
        "cronExpression": "0 9 * * 1"
      }
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    'https://app.horneross.com/api/tasks/trigger_abc123',
    {
      method: 'PUT',
      headers: {
        'Authorization': 'Bearer sk_live_xxx',
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        name: 'Resumen semanal',
        prompt: 'Genera un resumen semanal de las conversaciones',
        config: {
          cronExpression: '0 9 * * 1', // Lunes a las 9am
        },
      }),
    }
  );

  const { trigger } = await response.json();
  ```

  ```python Python theme={null}
  import requests

  response = requests.put(
      'https://app.horneross.com/api/tasks/trigger_abc123',
      headers={
          'Authorization': 'Bearer sk_live_xxx',
          'Content-Type': 'application/json',
      },
      json={
          'name': 'Resumen semanal',
          'prompt': 'Genera un resumen semanal de las conversaciones',
          'config': {
              'cronExpression': '0 9 * * 1'
          }
      }
  )
  ```
</RequestExample>

## Response

<ResponseField name="trigger" type="object" required>
  La tarea actualizada
</ResponseField>

<ResponseExample>
  ```json 200 - Success theme={null}
  {
    "trigger": {
      "id": "trigger_abc123",
      "agentId": "agent_xyz",
      "type": "schedule",
      "name": "Resumen semanal",
      "description": null,
      "config": {
        "prompt": "Genera un resumen semanal de las conversaciones",
        "cronExpression": "0 9 * * 1",
        "timezone": "America/Argentina/Buenos_Aires"
      },
      "isEnabled": true,
      "createdAt": "2024-01-21T10:00:00Z",
      "agent": {
        "id": "agent_xyz",
        "name": "Asistente de Ventas",
        "iconUrl": null
      }
    }
  }
  ```

  ```json 404 - Not Found theme={null}
  {
    "error": "Task not found"
  }
  ```
</ResponseExample>

<Info>
  Cuando actualizás `isEnabled` o `cronExpression` en una tarea tipo `schedule`, el sistema sincroniza automáticamente el schedule.
</Info>
