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

# Exchange code for token

> At the end of a Sequin-managed OAuth flow, Sequin redirects the user back to your app with a code. You can use that code to retrieve their credentials from this endpoint.

<ParamField body="code" type="string" required>
  The code you received at the end of the OAuth flow.
</ParamField>

<ParamField body="client_id" type="string" required>
  The **Sequin ID** of the OAuth app you want to use for this connection. You can find this ID in the Sequin console.

  Note that this is *not* the `client_id` corresponding to the OAuth app.
</ParamField>

<ParamField body="client_secret" type="string" required>
  The `client_secret` corresponding to the OAuth app you want to use for this connection. This is the `client_secret` the API provider gave you when you registered your OAuth app.
</ParamField>

<RequestExample>
  ```shell cURL theme={null}
  curl --request POST \
    --url https://api.sequin.io/link/oauth2/token \
    --header 'Content-Type: application/json' \
    --data '{
      "code": "BTNsQNebVfaVDUwme85dAO9PgUcvxvXkEAY",
      "client_id": "8ff58ef0-d376-4ae8-b2e2-9f0206aa65b8",
      "client_secret": "12345678901234567890123456789012"
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json 200 OK theme={null}
  {
    "credential": {
      "oauth_app_id": "8ff58ef0-d376-4ae8-b2e2-9f0206aa65b8",
      "properties": {
        "kind": "linear_oauth2",
        "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
        "scope": "read write issues:create",
        "linear_org_id": "abc123",
        "linear_org_name": "Arrakis Inc."
      }
    },
    "state": "ZTA5N2UxYzctMDRjZi00OTQwLThkODUtMTY0MTNhMTU4YmE4"
  }
  ```
</ResponseExample>

<ResponseField name="credential" type="object">
  The user's credentials. You can pass this full object directly to the [create credential](/management-api/credentials/create) endpoint or the [create sync](/management-api/syncs/create) endpoint.

  See [credential properties](/management-api/objects#credential-properties) for a list of possible properties for each provider.
</ResponseField>

<ResponseField name="state" type="string">
  The state you passed Sequin at the start of the flow.
</ResponseField>
