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

# Migrate Token

> Migrate an existing auth object onto a linked account's integration.

Import an existing auth object onto a linked account's integration. The `auth_object` is validated against the named app's auth schema, each value is encrypted, and the integration is created (or updated if it already exists) on the linked account identified by the `linked_account_id` header.

Use this to bring credentials you already hold (e.g. migrating from another system) into Refold without sending the user through a connect flow.

<Note>
  Custom apps are not supported by this endpoint. Many native apps **verify the credentials against the provider** before storing them.
</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 attach the integration to.
</ParamField>

## Body Parameters

<ParamField body="slug" type="string" required>
  The app slug being migrated.

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

<ParamField body="auth_object" type="object" required>
  An object with exactly one top-level key naming the auth type (`oauth2`, `keybased`, …). Its value is an object whose fields match the app's auth-type schema.
</ParamField>

## Response

<Tabs>
  <Tab title="200 OK">
    <ResponseField name="success" type="boolean">Whether the migration succeeded.</ResponseField>
    <ResponseField name="message" type="string">Confirmation message.</ResponseField>
  </Tab>

  <Tab title="200 Validation Error">
    On certain validation failures the service returns an `error` field with an HTTP 200 status.
    <ResponseField name="error" type="string">Validation failure detail (e.g. unsupported app).</ResponseField>
  </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.</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,
    "message": "Token migrated successfully"
  }
  ```

  ```json 200 Validation Error theme={null}
  {
    "error": "Custom apps are not supported for this endpoint."
  }
  ```

  ```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 (OAuth) theme={null}
  curl -X PUT "https://app.refold.ai/api/v2/public/migrate-token" \
    -H "x-api-key: YOUR_API_KEY" \
    -H "linked_account_id: YOUR_LINKED_ACCOUNT_ID" \
    -H "Content-Type: application/json" \
    -d '{
      "slug": "hubspot",
      "auth_object": {
        "oauth2": { "access_token": "YOUR_ACCESS_TOKEN", "refresh_token": "YOUR_REFRESH_TOKEN" }
      }
    }'
  ```

  ```bash cURL (key-based) theme={null}
  curl -X PUT "https://app.refold.ai/api/v2/public/migrate-token" \
    -H "x-api-key: YOUR_API_KEY" \
    -H "linked_account_id: YOUR_LINKED_ACCOUNT_ID" \
    -H "Content-Type: application/json" \
    -d '{
      "slug": "netsuite",
      "auth_object": {
        "keybased": {
          "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>
