> ## Documentation Index
> Fetch the complete documentation index at: https://cobalt-55-abhishek.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Get or Create Config

> Get or create an application config for a linked account.

Get or create the config (app installation) for an app on a linked account. If a config already exists it is returned; otherwise a new one is created. The `config_id` defaults to the linked account ID.

**Only `slug` is required.** With just a slug, this installs the config's field and workflow *skeleton* (the app's definitions, with default values) — it does not need any field values up front. You can optionally seed `workflows` (enable/disable) and `labels` in the body. Field **values** are normally set afterward via [Update Config Field Value](/v3/api-reference/config-fields/update-field-value), which is the reliable way to populate them.

<Note>
  **Multiple configs per account.** Omit `config_id` to manage the single default config (its ID is the linked account ID). Pass a custom `config_id` (e.g. `production`, `staging`) to create and manage **additional named configs** for the same linked account and app. Each is retrieved with [Get Config by ID](/v3/api-reference/configs/get-config) and all are returned by [List Config IDs](/v3/api-reference/configs/list-configs).
</Note>

## Authentication

Configs are scoped to a linked account via the `linked_account_id` header.

<ParamField header="x-api-key" type="string" required>
  Your Refold API key. Find it in **Settings → Credentials**.
</ParamField>

<ParamField header="linked_account_id" type="string" required>
  The linked account to install the config for.
</ParamField>

## Body Parameters

<ParamField body="slug" type="string" required>The app slug to install. This is the only required field. **Example:** `hubspot`</ParamField>

<ParamField body="config_id" type="string">
  A custom ID to create/manage a distinct named config for this account+app (e.g. `production`). Omit it to use the single default config (ID = the linked account ID).
</ParamField>

<ParamField body="workflows" type="array">
  Workflows to enable or disable at install, each `{ "id": "...", "enabled": true }`.
</ParamField>

<ParamField body="labels" type="object">Arbitrary key/value labels for the config.</ParamField>

<ParamField body="fields" type="array">
  Optional initial field definitions, each `{ "id": "...", "value": ... }`. Field **values** are more reliably set after install via [Update Config Field Value](/v3/api-reference/config-fields/update-field-value).
</ParamField>

## Response

<Tabs>
  <Tab title="200 OK">
    <ResponseField name="slug" type="string">The app slug.</ResponseField>
    <ResponseField name="config_id" type="string">The config ID.</ResponseField>
    <ResponseField name="fields" type="array">Configurable fields (see [Get All Config Fields](/v3/api-reference/config-fields/get-all-fields)).</ResponseField>
    <ResponseField name="workflows" type="array">Workflows in the config, each `{id, name, description, enabled}`.</ResponseField>
    <ResponseField name="field_errors" type="array">Any datasource resolution errors.</ResponseField>
  </Tab>

  <Tab title="404 Not Found">
    Returned when the app slug is unknown.
    <ResponseField name="status_code" type="integer">HTTP status code.</ResponseField>
    <ResponseField name="http_error_type" type="string">Error category.</ResponseField>
    <ResponseField name="error_code" type="string">Internal error code.</ResponseField>
    <ResponseField name="message" type="string">Human-readable error description.</ResponseField>
  </Tab>
</Tabs>

<ResponseExample>
  ```json 200 theme={null}
  {
    "slug": "hubspot",
    "config_id": "user_12345",
    "field_errors": [],
    "fields": [
      { "id": "699fec7a5bd27ed2af7243ad", "name": "Select", "field_type": "select", "required": false }
    ],
    "workflows": [
      { "id": "699d8648a81ba363578cc2f4", "name": "Sync Contacts", "description": "Sync contacts to HubSpot", "enabled": true }
    ]
  }
  ```

  ```json 404 theme={null}
  {
    "status_code": 404,
    "http_error_type": "NOT_FOUND",
    "error_code": "INVALID_APP_ID",
    "message": "Application with app_type 'unknown' not found for org 6500a1b2c3d4e5f6a7b8c9d0"
  }
  ```
</ResponseExample>

<RequestExample>
  ```bash cURL (minimal) theme={null}
  curl -X POST "https://app.refold.ai/api/v2/public/config" \
    -H "x-api-key: YOUR_API_KEY" \
    -H "linked_account_id: YOUR_LINKED_ACCOUNT_ID" \
    -H "Content-Type: application/json" \
    -d '{ "slug": "{slug}" }'
  ```

  ```bash cURL (named config + workflows + labels) theme={null}
  curl -X POST "https://app.refold.ai/api/v2/public/config" \
    -H "x-api-key: YOUR_API_KEY" \
    -H "linked_account_id: YOUR_LINKED_ACCOUNT_ID" \
    -H "Content-Type: application/json" \
    -d '{
      "slug": "{slug}",
      "config_id": "production",
      "workflows": [ { "id": "YOUR_WORKFLOW_ID", "enabled": true } ],
      "labels": { "env": "production" }
    }'
  ```
</RequestExample>
