---
title: "Archive — terminal; the schedule stops and the routine becomes immutable [write]"
method: POST
path: "/routines/{id}/archive"
---

# Archive — terminal; the schedule stops and the routine becomes immutable \[write\]

`POST /routines/{id}/archive`

## Request

- Base URL: `https://api.agentsky.dev/v1`
- URL: `https://api.agentsky.dev/v1/routines/{id}/archive`
- Auth: HTTP bearer

## Path parameters

- `id` string, required

## Response `200`

OK

- object
  - `routine` Routine, required: Scheduled agent execution: initial_events + a target (new_session per fire, or an existing session) bound to a cron schedule. Fires record routine runs.
    - `id` string: rtn_… identifier
    - `name` string
    - `description` string, nullable
    - `metadata` object
    - `target` object: {type:"new_session", agent, environment_id?, vault_ids?, reuse_session?} — a fresh session per fire (CMA parity); with reuse_session: true the first fire starts the session and every later fire posts into it (a new one only once it is archived or deleted; a fire while it is working or waiting on a person is skipped) · {type:"session", session_id} — a turn into the existing session every fire (busy target skips with session_busy_error)
    - `initial_events` object[]
    - `schedule` object, nullable: 5-field POSIX cron + IANA timezone, wall-clock matching, minute granularity; null = manual-run only
      - `type` 'cron'
      - `expression` string
      - `timezone` string
      - `last_run_at` string, nullable
      - `upcoming_runs_at` string[]: ≤5 upcoming fire times; empty once archived
    - `budget` object, nullable: Per-run cap (RFC-0080 shape): copied onto each new session (mode new_session) or granted as a per-fire delta allowance consumed+budget (mode session). Clearable.
    - `status` 'active' | 'paused'
    - `paused_reason` object, nullable: {type:"manual"} | {type:"error", error:{type}, consecutive_failures, message?} — non-null exactly when paused. A routine pauses itself after 3 runs in a row fail with an error that the next run would repeat, insufficient_credits_error included (the wallet that pays for it is empty); add credit, then unpause.
    - `archived_at` string, nullable
    - `created_at` string
    - `updated_at` string

## Other responses

- `default`: Error — { error: { code, message, request_id } }

## Changes

- **2026-11-02** `e5e8f0229a99`: 4 info
  - added the optional property `error/request_id` to the response with the `default` status
  - the response property `error` became required for the status `default`
  - the response property `error/code` became required for the status `default`
  - the response property `error/message` became required for the status `default`

[Operation history](https://skmtc.dev/agentsky/apis/agentsky-developer-api/changes/routines/:id/archive/post.md)

---

[API](https://skmtc.dev/agentsky/apis/agentsky-developer-api.md) - [All operations](https://skmtc.dev/agentsky/apis/agentsky-developer-api/llms.txt) - [OpenAPI document](https://skmtc.dev/agentsky/apis/agentsky-developer-api/revisions/8280a065ef6a?raw)
