Auth

Handle WorkOS callback (API response mode)

POST
/api/auth/workos/callback

Called by the SPA after the browser redirect to finalize the WorkOS session. Exchanges the authorization code, upserts the user, and returns access/refresh tokens plus the resolved session config - the JSON equivalent of the GET callback redirect.

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

curl -X POST "https://example.com/api/auth/workos/callback" \  -H "Content-Type: application/json" \  -d '{    "code": "01HX9R3K4N6P8QZBVTYM2D5A7C",    "state": "tether-csrf-7f4b2c1d",    "redirect_uri": "https://app.tether.example/auth/callback",    "organizationId": "org_01HX9R3K4N6P8QZBVTYM2D5A7C"  }'
{  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI1Zjdi...",  "refreshToken": "rt_64d2f9c5e8a1d4e001a0b1c2e6f7a8b9",  "sessionConfig": {    "enabled": true,    "idleTimeoutMinutes": 30,    "tokenExpiryHours": 8,    "warningTimeMinutes": 2  },  "user": {    "id": "5f7b1c2e8a1d4e0012c3b4a5",    "email": "admin@acme.example",    "fullName": "Acme Admin",    "organizationId": "64a1b2c3d4e5f60012345678",    "accessRole": "ADMIN"  }}