Documentation menu

OAuth

2 operations.

MethodEndpointDescription
GET/api/oauth/callback/{presetKey}Complete a BYOC OAuth dance and persist the Connection
GET/api/oauth/start/{presetKey}Begin a BYOC OAuth dance for a Project Environment

Complete a BYOC OAuth dance and persist the Connection

GET/api/oauth/callback/{presetKey}

Receives the redirect from the provider after the user grants consent. Reads the signed state cookie set by /api/oauth/start/:presetKey, verifies it, exchanges the authorization code for tokens at the provider's token endpoint, captures the granted scopes and account identity, encrypts the tokens, and upserts the Connection row for the Project Environment selected by the signed state.

After authentication, OAuth flow outcomes use a 302 redirect to the signed state's returnTo URL, or the Studio root if state is invalid. Authentication failures return 401; unexpected server failures remain 5xx.

Use a browser session or Bearer API key with current permission to connect the Project Environment pinned in the signed state. Permission is checked again before exchanging the code. API clients must return the retained state cookie and provider state value and handle the redirect manually.

Parameters

path

NameTypeRequiredDescription
presetKeystringrequiredIdentifies the OAuth preset whose authorization flow is being requested. Applies to Complete a BYOC OAuth dance and persist the Connection.

query

NameTypeRequiredDescription
codestringoptionalCarries the OAuth provider error code returned during authorization. Applies to Complete a BYOC OAuth dance and persist the Connection.
statestringoptionalOAuth CSRF and correlation token returned by the provider; send it back unchanged.
errorstringoptionalCarries the OAuth provider error identifier returned during authorization. Applies to Complete a BYOC OAuth dance and persist the Connection.
error_descriptionstringoptionalCarries the OAuth provider's human-readable error description. Applies to Complete a BYOC OAuth dance and persist the Connection.

Responses

StatusDescriptionBody
400Bad Request
application/json
object
  • error (required): object
401Authentication failed. Possible reasons: - Authorization header is not provided - Invalid API key - Session expired
application/json
object
  • error (required): object
403Access denied. The authenticated user does not have permission to perform this action.
application/json
object
  • error (required): object
404Resource not found.
application/json
object
  • error (required): object
422Request validation failed. Check the request body, query parameters, or path parameters.
application/json
object
  • error (required): object
429Rate limited by an upstream dependency. Retry after the Retry-After interval.
application/json
object
  • error (required): object
500Response for status 500
application/json
object
  • error (required): object
503Service temporarily unavailable (e.g. execution capacity exhausted). The response carries a Retry-After header; retry with backoff.
application/json
object
  • error (required): object

Begin a BYOC OAuth dance for a Project Environment

GET/api/oauth/start/{presetKey}

Generates a PKCE pair and signed state cookie, then redirects the browser to the provider's authorization endpoint. The companion /api/oauth/callback/:presetKey endpoint completes the exchange.

Use a browser session or Bearer API key with the required Project operation permission. The Project and Environment must exist in the caller's organization, and the organization must have a verified Integration registered for the preset. OAuth state pins the selected Integration Version until the callback completes. API clients must handle the redirect manually and retain the state cookie for the callback; never forward the Perstack API key to the provider.

Parameters

path

NameTypeRequiredDescription
presetKeystringrequiredIdentifies the OAuth preset whose authorization flow is being requested. Applies to Begin a BYOC OAuth dance for a Project Environment.

query

NameTypeRequiredDescription
projectIdstringrequiredFilters results to the specified Project. Applies to Begin a BYOC OAuth dance for a Project Environment.
environmentIdstringrequiredSelects the active Project environment coordinate. Applies to Begin a BYOC OAuth dance for a Project Environment.
returnTostringoptionalSets the browser return location after the OAuth flow completes. Applies to Begin a BYOC OAuth dance for a Project Environment.

Responses

StatusDescriptionBody
400Bad Request
application/json
object
  • error (required): object
401Authentication failed. Possible reasons: - Authorization header is not provided - Invalid API key - Session expired
application/json
object
  • error (required): object
403Access denied. The authenticated user does not have permission to perform this action.
application/json
object
  • error (required): object
404Resource not found.
application/json
object
  • error (required): object
422Request validation failed. Check the request body, query parameters, or path parameters.
application/json
object
  • error (required): object
429Rate limited by an upstream dependency. Retry after the Retry-After interval.
application/json
object
  • error (required): object
500Response for status 500
application/json
object
  • error (required): object
503Service temporarily unavailable (e.g. execution capacity exhausted). The response carries a Retry-After header; retry with backoff.
application/json
object
  • error (required): object