> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dfns.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Key

> Creates a key for the given scheme and curve. Returns the new key entity. 



## OpenAPI

````yaml /openapi.yaml post /keys
openapi: 3.1.0
info:
  version: 1.807.0
  title: Dfns
servers:
  - url: https://api.dfns.io
    description: Default - Europe
  - url: https://api.uae.dfns.io
    description: UAE
  - url: https://api.dfns.ninja
    description: <Deprecated> Staging
security: []
paths:
  /keys:
    post:
      tags:
        - Keys
      summary: Create Key
      description: >-
        Creates a key for the given scheme and curve. Returns the new key
        entity. 
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                scheme:
                  $ref: '#/components/schemas/KeyScheme'
                curve:
                  $ref: '#/components/schemas/KeyCurve'
                name:
                  type: string
                  maxLength: 100
                  description: Nickname for the key.
                masterKey:
                  type: boolean
                  description: >-
                    Whether this key can be used as a master key for HD
                    derivation.
                deriveFrom:
                  type: object
                  properties:
                    keyId:
                      type: string
                      minLength: 1
                      maxLength: 64
                      pattern: ^key-[a-z0-9]{5}-[a-z0-9]{5}-[a-z0-9]{14,16}$
                      description: The master key to derive from.
                      example: key-01snl-t56gb-j8tsok0vn802p80i
                    path:
                      type: string
                      pattern: ^m(\/(0|[1-9]\d{0,9}))+$
                      description: >-
                        Use this to specify the derivation path of the signing
                        key. One will be auto generated if left blank.
                  required:
                    - keyId
                  description: Options for hierarchical deterministic key derivation.
                storeId:
                  type: string
                  minLength: 1
                  maxLength: 64
                  pattern: ^store-[a-z0-9]{5}-[a-z0-9]{5}-[a-z0-9]{14,16}$
                  description: The key store to save the key to.
                  example: store-425nf-ebf0a-qq22t6qra51tj8j0
                delegateTo:
                  type: string
                  minLength: 1
                  maxLength: 64
                  pattern: ^us-[a-z0-9]{5}-[a-z0-9]{5}-[a-z0-9]{14,16}$
                  description: ID of the end user to delegate this key to.
                  example: us-6b58p-r53sr-rlrd3l5cj3uc4ome
                delayDelegation:
                  type: boolean
                  description: Whether to delay delegation until explicitly triggered.
              required:
                - scheme
                - curve
              additionalProperties: false
            examples:
              EdDSA:
                value:
                  scheme: EdDSA
                  curve: ed25519
              Schnorr:
                value:
                  scheme: Schnorr
                  curve: secp256k1
              Stark:
                value:
                  scheme: ECDSA
                  curve: stark
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Key'
      security:
        - authenticationToken: []
          userActionSignature: []
components:
  schemas:
    KeyScheme:
      type: string
      description: The cryptographic scheme for the key.
      enum:
        - ECDSA
        - EdDSA
        - Schnorr
    KeyCurve:
      type: string
      enum:
        - ed25519
        - secp256k1
        - stark
      description: The elliptic curve for the key.
    Key:
      type: object
      properties:
        id:
          type: string
          minLength: 1
          maxLength: 64
          pattern: ^key-[a-z0-9]{5}-[a-z0-9]{5}-[a-z0-9]{14,16}$
          description: Unique identifier for the key.
          example: key-01snl-t56gb-j8tsok0vn802p80i
        scheme:
          $ref: '#/components/schemas/KeyScheme'
        curve:
          $ref: '#/components/schemas/KeyCurve'
        publicKey:
          type: string
          description: Hex-encoded public key.
        masterKey:
          type: boolean
          description: Whether this key can be used as a master key for HD derivation.
        derivedFrom:
          type: object
          properties:
            keyId:
              type: string
              minLength: 1
              maxLength: 64
              pattern: ^key-[a-z0-9]{5}-[a-z0-9]{5}-[a-z0-9]{14,16}$
              description: The master key this key was derived from.
              example: key-01snl-t56gb-j8tsok0vn802p80i
            path:
              type: string
              description: The derivation path used.
          required:
            - keyId
            - path
          description: Derivation info if this key was derived from a master key.
        name:
          type: string
          description: Nickname for the key.
        status:
          type: string
          enum:
            - Active
            - Archived
          description: Current status of the key.
        custodial:
          type: boolean
          description: >-
            Whether the key is custodial (owned by organization) or
            non-custodial (delegated to end user).
        dateCreated:
          type: string
          format: date-time
          description: >-
            [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date (must be
            UTC). When the key was created.
          example: '2023-04-14T20:41:28.715Z'
        imported:
          type: boolean
          description: Whether this key was imported.
        exported:
          type: boolean
          description: Whether this key has been exported.
        dateExported:
          type: string
          format: date-time
          description: >-
            [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date (must be
            UTC). When the key was exported.
          example: '2023-04-14T20:41:28.715Z'
        dateDeleted:
          type: string
          format: date-time
          description: >-
            [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date (must be
            UTC). When the key was deleted.
          example: '2023-04-14T20:41:28.715Z'
      required:
        - id
        - scheme
        - curve
        - publicKey
        - status
        - custodial
        - dateCreated
  securitySchemes:
    authenticationToken:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        **Bearer Token:** Used to authenticate API requests.

        More details how to generate the token: [Authentication
        flows](https://docs.dfns.co/api-reference/auth/login-flows)
    userActionSignature:
      type: apiKey
      in: header
      name: X-DFNS-USERACTION
      description: >-
        **User Action Signature:** Used to sign the change-inducing API
        requests.

        More details how to generate the token: [User Action Signing
        flows](https://docs.dfns.co/api-reference/auth/signing-flows)

````