What’s changed
This release adds oauth.exchangeToken, so a scheduled job can replace an internal connection’s API token before it expires. Read Rotate an internal connection’s API token to set it up.
New capabilities
oauth.exchangeToken(#853)- Trades the connection’s current token (
subject_token) for a new one with the token exchange grant. The SDK signs the client assertion with yourprivate_key, so you don’t build a JWT yourself. private_keyis a PKCS #8 PEM string. EC keys must use P-256 and sign with ES256; RSA keys sign with RS256. Passkey_idto pick a signing key, or leave it out and Notion tries each of the connection’s keys.- Signing uses the Web Crypto API built into Node.js 22 and later. It adds no dependencies.
- New types:
OauthExchangeTokenParametersandOauthExchangeTokenResponse.
- Trades the connection’s current token (
missing_propertiesonpages.move(#850)pages.movetypes the optionalmissing_propertiesbody field ("add"or"omit"). With"omit", moving a page into a data source doesn’t add the source’s unmatched properties to its schema.
Compatibility
oauth.token,OauthTokenParameters, andOauthTokenResponseare unchanged. The token exchange grant has its own method becauseoauth.tokensends Basic auth, which Notion refuses on that grant.