---
type: api
title: SAML callback
description: Accepts a callback request from an identity provider and authenticates the user.
url: https://www.elastic.co/elastic/docs-builder/docs/4641/api/doc/cloud-enterprise/v4/operation/operation-saml-callback
resource: https://www.elastic.co/elastic/docs-builder/docs/4641/api/doc/cloud-enterprise/v4/operation/operation-saml-callback
products:
  - Elastic Cloud Enterprise
---

# SAML callback

Authentication: required

## Paths

- `POST` `/users/auth/saml/_callback`

## Description

Accepts a callback request from an identity provider and authenticates the user.

## Request body

`application/x-www-form-urlencoded`

- `SAMLResponse` (string) — required
  A message issued by the identity provider to the service provider
- `RelayState` (string) — optional
  The optional relay state that the API (service provider) sent to the identity provider.

## Responses

#### `302`

Redirects to the UI endpoint with an authorization token in the fragment and the relay state, if it was specified during the initialization.

`application/json`

Type: `object`

#### `401`

The supplied SAML response is invalid. (code: `root.unauthenticated`)

`application/json`

- `errors` (object[])
  A list of errors that occurred in the failing request
  - `code` (string)
    A structured code representing the error type that occurred
  - `message` (string)
    A human readable message describing the error that occurred
  - `fields` (string[])
    If the error can be tied to a specific field or fields in the user request, this lists those fields
##### Response headers

- `x-cloud-error-codes` (enum)
  The error codes associated with the response

#### `501`

The administrator needs to configure the authentication cluster. (code: `authc.no_authentication_cluster`)

`application/json`

- `errors` (object[])
  A list of errors that occurred in the failing request
  - `code` (string)
    A structured code representing the error type that occurred
  - `message` (string)
    A human readable message describing the error that occurred
  - `fields` (string[])
    If the error can be tied to a specific field or fields in the user request, this lists those fields
##### Response headers

- `x-cloud-error-codes` (enum)
  The error codes associated with the response

#### `502`

The authentication cluster failed to process the request. The response body contains details about the error. (code: `authc.authentication_cluster_error`)

`application/json`

- `errors` (object[])
  A list of errors that occurred in the failing request
  - `code` (string)
    A structured code representing the error type that occurred
  - `message` (string)
    A human readable message describing the error that occurred
  - `fields` (string[])
    If the error can be tied to a specific field or fields in the user request, this lists those fields
##### Response headers

- `x-cloud-error-codes` (enum)
  The error codes associated with the response

## Code examples

#### curl

```curl
curl -X POST "${API_URL}/users/auth/saml/_callback" \
  -u "${USERNAME}:${PASSWORD}"
```

## Response examples

#### 302

`application/json`

Generated from the API spec. Values are representative. Unions use the first variant; deeply nested or large bodies may omit fields.

```json
{}
```

#### 401

`application/json`

Generated from the API spec. Values are representative. Unions use the first variant; deeply nested or large bodies may omit fields.

```json
{
  "errors": [
    {
      "code": "string",
      "message": "string",
      "fields": [
        "string"
      ]
    }
  ]
}
```

#### 501

`application/json`

Generated from the API spec. Values are representative. Unions use the first variant; deeply nested or large bodies may omit fields.

```json
{
  "errors": [
    {
      "code": "string",
      "message": "string",
      "fields": [
        "string"
      ]
    }
  ]
}
```

#### 502

`application/json`

Generated from the API spec. Values are representative. Unions use the first variant; deeply nested or large bodies may omit fields.

```json
{
  "errors": [
    {
      "code": "string",
      "message": "string",
      "fields": [
        "string"
      ]
    }
  ]
}
```

