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

# Oauth2 Callback

> This callback/webhook is used while creating a new connection with Oauth2. See https://docs.peaka.com/how-to-guides/how-to-create-oauth2-based-connections-via-peaka for more information.

<span style={{display: "flex", gap: "10px", flexDirection: "row", alignItems: "center"}}>
  <img src="https://cdn.peaka.com/badges/partner-api-key-badge.png" />

  <img src="https://cdn.peaka.com/badges/project-api-key-badge.png" />
</span>


## OpenAPI

````yaml post /connections/{projectId}/oauth2
openapi: 3.0.1
info:
  title: Peaka Gateway API
  description: Peaka Gateway API Documentation
  version: '1.0'
servers:
  - url: https://partner.peaka.studio/api/v1
    description: Default Server URL (US Zone)
  - url: https://partner.eu.peaka.studio/api/v1
    description: EU Zone
security:
  - bearerAuth: []
paths:
  /connections/{projectId}/oauth2:
    post:
      tags:
        - Connections
      summary: Oauth2 Callback
      description: >-
        This callback/webhook is used while creating a new connection with
        Oauth2. See
        https://docs.peaka.com/how-to-guides/how-to-create-oauth2-based-connections-via-peaka
        for more information.
      operationId: oauth2Callback
      parameters:
        - name: projectId
          in: path
          description: ID of the project
          required: true
          schema:
            type: string
          example: mtKDhe1U
      requestBody:
        description: Oauth2 Callback Body
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Oauth2Callback'
            examples:
              Oauth2 Callback Request:
                description: Oauth2 Callback Request
                value:
                  queryParameters: code=1234&state=xyz&param1=value1&param2=value2
        required: true
      responses:
        '200':
          description: Connection created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Connection'
              examples:
                Successful Oauth2 Connection:
                  description: Sample Google Analytics Connection
                  value:
                    id: 6243f42a-42d0-4821-a90f-763cda6cda50
                    name: exampleOauth2Connection
                    type: google_analytics
components:
  schemas:
    Oauth2Callback:
      type: object
      properties:
        queryParameters:
          type: string
          description: >-
            Query parameters received from the Oauth2 redirection. Pass all
            query parameters as a single string.

             Example: "https://yourdomain.com/oauth2/mycallback?code=1234&state=xyz&param1=value1&param2=value2"

             "queryParameters": "code=1234&state=xyz&param1=value1&param2=value2"
    Connection:
      type: object
      properties:
        id:
          type: string
          description: Connection ID
        name:
          type: string
          description: Name of the connection
        type:
          type: string
          description: >
            Type of connection.


            Example: airtable for AirTable, stripe for Stripe,
            hubspot_access_token for HubSpot (with Access Token), etc.


            Exact list can be fetched by following url: /connections/config
        url:
          type: string
          description: |
            Oauth callback url if the connection is Oauth based.
  securitySchemes:
    bearerAuth:
      type: http
      description: >-
        Use the Authorization header with the value 'Bearer <apiKey>' to
        authenticate. Partner API Keys have full access; Project API Keys are
        limited to their project scope. Learn more:
        https://docs.peaka.com/api-reference/authentication
      scheme: bearer
      bearerFormat: Api Key

````