# Resolve Universal Lookup

Resolve choices for one action argument, such as finding Slack channels before sending a message. End-user lookups use Cirra, Hybrid, or temporarily unclassified legacy NULL connections. Needs the universal:read permission. limit accepts 1 to 200 and defaults to 50. Parent delegation cannot use Embedded connections, including by connectionId alone.

`GET https://connect.mindcloud.co/v2/universal/apps/:appSlug/actions/:actionSlug/lookups/:argumentKey`

Permissions: `universal:read`.

## Parameters

### Path

- `appSlug` (string, required): The app, by its slug or its id, from List Universal Apps.
- `actionSlug` (string, required): The action, by its slug or its id, from List Universal Actions.
- `argumentKey` (string, required): The argument key whose choices you need.

### Headers

- `X-Company-Id` (string): Optional. The id of the organization to act in. Leave it out to act in the API key's own organization. A key can also act in its child organizations, and, with "Use this key across all of your organizations" on, in every organization its creator can open in the app. List them with GET /v2/companies. Every response's X-Company-Id header names the organization it acted in. See [Organizations](https://mindcloud.co/docs/api/rest/introduction/organizations).

### Query

- `version` (string): The published app version. Defaults to latest.
  The app version to inspect. Defaults to latest.
  Default: `latest`
- `q` (string): Search the lookup choices.
  Search text to resolve, for example a channel, user, customer, or project name.
- `connectionId` (string): An exact public connection ID. With endUserId, select one account when several are usable.
  The public MindCloud connection ID to use when the lookup source requires authentication.
- `endUserId` (string): Use only accounts owned by this embedded end user. The API key company must own the end user.
  Use only connections owned by this embedded end user. The API key company must own the end user.

## Example request

```bash
curl --request GET \
  --url 'https://connect.mindcloud.co/v2/universal/apps/slack/actions/send-channel-message/lookups/channel?version=latest&q=support&connectionId=eQfDE3Jk1GT7&endUserId=enduser_GhSUEYhipn4g' \
  --header 'Authorization: Bearer $MINDCLOUD_API_TOKEN'
```

## Response fields

- `status` (string): Whether the lookup resolved or needs more input: resolved, ambiguous, or notFound.
  Allowed values:
    - `resolved`
    - `ambiguous`
    - `notFound`
- `reasonCode` (string): A stable reason code: EXACT_MATCH, STRONG_MATCH, MULTIPLE_HIGH_CONFIDENCE_CANDIDATES, INSUFFICIENT_CONFIDENCE, or NO_CANDIDATES.
- `selected` (object): The selected lookup option, when one exact match exists.
  - `value` (string): The canonical value to pass as the argument.
  - `label` (string): What the option is called.
- `candidates` (array of objects): Matching options the caller can choose from.
  - `value` (string): The canonical value to pass as the argument.
  - `label` (string): What the option is called.
- `source` (string): Where the choices came from: fixedOptions (the argument's own list) or lookupAction (a provider read).
  Allowed values:
    - `fixedOptions`
    - `lookupAction`
- `lookup` (object): The lookup definition for this argument.
  - `labelKey` (string): The source field shown as the option label.
  - `valueKey` (string): The source field passed as the argument value.
  - `actionId` (string): The action that lists the options, or null for fixed options.
- `paging` (object): Offset paging details for the candidates.
  - `limit` (number): The limit the source was asked for.
  - `offset` (number): The offset the source was asked for.
  - `fetchedCandidatesCount` (number): How many options the source answered.
- `hints` (array of objects): Instructions for the caller when more input is needed.
  - `code` (string): NO_CANDIDATES, or the reasonCode that needs a choice.
  - `message` (string): What to do next.

## Example response

```json
{
  "success": true,
  "data": {
    "status": "ambiguous",
    "reasonCode": "MULTIPLE_HIGH_CONFIDENCE_CANDIDATES",
    "candidates": [
      {
        "value": "C04SUPPORT",
        "label": "support"
      },
      {
        "value": "C04SUPPORTOPS",
        "label": "support-ops"
      }
    ],
    "source": "lookupAction",
    "lookup": {
      "labelKey": "name",
      "valueKey": "id",
      "actionId": "list-channels"
    },
    "paging": {
      "limit": 50,
      "offset": 0,
      "fetchedCandidatesCount": 2
    },
    "hints": [
      {
        "code": "MULTIPLE_HIGH_CONFIDENCE_CANDIDATES",
        "message": "Multiple candidates matched. Select one explicit candidate value and retry."
      }
    ]
  }
}
```

## Errors

- 400 Bad request (INVALID_QUERY, CONNECTION_REQUIRED, NO_CONNECTION, UNIVERSAL_LOOKUP_UNSUPPORTED): `VALIDATION_FAILED` / `CONNECTION_REQUIRED` "Pass connectionId. List this app's connections with GET /v2/connections?appId=slack and pass the id of the one to use."
- 404 Not found (CONNECTION_NOT_FOUND, UNIVERSAL_ACTION_NOT_FOUND, UNIVERSAL_LOOKUP_ARGUMENT_NOT_FOUND, UNIVERSAL_LOOKUP_SOURCE_NOT_FOUND): `NOT_FOUND` / `CONNECTION_NOT_FOUND` "Connection "eQfDE3Jk1GT7" was not found for the authenticated company. List connections with GET /v2/connections."
- 409 Select an end-user account: `CONFLICT` / `CONNECTION_CHOICE_REQUIRED` "Select a connectionId for this end user and retry."
- 502 Provider error: `PROVIDER_ERROR` / `RUN_UNIVERSAL_LOOKUP_FAILED` "The Universal lookup action failed."
