Logout from every session
curl --request POST \
--url https://api.example.com/api/v1/auth/logout-allimport requests
url = "https://api.example.com/api/v1/auth/logout-all"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.example.com/api/v1/auth/logout-all', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/api/v1/auth/logout-all",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/v1/auth/logout-all"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/api/v1/auth/logout-all")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/auth/logout-all")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_bodyAuth
Logout from every session
Revoke every refresh token for the authenticated user.
POST
/
api
/
v1
/
auth
/
logout-all
Logout from every session
curl --request POST \
--url https://api.example.com/api/v1/auth/logout-allimport requests
url = "https://api.example.com/api/v1/auth/logout-all"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.example.com/api/v1/auth/logout-all', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/api/v1/auth/logout-all",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/v1/auth/logout-all"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/api/v1/auth/logout-all")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/auth/logout-all")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_bodyOverview
Revokes every non-revoked refresh token belonging to the authenticated user — across every device, browser, and session. Use this for “log out everywhere” UX, post-password-change flows, or when a user reports a lost or stolen device. The user id is taken from thesub claim in the access token; clients pass nothing in the body. Already-revoked rows are left alone.
Authentication
Bearer <accessToken> required. Scope: user.
Path parameters
None.Query parameters
None.Request body
None.Response — 204 No Content
Empty body. All sessions for the user are revoked.Error responses
| Status | Code | Meaning |
|---|---|---|
| 401 | UNAUTHENTICATED | Missing, malformed, or expired access token. |
Example error — 401
{
"type": "https://api.swappr.co.uk/errors/unauthenticated",
"title": "Authentication required",
"status": 401,
"code": "UNAUTHENTICATED",
"detail": "Authenticated user required",
"instance": "/api/v1/auth/logout-all",
"requestId": "01HZQ7K3M4N5P6Q7R8S9T0V1W2"
}
Side effects
- Marks every non-revoked
refresh_tokensrow for the user withrevokedAt = now. - All other devices will receive
401 UNAUTHENTICATEDon their next/auth/refreshand must log in again. - The current device’s access token remains structurally valid until its 15-minute TTL elapses; on next refresh it too will be forced to log in.
See also
- Logout (current session) — revoke only the current session.
- Reset password — automatically logs out every device on success.
- Authentication — full token lifecycle.
curl
curl -X POST https://api.swappr.co.uk/api/v1/auth/logout-all \
-H "Authorization: Bearer $ACCESS_TOKEN"