---
title: "创建自动化"
method: POST
path: "/automations"
tags: ["自动化"]
---

# 创建自动化

`POST /automations`

## Request

- Base URL: `/api/v1` (relative, and the document was published on a file host, not at the API’s origin)
- URL: `/api/v1/automations`
- Auth: API key in header `Authorization`

创建一个按计划由 WeKnora 助手以当前用户身份运行的任务

## Request body

- InternalHandlerCreateAutomationRequest
  - `access_level` 'read_only' | 'confirm' | 'auto_write'
  - `approval_timeout_minutes` integer: How long a run waits for an approval before it fails, in minutes; default 1440
  - `carry_last_result` boolean: Whether each per_run conversation gets the last successful answer
  - `description` string: What it is for
  - `instruction` string, required: The task, sent as the user message of each run. May name now, last_run_at, last_success_at, run_id or automation_name inside double curly braces to have it filled in
  - `limits` GithubComTencentWeKnoraInternalTypesAutomationLimits
    - `max_duration_minutes` integer: MaxDurationMinutes caps a run's execution time, not counting time spent waiting for approval. 0 uses the default.
  - `misfire_policy` 'skip' | 'run_once': What happens to runs missed while the service was down; default skip
  - `model_id` string: Optional chat model from model.list; empty follows the assistant default
  - `name` string, required: What the automation is called
  - `notify_on_success` boolean: Whether a successful run notifies the owner; failures always do
  - `overlap_policy` 'skip' | 'queue': What happens when a run is due while the previous one is still going; default skip
  - `session_mode` 'per_run' | 'persistent': per_run (default) starts a new conversation each run; persistent keeps one
  - `trigger` GithubComTencentWeKnoraInternalTypesAutomationTrigger, required
    - `at` string: At is when a once trigger fires, RFC3339 or a wall-clock time in Timezone, such as "2006-01-02T15:04:05" or "2006-01-02 15:04".
    - `expr` string: Expr is a cron expression: five fields (minute first) or six (seconds first), or a descriptor such as @daily.
    - `timezone` string: Timezone is an IANA zone, e.g. Asia/Shanghai; empty means UTC.
    - `type` string: Type is cron or once.

## Response `201`

创建的自动化

- object
  - `data` GithubComTencentWeKnoraInternalTypesAutomation
    - `access_level` 'read_only' | 'confirm' | 'auto_write'
    - `active_run_status` string: ActiveRunStatus is projected from live runs and is not persisted.
    - `approval_timeout_minutes` integer: ApprovalTimeoutMinutes is how long a run waits for an approval before it fails.
    - `carry_last_result` boolean: CarryLastResult adds the last successful answer to each per-run conversation.
    - `consecutive_failures` integer
    - `created_at` string
    - `description` string
    - `enabled` boolean
    - `id` string
    - `instruction` string: Instruction is the task, sent as the user message of each run after its variables are filled in.
    - `last_run_at` string
    - `last_run_status` string
    - `last_success_at` string
    - `limits` GithubComTencentWeKnoraInternalTypesAutomationLimits
      - `max_duration_minutes` integer: MaxDurationMinutes caps a run's execution time, not counting time spent waiting for approval. 0 uses the default.
    - `misfire_policy` string
    - `model_id` string: ModelID overrides the assistant's chat model; empty follows the assistant default.
    - `name` string
    - `next_run_at` string
    - `notify_on_success` boolean
    - `overlap_policy` string
    - `owner_user_id` string: OwnerUserID is the account the automation runs as.
    - `paused_reason` string
    - `persistent_session_id` string: PersistentSessionID is the conversation of a persistent automation, created on its first run.
    - `session_mode` string
    - `tenant_id` integer
    - `trigger` GithubComTencentWeKnoraInternalTypesAutomationTrigger
      - `at` string: At is when a once trigger fires, RFC3339 or a wall-clock time in Timezone, such as "2006-01-02T15:04:05" or "2006-01-02 15:04".
      - `expr` string: Expr is a cron expression: five fields (minute first) or six (seconds first), or a descriptor such as @daily.
      - `timezone` string: Timezone is an IANA zone, e.g. Asia/Shanghai; empty means UTC.
      - `type` string: Type is cron or once.
    - `updated_at` string
  - `success` boolean

## Other responses

- `400`: 参数不合法

## Changes

- **2026-10-19** `80c72611fac6`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/tencentblueking/apis/weknora-api/changes/automations/post.md)

---

[API](https://skmtc.dev/tencentblueking/apis/weknora-api.md) - [All operations](https://skmtc.dev/tencentblueking/apis/weknora-api/llms.txt) - [OpenAPI document](https://skmtc.dev/tencentblueking/apis/weknora-api/revisions/685d1f9fce30?raw)
