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

# Start an action content draft

> Starts a content-draft run for the action with the same checks as Generate draft in the app: the Page Drafter for a create action, the Section Editor for a refresh action. A refusal carries its reason: 409 for not_content_action, read_only, brief_not_ready, brief_outdated (the brief predates the current brief format; regenerate it), no_target_page, page_locked, or draft_kind_changed (the action now takes the other kind than the draftKind sent); 403 for forbidden or unavailable (content drafts are off). 409 without a reason means a draft is already being written for this action, or the requestIdempotencyKey was already used for a different request. The API key must have been created by a member of the project with the manage permission. A retry with the same requestIdempotencyKey returns the run that key started as it stands, without rechecking the action, which may have changed since. A retry for another action, draftKind or modelId (an omitted modelId means the account default) is a 409. A dispatch that fails during the request returns 500 and starts no run. The run uses agent credits; a draft is never published by DevTune. This endpoint has a stricter rate limit than read endpoints.



## OpenAPI

````yaml /openapi.json post /projects/{projectId}/actions/{actionId}/draft
openapi: 3.1.0
info:
  title: DevTune API
  version: 2.0.0
  description: >-
    API for programmatic access to your AI visibility data, webhook
    subscriptions, and automation workflows. Use this API to integrate DevTune
    data into CI/CD pipelines, BI tools, AI agents, and operational systems.
servers:
  - url: https://devtune.ai/api/v2
    description: Production
security:
  - bearerAuth: []
paths:
  /projects/{projectId}/actions/{actionId}/draft:
    post:
      summary: Start an action content draft
      description: >-
        Starts a content-draft run for the action with the same checks as
        Generate draft in the app: the Page Drafter for a create action, the
        Section Editor for a refresh action. A refusal carries its reason: 409
        for not_content_action, read_only, brief_not_ready, brief_outdated (the
        brief predates the current brief format; regenerate it), no_target_page,
        page_locked, or draft_kind_changed (the action now takes the other kind
        than the draftKind sent); 403 for forbidden or unavailable (content
        drafts are off). 409 without a reason means a draft is already being
        written for this action, or the requestIdempotencyKey was already used
        for a different request. The API key must have been created by a member
        of the project with the manage permission. A retry with the same
        requestIdempotencyKey returns the run that key started as it stands,
        without rechecking the action, which may have changed since. A retry for
        another action, draftKind or modelId (an omitted modelId means the
        account default) is a 409. A dispatch that fails during the request
        returns 500 and starts no run. The run uses agent credits; a draft is
        never published by DevTune. This endpoint has a stricter rate limit than
        read endpoints.
      operationId: startActionContentDraft
      parameters:
        - name: projectId
          in: path
          required: true
          schema:
            type: string
            format: uuid
        - name: actionId
          in: path
          required: true
          description: UUID of the action.
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              properties:
                draftKind:
                  type: string
                  enum:
                    - page
                    - section_edits
                  description: >-
                    The draft the caller expects, from the draft read. When
                    sent, the start refuses with draft_kind_changed if the
                    action now takes the other kind.
                modelId:
                  type: string
                  minLength: 1
                  maxLength: 120
                  description: >-
                    A model id from the draft read; the default model when
                    absent.
                requestIdempotencyKey:
                  type: string
                  format: uuid
              required:
                - requestIdempotencyKey
      responses:
        '200':
          description: Started draft run
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/ContentDraftStartResult'
                  meta:
                    $ref: '#/components/schemas/Meta'
                required:
                  - data
                  - meta
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '402':
          description: Insufficient included or purchased credits
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '409':
          $ref: '#/components/responses/ConflictError'
        '429':
          $ref: '#/components/responses/RateLimitExceededError'
        '500':
          $ref: '#/components/responses/ServerError'
components:
  schemas:
    ContentDraftStartResult:
      type: object
      properties:
        runId:
          type: string
          format: uuid
          description: >-
            The draft run. Read its state from GET
            /projects/{projectId}/agents/runs/{runId}.
        status:
          type: string
          enum:
            - queued
            - failed
          description: >-
            queued for a run that is queued, running or finished, including a
            replay of an earlier requestIdempotencyKey. failed only when this
            requestIdempotencyKey was already used for a run that has since
            failed or been canceled; that run is returned as it ended. A
            dispatch that fails during this request returns 500 and starts no
            run.
      required:
        - runId
        - status
    Meta:
      type: object
      properties:
        timestamp:
          type: string
          format: date-time
        projectId:
          type: string
          format: uuid
    Error:
      type: object
      properties:
        error:
          type: string
        message:
          type: string
        reason:
          type: string
          description: >-
            Why the request was refused, for an error with more than one cause,
            such as a refused content-draft start.
        status:
          type: integer
      required:
        - error
        - message
        - status
  responses:
    BadRequestError:
      description: Bad request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    UnauthorizedError:
      description: Unauthorized
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    ForbiddenError:
      description: Forbidden
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFoundError:
      description: Not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    ConflictError:
      description: Request conflicts with current resource state
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    RateLimitExceededError:
      description: Rate limit exceeded
      headers:
        X-RateLimit-Limit:
          $ref: '#/components/headers/X-RateLimit-Limit'
        X-RateLimit-Remaining:
          $ref: '#/components/headers/X-RateLimit-Remaining'
        X-RateLimit-Reset:
          $ref: '#/components/headers/X-RateLimit-Reset'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    ServerError:
      description: Internal server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  headers:
    X-RateLimit-Limit:
      description: Maximum requests per window
      schema:
        type: integer
    X-RateLimit-Remaining:
      description: Requests remaining in current window
      schema:
        type: integer
    X-RateLimit-Reset:
      description: Unix timestamp when the window resets
      schema:
        type: integer
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        API key with dtk_live_ prefix. Obtain it from API Keys in the account
        sidebar. New keys start with all supported scopes selected for the
        chosen project, and you can narrow them to specific read/write scopes as
        needed.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.