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

# Scheduled Task aktualisieren

> Aktualisiere eine Scheduled Task, die diesem Workspace-API-Key gehört

Aktualisiert eine Scheduled Task, die diesem Workspace-API-Key gehört. Sende mindestens ein Feld. Die Antwort enthält kein `runCount`.

Weggelassene Felder bleiben, wie sie sind. Der Zeitplan wird geprüft, nachdem deine Felder mit der gespeicherten Uhrzeit zusammengeführt wurden. Änderst du nur `frequency`, kann die gespeicherte `timeOfDay` weiter gelten. Ein unvollständiger zusammengeführter Zeitplan liefert `400`.

`attachmentIds` ersetzen die Anhangliste. Lässt du `attachmentIds` weg, bleiben die Anhänge. Ein Tag-Array ersetzt dieses Array. Ein leeres Array leert es. Nicht erreichbare getaggte IDs und Slugs werden verworfen.

## Basis-URL

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

<Warning>
  **Dedicated Deployments**

  Ersetze `api.langdock.com` durch `<your-deployment-url>/api/public` in allen Anfragen.
</Warning>

## Benötigte Scopes

Dieser Endpoint braucht den Scope `AUTOMATION_API` (**Scheduled Tasks API**) auf einem Workspace-API-Key.

## Parameter

| Parameter                  | In   | Typ             | Pflicht | Beschreibung                                                                 |
| -------------------------- | ---- | --------------- | ------- | ---------------------------------------------------------------------------- |
| `automationId`             | Pfad | string          | Ja      | UUID der Scheduled Task.                                                     |
| `name`                     | Body | string          | Nein    | 1 bis 200 Zeichen.                                                           |
| `prompt`                   | Body | string          | Nein    | 1 bis 120000 Zeichen.                                                        |
| `frequency`                | Body | string          | Nein    | `MANUAL`, `DAILY`, `WEEKDAYS`, `WEEKLY`, `MONTHLY` oder `SELECTED_WEEKDAYS`. |
| `timeOfDay`                | Body | string \| null  | Nein    | `HH:mm` im 24-Stunden-Format.                                                |
| `dayOfWeek`                | Body | integer \| null | Nein    | 0 (Sonntag) bis 6 (Samstag).                                                 |
| `dayOfMonth`               | Body | integer \| null | Nein    | 1 bis 31.                                                                    |
| `daysOfWeek`               | Body | integer\[]      | Nein    | Tage von 0 bis 6. Höchstens 7 Werte.                                         |
| `timezone`                 | Body | string \| null  | Nein    | IANA-Name, höchstens 64 Zeichen.                                             |
| `modelMode`                | Body | string          | Nein    | `UNSET`, `EXPLICIT` oder `AUTO`.                                             |
| `modelId`                  | Body | string \| null  | Nein    | Pflicht in dieser Anfrage, wenn `modelMode` `EXPLICIT` ist.                  |
| `assistantId`              | Body | string \| null  | Nein    | Primärer Agent. `null` entfernt ihn.                                         |
| `taggedAssistantId`        | Body | string \| null  | Nein    | Zusätzliche Agentenerwähnung. `null` entfernt sie.                           |
| `taggedIntegrationIds`     | Body | string\[]       | Nein    | Ersetzt die Liste. Höchstens 20.                                             |
| `taggedKnowledgeFolderIds` | Body | string\[]       | Nein    | Ersetzt die Liste. Höchstens 20.                                             |
| `taggedWorkflowIds`        | Body | string\[]       | Nein    | Ersetzt die Liste. Höchstens 20.                                             |
| `taggedSkillSlugs`         | Body | string\[]       | Nein    | Ersetzt die Liste. Höchstens 20.                                             |
| `attachmentIds`            | Body | string\[]       | Nein    | Ersetzt die Anhänge. Höchstens 20. Jede ID muss diesem Key gehören.          |

Unbekannte Body-Felder werden abgelehnt. Ein ungültiger Body liefert `400` mit der Message `Invalid request` und einem `errors`-Array. Ein leerer Body liefert `400` mit der Message `At least one field must be provided.` Ein zusammengeführter Zeitplan, der weiter unvollständig ist, liefert `400` mit der Message `automation_time_of_day_required`, `automation_day_of_week_required`, `automation_day_of_month_required` oder `automation_days_of_week_required`.

## Beispiel

```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");
```

## Antwortformat

### Erfolgreiche Antwort (200 OK)

`automation` entspricht dem [Scheduled-Task-Objekt](/de/developer/scheduled-tasks-api/scheduled-tasks-overview) ohne `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[];
  };
}
```

## Fehlerbehandlung

| Statuscode | Beschreibung                                                                                                                       |
| ---------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| 400        | Ungültiger Body, Message `At least one field must be provided.` oder ein unvollständiger zusammengeführter Zeitplan                |
| 401        | Ungültiger oder fehlender API-Key, oder der Key-User wurde nicht gefunden                                                          |
| 403        | `AUTOMATION_API` fehlt, persönlicher API-Key, Scheduled Tasks deaktiviert, kein Produktzugriff oder `AUTOMATION_TAG_ACCESS_DENIED` |
| 404        | Message `AUTOMATION_NOT_FOUND`                                                                                                     |
| 405        | Methode nicht erlaubt                                                                                                              |
| 429        | Rate Limit überschritten                                                                                                           |
| 500        | Interner Serverfehler                                                                                                              |

<Info>
  Langdock blockiert Anfragen aus Browser-Origins absichtlich, um deinen API-Key zu schützen und deine Anwendungen sicher zu halten. Mehr dazu findest du im Guide zu [API Key Best Practices](/de/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"

````