Exchange an auth token issued by a trusted identity provider for a Stytch session. You must first register a Trusted Auth Token profile in the Stytch dashboard here. If a session token or session JWT is provided, it will add the trusted auth token as an authentication factor to the existing session.
Attest Session
POST
https://test.stytch.com/v1/sessions/attestBody parameters
profile_id* string
token* string
session_duration_minutes int
session_custom_claims map<string, any>
session_jwt string
session_token string
Response fields
status_code int
request_id string
session object
session_jwt string
session_token string
user_id string
user object
const stytch = require('stytch');
const client = new stytch.Client({
project_id: 'PROJECT_ID',
secret: 'SECRET',
});
const params = {
profile_id: "trusted-auth-token-profile-test-41920359-8bbb-4fe8-8fa3-aaa83f35f02c",
token: "eyJhb...",
session_duration_minutes: 60,
};
client.sessions.attest(params)
.then(resp => { console.log(resp) })
.catch(err => { console.log(err) });
RESPONSE
200
{
"status_code": 200,
"request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
"user_id": "user-test-16d9ba61-97a1-4ba4-9720-b03761dc50c6"
"session_jwt": "eyJ...",
"session_token": "mZAYn5aLEqKUlZ_Ad9U_fWr38GaAQ1oFAhT8ds245v7Q",
"user": {...},
"session": {...},
}