# Set up a SAML identity provider

> Page: https://docs.plotwork.dev/api/put-orgs-org-sso-saml. Index of every page: https://docs.plotwork.dev/llms.txt

Reads the provider's metadata from its HTTPS address or pasted XML and stores the entity id, the sign-in service and the signing certificates.

`PUT /orgs/{org}/sso/saml`

## TL;DR

| Question | Answer |
|---|---|
| What does it do? | Set up a SAML identity provider. |
| What does it take? | A JSON body of type [`SamlConnectionBody`](https://docs.plotwork.dev/api/schemas.md#samlconnectionbody). |
| What does it return? | Status 200 with a body of type [`SsoConnection`](https://docs.plotwork.dev/api/schemas.md#ssoconnection). |
| What can go wrong? | `400` the body is not valid, or no metadata the first time (sso.invalid); `401` not signed in; `403` a member or a reader (orgs.forbidden), a plan without single sign-on (plan.sso_not_included), or the request came from an origin that may not make changes; `404` no such organisation, or the caller is not a member of it; `422` the metadata cannot be fetched or used (sso.metadata_invalid); `429` too many requests; `503` single sign-on is not set up on this server (sso.unavailable), or organisations are not. Every failure uses the one error envelope. |

## What it does

Reads the provider's metadata from its HTTPS address or pasted XML and stores the entity id, the sign-in service and the signing certificates. `emailAttribute` names the attribute with the address; null reads the name identifier. A new connection is off until it is turned on. Enterprise; the owner and admins.

## Path parameters

| Field | Type | Required | Description |
|---|---|---|---|
| `org` | `string` | yes | The organisation's id or its slug. |

## Request body

The body has the type [`SamlConnectionBody`](https://docs.plotwork.dev/api/schemas.md#samlconnectionbody).

| Field | Type | Required | Description |
|---|---|---|---|
| `metadataUrl` | `string` | no | The address of the provider's metadata, fetched over HTTPS. Give this or `metadataXml`, or neither to keep the stored metadata. at least 9 characters; at most 500 characters. |
| `metadataXml` | `string` | no | The provider's metadata XML, pasted. at least 1 character; at most 262144 characters. |
| `emailAttribute` | `string \| null` | no | The attribute that carries the address. Null reads the name identifier; left out keeps the stored choice. at least 1 character; at most 200 characters. |

## Responses

| Status | Meaning | Body |
|---|---|---|
| 200 | The connection. | [`SsoConnection`](https://docs.plotwork.dev/api/schemas.md#ssoconnection) |
| 400 | The body is not valid, or no metadata the first time (sso.invalid). | [`ErrorResponse`](https://docs.plotwork.dev/api/schemas.md#errorresponse) |
| 401 | Not signed in. | [`ErrorResponse`](https://docs.plotwork.dev/api/schemas.md#errorresponse) |
| 403 | A member or a reader (orgs.forbidden), a plan without single sign-on (plan.sso_not_included), or the request came from an origin that may not make changes. | [`ErrorResponse`](https://docs.plotwork.dev/api/schemas.md#errorresponse) |
| 404 | No such organisation, or the caller is not a member of it. | [`ErrorResponse`](https://docs.plotwork.dev/api/schemas.md#errorresponse) |
| 422 | The metadata cannot be fetched or used (sso.metadata_invalid). | [`ErrorResponse`](https://docs.plotwork.dev/api/schemas.md#errorresponse) |
| 429 | Too many requests. | [`ErrorResponse`](https://docs.plotwork.dev/api/schemas.md#errorresponse) |
| 503 | Single sign-on is not set up on this server (sso.unavailable), or organisations are not. | [`ErrorResponse`](https://docs.plotwork.dev/api/schemas.md#errorresponse) |

## Response body

A 200 answer has the type [`SsoConnection`](https://docs.plotwork.dev/api/schemas.md#ssoconnection).

| Field | Type | Required | Description |
|---|---|---|---|
| `protocol` | `"oidc" \| "saml"` | yes | OpenID Connect or SAML 2.0. One connection, one protocol. |
| `issuer` | `string` | yes | The OpenID Connect issuer, or the SAML provider's entity id. |
| `clientId` | `string \| null` | yes | OpenID Connect only. |
| `secretSet` | `boolean` | yes | True when an OpenID Connect client secret is stored. It is never returned. Always false for SAML. |
| `tokenAuthMethod` | `"client_secret_basic" \| "client_secret_post" \| null` | yes |  |
| `saml` | `SamlConnection` | yes | SAML only. |
| `saml.entityId` | `string` | yes | The provider's entity id, which every `Issuer` must equal. |
| `saml.ssoUrl` | `string` | yes | The provider's sign-in service on the redirect binding. |
| `saml.certificates` | `object[]` | yes |  |
| `saml.certificates[].fingerprint` | `string` | yes | SHA-256 of the certificate, as providers show it. |
| `saml.certificates[].notAfter` | `integer` | yes | When the certificate expires, in milliseconds since the epoch. Shown, not enforced. |
| `saml.emailAttribute` | `string \| null` | yes | The attribute that carries the address, or null when the name identifier does. |
| `saml.metadataUrl` | `string \| null` | yes | Where the metadata was fetched from, or null when it was pasted. |
| `enabled` | `boolean` | yes |  |
| `requireSso` | `boolean` | yes |  |
| `jit` | `boolean` | yes |  |
| `jitRole` | `"member" \| "reader"` | yes |  |
| `updatedAt` | `integer` | yes |  |

## See also

| Doc | Why |
|---|---|
| [API reference](https://docs.plotwork.dev/api/reference.md) | Every endpoint, and the error envelope |
| [Schemas](https://docs.plotwork.dev/api/schemas.md) | Every request and response type |
| [Tool reference](https://docs.plotwork.dev/mcp/tools.md) | The operations as callable tools |
