[role="xpack"]
[[idp-saml-metadata]]
=== Generate SAML metadata for the IDP
++++
<titleabbrev>Generate SAML metadata for the IDP</titleabbrev>
++++
Generates a SAML metadata document for the Identity Provider, describing its configuration and capabilities.

[[idp-saml-metadata-request]]
==== {api-request-title}

`GET /_idp/saml/metadata/{sp_entity_id}`

[[idp-saml-metadata-prereqs]]
==== {api-prereq-title}

* To use this API, you must have a role that grants the `cluster:admin/idp/saml/metadata` privilege.

[[idp-saml-metadata-desc]]
==== {api-description-title}

This API generates a SAML metadata XML Document that can be consumed by a service provider in order
to be configured to work with this identity provider

[[idp-saml-metadata-path-params]]
==== {api-path-parms-title}

`sp_entity_id::
(string) The SAML entity Id of the service provider that will consume this SAML metadata document.

`acs`::
(Optional, string) The SAML Assertion Consumer Service URL of the service provider that will consume this SAML.
If this is not set, then this API will ignore any wildcard services and will fail if `sp_entity_id` is not a directly registered Service Provider.
metadata document.

[[idp-saml-metadata-example]]
==== {api-examples-title}

The following example generates a SAML metadata document to be consumed by the service provider with
entity Id `https://some.sp.org/`.

[source, console]
--------------------------------------------------------------------
GET /_idp/saml/metadata/https%3A%2F%2Fsome.sp.org%2F?acs=https%3A%2F%2Fsome.sp.org%2Fsaml%2Facs
--------------------------------------------------------------------
// TEST[skip:Do not enable identity provider for the docs cluster, at least not yet]

a successful call returns the SAML metadata as an XML String

[source, console-result]
--------------------------------------------------------------------
{
  "metadata" : "<?xml version="1.0" encoding="UTF-8"?><md:EntityDescriptor xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata" entityID="https://idp.org"><md:IDPSSODescriptor WantAuthnRequestsSigned="true" protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol"><md:KeyDescriptor use="signing"><ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#"><ds:X509Data><ds:X509Certificate> </ds:X509Certificate></ds:X509Data></ds:KeyInfo></md:KeyDescriptor><md:SingleLogoutService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" Location="https://idp.org/slo/post"/><md:NameIDFormat>urn:oasis:names:tc:SAML:2.0:nameid-format:persistent</md:NameIDFormat><md:NameIDFormat>urn:oasis:names:tc:SAML:2.0:nameid-format:transient</md:NameIDFormat><md:SingleSignOnService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect" Location="https://idp.org/sso/redirect"/></md:IDPSSODescriptor></md:EntityDescriptor>"
}
--------------------------------------------------------------------
// TESTRESPONSE[skip:Do not enable identity provider for the docs cluster, at least not yet]
