API Documentation
The SWT API is simple and consists of three main endpoints for managing your stateful tokens. All endpoints accept and return JSON. The base URL ishttps://api.swt.odysii.in
1. Sign Token
Create a new stateful web token with a secret and an arbitrary JSON payload.
POST
/v1/signRequest Body
{
"secret": "your-secret-key",
"payload": {
"userId": "123",
"role": "admin"
}
}Response
{
"token": "swt_0mt...",
"expiresAt": 1712630000
}2. Verify Token
Verify if a token is valid, not expired, and not revoked. Returns the original payload.
POST
/v1/verifyRequest Body
{
"token": "swt_0mt...",
"secret": "your-secret-key"
}Response
{
"valid": true,
"payload": {
"userId": "123",
"role": "admin"
}
}3. Revoke Token
Instantly invalidate a token. Subsequent verify requests will fail.
POST
/v1/revokeRequest Body
{
"token": "swt_0mt...",
"secret": "your-secret-key"
}Response
{
"success": true,
"message": "Token revoked successfully"
}