Logout
curl --request POST \
--url https://api.example.com/api/auth/logoutimport requests
url = "https://api.example.com/api/auth/logout"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.example.com/api/auth/logout', 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/auth/logout",
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/auth/logout"
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/auth/logout")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/auth/logout")
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{
"message": "<string>"
}Authentication
Logout
Client-side logout endpoint
POST
/
api
/
auth
/
logout
Logout
curl --request POST \
--url https://api.example.com/api/auth/logoutimport requests
url = "https://api.example.com/api/auth/logout"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.example.com/api/auth/logout', 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/auth/logout",
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/auth/logout"
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/auth/logout")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/auth/logout")
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{
"message": "<string>"
}Client-side logout endpoint. Since Cognito uses stateless JWTs, there is no server-side token invalidation. The client is responsible for discarding stored tokens (access token, refresh token) to complete the logout process.
Authentication
This is a public endpoint that does not require authentication.Rate Limiting
This endpoint is not rate-limited.Request Body
This endpoint does not require a request body.Request Example
curl -X POST https://api.example.com/api/auth/logout
Response
Success Response (200 OK)
string
Confirmation messageAlways returns
"Logged out successfully"{
"message": "Logged out successfully"
}
Notes
- Server-side token invalidation is not supported. Cognito uses stateless JWTs that cannot be revoked before their expiration time.
- The client application must:
- Delete the access token from local storage/cookies
- Delete the refresh token from local storage/cookies
- Redirect the user to the login page or public landing page
- Existing access tokens will remain valid until they expire (typically 1 hour after issuance)
- For immediate invalidation, consider implementing a token blacklist on the server side, but this is not provided by default
- This endpoint always returns a success response, regardless of whether the user was previously authenticated
⌘I