Create a new keyset
Creates a new keyset in a specified app either with default configuration or with optional configuration provided with request. For more configuration examples, see the config section of the API. In the response you will receive the keyset and the configuration with defaults set, if were not provided upon creation.
Note:
- Creating a keyset requires both
keyset:writeandkeyset-secret:readpermissions on the app. ThesecretKeysfield will always be included in the creation response. - Secret keys are only available at creation time and will not be returned in subsequent GET requests.
- file.region and appContext.region cannot be changed after initial setup.
| Header Parameters |
|---|
PubNub-Version string — REQUIREDPossible values: [ |
| Request Body — REQUIRED | |||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
keyset object — REQUIRED
| |||||||||||||||||||||||||||||||||||||||||||
config object
|
| Responses | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
201Success
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
400Bad Request Error
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
401UnauthorizedError
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
403ForbiddenError
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
404NotFoundError
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
500InternalErrorError
|
PubNub-Version*2025-11-15]keyset*config{
"keyset": {
"name": "My Production Keyset",
"type": "production",
"appId": "app_123456"
},
"config": {
"accessManager": {
"enabled": true,
"tokenRevoke": true
}
}
}keysetconfig{
"keyset": {
"name": "My Production Keyset",
"type": "production",
"appId": "app_123456",
"id": "keyset_abc123",
"publishKey": "pub-c-1234567890abcdef",
"subscribeKey": "sub-c-1234567890abcdef",
"createdAt": "2025-10-27T12:00:00Z",
"updatedAt": "2025-10-27T12:00:00Z",
"secretKeys": [
{
"secretKey": "sec-c-1234567890abcdef",
"expiresAt": null
}
]
},
"config": {
"accessManager": {
"enabled": true,
"tokenRevoke": true
},
"files": {
"enabled": true,
"retention": 90,
"region": "us-east-1"
},
"streamController": {
"enabled": true,
"wildcardSubscribe": true,
"channelGroupLimit": 50
},
"appContext": {
"enabled": true,
"userMetadataEvents": true,
"channelMetadataEvents": true,
"membershipEvents": true,
"disallowGetAllChannelMetadata": false,
"disallowGetAllUserMetadata": false,
"referentialIntegrity": true,
"region": "aws-iad-1"
},
"apns": {
"enabled": true,
"teamId": "ABCD1234EF",
"authKeyId": "XYZ9876ABC",
"filename": "AuthKey_XYZ9876ABC.p8"
},
"fcm": {
"filename": "firebase-service-account.json"
},
"messagePersistence": {
"enabled": true,
"includePresenceEvents": false,
"deleteFromHistory": true,
"retention": 30
},
"presence": {
"enabled": true,
"deltas": true,
"generateLeaveOnDisconnect": true,
"streamFiltering": true,
"activeNoticeChannel": null,
"announceMax": 20,
"interval": 30,
"debounce": 5
}
}
}statusCodeerrorView all values
"BadRequest"messageitemsstatusCodeerrorView all values
"Unauthorized"messageitemsstatusCodeerrorView all values
"NotFound"messageitemsstatusCodeerrorView all values
"InternalError"messageitems