# Get a field’s options

**POST** `/api/pieces/{id}/actions/{actionId}/options/{propertyName}`

Returns the choices of a drop-down field whose values aren’t in the app’s schema.

Needs [an API token](https://docs.gorunner.io/api/authentication#scopes) with the **Read** permission for workflows (`workflow:read`).

## Parameters

### Path

- `id` · Required · string: The app’s id.
- `actionId` · Required · string: The action the field belongs to. Triggers use this path too.
- `propertyName` · Required · string: The drop-down field.

### Body

Send at least `{}`: no body at all is a 400, except for the two fields the API answers itself.

- `values` · Optional · object: The step’s settings so far. Choices often depend on an earlier field.
- `connectionId` · Optional · UUID: A connection the app may sign in with. Sending one also needs the **Write** permission for workflows and the **Read** permission for connections.
- `searchQuery` · Optional · string: Words to filter by, for fields that search on the service.

## Which fields

The ones [Get an action’s fields](https://docs.gorunner.io/api/apps/get-app-action) lists in `dynamicFields`. A trigger’s drop-down is fetched through this same actions path.

Two are answered by the API itself, whatever `actionId` says: the Sub-flow step’s `workflow_id` (the workspace’s workflows, callable ones first) and the error and finished triggers’ `watch_workflow` (“All workflows”, then each workflow). Others run on a worker.

`disabled` is `true` when the app can’t offer choices yet, such as before an earlier field is set. `options` can be `null` too, with a `placeholder` saying what is missing, such as a connection.

## Responses

- 200 OK

  The choices. `value` goes in the step’s `config`; `label` is for people.

- 400 `INVALID_BODY`

  The body is missing or isn’t JSON.

- 400 `NOT_SUPPORTED`

  This app has no drop-downs of this kind.

- 403 `FORBIDDEN`

  The token lacks the **Read** permission for workflows. With `connectionId`, it also needs the **Write** permission for workflows and the **Read** permission for connections, because the call uses that connection’s sign-in. `details.permission` names the one missing.

- 403 `PIECE_NOT_ALLOWED`

  This workspace may not use the app.

- 404 `NOT_FOUND`

  No worker has this app.

- 500 `RESOLVE_FAILED`

  The workspace’s workflows couldn’t be listed.

- 500 `INTERNAL_ERROR`

  The worker failed or answered something unreadable.

- 503 `WORKER_UNAVAILABLE`

  No worker is checked in, so the app couldn’t be asked. Workflows are unaffected.

- 503 `PIECES_UNAVAILABLE`

  GoRunner couldn’t check which apps this workspace may use. Try again.

Any call can also answer: [`401 UNAUTHORIZED`](https://docs.gorunner.io/errors#UNAUTHORIZED) · [`401 TOKEN_ENDED`](https://docs.gorunner.io/errors#TOKEN_ENDED) · [`403 TOKEN_SURFACE_OFF`](https://docs.gorunner.io/errors#TOKEN_SURFACE_OFF) · [`403 FEATURE_OFF`](https://docs.gorunner.io/errors#FEATURE_OFF) · [`403 EMBED_NOT_ALLOWED`](https://docs.gorunner.io/errors#EMBED_NOT_ALLOWED) · [`403 EMBED_NOT_AVAILABLE`](https://docs.gorunner.io/errors#EMBED_NOT_AVAILABLE) · [`403 ACCOUNT_SUSPENDED`](https://docs.gorunner.io/errors#ACCOUNT_SUSPENDED) · [`413 PAYLOAD_TOO_LARGE`](https://docs.gorunner.io/errors#PAYLOAD_TOO_LARGE) · [`415 INVALID_CONTENT_TYPE`](https://docs.gorunner.io/errors#INVALID_CONTENT_TYPE) · [`429 RATE_LIMITED`](https://docs.gorunner.io/errors#RATE_LIMITED) · [`503 BUSY`](https://docs.gorunner.io/errors#BUSY) · [`503 PAUSED`](https://docs.gorunner.io/errors#PAUSED) · [`503 SERVICE_UNAVAILABLE`](https://docs.gorunner.io/errors#SERVICE_UNAVAILABLE). See [Errors](https://docs.gorunner.io/api/errors#by-status).

Request

**curl**

```bash
GORUNNER="https://api.gorunner.io"
GORUNNER_TOKEN="grt_…"  # needs Read for workflows
APP_ID="subflow"
ACTION_ID="execute"
FIELD="workflow_id"

URL="$GORUNNER/api/pieces/$APP_ID/actions/"
URL="${URL}$ACTION_ID/options/$FIELD"
curl -X POST "$URL" \
  -H "Authorization: Bearer $GORUNNER_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "values": {}
  }'
```

**JavaScript**

```js
const GORUNNER = "https://api.gorunner.io";
const TOKEN = process.env.GORUNNER_TOKEN;
const APP_ID = process.env.APP_ID;
const ACTION_ID = process.env.ACTION_ID;
const FIELD = process.env.FIELD;

const res = await fetch(
  `${GORUNNER}/api/pieces/${APP_ID}/actions/` +
    `${ACTION_ID}/options/${FIELD}`,
  {
    method: "POST",
    headers: {
        Authorization: `Bearer ${TOKEN}`,
        "Content-Type": "application/json",
      },
    body: JSON.stringify({
        values: {},
      }),
  },
);
const { data } = await res.json();
```

**Python**

```python
import os, requests

GORUNNER = "https://api.gorunner.io"
TOKEN = os.environ["GORUNNER_TOKEN"]
APP_ID = os.environ["APP_ID"]
ACTION_ID = os.environ["ACTION_ID"]
FIELD = os.environ["FIELD"]

res = requests.post(
    f"{GORUNNER}/api/pieces/{APP_ID}/actions/"
    f"{ACTION_ID}/options/{FIELD}",
    headers={"Authorization": f"Bearer {TOKEN}"},
    json={
      "values": {},
    },
)
data = res.json()["data"]
```

Response · 200 OK

```json
{
  "data": {
    "options": [
      {
        "label": "Order intake — callable",
        "value": "3b1e5c2a-7d4f-4e8b-a1c6-5f2d9b0e7a31"
      },
      {
        "label": "Nightly report (Schedule trigger) — draft, not published",
        "value": "6e9a1c3f-8b2d-4a57-9e0c-3f7b5d1a8c42"
      }
    ],
    "placeholder": "Select a workflow"
  }
}
```

**Every field**

The configuration so far, the connection to use, and an optional search term. Send at least `{}`: no body at all is a 400 `INVALID_BODY` (the two workspace pickers do not read it).

### Body

- `values` · Optional · object: The step’s configuration so far. Options often depend on an earlier field (see the property’s `refreshers`).
- `connectionId` · Optional · UUID: Connection whose credentials the app should use when it must call the third party.
- `searchQuery` · Optional · string: Server-side filter term, honoured only by apps whose property declares `refreshOnSearch`.

### Response · 200 OK

- `data` · object: The legal values for a dynamic dropdown.
  - `options` · array of objects or null: The choices. `null` when the app has none to offer yet (no connection, an earlier field unset); `placeholder` then says what to do.
    - `label` · string: Display text only — never store this in a step’s config.
    - `value` · string: The value to write into the step’s `config` for this property.
  - `disabled` · boolean: True when the app could not offer choices (for example a prerequisite field is unset).
  - `placeholder` · string: Hint text, e.g. `Select a workflow`.

Related: [Get an action’s fields](https://docs.gorunner.io/api/apps/get-app-action) · [Get a field’s sub-fields](https://docs.gorunner.io/api/apps/resolve-dynamic-properties)

Source: https://docs.gorunner.io/api/apps/resolve-dynamic-options
