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

# Upsert Default-App Credential

> Add or update a single auth credential on the org's default app.

Add or update a single `{key_name, key_value}` auth credential on the linked account's default-app integration. The value is encrypted before storage. The default-app integration must already exist on the account (it can be seeded when you [create the linked account](/legacy/api-reference/linked-accounts/create-linked-account) via `your_app.auth_credentials`).

## Authentication

This endpoint accepts **either** authentication method.

**Option 1 — API key**

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

<ParamField header="linked_account_id" type="string">
  The linked account to operate on. May also be passed as a query parameter.
</ParamField>

**Option 2 — Session token**

<ParamField header="Authorization" type="string">
  Session token for the linked account (the account is taken from the token).

  **Format:** `Bearer YOUR_SESSION_TOKEN`
</ParamField>

## Path Parameters

<ParamField path="key" type="string" required>
  The credential key name to add or update.

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

## Body Parameters

<ParamField body="value" type="string" required>
  The credential value. Coerced to a string and encrypted before storage.
</ParamField>

## Response

<Tabs>
  <Tab title="200 OK">
    <ResponseField name="success" type="boolean">Whether the operation succeeded.</ResponseField>
    <ResponseField name="message" type="string">Confirmation message.</ResponseField>
    <ResponseField name="action" type="string">`added` or `updated`.</ResponseField>
  </Tab>

  <Tab title="404 Not Found">
    Returned when the linked account has no default-app integration.
    <ResponseField name="status_code" type="integer">HTTP status code.</ResponseField>
    <ResponseField name="http_error_type" type="string">Error category, e.g. `NOT_FOUND`.</ResponseField>
    <ResponseField name="error" type="string">Internal error code, e.g. `RESOURCE_NOT_FOUND`.</ResponseField>
    <ResponseField name="message" type="string">Human-readable error description.</ResponseField>
  </Tab>
</Tabs>

<ResponseExample>
  ```json 200 theme={null}
  {
    "success": true,
    "message": "Auth credential 'api_key' added successfully",
    "action": "added"
  }
  ```

  ```json 404 theme={null}
  {
    "status_code": 404,
    "http_error_type": "NOT_FOUND",
    "error": "RESOURCE_NOT_FOUND",
    "message": "Default app integration not found for linked account user_12345"
  }
  ```
</ResponseExample>

<RequestExample>
  ```bash cURL (API key) theme={null}
  curl -X PUT "https://app.refold.ai/api/v2/public/linked-account/default-app/auth-credentials/{key}" \
    -H "x-api-key: YOUR_API_KEY" \
    -H "linked_account_id: YOUR_LINKED_ACCOUNT_ID" \
    -H "Content-Type: application/json" \
    -d '{ "value": "YOUR_CREDENTIAL_VALUE" }'
  ```

  ```bash cURL (session token) theme={null}
  curl -X PUT "https://app.refold.ai/api/v2/public/linked-account/default-app/auth-credentials/{key}" \
    -H "Authorization: Bearer YOUR_SESSION_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{ "value": "YOUR_CREDENTIAL_VALUE" }'
  ```
</RequestExample>
