---
updatedAt: 2026-05-20T20:59:45.000Z
agentTools:
  projectIndex: https://docs.developers.convert.com/llms.txt
---

# Exchange OAuth code for session token

Public endpoint used by OAuth clients to exchange a one-time authorization code for a scoped bearer session token.
Enforces PKCE binding.


# OpenAPI definition

````json
{
  "openapi": "3.0.3",
  "info": {
    "title": "Convert Management API",
    "description": "Move your app forward with the Convert API. The Convert API allows\nyou to manage your Convert Experiences projects using code. The REST API is\nan interface for managing and extending functionality of Convert. For\nexample, instead of creating and maintaining projects using the Convert\nExperiences web dashboard you can create an experiment programmatically.\nAdditionally, if you prefer to run custom analysis on experiment results you\ncan leverage the API to pull data from Convert Experiences into your own\nworkflow. If you do not have a Convert account already, sign up for a free\ndeveloper account at https://www.convert.com/api/.\n\n*[Convert API V1](/doc/v1) is still available and documentation can be found [here](/doc/v1) but using it is highly discouraged\nas it will be phased out in the future*\n",
    "version": "2.0.0"
  },
  "x-tagGroups": [
    {
      "name": "Client Authentication",
      "tags": [
        "API KEY Authentication",
        "Cookie Authentication",
        "OAuth Authorization"
      ]
    },
    {
      "name": "Common Parameters",
      "tags": [
        "Optional Fields",
        "Expandable Fields"
      ]
    },
    {
      "name": "Requests",
      "tags": [
        "User",
        "Accounts",
        "AI content",
        "Collaborators",
        "API Keys",
        "Notifications",
        "Projects",
        "SDK Keys",
        "Experiences",
        "Experience Variations",
        "Experience Sections",
        "Section Versions",
        "Version Changes",
        "Experiences Reports",
        "Experiences Heatmaps",
        "Goals",
        "Hypotheses",
        "Knowledge Bases",
        "Observations",
        "Locations",
        "Audiences",
        "Domains",
        "Cdn Images",
        "Files",
        "Tags",
        "Features",
        "Visitor Insights",
        "Visitors Data",
        "Visitor Data Placeholders",
        "OAuth",
        "Approval Requests"
      ]
    }
  ],
  "tags": [
    {
      "name": "OAuth Authorization",
      "description": "Delegated authorization endpoints for third-party OAuth clients.\n\nTypical flow:\n* OAuth client initiates GET request in browser (`/oauth/authorize`) with `client_id` + `response_type=code` + `scope` + `state` + `code_challenge` (PKCE)\n* While generating `code_challenge` — don't forget to store the `code_verifier` which will be used to obtain the access token\n* User authenticates in Convert and approves scope in consent UI\n* OAuth client exchanges one-time code (`/auth/oauth/token`) for a scoped bearer session token\n* User can list/revoke authorized OAuth sessions (`/auth/oauth/sessions*`)\n\nScopes: `selected_accounts_projects`\n\nExample:\n```\nhttps://app.convert.com/auth/oauth/authorize?client_id=1111111&state=randomstring&scope=selected_accounts_projects&response_type=code&code_challenge=generatedCodeChallenge\n```\n"
    }
  ],
  "paths": {
    "/auth/oauth/token": {
      "post": {
        "operationId": "requestOauthToken",
        "x-mutates": true,
        "summary": "Exchange OAuth code for session token",
        "description": "Public endpoint used by OAuth clients to exchange a one-time authorization code for a scoped bearer session token.\nEnforces PKCE binding.\n",
        "tags": [
          "OAuth Authorization"
        ],
        "requestBody": {
          "$ref": "#/components/requestBodies/OAuthTokenRequest"
        },
        "responses": {
          "200": {
            "$ref": "#/components/responses/OAuthTokenResponse"
          },
          "default": {
            "$ref": "#/components/responses/ErrorResponse"
          }
        }
      }
    }
  },
  "servers": [
    {
      "url": "https://api.convert.com/api/v2",
      "description": "Live API server"
    },
    {
      "url": "https://apidev.convert.com/api/v2",
      "description": "DEV API server"
    },
    {
      "url": "http://apidev.convert.com:5000/api/v2",
      "description": "DEV mocked API server"
    }
  ],
  "components": {
    "securitySchemes": {
      "secretKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "See **[API Key Authentication](/reference/api-key-authentication)** for more information.\n"
      },
      "cookieAuthentication": {
        "type": "apiKey",
        "in": "cookie",
        "name": "sid",
        "description": "Cookie authentication is used against Convert's own IdentityProvider  or third party identity providers and is described more in the \"[Cookie Authentication](/reference/cookie-authentication)\" section"
      },
      "requestSigningAppId": {
        "type": "apiKey",
        "in": "header",
        "name": "Convert-Application-ID",
        "description": "HMAC request signing — the Application ID from your Convert account. See **[API Key Authentication](/reference/api-key-authentication)** for how to generate the full three-header set."
      },
      "requestSigningExpires": {
        "type": "apiKey",
        "in": "header",
        "name": "Expires",
        "description": "HMAC request signing — UNIX timestamp after which the signature expires. See **[API Key Authentication](/reference/api-key-authentication)** for how to compute it."
      },
      "requestSigningAuthorization": {
        "type": "apiKey",
        "in": "header",
        "name": "Authorization",
        "description": "HMAC request signing — format: `Convert-HMAC-SHA256 Signature=<hex-hmac-sha256(AppID\\nExpires\\nURL\\nBody, Secret)>`. See **[API Key Authentication](/reference/api-key-authentication)** for the signing algorithm. The \"Try It\" playground cannot compute this for you; paste a pre-computed signature here or use the Bearer method instead."
      }
    },
    "requestBodies": {
      "OAuthTokenRequest": {
        "required": true,
        "description": "Exchanges a one-time authorization code for an OAuth bearer session token.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/OAuthTokenRequestData"
            }
          }
        }
      }
    },
    "responses": {
      "OAuthTokenResponse": {
        "description": "One-time code exchanged for a scoped OAuth bearer session token.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/OAuthTokenResponseData"
            }
          }
        }
      },
      "ErrorResponse": {
        "description": "Indicates an error occurred while processing the request. The `code` provides an HTTP status code, `message` offers a human-readable explanation or an array of validation errors, and `fields` (if present) specifies which input fields were problematic.\n",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorData"
            }
          }
        }
      }
    },
    "schemas": {
      "ErrorData": {
        "type": "object",
        "properties": {
          "code": {
            "type": "integer",
            "format": "int32"
          },
          "message": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            ]
          },
          "fields": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            ]
          },
          "context": {
            "type": "object",
            "description": "Additional context about the error."
          }
        }
      },
      "OAuthScopeMode": {
        "type": "string",
        "enum": [
          "selected_accounts_projects"
        ]
      },
      "OAuthScopeProject": {
        "type": "object",
        "required": [
          "project_id",
          "role"
        ],
        "properties": {
          "project_id": {
            "type": "integer",
            "minimum": 1
          },
          "role": {
            "description": "User's role for this project.",
            "type": "string"
          },
          "name": {
            "description": "Display name of the project.",
            "type": "string"
          }
        }
      },
      "OAuthGrantedScopeResponse": {
        "type": "object",
        "required": [
          "mode",
          "accounts"
        ],
        "properties": {
          "mode": {
            "$ref": "#/components/schemas/OAuthScopeMode"
          },
          "accounts": {
            "description": "Accounts and project scope persisted in the issued OAuth grant.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OAuthAuthorizedAccountRef"
            }
          }
        }
      },
      "OAuthAuthorizedAccountRef": {
        "type": "object",
        "required": [
          "account_id",
          "name"
        ],
        "properties": {
          "account_id": {
            "type": "integer",
            "minimum": 1
          },
          "name": {
            "type": "string"
          },
          "role": {
            "description": "Consent-time privilege ceiling for an entire-account grant.",
            "type": "string",
            "enum": [
              "account_manager",
              "admin",
              "publish",
              "review",
              "edit",
              "browse"
            ]
          },
          "projects": {
            "description": "Null for an entire-account grant; otherwise the approved project grants.",
            "type": "array",
            "nullable": true,
            "items": {
              "$ref": "#/components/schemas/OAuthScopeProject"
            }
          }
        }
      },
      "OAuthTokenRequestData": {
        "type": "object",
        "required": [
          "grant_type",
          "code",
          "client_id",
          "code_verifier"
        ],
        "properties": {
          "grant_type": {
            "description": "Authorization grant type.",
            "type": "string",
            "enum": [
              "authorization_code"
            ],
            "default": "authorization_code"
          },
          "code": {
            "description": "One-time authorization code from consent redirect.",
            "type": "string",
            "minLength": 1
          },
          "client_id": {
            "description": "Identifier of the OAuth client application that initiated the authorization request.",
            "type": "string"
          },
          "code_verifier": {
            "description": "PKCE verifier for code challenge validation.",
            "type": "string",
            "minLength": 43,
            "maxLength": 128,
            "pattern": "^[A-Za-z0-9\\-._~]+$"
          }
        }
      },
      "OAuthTokenResponseData": {
        "type": "object",
        "required": [
          "access_token",
          "token_type",
          "expires_at",
          "scope"
        ],
        "properties": {
          "access_token": {
            "description": "Opaque OAuth session bearer token.",
            "type": "string"
          },
          "token_type": {
            "type": "string",
            "enum": [
              "Bearer"
            ]
          },
          "expires_at": {
            "type": "integer",
            "description": "Absolute expiration timestamp (unix seconds)."
          },
          "scope": {
            "$ref": "#/components/schemas/OAuthGrantedScopeResponse"
          }
        }
      }
    }
  },
  "security": [
    {
      "requestSigningAppId": [],
      "requestSigningExpires": [],
      "requestSigningAuthorization": []
    },
    {
      "secretKey": []
    },
    {
      "cookieAuthentication": []
    }
  ]
}
````