Logout oauth — POST /v1/iam/oauth/logout

Ends a sign-in and sends the browser somewhere sensible.

POST /v1/iam/oauth/logout

Addresshttps://api.hanzo.ai/v1/iam/oauth/logout
MethodPOST
Operationpost_iam_oauth_logout
AuthAuthorization: Bearer $HANZO_API_KEY

Ends a sign-in and sends the browser somewhere sensible. Accepts GET or POST, so it works as a plain link.

It ACTUALLY signs you out — worth stating, because a logout that computes a redirect and answers {"status":"ok"} while ending no session and revoking no token is worse than none: the person on the shared machine believes it worked. Three things happen here, in this order:

  1. The browser session dies — sid revoked server-side AND the cookie expired (sessions.Clear). Server-side revocation is the load-bearing half: a copy of the cookie taken before logout must not still resolve.
  2. The relying party's tokens are revoked when an id_token_hint names it, so the refresh token cannot mint a fresh access token after the human left. Revocation state is authoritative — a JWT's exp still reads valid for days, so expiry is necessary but never sufficient.
  3. Only then is a redirect considered, and only to a REGISTERED uri.

The open-redirect guard: a redirect happens only when a VERIFIED id_token_hint (or client_id) identifies the application and that application has registered the target. Nobody can turn your logout link into a redirect to a site of their choosing.

A GET is the end-session navigation (OIDC RP-Initiated Logout 1.0 §2), so it always ends on a page: the registered address when one was asked for, else this issuer's sign-in page for the application being signed out of. A relying party therefore needs no configuration to sign someone out. A POST is also how a program signs out, so it keeps the JSON answer unless it asks for HTML.

Request

The document declares no body for POST /v1/iam/oauth/logout. The handler is typed in cloud but its shape is not yet emitted, so the fields are not listed here — ask MCP's describe for post_iam_oauth_logout, which answers from the running route.

Response

The document declares no response body for this operation. It answers 200 on success and the platform error shape on failure — see Errors.

Examples

hanzo iam oauth logout create
import { Configuration, IamApi } from 'hanzoai';

const api = new IamApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.postIamOauthLogout();
from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import IamApi

client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = IamApi(client).post_iam_oauth_logout()
cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)

resp, _, err := client.IamAPI.PostIamOauthLogout(context.Background()).Execute()
if err != nil {
	return err
}
use hanzo_client::apis::{configuration::Configuration, iam_api};

let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();

let result = iam_api::post_iam_oauth_logout(&cfg, Default::default()).await?;
import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.IamApi;

ApiClient client = new ApiClient();
client.setBearerToken(System.getenv("HANZO_API_KEY"));

var result = new IamApi(client).postIamOauthLogout();
curl -X POST https://api.hanzo.ai/v1/iam/oauth/logout \
  -H "Authorization: Bearer $HANZO_API_KEY"

MCP reaches iam through the iam tool, which names its 44 operations with its own verbs — this one among them, under a name only MCP declares. describe explains any of them:

curl -X POST https://api.hanzo.ai/v1/mcp \
  -H "Content-Type: application/json" \
  -d '{
       "jsonrpc": "2.0",
       "id": 1,
       "method": "tools/call",
       "params": {
         "name": "describe",
         "arguments": {
           "op": "list_iam_applications"
         }
       }
     }'

IAM API · All Hanzo APIs · Interactive reference

Was this page useful?