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

# Create an approval

> Sends a question to the people assigned to the agent. Returns right away; the answer arrives later on
`GET /v1/approvals/{requestId}/result` or on your `callback.url`.

Send the same `request_id` again to retry safely: an identical body returns the existing approval with
`idempotent: true`, and a different body returns `409`.




## OpenAPI

````yaml /api-reference/agent-api-openapi.yaml post /v1/approvals
openapi: 3.0.3
info:
  title: FinalSay Agent API
  description: >
    Ask a person before your agent acts. Create an approval, then poll for the
    result or receive it on a callback URL.


    Approval endpoints need two headers: `X-Agent-Id` (the agent's UUID) and
    `X-Api-Key` (a workspace API key).

    `GET /v1/agents` needs only `X-Api-Key`.
  version: 1.0.0
servers:
  - url: https://api.finalsay-hitl.com
security:
  - AgentId: []
    ApiKey: []
tags:
  - name: Approvals
    description: Create approvals and read their outcome
  - name: Agents
    description: List the agents a workspace API key can act as
paths:
  /v1/approvals:
    post:
      tags:
        - Approvals
      summary: Create an approval
      description: >
        Sends a question to the people assigned to the agent. Returns right
        away; the answer arrives later on

        `GET /v1/approvals/{requestId}/result` or on your `callback.url`.


        Send the same `request_id` again to retry safely: an identical body
        returns the existing approval with

        `idempotent: true`, and a different body returns `409`.
      operationId: createApproval
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateApprovalRequest'
            examples:
              minimal:
                summary: Minimal body (timeout from the agent's defaults)
                value:
                  question: Deploy v2.4 to production?
                  context_markdown: >-
                    **Change:** 12 commits since v2.3. Tests passed. Rollback:
                    redeploy v2.3.
                  options:
                    - label: Approve
                      value: approve
                    - label: Reject
                      value: reject
              full:
                summary: Retry-safe id, callback and a timeout override
                value:
                  request_id: deploy-v2.4-prod
                  correlation_id: run-8812
                  question: Deploy v2.4 to production?
                  context_markdown: >-
                    **Change:** 12 commits since v2.3. Tests passed. Rollback:
                    redeploy v2.3.
                  notification_summary: Deploy v2.4?
                  options:
                    - label: Approve
                      value: approve
                    - label: Reject
                      value: reject
                  timeout:
                    expires_in_seconds: 1800
                    mode: expire_with_predefined_instruction
                    predefined_instruction: Nobody answered. Do not deploy.
                  callback:
                    url: https://example.com/hooks/finalsay
      responses:
        '200':
          description: Created, or an idempotent match for a `request_id` you already used
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateApprovalResponse'
        '400':
          description: The body failed validation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorInvalidPayload'
        '401':
          description: Missing or invalid agent authentication
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorAgentAuth'
        '403':
          description: The workspace has used its plan's approvals for this period
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorUsageLimit'
        '409':
          description: This `request_id` was already used with a different body
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorIdempotencyConflict'
        '429':
          description: Too many create attempts for this agent in the last minute
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorRateLimited'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                type: object
                required:
                  - error
                properties:
                  error:
                    type: string
                    enum:
                      - approval_creation_failed
components:
  schemas:
    CreateApprovalRequest:
      type: object
      required:
        - question
        - context_markdown
        - options
      properties:
        question:
          type: string
          minLength: 1
          maxLength: 500
          description: One decision, phrased so a person can answer it from a lock screen.
        context_markdown:
          type: string
          minLength: 1
          maxLength: 2500
          description: >-
            Markdown shown under the question: what will happen, why, and how to
            undo it. `<script>` blocks and `javascript:` are removed.
        options:
          type: array
          minItems: 1
          maxItems: 4
          items:
            $ref: '#/components/schemas/Option'
        notification_summary:
          type: string
          maxLength: 120
          description: Push notification text. HTML tags are removed.
        request_id:
          type: string
          nullable: true
          maxLength: 120
          description: >-
            Your id for this approval and its idempotency key, unique per agent.
            Trimmed; omit it, or send null or blank, and the server generates a
            UUID. Reusing it with the same body returns the existing approval;
            with a different body, `409`.
        correlation_id:
          type: string
          nullable: true
          maxLength: 120
          description: >-
            Your id for the run, ticket or execution this approval belongs to.
            Not unique: many approvals can share one. Trimmed; null or blank
            means none. Returned in the result. Not part of the idempotency
            comparison: a retry with the same `request_id` and body but another
            `correlation_id` returns the existing approval, which keeps its
            original `correlation_id`.
        timeout:
          type: object
          description: >-
            Optional. Each field you send overrides only that part of the
            agent's defaults (new agents: 600 seconds, `expire_no_action`).
          properties:
            expires_in_seconds:
              type: integer
              minimum: 30
              maximum: 86400
            mode:
              type: string
              enum:
                - expire_no_action
                - expire_with_predefined_instruction
              description: >-
                `expire_with_predefined_instruction` returns
                `predefined_instruction` as `custom_instruction` when nobody
                answers. It needs a non-blank instruction after merging with the
                agent's defaults.
            predefined_instruction:
              type: string
              nullable: true
              maxLength: 1000
              description: >-
                Sending `null` clears the agent's default fallback for this
                approval.
        callback:
          type: object
          required:
            - url
          description: >-
            Where to POST the result when the approval leaves `pending`. Use
            HTTPS. Add a secret header with the agent's Callback security tab,
            not here.
          properties:
            url:
              type: string
              format: uri
            headers:
              type: object
              description: Extra non-secret headers, such as a trace id.
              additionalProperties:
                type: string
    CreateApprovalResponse:
      type: object
      required:
        - approval_id
        - request_id
        - status
        - expires_at
        - idempotent
      properties:
        approval_id:
          type: string
          format: uuid
          description: FinalSay's internal id. Poll with `request_id`, not this.
        request_id:
          type: string
          description: Your `request_id`, or the UUID the server generated.
        status:
          $ref: '#/components/schemas/ApprovalStatus'
        expires_at:
          type: string
          format: date-time
        idempotent:
          type: boolean
          description: >-
            `true` when this call matched an approval you already created with
            the same `request_id`. `status` and `expires_at` are then the
            existing approval's, so `status` may already be resolved.
    ErrorInvalidPayload:
      type: object
      required:
        - error
      properties:
        error:
          type: string
          enum:
            - invalid_payload
        issues:
          type: object
          description: Validation issues as `{ formErrors, fieldErrors }`.
    ErrorAgentAuth:
      type: object
      required:
        - error
      properties:
        error:
          type: string
          enum:
            - missing_agent_auth
            - invalid_agent
            - invalid_api_key
    ErrorUsageLimit:
      type: object
      required:
        - error
        - code
        - over_limit
      properties:
        error:
          type: string
          enum:
            - USAGE_APPROVAL_LIMIT
        code:
          type: string
          enum:
            - USAGE_APPROVAL_LIMIT
        over_limit:
          type: boolean
          enum:
            - true
    ErrorIdempotencyConflict:
      type: object
      required:
        - error
        - message
        - request_id
        - existing_approval_id
      properties:
        error:
          type: string
          enum:
            - idempotency_conflict
        message:
          type: string
        request_id:
          type: string
        existing_approval_id:
          type: string
          format: uuid
    ErrorRateLimited:
      type: object
      required:
        - error
      properties:
        error:
          type: string
          enum:
            - rate_limited
    Option:
      type: object
      required:
        - label
        - value
      properties:
        label:
          type: string
          minLength: 1
          maxLength: 120
          description: What the reviewer sees on the button.
        value:
          type: string
          minLength: 1
          maxLength: 500
          description: What your code gets back as `selected_option_value`.
    ApprovalStatus:
      type: string
      enum:
        - pending
        - selected_option
        - custom_instruction
        - expired
      description: >-
        `pending`: waiting. `selected_option`: someone picked an option.
        `custom_instruction`: someone wrote an answer. `expired`: nobody
        answered in time.
  securitySchemes:
    AgentId:
      type: apiKey
      in: header
      name: X-Agent-Id
      description: >-
        The agent's UUID, from the agent's page in the web dashboard or `GET
        /v1/agents`.
    ApiKey:
      type: apiKey
      in: header
      name: X-Api-Key
      description: >-
        A workspace API key (starts with `hitl_`). Shown once when an owner or
        admin creates it.

````

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