Skip to main content
POST
/
keys
Generate key
curl --request POST \
  --url https://api.datkey.dev/keys \
  --header 'Content-Type: application/json' \
  --data '
{
  "api_id": "{api_id}",
  "name": "{api_name}",
  "prefix": "prefix",
  "length": 16,
  "meta": {
    "user_id": "123456"
  },
  "expires_at": 123,
  "verification_limit": 123
}
'
{
  "key": {
    "id": "<key_id>",
    "name": "<key_name>",
    "key": "flox_sk_05ad2bfxxxxxxxx",
    "prefix": "flox_sk",
    "length": 16,
    "verifications": 0,
    "verification_limit": null,
    "expires_at": 1733237153,
    "meta": null,
    "created_at": "2023-12-05T11:31:23.000000Z",
    "updated_at": "2023-12-05T11:31:23.000000Z"
  }
}

Documentation Index

Fetch the complete documentation index at: https://docs.datkey.dev/llms.txt

Use this file to discover all available pages before exploring further.

The key returned would be show unencrypted the first time you generate it, ensure you show it to your user because it won’t be show to you again.

Headers

x-api-key
string

your workspace API key

Body

application/json
api_id
string
required

API ID from your dashboard

Example:

"{api_id}"

name
string
required

A name you would like to assign to the key

Example:

"{api_name}"

prefix
string

A string that would be prefixed to you key (prefix_keyxxxx)

Example:

"prefix"

length
integer
default:16

how long you want you key to be, minimum of 16

Required range: 16 <= x <= 255
meta
object

a object for you to pass values that would be meaningful to you

Example:
{ "user_id": "123456" }
expires_at
integer<int64>

a unix time stamp in the future of when you want the key to expire

verification_limit
integer<int64>

maximum verification allowed for this key

Response

OK

api_id
string

The ID of the API the key belongs to

Example:

"{api_id}"

name
string

The name assigned to the key

Example:

"{api_name}"

prefix
string

The prefix assigned to the key

Example:

"prefix"

length
integer
default:16

The length assigned to the key

Required range: 16 <= x <= 255
meta
object

extra details you passed via the meta attribute

Example:
{ "user_id": "123456" }
expires_at
integer<int64>

Unix timestamp of when the key expires, returns null when not set

verification_limit
integer<int64>

maximum verification allowed for this key, returns null when not set