---
type: api
title: Create SAML service provider metadata
description: Generate SAML metadata for a SAML 2.0 Service Provider.
url: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/elasticsearch/v8/operation/operation-security-saml-service-provider-metadata
resource: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/elasticsearch/v8/operation/operation-security-saml-service-provider-metadata
products:
  - Elasticsearch
---

# Create SAML service provider metadata

Availability: Generally available since 7.11

## Paths

- `GET` `/_security/saml/metadata/{realm_name}`

#### Path parameters

- `realm_name` (string) — required
  The name of the SAML realm in Elasticsearch.

## Description

Generate SAML metadata for a SAML 2.0 Service Provider.

The SAML 2.0 specification provides a mechanism for Service Providers to describe their capabilities and configuration using a metadata file.
This API generates Service Provider metadata based on the configuration of a SAML realm in Elasticsearch.

## Authentication

- Api key: `Authorization: <value>`
  Elasticsearch APIs support key-based authentication.
  You must create an API key and use the encoded value in the request header.
  For example:
  
  
  ```
  curl -X GET "${ES_URL}/_cat/indices?v=true" \
    -H "Authorization: ApiKey ${API_KEY}"
  ```
  
  To get API keys, use the `/_security/api_key` APIs.
- Basic: `Authorization: Basic <credentials>`
- Bearer: `Authorization: Bearer <token>`
  Elasticsearch APIs support the use of bearer tokens in the `Authorization` HTTP header to authenticate with the API.
  For examples, refer to [Token-based authentication services](https://www.elastic.co/guide/en/elasticsearch/reference/current/token-authentication-services.html)

## Response

`application/json`

- `metadata` (string)
  An XML string that contains a SAML Service Provider's metadata for the realm.
## Code examples

#### Console

```console
POST /_security/profile/u_P_0BMHgaOK3p7k-PFWUCbw9dQ-UFjt01oWJ_Dp2PmPc_0/_data
```

#### JavaScript

```javascript
const response = await client.security.updateUserProfileData({
  uid: "u_P_0BMHgaOK3p7k-PFWUCbw9dQ-UFjt01oWJ_Dp2PmPc_0",
});
```

#### Python

```python
resp = client.security.update_user_profile_data(
    uid="u_P_0BMHgaOK3p7k-PFWUCbw9dQ-UFjt01oWJ_Dp2PmPc_0",
)
```

#### curl

```curl
curl -X POST "$ELASTICSEARCH_URL/_security/profile/u_P_0BMHgaOK3p7k-PFWUCbw9dQ-UFjt01oWJ_Dp2PmPc_0/_data" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY"
```

#### Java

```java
client.security().updateUserProfileData(u -> u
    .uid("u_P_0BMHgaOK3p7k-PFWUCbw9dQ-UFjt01oWJ_Dp2PmPc_0")
);
```

#### C#

```c#
var response = await client.Security.UpdateUserProfileDataAsync(uid: "u_P_0BMHgaOK3p7k-PFWUCbw9dQ-UFjt01oWJ_Dp2PmPc_0");
```

#### PHP

```php
$resp = $client->security()->updateUserProfileData([
    "uid" => "u_P_0BMHgaOK3p7k-PFWUCbw9dQ-UFjt01oWJ_Dp2PmPc_0",
]);
```

#### Ruby

```ruby
response = client.security.update_user_profile_data(
  uid: "u_P_0BMHgaOK3p7k-PFWUCbw9dQ-UFjt01oWJ_Dp2PmPc_0"
)
```

## Response examples

#### Saml service provider metadata response example1

A successful response from `POST /_security/profile/u_P_0BMHgaOK3p7k-PFWUCbw9dQ-UFjt01oWJ_Dp2PmPc_0/_data`, which indicates that the request is acknowledged.

```json
{
  "acknowledged": true
}
```

