> ## 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.

# Toggle task

> Activar o desactivar una tarea.

## Endpoint

```
POST /api/tasks/{id}/toggle
```

## 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="enabled" type="boolean" required>
  `true` para activar, `false` para desactivar
</ParamField>

<RequestExample>
  ```bash cURL - Desactivar theme={null}
  curl -X POST "https://app.horneross.com/api/tasks/trigger_abc123/toggle" \
    -H "Authorization: Bearer sk_live_xxx" \
    -H "Content-Type: application/json" \
    -d '{"enabled": false}'
  ```

  ```bash cURL - Activar theme={null}
  curl -X POST "https://app.horneross.com/api/tasks/trigger_abc123/toggle" \
    -H "Authorization: Bearer sk_live_xxx" \
    -H "Content-Type: application/json" \
    -d '{"enabled": true}'
  ```

  ```javascript JavaScript theme={null}
  // Desactivar task
  const response = await fetch(
    'https://app.horneross.com/api/tasks/trigger_abc123/toggle',
    {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer sk_live_xxx',
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({ enabled: false }),
    }
  );

  const { trigger } = await response.json();
  console.log('Task estado:', trigger.isEnabled ? 'activa' : 'inactiva');
  ```

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

  # Activar task
  response = requests.post(
      'https://app.horneross.com/api/tasks/trigger_abc123/toggle',
      headers={
          'Authorization': 'Bearer sk_live_xxx',
          'Content-Type': 'application/json',
      },
      json={'enabled': True}
  )

  trigger = response.json()['trigger']
  print(f'Task {"activa" if trigger["isEnabled"] else "inactiva"}')
  ```
</RequestExample>

## Response

<ResponseField name="trigger" type="object" required>
  La tarea con el estado actualizado

  <Expandable title="Propiedades">
    <ResponseField name="trigger.id" type="string" required>
      ID de la tarea
    </ResponseField>

    <ResponseField name="trigger.isEnabled" type="boolean" required>
      Nuevo estado
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseExample>
  ```json 200 - Success theme={null}
  {
    "trigger": {
      "id": "trigger_abc123",
      "agentId": "agent_xyz",
      "type": "schedule",
      "name": "Resumen diario",
      "config": {
        "prompt": "...",
        "cronExpression": "0 9 * * *"
      },
      "isEnabled": false,
      "createdAt": "2024-01-21T10:00:00Z"
    }
  }
  ```

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

<Info>
  Para tareas tipo `integration_event`, al desactivar también se pausa el trigger en Composio. Al reactivar, se vuelve a habilitar automáticamente.
</Info>
