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

# Preview Stored AI Action



## OpenAPI

````yaml post /api/v2/ai-actions/{ai_action_id}/preview/
openapi: 3.1.0
info:
  title: Zapier AI Actions API V2
  version: 1.0.0
  description: ''
servers:
  - url: https://actions.zapier.com
security: []
paths:
  /api/v2/ai-actions/{ai_action_id}/preview/:
    post:
      tags:
        - execution
      summary: Preview Stored AI Action
      operationId: api_ai_actions_preview_ai_action
      parameters:
        - in: path
          name: ai_action_id
          schema:
            description: The ID of the action to execute.
            format: uuid
            title: Ai Action Id
            type: string
          required: true
          description: The ID of the action to execute.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ExecuteRequest'
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ExecuteResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '412':
          description: Precondition Failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: Unprocessable Entity
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - AccessPointApiKeyHeader: []
        - AccessPointOAuth: []
components:
  schemas:
    ExecuteRequest:
      additionalProperties: true
      description: Specifies information about how to run an AI Action
      properties:
        instructions:
          description: >-

            `instructions` should be plain English instructions about how to run
            the action


            For example, "Send a message with a joke about pirates delivering
            pizza to the #general Slack channel"
                    
          title: Instructions
          type: string
        params:
          additionalProperties:
            $ref: '#/components/schemas/ParamConstraint'
          description: >

            `params` can be used to give AI Actions specific values, or hints
            for how to guess values.


            Inside of the `params` object, each key should be the `key` of a
            specific need.


            Inside of the value for each need, you can set a `mode` and a
            `value`.



            #### `"mode": "locked"`


            A `mode` of `locked` means that when running the action, AI Actions
            will use the **exact** value provided inside of `value`.


            This is useful when the user has selected a specific value for a
            prefill, or has entered a specific value like a string.


            For example, if you know ahead of time the _exact ID_ of a Slack
            channel that you want to send a message to and you're using the
            `SlackAPI`'s `channel_message` action:


            ```json

            {
                "params": {
                    "channel": {
                        "mode": "locked",
                        "value": "CHANNEL_ID"
                    }
                }
            }

            ```


            #### `"mode": "guess"`


            When using a `mode` of `guess`, AI Actions will use the `value` to
            try and figure out what to use for the need.


            This is useful when you only have a text description of a need's
            value, but don't know its actual ID.


            For example, if you provide the following for the `SlackAPI` API's
            `channel_message` action:


            ```json

            {
                "params": {
                    "channel": {
                        "mode": "guess",
                        "value": "#general"
                    }
                }
            }

            ```


            Behind the scenes, when AI Actions runs the action it will look
            through all of the available fields for the `channel` prefill (the
            same list you would get from the [Get Prefill
            Choices](https://docs.zapier.com/ai-actions/how-tos/action-info/prefill-choices)
            endpoint) and choose the one that best semantically matches the
            `value` provided.


            #### `"mode": "choose_from"`


            When using a `mode` of `choose_from`, the `value` must be a list of
            values to choose from.


            The values must be an array of exact IDs from the [Get Prefill
            Choices](https://docs.zapier.com/ai-actions/how-tos/action-info/prefill-choices)
            endpoint.


            Using an array of values is useful if the user wants to choose from
            i.e. a list of Slack channels that they want to send a message to
            based on the instructions.


            For example,


            ```json

            {
                "params": {
                    "channel": {
                        "mode": "guess",
                        "value": ["CHANNEL_ID", "ANOTHER_CHANNEL_ID"]
                    }
                }
            }

            ```


            Behind the scenes, when AI Actions goes to run the action it will
            look up the label of the provided IDs and choose th one that makes
            the most sense based off of the provided instructions.
          title: Params
          type: object
      required:
        - instructions
      title: ExecuteRequest
      type: object
    ExecuteResponse:
      properties:
        execution_log_id:
          description: >

            ID of the execution log.
                                              
            This can be used with the [Rate Execution
            Log](/docs/api-reference/execution/rate-execution-log) endpoint to
            give feedback on the execution.


            We frequently monitor this feedback!
          title: Execution Log Id
          type: string
        action_used:
          description: The name of the action that was executed.
          title: Action Used
          type: string
        input_params:
          description: The parameters that were passed into the API.
          title: Input Params
          type: object
        resolved_params:
          anyOf:
            - type: object
            - type: 'null'
          description: >

            The resolved parameters for the action.


            If `preview_only` is `true`, this will be the parameters that the AI
            would have used to run the action if it were not a preview.

            If `preview_only` is `false`, these are the parameters that the AI
            used to run the action.
          title: Resolved Params
        results:
          anyOf:
            - items:
                type: object
              type: array
            - type: 'null'
          description: |-

            Results of the action after it ran.

            This will be an empty list if `preview_only` is `true`.
                    
          title: Results
        full_results:
          anyOf:
            - items:
                type: object
              type: array
            - type: 'null'
          description: >-
            DEPRECATED: Use `results` instead. This field is kept temporarily
            for compatibility.
          title: Full Results
        result_field_labels:
          anyOf:
            - type: object
            - type: 'null'
          description: Human readable labels for some of the keys in the result.
          title: Result Field Labels
        status:
          default: success
          description: |

            The status of the execution.

            - `success`: The action was executed successfully.
            - `error`: The action failed to execute, see `error` field.
            - `empty`: The action was not executed.
            - `preview`: The action was previewed.
          enum:
            - success
            - error
            - empty
            - preview
          title: Status
          type: string
        error:
          anyOf:
            - type: string
            - type: 'null'
          description: The error message if the execution failed.
          title: Error
      required:
        - execution_log_id
        - action_used
        - input_params
      title: ExecuteResponse
      type: object
    ErrorResponse:
      additionalProperties: true
      properties:
        error:
          description: Error message.
          title: Error
          type: string
      required:
        - error
      title: ErrorResponse
      type: object
    ParamConstraint:
      properties:
        mode:
          $ref: '#/components/schemas/ConstraintMode'
        value:
          anyOf:
            - type: string
            - items:
                type: string
              type: array
            - additionalProperties:
                type: string
              type: object
            - type: 'null'
          title: Value
      required:
        - mode
      title: ParamConstraint
      type: object
    ConstraintMode:
      enum:
        - locked
        - guess
        - choose_from
        - ignored
      title: ConstraintMode
      type: string
  securitySchemes:
    AccessPointApiKeyHeader:
      type: apiKey
      in: header
      name: x-api-key
    AccessPointOAuth:
      type: oauth2
      flows:
        authorizationCode:
          authorizationUrl: /oauth/authorize/
          tokenUrl: /oauth/token/
          scopes:
            nla:exposed_actions:execute: Run AI Actions
            openid: OpenID Connect scope

````