POST
/
api
/
v1
/
auth
/
logout-all
Logout from every session
curl --request POST \
  --url https://api.example.com/api/v1/auth/logout-all
import 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_body

Overview

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 the sub 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

StatusCodeMeaning
401UNAUTHENTICATEDMissing, 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_tokens row for the user with revokedAt = now.
  • All other devices will receive 401 UNAUTHENTICATED on their next /auth/refresh and 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

curl

curl -X POST https://api.swappr.co.uk/api/v1/auth/logout-all \
  -H "Authorization: Bearer $ACCESS_TOKEN"