---
type: api
title: Logout of SAML completely
description: Verifies the logout response sent from the SAML IdP.
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v9/operation/operation-security-saml-complete-logout
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v9/operation/operation-security-saml-complete-logout
products:
  - Elasticsearch
---

# Logout of SAML completely

Availability: 7.14+

## Paths

- `POST` `/_security/saml/complete_logout`

- [Api key auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v9/authentication#apikeyauth)
- [Basic auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v9/authentication#basicauth)
- [Bearer auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v9/authentication#bearerauth)

## Description

Verifies the logout response sent from the SAML IdP.

NOTE: This API is intended for use by custom web applications other than Kibana.
If you are using Kibana, refer to the documentation for configuring SAML single-sign-on on the Elastic Stack.

The SAML IdP may send a logout response back to the SP after handling the SP-initiated SAML Single Logout.
This API verifies the response by ensuring the content is relevant and validating its signature.
An empty response is returned if the verification process is successful.
The response can be sent by the IdP with either the HTTP-Redirect or the HTTP-Post binding.
The caller of this API must prepare the request accordingly so that this API can handle either of them.

[More about SAML authentication](https://www.elastic.co/docs/deploy-manage/users-roles/cluster-or-deployment-auth/saml)

## Request Body

`application/json`

- `realm` (string) — required
  The name of the SAML realm in Elasticsearch for which the configuration is used to verify the logout response.
- `ids` (string Ids) — required
  A JSON array with all the valid SAML Request Ids that the caller of the API has for the current user.
- `query_string` (string) — optional
  If the SAML IdP sends the logout response with the HTTP-Redirect binding, this field must be set to the query string of the redirect URI.
- `content` (string) — optional
  If the SAML IdP sends the logout response with the HTTP-Post binding, this field must be set to the value of the SAMLResponse form parameter from the logout response.

## Response

## Code Examples

#### Console

```console
POST /_security/saml/complete_logout
{
  "realm": "saml1",
  "ids": [ "_1c368075e0b3..." ],
  "query_string": "SAMLResponse=fZHLasMwEEVbfb1bf...&SigAlg=http%3A%2F%2Fwww.w3.org%2F2000%2F09%2Fxmldsig%23rsa-sha1&Signature=CuCmFn%2BLqnaZGZJqK..."
}
```

#### JavaScript

```javascript
const response = await client.security.samlCompleteLogout({
  realm: "saml1",
  ids: ["_1c368075e0b3..."],
  query_string:
    "SAMLResponse=fZHLasMwEEVbfb1bf...&SigAlg=http%3A%2F%2Fwww.w3.org%2F2000%2F09%2Fxmldsig%23rsa-sha1&Signature=CuCmFn%2BLqnaZGZJqK...",
});
```

#### Python

```python
resp = client.security.saml_complete_logout(
    realm="saml1",
    ids=[
        "_1c368075e0b3..."
    ],
    query_string="SAMLResponse=fZHLasMwEEVbfb1bf...&SigAlg=http%3A%2F%2Fwww.w3.org%2F2000%2F09%2Fxmldsig%23rsa-sha1&Signature=CuCmFn%2BLqnaZGZJqK...",
)
```

#### curl

```curl
curl -X POST "$ELASTICSEARCH_URL/_security/saml/complete_logout" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "realm": "saml1",
    "ids": [
      "_1c368075e0b3..."
    ],
    "query_string": "SAMLResponse=fZHLasMwEEVbfb1bf...\u0026SigAlg=http%3A%2F%2Fwww.w3.org%2F2000%2F09%2Fxmldsig%23rsa-sha1\u0026Signature=CuCmFn%2BLqnaZGZJqK..."
  }'
```

#### Java

```java
client.security().samlCompleteLogout(s -> s
    .ids("_1c368075e0b3...")
    .queryString("SAMLResponse=fZHLasMwEEVbfb1bf...&SigAlg=http%3A%2F%2Fwww.w3.org%2F2000%2F09%2Fxmldsig%23rsa-sha1&Signature=CuCmFn%2BLqnaZGZJqK...")
    .realm("saml1")
);
```

#### C#

```c#
var response = await client.Security
    .SamlCompleteLogoutAsync(d1 => d1
        .Ids(new[] { "_1c368075e0b3..." })
        .QueryString("SAMLResponse=fZHLasMwEEVbfb1bf...&SigAlg=http%3A%2F%2Fwww.w3.org%2F2000%2F09%2Fxmldsig%23rsa-sha1&Signature=CuCmFn%2BLqnaZGZJqK...")
        .Realm("saml1")
    );
```

#### PHP

```php
$resp = $client->security()->samlCompleteLogout([
    "body" => [
        "realm" => "saml1",
        "ids" => array(
            "_1c368075e0b3...",
        ),
        "query_string" => "SAMLResponse=fZHLasMwEEVbfb1bf...&SigAlg=http%3A%2F%2Fwww.w3.org%2F2000%2F09%2Fxmldsig%23rsa-sha1&Signature=CuCmFn%2BLqnaZGZJqK...",
    ],
]);
```

#### Ruby

```ruby
response = client.security.saml_complete_logout(
  body: {
    "realm": "saml1",
    "ids": [
      "_1c368075e0b3..."
    ],
    "query_string": "SAMLResponse=fZHLasMwEEVbfb1bf...&SigAlg=http%3A%2F%2Fwww.w3.org%2F2000%2F09%2Fxmldsig%23rsa-sha1&Signature=CuCmFn%2BLqnaZGZJqK..."
  }
)
```

