---
source_url: https://www.pubnub.com/docs/admin-api/v2025-11-15/create-a-new-keyset
title: Create a new keyset
---

# Create a new keyset

> For AI agents: documentation index at https://www.pubnub.com/llms-full.txt

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:write` and `keyset-secret:read` permissions on the app. The `secretKeys` field 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.

## Request

Example

```
{
  "keyset": {
    "name": "string",
    "type": "testing",
    "appId": "string",
    "id": "string",
    "publishKey": "string",
    "subscribeKey": "string",
    "createdAt": "string",
    "updatedAt": "string",
    "secretKeys": [
      {
        "secretKey": "string",
        "expiresAt": "string"
      }
    ]
  },
  "config": {
    "accessManager": {
      "enabled": false,
      "tokenRevoke": false
    },
    "files": {
      "enabled": false,
      "retention": 0,
      "region": "string"
    },
    "streamController": {
      "enabled": false,
      "wildcardSubscribe": false,
      "channelGroupLimit": 0
    },
    "appContext": {
      "enabled": false,
      "userMetadataEvents": false,
      "channelMetadataEvents": false,
      "membershipEvents": false,
      "disallowGetAllChannelMetadata": false,
      "disallowGetAllUserMetadata": false,
      "referentialIntegrity": false,
      "region": "string"
    },
    "apns": {
      "enabled": false,
      "teamId": "string",
      "authKeyId": "string",
      "filename": "string"
    },
    "fcm": {
      "filename": "string"
    },
    "messagePersistence": {
      "enabled": false,
      "includePresenceEvents": false,
      "deleteFromHistory": false,
      "retention": 0
    },
    "presence": {
      "enabled": false,
      "deltas": false,
      "generateLeaveOnDisconnect": false,
      "streamFiltering": false,
      "activeNoticeChannel": "string",
      "announceMax": 0,
      "interval": 0,
      "debounce": 0
    }
  }
}
```

Example

```
{
  "statusCode": 0,
  "error": "BadRequest",
  "message": [
    "string"
  ]
}
```

Example

```
{
  "statusCode": 0,
  "error": "Unauthorized",
  "message": [
    "string"
  ]
}
```

Example

```
{
  "statusCode": 0,
  "error": "Forbidden",
  "message": [
    "string"
  ]
}
```

Example

```
{
  "statusCode": 0,
  "error": "NotFound",
  "message": [
    "string"
  ]
}
```

Example

```
{
  "statusCode": 0,
  "error": "InternalError",
  "message": [
    "string"
  ]
}
```
