| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 | [role="xpack"][[security-api-saml-logout]]=== SAML logout API++++<titleabbrev>SAML logout</titleabbrev>++++Submits a request to invalidate an access token and refresh token.NOTE: This API is intended for use by custom web applications other than {kib}.If you are using {kib}, see the <<saml-guide-stack>>.[[security-api-saml-logout-request]]==== {api-request-title}`POST /_security/saml/logout`[[security-api-saml-logout-desc]]==== {api-description-title}This API invalidates the tokens that were generated for a user by the<<security-api-saml-authenticate,SAML authenticate API>>.If the SAML realm in {es} is configured accordingly and the SAML IdP supportsthis, the {es} response contains a URL to redirect the user to the IdPthat contains a SAML logout request (starting an SP-initiated SAML Single Logout).{es} exposes all the necessary SAML related functionality via the SAML APIs.These APIs are used internally by {kib} in order to provide SAML basedauthentication, but can also be used by other custom web applications or otherclients. See also <<security-api-saml-authenticate,SAML authenticate API>>,<<security-api-saml-prepare-authentication,SAML prepare authentication API>>,<<security-api-saml-invalidate,SAML invalidate API>>, and<<security-api-saml-complete-logout, SAML complete logout API>>.[[security-api-saml-logout-request-body]]==== {api-request-body-title}`token`::  (Required, string) The access token that was returned as a response to calling the  <<security-api-saml-authenticate,SAML authenticate API>>. Alternatively, the most  recent token that was received after refreshing the original one by using a  `refresh_token`.`refresh_token`::  (Optional, string) The refresh token that was returned as a response to calling the  <<security-api-saml-authenticate,SAML authenticate API>>. Alternatively, the  most recent refresh token that was received after refreshing the original access token.[[security-api-saml-logout-response-body]]==== {api-response-body-title}`redirect`::  (string) A URL that contains a SAML logout request as a parameter. The user  can use this URL to be redirected back to the SAML IdP and to initiate Single  Logout.[[security-api-saml-logout-example]]==== {api-examples-title}The following example invalidates the pair of tokens that were generated bycalling the <<security-api-saml-authenticate,SAML authenticate API>>with a successful SAML response:[source,console]--------------------------------------------------POST /_security/saml/logout{  "token" : "46ToAxZVaXVVZTVKOVF5YU04ZFJVUDVSZlV3",  "refresh_token" : "mJdXLtmvTUSpoLwMvdBt_w"}--------------------------------------------------// TEST[skip:can't test this without a valid SAML Response]The API returns the following response:[source,js]--------------------------------------------------{  "redirect" : "https://my-idp.org/logout/SAMLRequest=...."}--------------------------------------------------// NOTCONSOLE
 |