Skip to main content
An internal connection’s API token can expire. Token rotation replaces it before it does. This page explains how rotation works. To set it up, follow Rotate an internal connection’s API token.

Token lifetimes

Each internal connection has a setting in the Developer portal for how long each new API token lasts: Token expiration when you create the connection, and New token expiration on the connection’s page after that. The options are 7 days, 30 days, 90 days, 180 days, 1 year, and No expiration, the default. The setting applies to every new token, whether it comes from token exchange or from Refresh in the Developer portal. Existing tokens keep their expiration unless you also turn on Apply expiration to current API token. Then the current token gets the new lifetime, counted from when you save, and so does an older token that token exchange hasn’t revoked yet. A token that Refresh or automatic rotation replaced keeps its expiration. The API rejects an expired token with the same 401 error as an invalid one, so store each token’s expiry from expires_in alongside it.

Expiry warnings

Notion warns a connection’s owners 7 days and 1 day before its API token expires, by email and in their Notion inbox. The warning links to the connection in the Developer portal, where they can select Refresh to get a new token. A token gets only the warnings that fall in the second half of its lifetime, so a 7-day token gets only the 1-day warning. Tokens with No expiration get none. Warnings go to the people on the connection’s Owners tab, including members of groups added there. If nobody was added, they go to the connection’s creator, if they can still manage it. If none of these people are still in the workspace, they go to the workspace owners. Notion doesn’t warn about a token that a newer token has replaced, through token exchange or Refresh. If your rotation job runs on schedule and the lifetime is longer than the schedule, you won’t get warnings. A warning means the job hasn’t replaced the token yet.

Token exchange

Token exchange trades the connection’s current API token for a new one with a fresh lifetime. Your automation sends the current token to POST /v1/oauth/token, using the token exchange grant from RFC 8693. Only internal connections can use token exchange. Public connections use the refresh token grant instead.

Signing keys and client assertions

A token exchange request must prove that it has the current token and that it comes from the connection’s owner. The token proves the first, and a client assertion proves the second. A client assertion is a short-lived JSON Web Token (JWT) that your automation signs with a private key for each request. You register the matching public key with the connection ahead of time. Notion calls these public keys the connection’s signing keys, and checks each assertion’s signature against them. Notion stores only public keys, so the private key never leaves your system. This method is private_key_jwt, from RFC 7523. Because of the signature, a token can’t create another token on its own. Someone who copies a token from a log can use it until it expires, but can’t exchange it without the private key. A connection can have more than one signing key, so you can replace a key without a gap: add the new key, move your automation to it, then revoke the old key. Each signing key has a key ID (kid) that a client assertion can name, so Notion knows which key to check. For key types, limits, and steps, see Rotate signing keys.

When the old token stops working

Token exchange doesn’t revoke the old token right away. The old token keeps working until the new token makes its first successful API call. This gives your automation time to store the new token and hand it to every process that uses it. These rules keep at most two tokens live at a time:
  • If you exchange the same token again before its newer token is used, Notion revokes the unused newer token and returns another. So a job that fails after the exchange can run again with the old token.
  • If you exchange a token that has never been used, Notion revokes the token it replaced. Exchanging counts as using it.
Refresh in the Developer portal works differently. It issues a separate new token, and the existing tokens expire at the end of the grace period you choose, or sooner if they already expire before then. Token exchange stops accepting the existing tokens right away, so put the token from Refresh in your secret store before your next rotation runs. Because the first API call with the new token revokes the old one, the order of your job’s steps matters. See Store the new token safely.

Automatic rotation

With automatic rotation, Notion creates each new token, and a person moves your app to it. Only internal API connections have this setting, not workspace MCP connections. To turn it on, open the connection in the Developer portal, select New token expiration, and turn on Rotate automatically. You can also turn it on under Token expiration when you create the connection. Automatic rotation needs a token expiration of 30 days or more. Changing the expiration to 7 days or No expiration turns it off. If the current token never expires, or expires too soon to rotate, turning on Rotate automatically also turns on Apply expiration to current API token, so the current token can rotate too. Seven days before the current token expires, Notion creates a new token and notifies the people who get expiry warnings, by email and in their inbox. The connection’s page shows the rotation date under the API token. The current token keeps working until it expires, so copy the new token from the connection’s page and switch your app to it before then. You can’t turn on automatic rotation while the connection has a signing key, because those connections rotate through token exchange. If you add a signing key after turning it on, Notion stops rotating the token and sends expiry warnings instead. Use automatic rotation when your app stores a static token and a person can update it within a week. Use token exchange when your app can replace its own token.