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 same401 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 toPOST /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 isprivate_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.