Create Key
POST
/v1/keys
const url = 'https://example.com/v1/keys';const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"name":"example","env":"test","scopes":["example"],"tenantId":"example","createdBy":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://example.com/v1/keys \ --header 'Content-Type: application/json' \ --data '{ "name": "example", "env": "test", "scopes": [ "example" ], "tenantId": "example", "createdBy": "example" }'Mint an SDK API key (pn_live_… / pn_test_…). Only the salted hash
is stored — the plaintext is returned ONCE here and is unrecoverable after.
Request Body required
Section titled “Request Body required ” Media type application/json
CreateKeyRequest
Mint a new SDK API key. env selects the prefix (live -> pn_live_,
test -> pn_test_). scopes is a free-form allowlist the SDK presents;
deny-by-default — an empty list grants nothing. The plaintext is returned ONCE.
Responses
Section titled “ Responses ”Successful Response
Media type application/json
CreateKeyResponse
Create/rotate response. plaintext is shown EXACTLY ONCE — it is not
stored (only its salted hash is) and can never be retrieved again.
object
key
required
ApiKeyRecord
The browser-/SDK-safe view of a key. The plaintext and its hash are NEVER in here — only a masked display string + the last four chars.
object
id
required
Id
string
name
required
Name
string
env
required
Env
string
prefix
required
Prefix
string
masked
required
Masked
string
last4
required
Last4
string
scopes
Scopes
Array<string>
status
required
Status
string
createdAt
required
Createdat
string
plaintext
required
Plaintext
string
Example generated
{ "key": { "id": "example", "name": "example", "env": "example", "prefix": "example", "masked": "example", "last4": "example", "scopes": [ "example" ], "status": "example", "tenantId": "example", "createdBy": "example", "createdAt": "example", "lastUsedAt": "example", "revokedAt": "example", "revokedBy": "example", "rotatedAt": "example", "rotatedFrom": "example" }, "plaintext": "example"}Validation Error
Media type application/json
HTTPValidationError
object
detail
Detail
Array<object>
ValidationErrorobject
loc
required
Location
Array
msg
required
Message
string
type
required
Error Type
string
input
Input
ctx
Context
object
Example generated
{ "detail": [ { "loc": [ "example" ], "msg": "example", "type": "example", "input": "example", "ctx": {} } ]}