Logout
curl --request POST \
--url https://api.example.com/api/v1/auth/logoutimport requests
url = "https://api.example.com/api/v1/auth/logout"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.example.com/api/v1/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/v1/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/v1/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/v1/auth/logout")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/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_bodyAuthentication
Logout
Invalidate the current refresh token and clear the authentication cookie
POST
/
api
/
v1
/
auth
/
logout
Logout
curl --request POST \
--url https://api.example.com/api/v1/auth/logoutimport requests
url = "https://api.example.com/api/v1/auth/logout"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.example.com/api/v1/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/v1/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/v1/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/v1/auth/logout")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/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_bodyEndpoint
POST /api/v1/auth/logout
http://localhost:3000/api/v1
This endpoint does not use Bearer authentication. It requires the
refreshToken cookie issued at
login or email verification.Authentication
Include the refresh token cookie with the request:Cookie: refreshToken=YOUR_REFRESH_TOKEN
fetch('/api/v1/auth/logout', {
method: 'POST',
credentials: 'include',
});
Description
This endpoint:- verifies the refresh token from the cookie
- invalidates it in storage
- clears the
refreshTokencookie from the response
Response
Success Response (200 OK)
{
"success": true,
"data": {},
"message": "Logged out successfully",
"meta": {
"timestamp": "2026-04-23T20:00:00.000Z",
"path": "/auth/logout",
"method": "POST"
}
}
Error Responses
401 Unauthorized - Refresh Token Not Found
{
"success": false,
"error": {
"message": "Refresh token not found",
"statusCode": 401,
"timestamp": "2026-04-23T20:00:00.000Z",
"path": "/auth/logout",
"method": "POST",
"details": "Unauthorized"
}
}
401 Unauthorized - Invalid Refresh Token
{
"success": false,
"error": {
"message": "invalid token",
"statusCode": 401,
"timestamp": "2026-04-23T20:00:00.000Z",
"path": "/auth/logout",
"method": "POST",
"details": "Unauthorized"
}
}
Notes
Cookie-Based Logout: This endpoint is tied to the refresh token cookie, not the access token
in the Authorization header.
Frontend: After logout succeeds, clear any locally stored access token on the client side.
Related Endpoints
- Login - Create a new authenticated session
- Refresh Token - Rotate the access token using the cookie
