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

# Exchange OAuth authorization code

> Exchanges an OAuth authorization code for an access token using the authorization code flow. Returns the access token and associated session information.



## OpenAPI

````yaml /api-reference/management-expert.json post /v6/security/oauth/flow/exchange
openapi: 3.0.1
info:
  description: >-
    Advanced configuration endpoints for Extole platform experts: campaign
    controllers, typed actions and triggers, advanced component types and
    facets, source mapping, report post-handlers, pre-handlers, and other expert
    configuration surfaces not included in the standard Management API.


    These endpoints are for advanced use. Use them only when you know how the
    configuration they change works, because a wrong call can change how a live
    program behaves. For most configuration, use the Management API.


    ## Updating a resource


    `PUT` merges. A field you omit from the body is left at its stored value, so
    you do not need to read a resource and send it back whole in order to change
    one field. This is a deliberate departure from the HTTP convention that
    `PUT` replaces, and it holds across this API.


    Two qualifications, both visible on each operation's own request schema:


    - Some operations mark fields `required` in their request schema. Those must
    be sent on every request, whether or not you are changing them.

    - A field that holds a list or a map is replaced, not merged, when you
    supply it. Sending one entry of a collection stores that entry and drops the
    rest, so to change one member of a collection you must send the collection's
    other members alongside it.
  title: Management Expert API
  version: '1.0'
servers:
  - description: Production
    url: https://api.extole.io
security:
  - HEADER: []
  - QUERY: []
  - COOKIE: []
tags:
  - name: Authentication
  - name: Campaign Controllers
  - name: Campaign Controllers Actions
  - name: Campaign Controllers Triggers
  - name: Campaign Flow Steps
  - name: Components
  - name: Components Grants
  - name: Components Subscriptions
  - name: Components Types
  - name: Content
  - name: Debug
  - name: Domains
  - name: Email
  - name: Event Prehandlers
  - name: Events
  - name: Javascript Core Extensions
  - name: Persons
  - name: Profiles
  - name: Report Schedules
  - name: Report Types
  - name: Reporting
  - name: Settings
paths:
  /v6/security/oauth/flow/exchange:
    post:
      tags:
        - Authentication
      summary: Exchange OAuth authorization code
      description: >-
        Exchanges an OAuth authorization code for an access token using the
        authorization code flow. Returns the access token and associated session
        information.
      requestBody:
        content:
          application/json:
            example:
              client_key_id: client_key_id
              code: code
              component_id: component_id
              key_type: STANDARD
              redirect_uri: redirect_uri
            schema:
              $ref: '#/components/schemas/OAuthFlowCodeExchangeRequest'
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OAuthFlowCodeExchangeResponse'
          description: Successful response
        '400':
          content:
            application/json:
              examples:
                binding_error:
                  $ref: '#/components/examples/binding_error'
                client_key_already_exists:
                  $ref: '#/components/examples/client_key_already_exists'
                client_key_exchanger_not_found:
                  $ref: '#/components/examples/client_key_exchanger_not_found'
                component_not_found:
                  $ref: '#/components/examples/component_not_found'
                exchange_client_key_not_found:
                  $ref: '#/components/examples/exchange_client_key_not_found'
                invalid_incoming_url:
                  $ref: '#/components/examples/invalid_incoming_url'
                invalid_json:
                  $ref: '#/components/examples/invalid_json'
                invalid_parameter:
                  $ref: '#/components/examples/invalid_parameter'
                invalid_uri_in_json:
                  $ref: '#/components/examples/invalid_uri_in_json'
                invalid_uri_in_query_parameter:
                  $ref: '#/components/examples/invalid_uri_in_query_parameter'
                missing_request_body:
                  $ref: '#/components/examples/missing_request_body'
              schema:
                $ref: '#/components/schemas/RestExceptionResponse'
          description: Bad Request
        '401':
          content:
            application/json:
              examples:
                method_unauthorized:
                  $ref: '#/components/examples/method_unauthorized'
              schema:
                $ref: '#/components/schemas/RestExceptionResponse'
          description: Unauthorized
        '402':
          content:
            application/json:
              examples:
                payment_required:
                  $ref: '#/components/examples/payment_required'
              schema:
                $ref: '#/components/schemas/RestExceptionResponse'
          description: Payment Required
        '403':
          content:
            application/json:
              examples:
                access_denied:
                  $ref: '#/components/examples/access_denied'
                key_exchange_exception:
                  $ref: '#/components/examples/key_exchange_exception'
                method_unauthorized:
                  $ref: '#/components/examples/method_unauthorized'
                missing_access_token:
                  $ref: '#/components/examples/missing_access_token'
              schema:
                $ref: '#/components/schemas/RestExceptionResponse'
          description: Forbidden
        '415':
          content:
            application/json:
              examples:
                unsupported_media_type:
                  $ref: '#/components/examples/unsupported_media_type'
              schema:
                $ref: '#/components/schemas/RestExceptionResponse'
          description: Unsupported Media Type
        '429':
          content:
            application/json:
              examples:
                too_many_requests:
                  $ref: '#/components/examples/too_many_requests'
              schema:
                $ref: '#/components/schemas/RestExceptionResponse'
          description: Too Many Requests
        '500':
          content:
            application/json:
              examples:
                exchanged_client_key_creation_failed:
                  $ref: '#/components/examples/exchanged_client_key_creation_failed'
                invalid_key_exchange_response:
                  $ref: '#/components/examples/invalid_key_exchange_response'
              schema:
                $ref: '#/components/schemas/RestExceptionResponse'
          description: Internal Server Error
components:
  schemas:
    OAuthFlowCodeExchangeRequest:
      properties:
        client_key_id:
          type: string
        code:
          type: string
        component_id:
          description: >-
            Integration component this connection belongs to. When set, the
            exchanged key is added to that component.
          type: string
        key_type:
          enum:
            - STANDARD
          type: string
        redirect_uri:
          type: string
      required:
        - client_key_id
        - code
        - redirect_uri
      type: object
    OAuthFlowCodeExchangeResponse:
      properties:
        client_key_id:
          type: string
      required:
        - client_key_id
      type: object
    RestExceptionResponse:
      description: Represents the API error response
      properties:
        code:
          description: Specific error code for this error type, documented per endpoint
          type: string
        http_status_code:
          description: >-
            HTTP status code that was returned with this error, useful if client
            get response code
          format: int32
          type: integer
        message:
          description: User readable English description of the error
          type: string
        parameters:
          additionalProperties:
            description: >-
              Attributes related to the error, varies be error code, documented
              per endpoint
            type: object
          description: >-
            Attributes related to the error, varies be error code, documented
            per endpoint
          type: object
        unique_id:
          description: >-
            Unique id associated with this error, useful for discussions with
            Extole
          type: string
      required:
        - code
        - http_status_code
        - message
        - parameters
        - unique_id
      type: object
  examples:
    binding_error:
      summary: binding_error
      value:
        code: binding_error
        http_status_code: 400
        message: Argument is not of the expected type
        parameters: {}
        unique_id: 00000000-0000-0000-0000-000000000000
    client_key_already_exists:
      summary: client_key_already_exists
      value:
        code: client_key_already_exists
        http_status_code: 400
        message: Client key for this integration already exists
        parameters: {}
        unique_id: 00000000-0000-0000-0000-000000000000
    client_key_exchanger_not_found:
      summary: client_key_exchanger_not_found
      value:
        code: client_key_exchanger_not_found
        http_status_code: 400
        message: >-
          Failed to exchange code to an access token, client key exchanger not
          found
        parameters: {}
        unique_id: 00000000-0000-0000-0000-000000000000
    component_not_found:
      summary: component_not_found
      value:
        code: component_not_found
        http_status_code: 400
        message: Component not found
        parameters: {}
        unique_id: 00000000-0000-0000-0000-000000000000
    exchange_client_key_not_found:
      summary: exchange_client_key_not_found
      value:
        code: exchange_client_key_not_found
        http_status_code: 400
        message: Exchange ClientKey not found
        parameters: {}
        unique_id: 00000000-0000-0000-0000-000000000000
    invalid_incoming_url:
      summary: invalid_incoming_url
      value:
        code: invalid_incoming_url
        http_status_code: 400
        message: Incoming URL is an invalid URI
        parameters: {}
        unique_id: 00000000-0000-0000-0000-000000000000
    invalid_json:
      summary: invalid_json
      value:
        code: invalid_json
        http_status_code: 400
        message: JSON is invalid
        parameters: {}
        unique_id: 00000000-0000-0000-0000-000000000000
    invalid_parameter:
      summary: invalid_parameter
      value:
        code: invalid_parameter
        http_status_code: 400
        message: Parameter is invalid.
        parameters: {}
        unique_id: 00000000-0000-0000-0000-000000000000
    invalid_uri_in_json:
      summary: invalid_uri_in_json
      value:
        code: invalid_uri_in_json
        http_status_code: 400
        message: Invalid URI in JSON
        parameters: {}
        unique_id: 00000000-0000-0000-0000-000000000000
    invalid_uri_in_query_parameter:
      summary: invalid_uri_in_query_parameter
      value:
        code: invalid_uri_in_query_parameter
        http_status_code: 400
        message: Invalid URI in query parameter
        parameters: {}
        unique_id: 00000000-0000-0000-0000-000000000000
    missing_request_body:
      summary: missing_request_body
      value:
        code: missing_request_body
        http_status_code: 400
        message: Missing request body
        parameters: {}
        unique_id: 00000000-0000-0000-0000-000000000000
    method_unauthorized:
      summary: method_unauthorized
      value:
        code: method_unauthorized
        http_status_code: 401
        message: Unauthorized access to this endpoint
        parameters: {}
        unique_id: 00000000-0000-0000-0000-000000000000
    payment_required:
      summary: payment_required
      value:
        code: payment_required
        http_status_code: 402
        message: The access_token provided is associated with an unpaid account.
        parameters: {}
        unique_id: 00000000-0000-0000-0000-000000000000
    access_denied:
      summary: access_denied
      value:
        code: access_denied
        http_status_code: 403
        message: >-
          The access_token provided is not permitted to access the specified
          resource.
        parameters: {}
        unique_id: 00000000-0000-0000-0000-000000000000
    key_exchange_exception:
      summary: key_exchange_exception
      value:
        code: key_exchange_exception
        http_status_code: 403
        message: Failed to exchange code
        parameters: {}
        unique_id: 00000000-0000-0000-0000-000000000000
    missing_access_token:
      summary: missing_access_token
      value:
        code: missing_access_token
        http_status_code: 403
        message: No access_token was provided with this request.
        parameters: {}
        unique_id: 00000000-0000-0000-0000-000000000000
    unsupported_media_type:
      summary: unsupported_media_type
      value:
        code: unsupported_media_type
        http_status_code: 415
        message: Request had an unsupported or no media type
        parameters: {}
        unique_id: 00000000-0000-0000-0000-000000000000
    too_many_requests:
      summary: too_many_requests
      value:
        code: too_many_requests
        http_status_code: 429
        message: >-
          The server is unable to process your request at the moment, please
          retry later.
        parameters: {}
        unique_id: 00000000-0000-0000-0000-000000000000
    exchanged_client_key_creation_failed:
      summary: exchanged_client_key_creation_failed
      value:
        code: exchanged_client_key_creation_failed
        http_status_code: 500
        message: Failed to create a client key using exchanged access token
        parameters: {}
        unique_id: 00000000-0000-0000-0000-000000000000
    invalid_key_exchange_response:
      summary: invalid_key_exchange_response
      value:
        code: invalid_key_exchange_response
        http_status_code: 500
        message: Received invalid response when exchange code to access token
        parameters: {}
        unique_id: 00000000-0000-0000-0000-000000000000
  securitySchemes:
    HEADER:
      in: header
      name: Authorization
      type: apiKey
      x-bearer-format: bearer
    QUERY:
      in: query
      name: access_token
      type: apiKey
    COOKIE:
      in: cookie
      name: extole_token
      type: apiKey

````

## Related topics

- [Exchange OIDC authorization code](https://docs.extole.com/api-reference/expert/authentication/exchange-oidc-authorization-code.md)
- [Exchange an IdP-initiated OIDC authorization code](https://docs.extole.com/api-reference/expert/authentication/exchange-an-idp-initiated-oidc-authorization-code.md)
- [Exchange access token](https://docs.extole.com/api-reference/authentication/exchange-access-token.md)
- [Create a managed token via authorization code](https://docs.extole.com/api-reference/expert/authentication/create-a-managed-token-via-authorization-code.md)
- [Microsoft Copilot](https://docs.extole.com/technical/extole-ai-tools/extole-mcp-server/setup-copilot-studio.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.