> ## 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.

# Get prefill choices

> Get prefill choices for an app's prefill.

If a need that comes back from the [Get Action Details](/ai-actions/how-tos/action-info/action-details) endpoint has a `prefill` key, then this endpoint can be used to get the choices for that prefill.

## Dependent needs

If a need has any values in its `depends_on` array, the values for each of the needs in `depends_on` *must* be included in the `params` in the body of the `POST` to get prefill choices.

As an example, the `action_needs` list for the `add_row` action for the `GoogleSheetsV2API` app from [Get action details and needs](/ai-actions/how-tos/action-info/action-details) includes a `spreadsheet` and a `worksheet` need:

```json theme={null}
{
  "action_needs": [
    {
      "key": "spreadsheet",
      "label": "Spreadsheet",
      "prefill": "spreadsheet.id.title",
      "depends_on": []
    },
    {
      "key": "worksheet",
      "label": "Worksheet",
      "prefill": "worksheet.id.title",
      "depends_on": ["spreadsheet"]
    }
  ]
}
```

This means that, in order to get the `worksheet.id.title` prefill choices, you need to include a `spreadsheet` value in the request to this endpoint:

```json theme={null}
{
  "params": { "spreadsheet": "SOME_SPREADHSEET_ID" }
}
```

`SOME_SPREADHSEET_ID` would have come from a call to get prefill choices for the `spreadsheet.id.title` value.

## Caching

By default, responses from this endpoint for a given `app`, `prefill`, `params`, and user will be cached for 24 hours.

When this endpoint is first hit, a background job is started that will paginate through all of the available choices.

While this background job is running, the results from this endpoint will return with `"is_loading": true`.

If `is_loading` is `true`, then the endpoint should be polled every \~1 second until `is_loading` is `false`, at which point all of the available results are returned.

The time that the cache was last updated is returned with `last_refresh_seconds_ago`.

To force a refresh of the cache, the `force_refresh` query parameter can be set to `true`.

<Warning>
  `force_refresh` should only be used when the choices are expected to have changed, and should only be used with a single request.

  Repeated reqeusts with `force_refresh` set to `true` will cause results to continuously load.
</Warning>


## OpenAPI

````yaml post /api/v2/apps/{app}/choices/{prefill}/
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/apps/{app}/choices/{prefill}/:
    post:
      tags:
        - actions
      summary: Get Prefill Choices
      description: Get prefill choices for an app's prefill.
      operationId: api_actions_get_prefill_choices
      parameters:
        - in: path
          name: app
          schema:
            description: The app that the prefill belongs to.
            title: App
            type: string
          required: true
          description: The app that the prefill belongs to.
        - in: path
          name: prefill
          schema:
            description: The prefill to get choices for.
            title: Prefill
            type: string
          required: true
          description: The prefill to get choices for.
        - in: query
          name: authentication_id
          schema:
            anyOf:
              - type: integer
              - type: 'null'
            description: >

              ID of the authentication to use for the app.


              Authentications available to the user can be listed using the
              [List Authentications For
              App](/docs/api-reference/actions/list-authentications-for-app)
              endpoint.
            title: Authentication Id
          required: false
          description: >

            ID of the authentication to use for the app.


            Authentications available to the user can be listed using the [List
            Authentications For
            App](/docs/api-reference/actions/list-authentications-for-app)
            endpoint.
        - in: query
          name: account_id
          schema:
            description: >

              The Zapier account ID to use.


              Account IDs available to the user can be listed using the [Get
              Account List](/docs/api-reference/meta/get-account-list) endpoint 
            title: Account Id
            type: integer
          required: false
          description: >

            The Zapier account ID to use.


            Account IDs available to the user can be listed using the [Get
            Account List](/docs/api-reference/meta/get-account-list) endpoint 
        - in: query
          name: query
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: Optional query to filter results by.
            title: Query
          required: false
          description: Optional query to filter results by.
        - in: query
          name: force_refresh
          schema:
            default: false
            description: >

              The list of prefill options for each user/app/prefill combo is
              cached for 24 hours.
                                              
              If `force_refresh` is set to `true`, the cache will be refreshed.
              This should only be used when the list of prefill options is known
              to have changed.
                                              
              Best practice is to offer a "Refresh" button to the user that sets
              this to `true` for one request.
            title: Force Refresh
            type: boolean
          required: false
          description: >

            The list of prefill options for each user/app/prefill combo is
            cached for 24 hours.
                                            
            If `force_refresh` is set to `true`, the cache will be refreshed.
            This should only be used when the list of prefill options is known
            to have changed.
                                            
            Best practice is to offer a "Refresh" button to the user that sets
            this to `true` for one request.
      requestBody:
        content:
          application/json:
            schema:
              allOf:
                - $ref: '#/components/schemas/ActionDetailsParamsSchema'
              default:
                params: {}
        required: false
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PrefillChoicesResultsSchema'
      security:
        - AccessPointApiKeyHeader: []
        - AccessPointOAuth: []
components:
  schemas:
    ActionDetailsParamsSchema:
      additionalProperties: true
      properties:
        params:
          description: >-
            A dictionary of key-value pairs, where the key is a `need` key and
            the value is a selected value for that need.
          title: Params
          type: object
      required:
        - params
      title: ActionDetailsParamsSchema
      type: object
    PrefillChoicesResultsSchema:
      additionalProperties: true
      properties:
        is_loading:
          description: >

            If this is `true`, then it means that the list of prefill options is
            still being loaded.
                                         
            While this is `true`, the endpoint should be polled (in general
            every second) until it returns `false`.
          title: Is Loading
          type: boolean
        last_refresh_seconds_ago:
          anyOf:
            - type: integer
            - type: 'null'
          description: >

            Seconds that have elapsed since the list of options for this prefill
            has been refreshed.
                                                             
            To refresh the list, use the `force_refresh` query parameter.
          title: Last Refresh Seconds Ago
        results:
          items:
            $ref: '#/components/schemas/ChoiceT'
          title: Results
          type: array
      required:
        - is_loading
        - last_refresh_seconds_ago
        - results
      title: PrefillChoicesResultsSchema
      type: object
    ChoiceT:
      properties:
        key:
          title: Key
          type: string
        label:
          title: Label
          type: string
        sample:
          title: Sample
          type: string
      title: ChoiceT
      type: object
  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

````