Portal
Portal Logout
Logout from the customer portal and invalidate the current session.
POST
/
portal
/
api
/
logout
Log out of the customer portal
curl --request POST \
--url https://billing.example.com/portal/api/logout \
--cookie portal_session=import requests
url = "https://billing.example.com/portal/api/logout"
headers = {"cookie": "portal_session="}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {cookie: 'portal_session='}};
fetch('https://billing.example.com/portal/api/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://billing.example.com/portal/api/logout",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_COOKIE => "portal_session=",
]);
$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://billing.example.com/portal/api/logout"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("cookie", "portal_session=")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://billing.example.com/portal/api/logout")
.header("cookie", "portal_session=")
.asString();require 'uri'
require 'net/http'
url = URI("https://billing.example.com/portal/api/logout")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["cookie"] = 'portal_session='
response = http.request(request)
puts response.read_body{
"message": "<string>"
}This endpoint requires an active portal session. No request body is needed.
Example Request
curl -X POST https://api.recurso.dev/portal/api/logout \
-H "Cookie: portal_session=ps_abc123..."
Response
Returns a confirmation message. The portal session cookie is invalidated and can no longer be used for authenticated requests.{
"message": "Logged out successfully"
}
Error Responses
| Status | Description |
|---|---|
401 Unauthorized | No active portal session found. The session may have already expired or been invalidated. |
500 Internal Server Error | An unexpected error occurred while invalidating the session. |
After logout, any subsequent requests using the same portal session cookie will
receive a
401 Unauthorized response. The customer must log in again to access
portal features.⌘I
Log out of the customer portal
curl --request POST \
--url https://billing.example.com/portal/api/logout \
--cookie portal_session=import requests
url = "https://billing.example.com/portal/api/logout"
headers = {"cookie": "portal_session="}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {cookie: 'portal_session='}};
fetch('https://billing.example.com/portal/api/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://billing.example.com/portal/api/logout",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_COOKIE => "portal_session=",
]);
$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://billing.example.com/portal/api/logout"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("cookie", "portal_session=")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://billing.example.com/portal/api/logout")
.header("cookie", "portal_session=")
.asString();require 'uri'
require 'net/http'
url = URI("https://billing.example.com/portal/api/logout")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["cookie"] = 'portal_session='
response = http.request(request)
puts response.read_body{
"message": "<string>"
}