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

# Initiate WebAuthn Registration (beta)

> Initiate a WebAuthn Registration Request. This endpoint requires that a user already exists on MoonKey. Pass the returned JSON object in `public_key_credential_creation_options` property into `await create(options)` as `options` if you are using [webauthn-json](https://github.com/github/webauthn-json) or to [navigator.credentials.create(options)](https://w3c.github.io/webappsec-credential-management/#algorithm-create-cred).
## Returns

A successful response returns a `public_key_credential_creation_options` property and `user_id` property.



## OpenAPI

````yaml post /v1/auth/webauthn/registrations/begin
openapi: 3.1.0
info:
  title: MoonKey Auth API
  description: >-
    Explore all the details of MoonKey Auth API. All of our APIs are RESTful and
    accept and return JSON.
  version: v1
servers:
  - url: https://api.moonkey.fun
    description: Production
    variables: {}
security:
  - Authorization: []
tags:
  - name: Users
    description: User management API
  - name: Magic Links
    description: ''
  - name: OTPs
    description: >-
      Send OTP (One-time passcodes) by all the supported delivery methods such
      as SMS, email.
  - name: OAuth
    description: ''
  - name: Wallets Login
    description: ''
  - name: Managed Wallets
    description: ''
  - name: Wallet Import
    description: >-
      Import existing wallets into the platform using secure HPKE encryption.
      This flow ensures raw entropy (seed phrases or private keys) never touches
      the server in plaintext.
externalDocs:
  url: ''
  description: ''
paths:
  /v1/auth/webauthn/registrations/begin:
    parameters: []
    post:
      tags:
        - WebAuthn
      summary: Initiate WebAuthn Registration (beta)
      description: >-
        Initiate a WebAuthn Registration Request. This endpoint requires that a
        user already exists on MoonKey. Pass the returned JSON object in
        `public_key_credential_creation_options` property into `await
        create(options)` as `options` if you are using
        [webauthn-json](https://github.com/github/webauthn-json) or to
        [navigator.credentials.create(options)](https://w3c.github.io/webappsec-credential-management/#algorithm-create-cred).

        ## Returns


        A successful response returns a `public_key_credential_creation_options`
        property and `user_id` property.
      operationId: BeginWebAuthnRegistration
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BeginWebAuthnRegistrationRequest'
            examples:
              BeginWebAuthnRegistrationReq:
                value:
                  domain: localhost
                  user_id: user_24wFP9pDa9YiMJLun94iKykoZs2
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                description: ''
                type: object
                properties:
                  public_key_credential_creation_options:
                    type: object
                    properties:
                      publicKey:
                        type: object
                        properties:
                          challenge:
                            type: string
                            minLength: 1
                          rp:
                            type: object
                            properties:
                              name:
                                type: string
                                minLength: 1
                              id:
                                type: string
                                minLength: 1
                            required:
                              - name
                              - id
                          user:
                            type: object
                            properties:
                              name:
                                type: string
                                minLength: 1
                              displayName:
                                type: string
                                minLength: 1
                              id:
                                type: string
                                minLength: 1
                            required:
                              - name
                              - displayName
                              - id
                          pubKeyCredParams:
                            type: array
                            uniqueItems: true
                            minItems: 1
                            items:
                              required:
                                - type
                                - alg
                              properties:
                                type:
                                  type: string
                                  minLength: 1
                                alg:
                                  type: number
                          authenticatorSelection:
                            type: object
                            properties:
                              authenticatorAttachment:
                                type: string
                                minLength: 1
                              userVerification:
                                type: string
                                minLength: 1
                            required:
                              - authenticatorAttachment
                              - userVerification
                          timeout:
                            type: number
                          excludeCredentials:
                            type: array
                            uniqueItems: true
                            minItems: 1
                            items:
                              required:
                                - type
                                - id
                              properties:
                                type:
                                  type: string
                                  minLength: 1
                                id:
                                  type: string
                                  minLength: 1
                        required:
                          - challenge
                          - rp
                          - user
                          - pubKeyCredParams
                          - authenticatorSelection
                          - timeout
                          - excludeCredentials
                    required:
                      - publicKey
                  user_id:
                    type: string
                    minLength: 1
                required:
                  - public_key_credential_creation_options
                  - user_id
              examples:
                BeginWebAuthnRegistrationResp:
                  value:
                    public_key_credential_creation_options:
                      publicKey:
                        challenge: pz6ZOb3m7DnCLh+r7jFBymXY4N1Opz99hzAiVTTsRxU=
                        rp:
                          name: My App
                          id: localhost
                        user:
                          name: John Smith
                          displayName: John
                          id: dXNlcl8yNmw3ZGJmQVk1OWZ0ZWptbTZtM09UZjRvejE=
                        pubKeyCredParams:
                          - type: public-key
                            alg: -7
                        authenticatorSelection:
                          authenticatorAttachment: platform
                          userVerification: discouraged
                        timeout: 60000
                        excludeCredentials:
                          - type: public-key
                            id: >-
                              AQIWquELcChySRRIz9LpkduwNywFhzzKxsZye7Ms/t1noz72KiECL7tNSehkJGRwK22tlPdUBddfnyvjXQtfAJGa6oQ68D0LYLZlIleHyCin89yyZaZ9
                    user_id: user_24wFP9pDa9YiMJLun94iKykoZs2
components:
  schemas:
    BeginWebAuthnRegistrationRequest:
      description: ''
      type: object
      properties:
        domain:
          type: string
          minLength: 1
          description: >-
            `Required` Domain of the app that will be using WebAuthn to provide
            user sign in.
        user_id:
          type: string
          minLength: 1
          description: >-
            `Required` User ID of the user to attach this WebAuthn registration
            to.
        authenticator_type:
          type: string
          minLength: 1
          description: >-
            `Optional` The intended authenticator type for the WebAuthn device
            used. `cross-platform` is recommended for portable WebAuthn device
            like YubiKey and `platform` if you want to enable log in via
            platform specific methods such as FaceID or TouchID. Possible
            values: platform, cross-platform. Defaults to platform. 
      required:
        - domain
        - user_id
  securitySchemes:
    Authorization:
      type: http
      scheme: bearer
      description: >-
        Auth Platform API includes all the Auth related features. All Users,
        Phone Numbers, Emails, and OTPs are associated with an `App` as the
        container.


        Endpoints only accept App's `Secret API keys` other than certain
        endpoints that are used client side or via SDK that accept the
        `public_token`.


        ## Authentication using App Api Key


        ## Header:


        ```

        Authorization: Bearer {api_key}

        ```


        ## Authenticated Request


        ```curl

        curl \
          -X GET https://api.moonkey.fun/v1/auth/users/user_24wFP9pDa9YiMJLun94iKykoZs2 \
          -H "Authorization: Bearer sk_test_pRqweh3wvWmJAAVYv7Z0T5iPLzFM4ql0muoyQcjOxGeN3p1r"
        ```

````