B2B Saas Authentication

/

API reference

/

Session management

/

Migrate Session

Migrate Session

POSThttps://test.stytch.com/v1/b2b/sessions/migrate

Migrate a session from an external OIDC compliant endpoint. Stytch will call the external UserInfo endpoint defined in your Stytch Project settings in the Dashboard, and then perform a lookup using the session_token. If the response contains a valid email address, Stytch will attempt to match that email address with an existing Member in your Organization and create a Stytch Session. You will need to create the member before using this endpoint.


Body parameters


session_token*string

organization_id*string

session_duration_minutesint

session_custom_claimsmap<string, any>

Response fields


request_idstring

member_idstring

member_sessionobject

session_tokenstring

session_jwtstring

memberobject

organizationobject
curl --request POST \
  --url https://test.stytch.com/v1/b2b/sessions/migrate \
  -u 'PROJECT_ID:SECRET' \
  -H 'Content-Type: application/json' \
  -d '{
    "session_token": "mZAYn5aLEqKUlZ_Ad9U_fWr38GaAQ1oFAhT8ds245v7Q",
    "organization_id": "organization-test-07971b06-ac8b-4cdb-9c15-63b17e653931"
  }'

RESPONSE

200
{
  "status_code": 200,
  "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
  "member_id": "member-test-32fc5024-9c09-4da3-bd2e-c9ce4da9375f",
  "session_token": "mZAYn5aLEqKUlZ_Ad9U_fWr38GaAQ1oFAhT8ds245v7Q",
  "session_jwt": "eyJ...",
  "member": "{...}",
  "organization": "{...}",
  "member_session": "{...}"
}

Common Error Types