---
title: "Give an agent a routine"
method: POST
path: "/v1/personal-agents/{id}/routines"
tags: ["Agents"]
---

# Give an agent a routine

`POST /v1/personal-agents/{id}/routines`

## Request

- Base URL: `https://api.openworklabs.com`
- URL: `https://api.openworklabs.com/v1/personal-agents/{id}/routines`
- Auth: one of:
  - API key in header `x-api-key`
  - HTTP bearer

An agent has an owner, a name, a brief that says how it works, and rules for which tools it can use. Every change to the brief or tool policy makes a new version. An agent does its work through routines. A routine is a Cloud Automation that belongs to the agent, so it also appears in the Automation capabilities; each run starts from the agent's brief and can use only what the agent's tool policy allows. The owner can share the agent with teammates. Managers can change who can collaborate. The owner must approve changes a manager proposes to the brief, tool policy or routines. Collaborators can use the agent and ask for changes. Runs started by a teammate are private. Scheduled runs use the owner’s accounts and share their results with the team. A manager’s request waits for the owner’s approval. Once created, the routine is active and runs in OpenWork Cloud on its schedule. Its instructions say what this routine does; do not repeat the brief in them. Change or pause it with the agent routine update.

## Path parameters

- `id` string, required

## Request body

- CreatePersonalAgentRoutine
  - `name` string, required
  - `instructions` string, required: What this routine does each time it runs. The agent's brief is added in front of it.
  - `schedule` union, required
    - object
      - `kind` 'once', required
      - `timezone` string, required
      - `at` integer, required
    - object
      - `kind` 'daily', required
      - `timezone` string, required
      - `hour` integer, required
      - `minute` integer, required
    - object
      - `kind` 'weekly', required
      - `timezone` string, required
      - `daysOfWeek` integer[], required
      - `hour` integer, required
      - `minute` integer, required
    - object: Every everyHours hours on the hour, counted from startHour on each listed day (0 = Sunday) and stopping before endHour, in timezone. Needs the organization's every-few-hours schedules.
      - `kind` 'interval', required
      - `timezone` string, required
      - `everyHours` integer, required
      - `daysOfWeek` integer[]
      - `startHour` integer
      - `endHour` integer
    - object: Runs offsetMinutes (negative is before) from the start or end of each meeting on the owner's primary Google Calendar: timed meetings they accepted or organize, with someone else invited. Cloud Automations only; needs Google Calendar connected and the organization's before-and-after-meeting Automations.
      - `kind` 'calendar', required
      - `timezone` string, required
      - `edge` 'start' | 'end', required
      - `offsetMinutes` integer, required
      - `rule` object
        - `withExternalAttendees` boolean
        - `titleIncludes` string
    - object
      - `kind` 'event', required
  - `model` object: Omit to run on the organization's cloud default model.
    - `providerId` string, required
    - `modelId` string, required
    - `variant` string, nullable
  - `executionTarget` 'cloud': A routine always runs in OpenWork Cloud; this may be omitted.

## Response `201`

Routine created as an active Cloud Automation that carries the agent's id.

- AutomationDetail
  - `automation` Automation, required
    - `id` string, required
    - `organizationId` string, required
    - `ownerMemberId` string, required
    - `name` string, required
    - `state` 'active' | 'inactive' | 'needs_attention' | 'archived', required
    - `currentRevisionId` string, required
    - `nextDueAt` integer, nullable, required
    - `latestRunAt` integer, nullable, required
    - `latestSuccessfulRunId` string, nullable
    - `latestSuccessfulResult` unknown
    - `needsAttentionReason` AutomationNeedsAttentionReason, nullable, required
      - `code` 'owner_membership_lost' | 'model_access_lost' | 'provider_unavailable' | 'connect_access_unavailable' | 'openwork_web_access_required' | 'execution_runtime_unavailable', required
      - `message` string, required
      - `occurredAt` integer, required
    - `agentId` string, nullable
    - `createdAt` integer, required
    - `updatedAt` integer, required
    - `archivedAt` integer, nullable, required
  - `revision` AutomationRevision, required
    - `id` string, required
    - `automationId` string, required
    - `version` integer, required
    - `instructions` string, required
    - `schedule` union, required
      - object
        - `kind` 'once', required
        - `timezone` string, required
        - `at` integer, required
      - object
        - `kind` 'daily', required
        - `timezone` string, required
        - `hour` integer, required
        - `minute` integer, required
      - object
        - `kind` 'weekly', required
        - `timezone` string, required
        - `daysOfWeek` integer[], required
        - `hour` integer, required
        - `minute` integer, required
      - object: Every everyHours hours on the hour, counted from startHour on each listed day (0 = Sunday) and stopping before endHour, in timezone. Needs the organization's every-few-hours schedules.
        - `kind` 'interval', required
        - `timezone` string, required
        - `everyHours` integer, required
        - `daysOfWeek` integer[]
        - `startHour` integer
        - `endHour` integer
      - object: Runs offsetMinutes (negative is before) from the start or end of each meeting on the owner's primary Google Calendar: timed meetings they accepted or organize, with someone else invited. Cloud Automations only; needs Google Calendar connected and the organization's before-and-after-meeting Automations.
        - `kind` 'calendar', required
        - `timezone` string, required
        - `edge` 'start' | 'end', required
        - `offsetMinutes` integer, required
        - `rule` object
          - `withExternalAttendees` boolean
          - `titleIncludes` string
      - object
        - `kind` 'event', required
    - `model` object, required
      - `providerId` string, required
      - `modelId` string, required
      - `variant` string, nullable
    - `action` union
      - object
        - `kind` 'agent', required
        - `instructions` string, required
        - `model` object, required
          - `providerId` string, required
          - `modelId` string, required
          - `variant` string, nullable
      - object
        - `kind` 'saved_script', required
        - `script` object, required
          - `pluginId` string, required
          - `configObjectId` string, required
          - `configObjectVersionId` string, required
        - `input` unknown
    - `executionTarget` 'desktop' | 'cloud'
    - `workspaceId` string, nullable
    - `agentRevisionId` string, nullable
    - `maximumRuntimeMs` integer, required
    - `digest` string, required
    - `createdAt` integer, required
  - `latestRun` AutomationRun, nullable, required
    - `id` string, required
    - `automationId` string, required
    - `revisionId` string, required
    - `trigger` 'scheduled' | 'recovery' | 'manual', required
    - `scheduledFor` integer, nullable, required
    - `idempotencyKey` string, required
    - `status` 'queued' | 'claimed' | 'running' | 'succeeded' | 'failed' | 'cancelled' | 'skipped', required
    - `leaseOwner` string, nullable, required
    - `leaseExpiresAt` integer, nullable, required
    - `heartbeatAt` integer, nullable, required
    - `attemptCount` integer, required
    - `executionTarget` 'desktop' | 'cloud', required
    - `executionThread` AutomationExecutionThread, nullable, required
      - `id` string, required
      - `threadKind` 'automation', required
      - `executionLocation` 'desktop' | 'cloud', required
      - `automationId` string, required
      - `automationRunId` string, required
      - `engineKind` string, required
      - `nativeThreadId` string, nullable
      - `workspaceId` string, nullable
    - `providerId` string, required
    - `modelId` string, required
    - `modelVariant` string, nullable
    - `startedAt` integer, nullable, required
    - `finishedAt` integer, nullable, required
    - `error` AutomationError, nullable, required
      - `code` 'owner_membership_lost' | 'model_access_lost' | 'provider_unavailable' | 'connect_access_unavailable' | 'openwork_web_access_required' | 'execution_runtime_unavailable' | 'connection_action_required' | 'execution_failed' | 'execution_timed_out' | 'runner_unavailable' | 'cancelled' | 'lease_lost' | 'internal_error', required
      - `message` string, required
      - `retryable` boolean, required
    - `resultSummary` string, nullable, required
    - `codemodeReceiptId` string, nullable
    - `validatedResult` unknown
    - `triggerContext` AutomationRunTriggerContext, nullable
      - `kind` 'calendar_meeting', required
      - `eventId` string, required
      - `title` string, nullable, required
      - `start` integer, required
      - `end` integer, required
      - `attendeeDomains` string[], required
      - `externalAttendees` integer, required
      - `link` string, nullable, required
    - `usage` AutomationUsage, required
      - `inputTokens` integer, nullable, required
      - `outputTokens` integer, nullable, required
      - `costMicros` integer, nullable, required
    - `createdAt` integer, required
    - `updatedAt` integer, required

## Other responses

- `202`: Routine requested and waiting for the owner.
- `400`: Invalid request.
- `403`: Cloud Automations are not available.
- `404`: Not found.
- `409`: Cloud runtime or model access is unavailable.

## Changes

- **2026-12-02** `b20ab6931f6a`: 1 breaking, 1 info
  - added `subschema #6` to the `revision/schedule` response property `oneOf` list for the response status `201`
  - added `subschema #6` to the `schedule` request property `oneOf` list
- **2026-11-26** `b55d1864549e`: 2 warning, 1 info
  - added the new `awaiting_owner` enum value to the `request/status` response property for the response status `202`
  - added the new `turn_on` enum value to the `request/canDecide/items/` response property for the response status `202`
  - added the optional property `request/connectorAccess` to the response with the `202` status
- **2026-11-26** `bc0092687a7b`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/openworklabs/apis/den-api/changes/v1/personal-agents/:id/routines/post.md)

---

[API](https://skmtc.dev/openworklabs/apis/den-api.md) - [All operations](https://skmtc.dev/openworklabs/apis/den-api/llms.txt) - [OpenAPI document](https://skmtc.dev/openworklabs/apis/den-api/revisions/84fb0f99fb95?raw)
