Skip to main content

Authentication API

Use these endpoints to create, inspect, refresh, and revoke user sessions.

Base path: /api/auth

Endpoint overview

MethodPathAuthenticationPurpose
POST/loginPublicExchange credentials for an access token
GET/sessionAuthorization headerValidate the current session
GET/meBearer tokenRead the current user
POST/logoutToken in JSON bodyRevoke the supplied session token
POST/logout-allBearer tokenRevoke every session for the current user

Bearer authentication

Send the token returned by login on protected endpoints:

Authorization: Bearer <access_token>

Login

POST /api/auth/login

Authenticate with a username and password.

Authentication: Public

Request body: application/json

FieldTypeRequiredDescription
usernamestringYesSociovite username
passwordstringYesAccount password
{
"username": "your_username",
"password": "your_password"
}

Success response — 200 OK:

{
"token": "eyJhbGciOi...",
"expires_at": "2026-07-29T23:26:03.041292+07:00",
"roles": [
"user"
],
"user": {
"userId": "user_id",
"name": "user",
"email": "user@example.com",
"username": "user"
}
}

Use token as the bearer access token. The contract declares expires_at as a string and does not constrain its date format.

Other responses:

StatusMeaning
400Invalid request body or missing credentials
401Invalid credentials
curl -X POST \
"$SOCIOVITE_API_URL/api/auth/login" \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"username": "your_username",
"password": "your_password"
}'

Validate a session

GET /api/auth/session

Validate the supplied access token and return the session identity.

Required header:

Authorization: Bearer <access_token>

Success response — 200 OK:

{
"valid": true,
"expires_at": "2026-07-29T23:26:03.041292+07:00",
"roles": [
"admin"
],
"user": {
"userId": "user_id",
"name": "Admin",
"email": "admin@example.com",
"username": "admin"
}
}

Other response: 401 when the token is invalid or missing.

curl \
"$SOCIOVITE_API_URL/api/auth/session" \
-H 'accept: application/json' \
-H 'Authorization: Bearer <access_token>'

Get the current user

GET /api/auth/me

Return the user represented by the bearer token.

Authentication: Bearer token

Success response — 200 OK:

{
"userId": "user_id",
"name": "Admin",
"email": "admin@example.com",
"username": "admin"
}

Other response: 401 when the token is unauthorized or invalid.

curl \
"$SOCIOVITE_API_URL/api/auth/me" \
-H 'accept: application/json' \
-H 'Authorization: Bearer <access_token>'

Logout one session

POST /api/auth/logout

Invalidate the session represented by the supplied token. Swagger describes this body value as a refresh token.

Authentication: No bearer header is declared. The token is sent in the body.

Request body: application/json

FieldTypeRequired
tokenstringYes
{
"token": "current_access_token"
}

Success response — 200 OK:

{
"success": true,
"message": "Logout successful"
}

Other responses:

StatusMeaning
400Invalid request
401Invalid token
curl -X POST \
"$SOCIOVITE_API_URL/api/auth/logout" \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"token": "current_access_token"
}'

Logout all devices

POST /api/auth/logout-all

Invalidate every session associated with the authenticated user.

Authentication: Bearer token

Request body: None

Success response — 200 OK:

{
"success": true,
"message": "All sessions revoked",
"revoked": 3
}

revoked is the number of sessions invalidated.

Other response: 401 when the request is unauthorized.

curl -X POST \
"$SOCIOVITE_API_URL/api/auth/logout-all" \
-H 'accept: application/json' \
-H 'Authorization: Bearer <access_token>'

Error shape

Authentication errors use the shared error model:

{
"success": false,
"error": "Invalid credentials",
"message": "Unable to authenticate the request"
}