const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
scopes: ['<string>'],
expires_in: 3600,
settlement_ids: ['3c90c3cc-0d44-4b50-8888-8dd25736052a'],
metadata: {}
})
};
fetch('https://api-staging.keystoneos.xyz/v1/sessions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api-staging.keystoneos.xyz/v1/sessions"
payload = {
"scopes": ["<string>"],
"expires_in": 3600,
"settlement_ids": ["3c90c3cc-0d44-4b50-8888-8dd25736052a"],
"metadata": {}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)curl --request POST \
--url https://api-staging.keystoneos.xyz/v1/sessions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"scopes": [
"<string>"
],
"expires_in": 3600,
"settlement_ids": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
],
"metadata": {}
}
'{
"session_token": "<string>",
"expires_at": "2023-11-07T05:31:56Z",
"token_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
],
"code": "VALIDATION_ERROR",
"docs_url": "https://docs.keystoneos.xyz/guides/error-codes#validation-error"
}Create a session token
Requires the sessions:write scope (as an M2M scope or a user permission).
Exchange M2M credentials for a scoped, short-lived session token that can be used in frontend widgets. Session tokens cannot create other session tokens.
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
scopes: ['<string>'],
expires_in: 3600,
settlement_ids: ['3c90c3cc-0d44-4b50-8888-8dd25736052a'],
metadata: {}
})
};
fetch('https://api-staging.keystoneos.xyz/v1/sessions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api-staging.keystoneos.xyz/v1/sessions"
payload = {
"scopes": ["<string>"],
"expires_in": 3600,
"settlement_ids": ["3c90c3cc-0d44-4b50-8888-8dd25736052a"],
"metadata": {}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)curl --request POST \
--url https://api-staging.keystoneos.xyz/v1/sessions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"scopes": [
"<string>"
],
"expires_in": 3600,
"settlement_ids": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
],
"metadata": {}
}
'{
"session_token": "<string>",
"expires_at": "2023-11-07T05:31:56Z",
"token_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
],
"code": "VALIDATION_ERROR",
"docs_url": "https://docs.keystoneos.xyz/guides/error-codes#validation-error"
}Authorizations
Auth0 JWT access token. See Authentication for details.
Body
Request body for creating a new session token.
Permissions granted to this session token.
1Token TTL in seconds (60 to 86400).
60 <= x <= 86400Restrict token to specific settlement IDs. Omit the field entirely for an unrestricted token. An empty list is rejected: a caller that computed an empty permitted set is asking for a token that reaches nothing, and silently minting an environment-wide token there would invert the intent.
1Platform-provided context for audit trail (e.g., user_id, user_email).