> This page is for version v1 (default).
> For other versions, use one of these documentation indexes:
> - v1 (default): https://docs.butterix.com/llms.txt
> - v0: https://docs.butterix.com/v0/llms.txt

> For the MDX source of any page, append .mdx to the page URL.
> For a complete documentation index, see https://docs.butterix.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.butterix.com/_mcp/server.
> If something on this page is wrong or missing, POST JSON {"page": "<page URL>", "message": "<what is wrong>"} to https://docs.butterix.com/_biti/feedback/agent.

# 获取定时任务

`GET /sites/{site}/automations/{id}`

Base URL: https://api.butterix.com/v1

Authentication: bearer token in Authorization header or API key in cookie `biti_session`

## Path parameters

| Name | Type | Required | Description |
|---|---|---|---|
| `site` | string | yes | 站点 slug 或 id |
| `id` | string | yes | 定时任务 id |

## Example request

```bash
curl https://api.butterix.com/v1/sites/acme-payments/automations/auto_01jd8x2k7q \
     -H "Authorization: Bearer <token>"
```

## Responses

### 200

定时任务

Content type: `application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `id` | string | no |  |
| `name` | string | no |  |
| `prompt` | string | no |  |
| `schedule` | object | no |  |
| `schedule.every` | enum | yes | Allowed: `day`, `week`. |
| `schedule.weekday` | integer | no | 1（周一）到 7（周日），`every` 为 `week` 时必填 |
| `schedule.hour` | integer | yes |  |
| `schedule.minute` | integer | no |  |
| `schedule.timezone` | string | no | IANA 时区 |
| `canEdit` | boolean | no | 允许修改文档 |
| `enabled` | boolean | no |  |
| `createdBy` | object | no |  |
| `createdBy.id` | string | no |  |
| `createdBy.name` | string | no |  |
| `createdAt` | integer | no |  |
| `nextAt` | integer | no | 下一次运行的时间 May be null. |
| `lastRun` | union | no | 最近一次运行（不含报告）；还没有运行过时为 `null` |
| _Variant 1_ | variant |  |  |
| `lastRun.id` | string | no |  |
| `lastRun.automationId` | string | no |  |
| `lastRun.cause` | enum | no | Allowed: `schedule`, `manual`. |
| `lastRun.status` | enum | no | Allowed: `running`, `done`, `failed`. |
| `lastRun.report` | string | no | 报告（Markdown） |
| `lastRun.branch` | string | no | 有改动时的草稿分支 |
| `lastRun.files` | list of strings | no | 修改的文件 |
| `lastRun.error` | string | no | 失败原因 |
| `lastRun.usage` | object | no | token 用量 |
| `lastRun.usage.input` | integer | no |  |
| `lastRun.usage.output` | integer | no |  |
| `lastRun.startedAt` | integer | no |  |
| `lastRun.finishedAt` | integer | no | May be null. |

### 404

资源不存在，或你没有访问权限

Content type: `application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | string | yes | 人类可读的错误信息 |
| `code` | string | no | 机器可读的错误码（部分接口提供） |

### Example response (200)

```json
{
  "id": "auto_01jd8x2k7q",
  "name": "每周文档缺口",
  "prompt": "string",
  "schedule": {
    "every": "day",
    "weekday": 1,
    "hour": 0,
    "minute": 0,
    "timezone": "Asia/Shanghai"
  },
  "canEdit": true,
  "enabled": true,
  "createdBy": {
    "id": "string",
    "name": "string"
  },
  "createdAt": 1,
  "nextAt": 1,
  "lastRun": {
    "id": "run_01jd8x2k7q",
    "automationId": "string",
    "cause": "schedule",
    "status": "running",
    "report": "string",
    "branch": "automation/2k7q9x1a",
    "files": [
      "string"
    ],
    "error": "string",
    "usage": {
      "input": 1,
      "output": 1
    },
    "startedAt": 1,
    "finishedAt": 1
  }
}
```
