OpenCognitOpenCognitDOCS

Routines & Scheduling

Automate recurring tasks with cron triggers.

What are Routines?

Routines are predefined tasks that run automatically on a schedule. Ideal for:

  • Daily: Morning reports, status updates, backups
  • Weekly: Sprint reviews, cost summaries
  • Hourly: Monitoring checks, API queries
  • Event-based: Webhook triggers from external systems

Create a Routine

POST /api/unternehmen/:id/routinen
Authorization: Bearer <token>
Content-Type: application/json

{
  "name": "Daily Morning Report",
  "beschreibung": "Generate a status report covering all ongoing projects.",
  "expertId": "<agent-id>",
  "concurrencyPolicy": "skip",
  "catchUpPolicy": "skip"
}

Fields

FieldValuesDescription
concurrencyPolicyskip, queue, replaceWhat happens if the routine is already running?
catchUpPolicyskip, run_onceWhat happens with missed executions?

Execution History

GET /api/routinen/:id/ausfuehrungen
Authorization: Bearer <token>

Response:

[
  {
    "id": "run-123",
    "status": "success",
    "gestartetAm": "2026-04-04T09:00:00Z",
    "beendetAm": "2026-04-04T09:03:42Z",
    "durationMs": 222000,
    "triggerTyp": "schedule",
    "tokenVerbrauch": 1240,
    "kostenCent": 18
  }
]

Cron Triggers

Routines are triggered via 5-field cron expressions:

┌───────────── Minute (0–59)
│ ┌───────────── Hour (0–23)
│ │ ┌───────────── Day of month (1–31)
│ │ │ ┌───────────── Month (1–12)
│ │ │ │ ┌───────────── Day of week (0–6, Sun=0)
│ │ │ │ │
* * * * *

Examples

ExpressionDescription
0 9 * * 1-5Weekdays at 9:00 AM
0 * * * *Every hour
0 8 * * 1Every Monday at 8:00 AM
*/15 * * * *Every 15 minutes
0 18 * * 5Fridays at 6:00 PM
0 0 1 * *First day of every month at midnight

Trigger Types

Time-based execution with 5-field cron expression.

POST /api/routinen/:id/triggers

{
  "typ": "schedule",
  "cron": "0 9 * * 1-5"
}

Immediate execution via API or dashboard.

POST /api/routinen/:id/trigger
Authorization: Bearer <token>

Triggered by external systems via HTTP POST.

{
  "typ": "webhook",
  "secret": "my-webhook-secret"
}

Concurrency & Catch-Up Policies

Concurrency Policy

Defines what happens when a trigger fires while the routine is still running:

PolicyBehavior
skipNew execution is skipped (recommended for long tasks)
queueNew execution is queued
replaceRunning execution is cancelled, new one starts

Catch-Up Policy

Defines what happens with missed executions (e.g. system was offline):

PolicyBehavior
skipMissed executions are ignored
run_onceOne catch-up execution starts immediately

For most use cases, we recommend concurrencyPolicy: "skip" and catchUpPolicy: "skip" to avoid queuing up executions when the system was briefly offline.


Routines API

MethodEndpointDescription
GET/api/unternehmen/:id/routinenList all routines
POST/api/unternehmen/:id/routinenCreate routine
GET/api/routinen/:idRoutine details
PATCH/api/routinen/:idUpdate routine
DELETE/api/routinen/:idDelete routine
GET/api/routinen/:id/triggersGet triggers
POST/api/routinen/:id/triggersCreate trigger
POST/api/routinen/:id/triggerTrigger manually
GET/api/routinen/:id/ausfuehrungenExecution history