> ## 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 Credential With Code

> Finalizes the flow [Create Credential With Code](https://docs.dfns.co/api-reference/auth/credentials#create-credential-with-code-flow).
  
Adds a new credential to a user's account. This endpoint is similar to the [Create Credential](https://docs.dfns.co/api-reference/auth/create-credential) endpoint, except:
* it does not need the user to be authenticated
* it does not need user action signing
* it will only work with the challenge gotten from the [Create Credential Challenge With Code](https://docs.dfns.co/api-reference/auth/create-credential-challenge-with-code) endpoint

  



## OpenAPI

````yaml /openapi.yaml post /auth/credentials/code/verify
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:
  /auth/credentials/code/verify:
    post:
      tags:
        - Auth
      summary: Create Credential With Code
      description: >-
        Finalizes the flow [Create Credential With
        Code](https://docs.dfns.co/api-reference/auth/credentials#create-credential-with-code-flow).
          
        Adds a new credential to a user's account. This endpoint is similar to
        the [Create
        Credential](https://docs.dfns.co/api-reference/auth/create-credential)
        endpoint, except:

        * it does not need the user to be authenticated

        * it does not need user action signing

        * it will only work with the challenge gotten from the [Create
        Credential Challenge With
        Code](https://docs.dfns.co/api-reference/auth/create-credential-challenge-with-code)
        endpoint

          
      requestBody:
        content:
          application/json:
            schema:
              oneOf:
                - $ref: '#/components/schemas/Fido2Attestation'
                - $ref: '#/components/schemas/KeyAttestation'
                - $ref: '#/components/schemas/PasswordProtectedKeyAttestation'
                - $ref: '#/components/schemas/RecoveryKeyAttestation'
                - $ref: '#/components/schemas/PasswordAttestation'
                - $ref: '#/components/schemas/TotpAttestation'
              discriminator:
                propertyName: credentialKind
                mapping:
                  Fido2:
                    $ref: '#/components/schemas/Fido2Attestation'
                  Key:
                    $ref: '#/components/schemas/KeyAttestation'
                  PasswordProtectedKey:
                    $ref: '#/components/schemas/PasswordProtectedKeyAttestation'
                  RecoveryKey:
                    $ref: '#/components/schemas/RecoveryKeyAttestation'
                  Password:
                    $ref: '#/components/schemas/PasswordAttestation'
                  Totp:
                    $ref: '#/components/schemas/TotpAttestation'
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Credential'
      security:
        - {}
components:
  schemas:
    Fido2Attestation:
      type: object
      properties:
        credentialKind:
          type: string
          enum:
            - Fido2
        credentialInfo:
          type: object
          properties:
            credId:
              type: string
              minLength: 1
            clientData:
              type: string
              minLength: 1
            attestationData:
              type: string
              minLength: 1
          required:
            - credId
            - clientData
            - attestationData
          additionalProperties: false
        credentialName:
          type: string
          minLength: 1
        challengeIdentifier:
          type: string
          minLength: 1
      required:
        - credentialKind
        - credentialInfo
        - credentialName
        - challengeIdentifier
      additionalProperties: false
      description: >-
        Register a Fido2 Credential, also known as Passkeys or WebauthN
        credential.
      title: Fido2/Passkeys
    KeyAttestation:
      type: object
      properties:
        credentialKind:
          type: string
          enum:
            - Key
        credentialInfo:
          type: object
          properties:
            credId:
              type: string
              minLength: 1
            clientData:
              type: string
              minLength: 1
            attestationData:
              type: string
              minLength: 1
          required:
            - credId
            - clientData
            - attestationData
          additionalProperties: false
        credentialName:
          type: string
          minLength: 1
        challengeIdentifier:
          type: string
          minLength: 1
      required:
        - credentialKind
        - credentialInfo
        - credentialName
        - challengeIdentifier
      additionalProperties: false
      description: >-
        Register a "raw" public/private keypair, mostly meant to be used by
        Service Accounts. See [Generate a Key
        Pair](https://docs.dfns.co/developers/guides/generate-a-key-pair) for
        more details.
      title: Public/Private key pair
    PasswordProtectedKeyAttestation:
      type: object
      properties:
        credentialKind:
          type: string
          enum:
            - PasswordProtectedKey
        credentialInfo:
          type: object
          properties:
            credId:
              type: string
              minLength: 1
            clientData:
              type: string
              minLength: 1
            attestationData:
              type: string
              minLength: 1
          required:
            - credId
            - clientData
            - attestationData
          additionalProperties: false
        encryptedPrivateKey:
          type: string
          minLength: 1
        credentialName:
          type: string
          minLength: 1
        challengeIdentifier:
          type: string
          minLength: 1
      required:
        - credentialKind
        - credentialInfo
        - encryptedPrivateKey
        - credentialName
        - challengeIdentifier
      additionalProperties: false
      description: >-
        Register an encrypted private key. Note that Dfns only stores the
        encrypted private key and should not have access to the password to
        decrypt it!
      title: Password-protected Key
    RecoveryKeyAttestation:
      type: object
      properties:
        credentialKind:
          type: string
          enum:
            - RecoveryKey
        credentialInfo:
          type: object
          properties:
            credId:
              type: string
              minLength: 1
            clientData:
              type: string
              minLength: 1
            attestationData:
              type: string
              minLength: 1
          required:
            - credId
            - clientData
            - attestationData
          additionalProperties: false
        encryptedPrivateKey:
          type: string
          minLength: 1
        credentialName:
          type: string
          minLength: 1
        challengeIdentifier:
          type: string
          minLength: 1
      required:
        - credentialKind
        - credentialInfo
        - credentialName
        - challengeIdentifier
      additionalProperties: false
      description: >-
        Register a recovery key. See [Account
        Recovery](https://docs.dfns.co/api-reference/auth/account-recovery) for
        more details.
      title: Recovery Key
    PasswordAttestation:
      type: object
      properties:
        credentialKind:
          type: string
          enum:
            - Password
        credentialInfo:
          type: object
          properties:
            password:
              type: string
              minLength: 1
          required:
            - password
          additionalProperties: false
        credentialName:
          type: string
          minLength: 1
        challengeIdentifier:
          type: string
          minLength: 1
      required:
        - credentialKind
        - credentialInfo
        - credentialName
        - challengeIdentifier
      additionalProperties: false
      description: Not supported, will be removed in a future release.
      title: <Deprecated> Password
    TotpAttestation:
      type: object
      properties:
        credentialKind:
          type: string
          enum:
            - Totp
        credentialInfo:
          type: object
          properties:
            otpCode:
              type: string
              minLength: 1
          required:
            - otpCode
          additionalProperties: false
        credentialName:
          type: string
          minLength: 1
        challengeIdentifier:
          type: string
          minLength: 1
      required:
        - credentialKind
        - credentialInfo
        - credentialName
        - challengeIdentifier
      additionalProperties: false
      description: Not supported, will be removed in a future release.
      title: <Deprecated> TOTP
    Credential:
      type: object
      properties:
        kind:
          type: string
          enum:
            - Fido2
            - Key
            - Password
            - Totp
            - RecoveryKey
            - PasswordProtectedKey
        credentialId:
          type: string
        credentialUuid:
          type: string
        dateCreated:
          type: string
        isActive:
          type: boolean
        name:
          type: string
        publicKey:
          type: string
        relyingPartyId:
          type: string
        origin:
          type: string
      required:
        - kind
        - credentialId
        - credentialUuid
        - dateCreated
        - isActive
        - name
        - publicKey
        - relyingPartyId
        - origin

````