Exchange Logto token for custom JWT
Exchange a Logto access token for a custom JWT with embedded permissions
POST
/auth/exchange
curl \
--request POST 'https://collect.your-domain.com/api/auth/exchange' \
--header "Content-Type: application/json" \
--data '{"access_token":"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..."}'
Request examples
{
"access_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..."
}
Response examples (200)
{
"code": 200,
"message": "token exchange successful",
"data": {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"expires_in": 86400,
"user": {
"id": "user_123456789",
"logto_id": "user_abc123def456",
"username": "john.doe",
"email": "john@example.com",
"name": "John Doe",
"phone": "+39 333 123456",
"user_roles": [
"Admin"
],
"user_role_ids": [
"rol_admin_id_123"
],
"user_permissions": [
"destroy:systems",
"manage:systems",
"read:systems"
],
"org_role": "Owner",
"org_role_id": "org_rol_owner_456",
"org_permissions": [
"create:distributors",
"manage:distributors"
],
"organization_id": "org_123",
"organization_name": "ACME Distribution"
}
}
}
Response examples (400)
{
"code": 400,
"message": "validation failed",
"data": {
"type": "validation_error",
"errors": [
{
"key": "username",
"message": "required",
"value": "string"
}
]
}
}
Response examples (401)
{
"code": 401,
"message": "invalid token",
"data": {}
}