Skip to content

Latest commit

 

History

History
23 lines (20 loc) · 34.6 KB

createkeyrequestbody.md

File metadata and controls

23 lines (20 loc) · 34.6 KB

CreateKeyRequestBody

Fields

Field Type Required Description Example
APIID string ✔️ Choose an API where this key should be created. api_123
Prefix *string To make it easier for your users to understand which product an api key belongs to, you can add prefix them.

For example Stripe famously prefixes their customer ids with cus_ or their api keys with sk_live_.

The underscore is automatically added if you are defining a prefix, for example: "prefix": "abc" will result in a key like abc_xxxxxxxxx
Name *string The name for your Key. This is not customer facing. my key
ByteLength *int64 The byte length used to generate your key determines its entropy as well as its length. Higher is better, but keys become longer and more annoying to handle. The default is 16 bytes, or 2^^128 possible combinations.
OwnerID *string : warning: ** DEPRECATED **: This will be removed in a future release, please migrate away from it as soon as possible.

Deprecated, use externalId
team_123
ExternalID *string Your user's Id. This will provide a link between Unkey and your customer record.
When validating a key, we will return this back to you, so you can clearly identify your user from their api key.
team_123
Meta map[string]any This is a place for dynamic meta data, anything that feels useful for you should go here {
"billingTier": "PRO",
"trialEnds": "2023-06-16T17:16:37.161Z"
}
Roles []string A list of roles that this key should have. If the role does not exist, an error is thrown [
"admin",
"finance"
]
Permissions []string A list of permissions that this key should have. If the permission does not exist, an error is thrown [
"domains.create_record",
"say_hello"
]
Expires *int64 You can auto expire keys by providing a unix timestamp in milliseconds. Once Keys expire they will automatically be disabled and are no longer valid unless you enable them again. 1623869797161
Remaining *int64 You can limit the number of requests a key can make. Once a key reaches 0 remaining requests, it will automatically be disabled and is no longer valid unless you update it.

Learn more
1000
Refill *operations.Refill Unkey enables you to refill verifications for each key at regular intervals. {
"interval": "daily",
"amount": 100
}
Ratelimit *operations.Ratelimit Unkey comes with per-key fixed-window ratelimiting out of the box. {
"type": "fast",
"limit": 10,
"duration": 60000
}
Enabled *bool Sets if key is enabled or disabled. Disabled keys are not valid. false
Recoverable *bool You may want to show keys again later. While we do not recommend this, we leave this option open for you.

In addition to storing the key's hash, recoverable keys are stored in an encrypted vault, allowing you to retrieve and display the plaintext later.

https://www.unkey.com/docs/security/recovering-keys for more information.
Environment *string Environments allow you to divide your keyspace.

Some applications like Stripe, Clerk, WorkOS and others have a concept of "live" and "test" keys to
give the developer a way to develop their own application without the risk of modifying real world
resources.

When you set an environment, we will return it back to you when validating the key, so you can
handle it correctly.