> ## 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.

# Generate Key

> 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.


## OpenAPI

````yaml POST /keys
openapi: 3.0.0
info:
  title: Datkey Dev
  version: 1.0.0
servers:
  - url: https://api.datkey.dev
security: []
tags:
  - name: keys
paths:
  /keys:
    post:
      tags:
        - keys
      summary: Generate key
      parameters:
        - name: x-api-key
          in: header
          schema:
            type: string
          description: your workspace API key
          example: <api_key>
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
                - api_id
              properties:
                api_id:
                  type: string
                  example: '{api_id}'
                  description: API ID from your dashboard
                name:
                  type: string
                  example: '{api_name}'
                  description: A name you would like to assign to the key
                prefix:
                  type: string
                  example: prefix
                  description: A string that would be prefixed to you key (prefix_keyxxxx)
                length:
                  type: integer
                  minimum: 16
                  maximum: 255
                  default: 16
                  description: how long you want you key to be, minimum of 16
                meta:
                  type: object
                  additionalProperties:
                    nullable: true
                  example:
                    user_id: '123456'
                  description: >-
                    a object for you to pass values that would be meaningful to
                    you
                expires_at:
                  type: integer
                  format: int64
                  additionalProperties:
                    nullable: true
                  description: >-
                    a unix time stamp in the future of when you want the key to
                    expire
                verification_limit:
                  type: integer
                  format: int64
                  additionalProperties:
                    nullable: true
                  description: maximum verification allowed for this key
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  api_id:
                    type: string
                    example: '{api_id}'
                    description: The ID of the API the key belongs to
                  name:
                    type: string
                    example: '{api_name}'
                    description: The name assigned to the key
                  prefix:
                    type: string
                    example: prefix
                    description: The prefix assigned to the key
                  length:
                    type: integer
                    minimum: 16
                    maximum: 255
                    default: 16
                    description: The length assigned to the key
                  meta:
                    type: object
                    additionalProperties:
                      nullable: true
                    example:
                      user_id: '123456'
                    description: extra details you passed via the meta attribute
                  expires_at:
                    type: integer
                    additionalProperties:
                      nullable: true
                    format: int64
                    description: >-
                      Unix timestamp of when the key expires, returns `null`
                      when not set
                  verification_limit:
                    type: integer
                    format: int64
                    additionalProperties:
                      nullable: true
                    description: >-
                      maximum verification allowed for this key, returns `null`
                      when not set
              example:
                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'
        '406':
          description: Not Acceptable
          content:
            application/json:
              schema:
                type: object
              example:
                message: key expiry cannot be back dated

````