> ## Documentation Index
> Fetch the complete documentation index at: https://help.teable.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Save routine draft

> Stores edits without changing what runs. Scheduled runs keep using the published snapshot until the draft is published. A draft matching the published config is cleared instead of stored.

Required token scopes: `routine|update`



## OpenAPI

````yaml /swagger.json put /base/{baseId}/routine/{routineId}/draft
openapi: 3.0.0
info:
  version: 1.0.0
  title: Teable App
  description: Manage Data as easy as drink a cup of tea
  x-logo:
    backgroundColor: '#F0F0F0'
    altText: Teable logo
servers:
  - url: https://app.teable.ai/api
security: []
tags:
  - name: base
    x-group: project
  - name: base node
    x-group: project node
  - name: base-share
    x-group: project-share
paths:
  /base/{baseId}/routine/{routineId}/draft:
    put:
      tags:
        - routine
      summary: Save routine draft
      description: >-
        Stores edits without changing what runs. Scheduled runs keep using the
        published snapshot until the draft is published. A draft matching the
        published config is cleared instead of stored.


        Required token scopes: `routine|update`
      parameters:
        - schema:
            type: string
          required: true
          name: baseId
          in: path
        - schema:
            type: string
          required: true
          name: routineId
          in: path
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                config:
                  type: object
                  properties:
                    prompt:
                      type: string
                      minLength: 1
                    model:
                      type: string
                    effort:
                      type: string
                      enum:
                        - low
                        - medium
                        - high
                        - xhigh
                    trigger:
                      type: object
                      properties:
                        type:
                          type: string
                          enum:
                            - schedule
                        rrule:
                          type: string
                          minLength: 1
                          description: >-
                            RFC 5545 RRULE parts, e.g.
                            'FREQ=DAILY;BYHOUR=9;BYMINUTE=0'
                        timezone:
                          type: string
                          description: IANA timezone, e.g. Asia/Shanghai
                        starting:
                          type: string
                          format: date-time
                          description: >-
                            No runs before this moment; the DTSTART anchor for
                            COUNT / INTERVAL
                        ending:
                          type: string
                          format: date-time
                      required:
                        - type
                        - rrule
                        - timezone
                        - starting
                    maxRunMinutes:
                      type: integer
                      minimum: 5
                      maximum: 120
                      description: >-
                        Wall-clock limit for one run in minutes; a run past it
                        is aborted and marked failed(timeout). Default 30.
                    chatMode:
                      type: string
                      enum:
                        - new
                        - continue
                      description: >-
                        Where each run's conversation goes: 'new' (default)
                        opens a fresh chat per run; 'continue' sends the run
                        into the previous run's chat, so the agent sees what it
                        did last time.
                  required:
                    - prompt
                    - trigger
              required:
                - config
      responses:
        '200':
          description: Draft saved
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                  baseId:
                    type: string
                  name:
                    type: string
                  status:
                    type: string
                    enum:
                      - draft
                      - active
                      - inactive
                  currentSnapshotId:
                    type: string
                    nullable: true
                  config:
                    type: object
                    nullable: true
                    properties:
                      prompt:
                        type: string
                        minLength: 1
                      model:
                        type: string
                      effort:
                        type: string
                        enum:
                          - low
                          - medium
                          - high
                          - xhigh
                      trigger:
                        type: object
                        properties:
                          type:
                            type: string
                            enum:
                              - schedule
                          rrule:
                            type: string
                            minLength: 1
                            description: >-
                              RFC 5545 RRULE parts, e.g.
                              'FREQ=DAILY;BYHOUR=9;BYMINUTE=0'
                          timezone:
                            type: string
                            description: IANA timezone, e.g. Asia/Shanghai
                          starting:
                            type: string
                            format: date-time
                            description: >-
                              No runs before this moment; the DTSTART anchor for
                              COUNT / INTERVAL
                          ending:
                            type: string
                            format: date-time
                        required:
                          - type
                          - rrule
                          - timezone
                          - starting
                      maxRunMinutes:
                        type: integer
                        minimum: 5
                        maximum: 120
                        description: >-
                          Wall-clock limit for one run in minutes; a run past it
                          is aborted and marked failed(timeout). Default 30.
                      chatMode:
                        type: string
                        enum:
                          - new
                          - continue
                        description: >-
                          Where each run's conversation goes: 'new' (default)
                          opens a fresh chat per run; 'continue' sends the run
                          into the previous run's chat, so the agent sees what
                          it did last time.
                    required:
                      - prompt
                      - trigger
                  hasDraft:
                    type: boolean
                  createdBy:
                    type: string
                  createdTime:
                    type: string
                  lastModifiedBy:
                    type: string
                    nullable: true
                  lastModifiedTime:
                    type: string
                    nullable: true
                  nextRunAt:
                    type: string
                    nullable: true
                  alertContact:
                    type: object
                    nullable: true
                    properties:
                      id:
                        type: string
                      name:
                        type: string
                      email:
                        type: string
                        nullable: true
                      avatar:
                        type: string
                        nullable: true
                    required:
                      - id
                      - name
                required:
                  - id
                  - baseId
                  - name
                  - status
                  - currentSnapshotId
                  - config
                  - hasDraft
                  - createdBy
                  - createdTime
      security:
        - bearerAuth: []
      x-codeSamples:
        - lang: Shell
          source: |-
            curl --request PUT \
              --url https://app.teable.ai/api/base/%7BbaseId%7D/routine/%7BroutineId%7D/draft \
              --header 'Authorization: Bearer REPLACE_BEARER_TOKEN' \
              --header 'content-type: application/json' \
              --data '{"config":{"prompt":"string","model":"string","effort":"low","trigger":{"type":"schedule","rrule":"string","timezone":"string","starting":"2019-08-24T14:15:22Z","ending":"2019-08-24T14:15:22Z"},"maxRunMinutes":5,"chatMode":"new"}}'
        - lang: JavaScript
          source: >-
            const url =
            'https://app.teable.ai/api/base/%7BbaseId%7D/routine/%7BroutineId%7D/draft';

            const options = {
              method: 'PUT',
              headers: {
                Authorization: 'Bearer REPLACE_BEARER_TOKEN',
                'content-type': 'application/json'
              },
              body: '{"config":{"prompt":"string","model":"string","effort":"low","trigger":{"type":"schedule","rrule":"string","timezone":"string","starting":"2019-08-24T14:15:22Z","ending":"2019-08-24T14:15:22Z"},"maxRunMinutes":5,"chatMode":"new"}}'
            };


            try {
              const response = await fetch(url, options);
              const data = await response.json();
              console.log(data);
            } catch (error) {
              console.error(error);
            }
        - lang: Node.js
          source: |-
            const http = require('https');

            const options = {
              method: 'PUT',
              hostname: 'app.teable.ai',
              port: null,
              path: '/api/base/%7BbaseId%7D/routine/%7BroutineId%7D/draft',
              headers: {
                Authorization: 'Bearer REPLACE_BEARER_TOKEN',
                'content-type': 'application/json'
              }
            };

            const req = http.request(options, function (res) {
              const chunks = [];

              res.on('data', function (chunk) {
                chunks.push(chunk);
              });

              res.on('end', function () {
                const body = Buffer.concat(chunks);
                console.log(body.toString());
              });
            });

            req.write(JSON.stringify({
              config: {
                prompt: 'string',
                model: 'string',
                effort: 'low',
                trigger: {
                  type: 'schedule',
                  rrule: 'string',
                  timezone: 'string',
                  starting: '2019-08-24T14:15:22Z',
                  ending: '2019-08-24T14:15:22Z'
                },
                maxRunMinutes: 5,
                chatMode: 'new'
              }
            }));
            req.end();
        - lang: Python
          source: >-
            import http.client


            conn = http.client.HTTPSConnection("app.teable.ai")


            payload =
            "{\"config\":{\"prompt\":\"string\",\"model\":\"string\",\"effort\":\"low\",\"trigger\":{\"type\":\"schedule\",\"rrule\":\"string\",\"timezone\":\"string\",\"starting\":\"2019-08-24T14:15:22Z\",\"ending\":\"2019-08-24T14:15:22Z\"},\"maxRunMinutes\":5,\"chatMode\":\"new\"}}"


            headers = {
                'Authorization': "Bearer REPLACE_BEARER_TOKEN",
                'content-type': "application/json"
            }


            conn.request("PUT",
            "/api/base/%7BbaseId%7D/routine/%7BroutineId%7D/draft", payload,
            headers)


            res = conn.getresponse()

            data = res.read()


            print(data.decode("utf-8"))
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````