# Rotate the signing key of a federated credential or a private key JWT

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

Makes a new RS256 key that signs from now on, and keeps the old public key published for a day.

`POST /orgs/{org}/sso/connection/rotate-key`

## TL;DR

| Question | Answer |
|---|---|
| What does it do? | Rotate the signing key of a federated credential or a private key JWT. |
| What does it take? | `org` in the path. |
| 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` no connection, or one with a client secret, which has no key (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

Makes a new RS256 key that signs from now on, and keeps the old public key published for a day. A provider holding a pasted copy of the key needs the new one. Only for `federated` and `private_key_jwt`. The owner and admins.

## Path parameters

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

## Responses

| Status | Meaning | Body |
|---|---|---|
| 200 | The connection, with its new key. | [`SsoConnection`](https://docs.plotwork.dev/api/schemas.md#ssoconnection) |
| 400 | No connection, or one with a client secret, which has no key (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. |
| `credential` | `"client_secret" \| "federated" \| "private_key_jwt" \| null` | yes | What the connection proves itself with at the token endpoint: a client secret, a Microsoft Entra ID federated credential, or a private key JWT. OpenID Connect only. |
| `secretSet` | `boolean` | yes | True when an OpenID Connect client secret is stored. It is never returned. False for the other credentials and for SAML. |
| `tokenAuthMethod` | `"client_secret_basic" \| "client_secret_post" \| "private_key_jwt" \| null` | yes |  |
| `signingKey` | `SsoSigningKey` | yes | The connection's signing key, for `federated` and `private_key_jwt`; null otherwise. |
| `signingKey.kid` | `string` | yes |  |
| `signingKey.createdAt` | `integer` | yes | When the key was made: the last rotation, or when the credential was chosen. Milliseconds since the epoch. |
| `signingKey.publicJwk` | `SsoPublicJwk` | yes |  |
| `signingKey.publicJwk.kty` | `"RSA"` | yes |  |
| `signingKey.publicJwk.n` | `string` | yes | The modulus, base64url. |
| `signingKey.publicJwk.e` | `string` | yes | The public exponent, base64url. |
| `signingKey.publicJwk.kid` | `string` | yes | The key id: the key's RFC 7638 thumbprint. |
| `signingKey.publicJwk.alg` | `"RS256"` | yes |  |
| `signingKey.publicJwk.use` | `"sig"` | yes |  |
| `signingKey.publicKeyPem` | `string` | yes | The same public key as a PEM `PUBLIC KEY`, for a provider that takes a pasted key. |
| `signingKey.previousKid` | `string \| null` | yes | The key a rotation replaced, while it is still published (a day), or null. |
| `signingKey.previousExpiresAt` | `integer \| null` | yes | When the previous key leaves the JWKS, or null. |
| `warnings` | `"private_key_jwt_not_listed"[]` | yes | What the save noticed but did not refuse: `private_key_jwt_not_listed` when the provider's discovery document does not list `private_key_jwt`. Empty when read. |
| `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 |
