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

# Get Provider Options

> Resolve an imports options_source key into selectable value/label pairs

# Get Provider Options

Use this endpoint when an imports template column exposes `options_source` instead of inline `options`.

It resolves backend-managed provider keys such as `countries`, `logistics_tocs`, and `fuels`
into a simple list of selectable values:

* `value`: the canonical value the backend validates and stores
* `label`: the display label a client can show in dropdowns or selectors

<Note>
  This endpoint is especially useful for the Imports Mapping and Review steps, where a client needs to populate
  category dropdowns without hardcoding reference data.
</Note>

## Request

### Path Parameters

<ParamField path="source_key" type="string" required>
  Provider key declared by a template column's `options_source`.

  Supported keys are defined by the template metadata. Common examples include:

  * `countries`
  * `logistics_tocs`
  * `fuels`
</ParamField>

### Headers

<ParamField header="x-api-key" type="string" required>
  Your API key for authentication

  **Example:** `sk_live_1234567890abcdef`
</ParamField>

<ParamField header="x-organization-id" type="string" required>
  Your organization UUID

  **Example:** `a8315ef3-dd50-43f8-b7ce-d839e68d51fa`
</ParamField>

## Response

<ResponseField name="source_key" type="string">
  The provider key that was resolved.
</ResponseField>

<ResponseField name="options" type="array[object]">
  List of resolved option objects.

  <Expandable title="Option Object">
    <ResponseField name="value" type="string">
      Canonical backend value used for validation and corrections.
    </ResponseField>

    <ResponseField name="label" type="string">
      Human-readable display label for UI components.
    </ResponseField>
  </Expandable>
</ResponseField>

## Example

### Fetch country options

<CodeGroup>
  ```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
  curl -X GET "https://api.dcycle.io/v2/imports/options/countries" \
    -H "x-api-key: ${DCYCLE_API_KEY}" \
    -H "x-organization-id: ${DCYCLE_ORG_ID}"
  ```

  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  import os
  import requests

  response = requests.get(
      "https://api.dcycle.io/v2/imports/options/countries",
      headers={
          "x-api-key": os.environ["DCYCLE_API_KEY"],
          "x-organization-id": os.environ["DCYCLE_ORG_ID"],
      },
      timeout=30,
  )

  payload = response.json()
  for option in payload["options"][:5]:
      print(option["value"], option["label"])
  ```

  ```javascript JavaScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
  const axios = require('axios');

  axios.get('https://api.dcycle.io/v2/imports/options/countries', {
    headers: {
      'x-api-key': process.env.DCYCLE_API_KEY,
      'x-organization-id': process.env.DCYCLE_ORG_ID,
    },
  }).then((response) => {
    response.data.options.slice(0, 5).forEach((option) => {
      console.log(option.value, option.label);
    });
  });
  ```
</CodeGroup>

### Successful Response

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "source_key": "countries",
  "options": [
    {
      "value": "es",
      "label": "Spain"
    },
    {
      "value": "fr",
      "label": "France"
    },
    {
      "value": "pt",
      "label": "Portugal"
    }
  ]
}
```

## Typical Usage In The Imports Flow

1. Call `GET /v2/imports/templates/{template_id}`.
2. Inspect each column.
3. If a category column has inline `options`, render those directly.
4. If a category column has `options_source`, call `GET /v2/imports/options/{source_key}`.
5. Render the returned `value` / `label` pairs in the UI.

For example:

* `country` may use `options_source="countries"`
* `fuel` may use `options_source="fuels"` for canonical logistics recharge fuel names
* `toc` may use `options_source="logistics_tocs"`

## Common Errors

### 401 Unauthorized

**Cause:** Missing or invalid API key

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{"detail": "Invalid API key for organization", "code": "INVALID_API_KEY"}
```

### 403 Forbidden

**Cause:** The authenticated user is not a member of the organization

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{"detail": "Logged User is not Member of Organization", "code": "LOGGED_USER_NOT_MEMBER"}
```

### 404 Not Found

**Cause:** Unknown `source_key`

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "detail": "Options source 'unknown' not found",
  "code": "IMPORT_OPTIONS_SOURCE_NOT_FOUND"
}
```

**Solution:** Make sure the template actually uses that `options_source` key.

## Related Endpoints

<CardGroup cols={2}>
  <Card title="Get Template" icon="file-code" href="/api-reference/imports/get-template">
    Get the template that defines available options sources
  </Card>

  <Card title="Create Import Session" icon="plus" href="/api-reference/imports/create-session">
    Start a new import session
  </Card>

  <Card title="Suggest Mapping" icon="wand-magic-sparkles" href="/api-reference/imports/suggest-mapping">
    Auto-map columns using AI
  </Card>

  <Card title="Imports Overview" icon="book" href="/api-reference/imports/overview">
    Learn about the Imports API
  </Card>
</CardGroup>
