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

# Save Key Credentials

> Save key-based credentials for an app on a linked account.

Store key-based credentials for an app on a linked account. The app must support `keybased` auth. The request body is treated as opaque `auth_data` and forwarded to the app's save-credentials handler — the exact fields depend on the app's auth schema (see [Get Application](/v3/api-reference/applications/get-application) for an app's `auth_input_map`).

<Note>
  Many apps **verify the credentials against the provider** before storing them. Invalid credentials return a verification error rather than being saved.
</Note>

## Authentication

<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 store credentials on. May also be passed as a query parameter.
</ParamField>

## Path Parameters

<ParamField path="slug" type="string" required>
  The app slug. Must be an app that supports key-based auth.

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

## Query Parameters

<ParamField query="auth_type" type="string">
  Optional auth type when the app supports more than one.
</ParamField>

## Body Parameters

The body is the app-specific credential map. For example, NetSuite expects:

<ParamField body="account_id" type="string" required>Provider account ID.</ParamField>
<ParamField body="consumer_key" type="string" required>OAuth consumer key.</ParamField>
<ParamField body="consumer_secret" type="string" required>OAuth consumer secret.</ParamField>
<ParamField body="token_id" type="string" required>Token ID.</ParamField>
<ParamField body="token_secret" type="string" required>Token secret.</ParamField>

## Response

<Tabs>
  <Tab title="200 OK">
    Returns an app-specific success object confirming the credentials were saved.
  </Tab>

  <Tab title="500 Verification Failed">
    Returned when the provider rejects the supplied credentials.
    <ResponseField name="status_code" type="integer">HTTP status code.</ResponseField>
    <ResponseField name="http_error_type" type="string">Error category, e.g. `INTERNAL_SERVER_ERROR`.</ResponseField>
    <ResponseField name="error" type="string">Internal error code.</ResponseField>
    <ResponseField name="message" type="string">Verification failure detail.</ResponseField>
  </Tab>
</Tabs>

<ResponseExample>
  ```json 200 theme={null}
  {
    "success": true
  }
  ```

  ```json 500 Verification Failed theme={null}
  {
    "status_code": 500,
    "http_error_type": "INTERNAL_SERVER_ERROR",
    "error": "SERVER_ERROR",
    "message": "Failed to verify credentials: getaddrinfo ENOTFOUND your-account.suitetalk.api.netsuite.com"
  }
  ```
</ResponseExample>

<RequestExample>
  ```bash cURL theme={null}
  curl -X PUT "https://app.refold.ai/api/v2/public/linked-account/integration/save-key-credentials/{slug}" \
    -H "x-api-key: YOUR_API_KEY" \
    -H "linked_account_id: YOUR_LINKED_ACCOUNT_ID" \
    -H "Content-Type: application/json" \
    -d '{
      "account_id": "YOUR_ACCOUNT_ID",
      "consumer_key": "YOUR_CONSUMER_KEY",
      "consumer_secret": "YOUR_CONSUMER_SECRET",
      "token_id": "YOUR_TOKEN_ID",
      "token_secret": "YOUR_TOKEN_SECRET"
    }'
  ```
</RequestExample>
