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

# Update Scheduled Task

> Update a scheduled task owned by the workspace API key

Updates one scheduled task owned by this workspace API key. Send at least one field. The response does not include `runCount`.

Omitted fields stay as they are. The schedule is checked after your fields are merged with the stored clock. Changing only `frequency` can reuse the stored `timeOfDay`. A merged clock that is incomplete returns `400`.

Sending `attachmentIds` replaces the attachment list. Omitting `attachmentIds` leaves attachments unchanged. Sending a tag array replaces that array. An empty array clears it. Inaccessible tagged ids and slugs are dropped.

## Base URL

```
https://api.langdock.com/automations/v1/{automationId}
```

<Warning>
  **Dedicated deployments**

  Replace `api.langdock.com` with `<your-deployment-url>/api/public` in all requests.
</Warning>

## Required scopes

This endpoint requires the `AUTOMATION_API` scope (**Scheduled Tasks API**) on a workspace API key.

## Parameters

| Parameter                  | In   | Type            | Required | Description                                                                 |
| -------------------------- | ---- | --------------- | -------- | --------------------------------------------------------------------------- |
| `automationId`             | Path | string          | Yes      | UUID of the scheduled task.                                                 |
| `name`                     | Body | string          | No       | 1 to 200 characters.                                                        |
| `prompt`                   | Body | string          | No       | 1 to 120000 characters.                                                     |
| `frequency`                | Body | string          | No       | `MANUAL`, `DAILY`, `WEEKDAYS`, `WEEKLY`, `MONTHLY`, or `SELECTED_WEEKDAYS`. |
| `timeOfDay`                | Body | string \| null  | No       | 24 hour `HH:mm`.                                                            |
| `dayOfWeek`                | Body | integer \| null | No       | 0 (Sunday) through 6 (Saturday).                                            |
| `dayOfMonth`               | Body | integer \| null | No       | 1 through 31.                                                               |
| `daysOfWeek`               | Body | integer\[]      | No       | Days 0 through 6. At most 7 values.                                         |
| `timezone`                 | Body | string \| null  | No       | IANA name, at most 64 characters.                                           |
| `modelMode`                | Body | string          | No       | `UNSET`, `EXPLICIT`, or `AUTO`.                                             |
| `modelId`                  | Body | string \| null  | No       | Required in this request when `modelMode` is `EXPLICIT`.                    |
| `assistantId`              | Body | string \| null  | No       | Primary agent. `null` clears it.                                            |
| `taggedAssistantId`        | Body | string \| null  | No       | Extra agent mention. `null` clears it.                                      |
| `taggedIntegrationIds`     | Body | string\[]       | No       | Replaces the list. At most 20.                                              |
| `taggedKnowledgeFolderIds` | Body | string\[]       | No       | Replaces the list. At most 20.                                              |
| `taggedWorkflowIds`        | Body | string\[]       | No       | Replaces the list. At most 20.                                              |
| `taggedSkillSlugs`         | Body | string\[]       | No       | Replaces the list. At most 20.                                              |
| `attachmentIds`            | Body | string\[]       | No       | Replaces attachments. At most 20. Each id must belong to this key.          |

Unknown body fields are rejected. An invalid body returns `400` with message `Invalid request` and an `errors` array. An empty body returns `400` with message `At least one field must be provided.` A merged schedule that is still incomplete returns `400` with message `automation_time_of_day_required`, `automation_day_of_week_required`, `automation_day_of_month_required`, or `automation_days_of_week_required`.

## Example

```javascript theme={null}
const axios = require("axios");

async function updateScheduledTask(automationId) {
  const response = await axios.patch(
    `https://api.langdock.com/automations/v1/${automationId}`,
    {
      prompt: "Summarize overnight pipeline changes and flag deals that slipped."
    },
    {
      headers: {
        Authorization: "Bearer YOUR_API_KEY",
        "Content-Type": "application/json"
      }
    }
  );

  console.log(response.data.automation.name);
}

updateScheduledTask("550e8400-e29b-41d4-a716-446655440000");
```

## Response format

### Success response (200 OK)

`automation` matches the [scheduled task object](/en/developer/scheduled-tasks-api/scheduled-tasks-overview) without `runCount`.

```typescript theme={null}
{
  automation: {
    id: string;
    createdAt: string;
    name: string;
    prompt: string;
    frequency:
      | "MANUAL"
      | "DAILY"
      | "WEEKDAYS"
      | "WEEKLY"
      | "MONTHLY"
      | "SELECTED_WEEKDAYS";
    timeOfDay: string | null;
    dayOfWeek: number | null;
    dayOfMonth: number | null;
    daysOfWeek: number[];
    timezone: string | null;
    active: boolean;
    modelId: string | null;
    modelMode: "UNSET" | "EXPLICIT" | "AUTO";
    assistantId: string | null;
    taggedAssistantId: string | null;
    lastRunAt: string | null;
    attachments: Array<{
      id: string;
      name: string;
      mimeType: string | null;
      type: string | null;
    }>;
    taggedIntegrationIds: string[];
    taggedKnowledgeFolderIds: string[];
    taggedWorkflowIds: string[];
    taggedSkillSlugs: string[];
  };
}
```

## Error handling

| Status code | Description                                                                                                                  |
| ----------- | ---------------------------------------------------------------------------------------------------------------------------- |
| 400         | Invalid body, message `At least one field must be provided.`, or an incomplete merged schedule                               |
| 401         | Invalid or missing API key, or the key user was not found                                                                    |
| 403         | Missing `AUTOMATION_API`, a personal API key, Scheduled Tasks disabled, no product access, or `AUTOMATION_TAG_ACCESS_DENIED` |
| 404         | `AUTOMATION_NOT_FOUND`                                                                                                       |
| 405         | Method not allowed                                                                                                           |
| 429         | Rate limit exceeded                                                                                                          |
| 500         | Internal server error                                                                                                        |

<Info>
  Langdock intentionally blocks browser-origin requests to protect your API key and ensure your applications remain secure. For more information, please see our guide on [API Key Best Practices](/en/admin/ai-adoption-and-rollout/best-practices/api-key-best-practices).
</Info>


## OpenAPI

````yaml PATCH /automations/v1/{automationId}
openapi: 3.0.0
info:
  title: Langdock API
  version: 3.0.0
servers:
  - url: https://api.langdock.com
    description: Production
security:
  - bearerAuth: []
paths:
  /automations/v1/{automationId}:
    patch:
      tags:
        - Scheduled Tasks
      summary: Update a scheduled task
      description: >-
        Updates one scheduled task owned by this workspace API key. Send at
        least one field. The response does not include runCount. The merged
        schedule is validated.
      operationId: updateScheduledTask
      parameters:
        - name: automationId
          in: path
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              minProperties: 1
              properties:
                name:
                  type: string
                  minLength: 1
                  maxLength: 200
                prompt:
                  type: string
                  minLength: 1
                  maxLength: 120000
                frequency:
                  type: string
                  enum:
                    - MANUAL
                    - DAILY
                    - WEEKDAYS
                    - WEEKLY
                    - MONTHLY
                    - SELECTED_WEEKDAYS
                timeOfDay:
                  type: string
                  nullable: true
                  description: 24 hour HH:mm. Omitted keeps the stored value.
                dayOfWeek:
                  type: integer
                  minimum: 0
                  maximum: 6
                  nullable: true
                  description: >-
                    0 is Sunday and 6 is Saturday. Omitted keeps the stored
                    value.
                dayOfMonth:
                  type: integer
                  minimum: 1
                  maximum: 31
                  nullable: true
                  description: Omitted keeps the stored value.
                daysOfWeek:
                  type: array
                  maxItems: 7
                  items:
                    type: integer
                    minimum: 0
                    maximum: 6
                  description: Omitted keeps the stored value.
                timezone:
                  type: string
                  nullable: true
                  maxLength: 64
                  description: >-
                    IANA timezone. Omitted keeps the stored value. Empty is
                    stored as UTC on a scheduled frequency.
                modelMode:
                  type: string
                  enum:
                    - UNSET
                    - EXPLICIT
                    - AUTO
                modelId:
                  type: string
                  format: uuid
                  nullable: true
                  description: Required in this request when modelMode is EXPLICIT.
                assistantId:
                  type: string
                  format: uuid
                  nullable: true
                taggedAssistantId:
                  type: string
                  format: uuid
                  nullable: true
                taggedIntegrationIds:
                  type: array
                  maxItems: 20
                  items:
                    type: string
                    format: uuid
                taggedKnowledgeFolderIds:
                  type: array
                  maxItems: 20
                  items:
                    type: string
                    format: uuid
                taggedWorkflowIds:
                  type: array
                  maxItems: 20
                  items:
                    type: string
                    format: uuid
                taggedSkillSlugs:
                  type: array
                  maxItems: 20
                  items:
                    type: string
                    maxLength: 100
                attachmentIds:
                  type: array
                  maxItems: 20
                  items:
                    type: string
                    format: uuid
      responses:
        '200':
          description: >-
            Scheduled task updated. The automation object does not include
            runCount.
        '400':
          description: >-
            Invalid body, message At least one field must be provided, or an
            incomplete merged schedule
        '401':
          description: Invalid or missing API key, or the key user was not found
        '403':
          description: >-
            Missing AUTOMATION_API, a personal API key, Scheduled Tasks
            disabled, no product access, or AUTOMATION_TAG_ACCESS_DENIED
        '404':
          description: Message AUTOMATION_NOT_FOUND
        '405':
          description: Method not allowed
        '429':
          description: Rate limit exceeded
        '500':
          description: Internal server error
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: API key as Bearer token. Format "Bearer YOUR_API_KEY"

````