Rotate secret key
Rotates the keyset's secret key. Supports two rotation modes depending on whether an expiration time is provided:
Rotation with Overlap (paid plan required):
When expiresAt is provided:
- The current permanent secret key is assigned the specified expiration time
- A new permanent (non-expiring) secret key becomes the current key and is returned in the response
- You may replace the previous secret key with the new one without downtime.
Requirements:
- Requires a paid plan
- Maximum 5 rotated secret keys per keyset
- Expiration must be at least 60 seconds in the future
- Expiration must be at most 366 days in the future
Immediate Rotation:
When expiresAt is NOT provided:
- The current secret key is immediately replaced with a new randomly generated secret key
- The old secret key becomes invalid
- There is no overlap period. We recommend you use this in development and testing environments
| Path Parameters |
|---|
keysetId string — REQUIREDa string to be decoded into a number |
| Header Parameters |
|---|
PubNub-Version string — REQUIREDPossible values: [ |
| Request Body — REQUIRED |
|---|
expiresAt date-timePossible values: Value must match regular expression Timestamp in ISO 8601 UTC format. Must end with "Z" to indicate UTC timezone. |
| Responses | ||||
|---|---|---|---|---|
201Success
| ||||
400Bad Request Error
| ||||
401UnauthorizedError
| ||||
403ForbiddenError
| ||||
404NotFoundError
| ||||
500InternalErrorError
|
PubNub-Version*2025-11-01]keysetId*expiresAtsecretKey{
"secretKey": "sec-c-abcd123"
}statusCodeerrorView all values
"BadRequest"messageitemsstatusCodeerrorView all values
"Unauthorized"messageitemsstatusCodeerrorView all values
"NotFound"messageitemsstatusCodeerrorView all values
"InternalError"messageitems