---
agentTools:
  projectIndex: https://docs.privakey.com/llms.txt
---

# Bind Account Webauthn

Creates or associates an account from your system to a Privakey account.

**If the accountId has not yet been used**, a new account is created. The location URL of the new account is placed in the header. Additionally, "registrationOptions" are returned. This value is intended to be used by the webauthn client to create new credentials.

** If the accountId has already been used**, the registration options are simply returned.

# OpenAPI definition

```json
{
  "openapi": "3.1.0",
  "info": {
    "title": "API Settings",
    "version": "2.4"
  },
  "servers": [
    {
      "url": "https://cloud.privakey.com"
    }
  ],
  "security": [
    {}
  ],
  "paths": {
    "/api/account/webauthn/bind": {
      "put": {
        "summary": "Bind Account Webauthn",
        "description": "Creates or associates an account from your system to a Privakey account.\n\n**If the accountId has not yet been used**, a new account is created. The location URL of the new account is placed in the header. Additionally, \"registrationOptions\" are returned. This value is intended to be used by the webauthn client to create new credentials.\n\n** If the accountId has already been used**, the registration options are simply returned.",
        "operationId": "bind-account-webauthn",
        "parameters": [
          {
            "name": "Authorization",
            "in": "header",
            "description": "Either Basic or HMAC, depending on how the Request Origin is configured.",
            "required": true,
            "schema": {
              "type": "string",
              "default": "Basic <basic creds>"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "required": [
                  "accountId",
                  "userInfo",
                  "domain"
                ],
                "properties": {
                  "accountId": {
                    "type": "string",
                    "description": "The user's account id"
                  },
                  "userInfo": {
                    "type": "string",
                    "description": "A JSON string containing \"name\" and \"displayName\" properties that will be used to identify the webauthn credential to the end user",
                    "format": "json"
                  },
                  "domain": {
                    "type": "string",
                    "description": "The domain name of the server that will be registering the webauthn credential"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "201",
            "content": {
              "application/json": {
                "examples": {
                  "Created": {
                    "value": "{\n    \"privakeyId\": \"57125de1-b295-4b4c-b7a6-91f40726c5ca\",\n    \"externalIdentifier\": \"999999\",\n    \"appSpaceName\": \"Webauthn\",\n    \"registrationOptions\": {\n        \"rp\": {\n            \"name\": \"Webauthn\",\n            \"id\": \"localhost\"\n        },\n        \"user\": {\n            \"id\": \"a977ade7-bdcf-4c72-ac47-6a8619428aba\",\n            \"name\": \"Test User\",\n            \"displayName\": \"Test\"\n        },\n        \"challenge\": \"LlifkoOvDCHEiL7n1kJgf8gBD5hgXxQrybiIye6Mt2jfx5dWW7txxCJhFihk38oC_JAhs0oDNBZWHTG57_w1-ajB2mDXmuGvr4hu677ESLnSuUi4k8fAT8oodiTH9JWYuYZPszhStEySahYTK77CEgV462MuhePl83OobhERbbI\",\n        \"pubKeyCredParams\": [\n            {\n                \"type\": \"public-key\",\n                \"alg\": -7\n            },\n            {\n                \"type\": \"public-key\",\n                \"alg\": -257\n            }\n        ],\n        \"timeout\": 60000,\n        \"attestation\": \"none\",\n        \"authenticatorSelection\": {\n            \"requireResidentKey\": false,\n            \"userVerification\": \"discouraged\"\n        }\n    }\n}"
                  }
                },
                "schema": {
                  "type": "object",
                  "properties": {
                    "privakeyId": {
                      "type": "string",
                      "example": "57125de1-b295-4b4c-b7a6-91f40726c5ca"
                    },
                    "externalIdentifier": {
                      "type": "string",
                      "example": "999999"
                    },
                    "appSpaceName": {
                      "type": "string",
                      "example": "Webauthn"
                    },
                    "registrationOptions": {
                      "type": "object",
                      "properties": {
                        "rp": {
                          "type": "object",
                          "properties": {
                            "name": {
                              "type": "string",
                              "example": "Webauthn"
                            },
                            "id": {
                              "type": "string",
                              "example": "localhost"
                            }
                          }
                        },
                        "user": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "example": "a977ade7-bdcf-4c72-ac47-6a8619428aba"
                            },
                            "name": {
                              "type": "string",
                              "example": "Test User"
                            },
                            "displayName": {
                              "type": "string",
                              "example": "Test"
                            }
                          }
                        },
                        "challenge": {
                          "type": "string",
                          "example": "LlifkoOvDCHEiL7n1kJgf8gBD5hgXxQrybiIye6Mt2jfx5dWW7txxCJhFihk38oC_JAhs0oDNBZWHTG57_w1-ajB2mDXmuGvr4hu677ESLnSuUi4k8fAT8oodiTH9JWYuYZPszhStEySahYTK77CEgV462MuhePl83OobhERbbI"
                        },
                        "pubKeyCredParams": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "example": "public-key"
                              },
                              "alg": {
                                "type": "integer",
                                "example": -7,
                                "default": 0
                              }
                            }
                          }
                        },
                        "timeout": {
                          "type": "integer",
                          "example": 60000,
                          "default": 0
                        },
                        "attestation": {
                          "type": "string",
                          "example": "none"
                        },
                        "authenticatorSelection": {
                          "type": "object",
                          "properties": {
                            "requireResidentKey": {
                              "type": "boolean",
                              "example": false,
                              "default": true
                            },
                            "userVerification": {
                              "type": "string",
                              "example": "discouraged"
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "400",
            "content": {
              "application/json": {
                "examples": {
                  "Result": {
                    "value": "{}"
                  }
                },
                "schema": {
                  "type": "object",
                  "properties": {}
                }
              }
            }
          }
        },
        "deprecated": false,
        "security": [],
        "x-readme": {
          "code-samples": [
            {
              "language": "curl",
              "code": "curl --location --request PUT \"https://cloud.privakey.com/api/account/webauthn/bind\" --header \"Authorization: Basic <basic creds>\" --header \"Content-Type: application/x-www-form-urlencoded\" --data \"accountId=999999&userInfo={\"\"name\"\":\"\"Test User\"\",\"\"displayName\"\":\"\"Test\"\"}&domain=localhost\""
            },
            {
              "language": "javascript",
              "code": "const body = { accountId: \"999999\",\n             \t userInfo:{\"name\":\"Test User\",\"displayName\":\"Test\"},\n               domain:\"localhost\"}\nconst options = {\n  headers: {'Authorization':`Basic ${basicCreds}`},\n  method: 'PUT',\n  body\n}\n\nfetch('https://cloud.privakey.com/api/account/webauthn/bind', options)\n  .then(data => console.log(data.registrationOptions))"
            }
          ],
          "samples-languages": [
            "curl",
            "javascript"
          ]
        }
      }
    }
  },
  "x-readme": {
    "headers": [],
    "explorer-enabled": false,
    "proxy-enabled": true
  },
  "x-readme-fauxas": true,
  "_id": "660d684fcb33080067214619:660d684fcb3308006721465f"
}
```