# Turn single sign-on on or off, and set Require SSO and who joins on first sign-in

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

Each field left out keeps its value.

`PATCH /orgs/{org}/sso/connection`

## TL;DR

| Question | Answer |
|---|---|
| What does it do? | Turn single sign-on on or off, and set Require SSO and who joins on first sign-in. |
| What does it take? | A JSON body of type [`SsoSwitchesBody`](https://docs.plotwork.dev/api/schemas.md#ssoswitchesbody). |
| 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, no connection is set up, or require sso cannot be turned on yet (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; `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

Each field left out keeps its value. Require SSO needs the connection on and a verified domain; turning the connection off turns Require SSO off. People who join on first sign-in are members or readers, never admins, within the member limit.

## Path parameters

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

## Request body

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

| Field | Type | Required | Description |
|---|---|---|---|
| `enabled` | `boolean` | no |  |
| `requireSso` | `boolean` | no |  |
| `jit` | `boolean` | no |  |
| `jitRole` | `"member" \| "reader"` | no |  |

## Responses

| Status | Meaning | Body |
|---|---|---|
| 200 | The connection. | [`SsoConnection`](https://docs.plotwork.dev/api/schemas.md#ssoconnection) |
| 400 | The body is not valid, no connection is set up, or Require SSO cannot be turned on yet (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) |
| 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 |
