Skip to main content
POST
/
webauthn
/
registration
/
finalize
Finalize WebAuthn registration
curl --request POST \
  --url https://{tenant_id}.hanko.io/webauthn/registration/finalize \
  --header 'Content-Type: application/json' \
  --cookie hanko= \
  --data '
{
  "id": "_18q6IjW09tiM4NSbsZjocUtGx00Muv5mN6LZCelCMDD...",
  "rawId": "_18q6IjW09tiM4NSbsZjocUtGx00Muv5mN6LZCelCMDD...",
  "type": "public-key",
  "response": {
    "clientDataJson": "eyJ0eXBlIjoid2ViYXV0aG4uZ2V0IiwiY2hhbGxlbmdl...",
    "attestationObject": "o2NmbXRkbm9uZWdhdHRTdG10oGhhdXRoRGF0YVjfSZYN...",
    "transports": [
      "internal"
    ]
  }
}
'
import requests

url = "https://{tenant_id}.hanko.io/webauthn/registration/finalize"

payload = {
"id": "_18q6IjW09tiM4NSbsZjocUtGx00Muv5mN6LZCelCMDD...",
"rawId": "_18q6IjW09tiM4NSbsZjocUtGx00Muv5mN6LZCelCMDD...",
"type": "public-key",
"response": {
"clientDataJson": "eyJ0eXBlIjoid2ViYXV0aG4uZ2V0IiwiY2hhbGxlbmdl...",
"attestationObject": "o2NmbXRkbm9uZWdhdHRTdG10oGhhdXRoRGF0YVjfSZYN...",
"transports": ["internal"]
}
}
headers = {
"cookie": "hanko=",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {cookie: 'hanko=', 'Content-Type': 'application/json'},
body: JSON.stringify({
id: '_18q6IjW09tiM4NSbsZjocUtGx00Muv5mN6LZCelCMDD...',
rawId: '_18q6IjW09tiM4NSbsZjocUtGx00Muv5mN6LZCelCMDD...',
type: 'public-key',
response: {
clientDataJson: 'eyJ0eXBlIjoid2ViYXV0aG4uZ2V0IiwiY2hhbGxlbmdl...',
attestationObject: 'o2NmbXRkbm9uZWdhdHRTdG10oGhhdXRoRGF0YVjfSZYN...',
transports: ['internal']
}
})
};

fetch('https://{tenant_id}.hanko.io/webauthn/registration/finalize', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://{tenant_id}.hanko.io/webauthn/registration/finalize",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'id' => '_18q6IjW09tiM4NSbsZjocUtGx00Muv5mN6LZCelCMDD...',
'rawId' => '_18q6IjW09tiM4NSbsZjocUtGx00Muv5mN6LZCelCMDD...',
'type' => 'public-key',
'response' => [
'clientDataJson' => 'eyJ0eXBlIjoid2ViYXV0aG4uZ2V0IiwiY2hhbGxlbmdl...',
'attestationObject' => 'o2NmbXRkbm9uZWdhdHRTdG10oGhhdXRoRGF0YVjfSZYN...',
'transports' => [
'internal'
]
]
]),
CURLOPT_COOKIE => "hanko=",
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://{tenant_id}.hanko.io/webauthn/registration/finalize"

payload := strings.NewReader("{\n \"id\": \"_18q6IjW09tiM4NSbsZjocUtGx00Muv5mN6LZCelCMDD...\",\n \"rawId\": \"_18q6IjW09tiM4NSbsZjocUtGx00Muv5mN6LZCelCMDD...\",\n \"type\": \"public-key\",\n \"response\": {\n \"clientDataJson\": \"eyJ0eXBlIjoid2ViYXV0aG4uZ2V0IiwiY2hhbGxlbmdl...\",\n \"attestationObject\": \"o2NmbXRkbm9uZWdhdHRTdG10oGhhdXRoRGF0YVjfSZYN...\",\n \"transports\": [\n \"internal\"\n ]\n }\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("cookie", "hanko=")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://{tenant_id}.hanko.io/webauthn/registration/finalize")
.header("cookie", "hanko=")
.header("Content-Type", "application/json")
.body("{\n \"id\": \"_18q6IjW09tiM4NSbsZjocUtGx00Muv5mN6LZCelCMDD...\",\n \"rawId\": \"_18q6IjW09tiM4NSbsZjocUtGx00Muv5mN6LZCelCMDD...\",\n \"type\": \"public-key\",\n \"response\": {\n \"clientDataJson\": \"eyJ0eXBlIjoid2ViYXV0aG4uZ2V0IiwiY2hhbGxlbmdl...\",\n \"attestationObject\": \"o2NmbXRkbm9uZWdhdHRTdG10oGhhdXRoRGF0YVjfSZYN...\",\n \"transports\": [\n \"internal\"\n ]\n }\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://{tenant_id}.hanko.io/webauthn/registration/finalize")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["cookie"] = 'hanko='
request["Content-Type"] = 'application/json'
request.body = "{\n \"id\": \"_18q6IjW09tiM4NSbsZjocUtGx00Muv5mN6LZCelCMDD...\",\n \"rawId\": \"_18q6IjW09tiM4NSbsZjocUtGx00Muv5mN6LZCelCMDD...\",\n \"type\": \"public-key\",\n \"response\": {\n \"clientDataJson\": \"eyJ0eXBlIjoid2ViYXV0aG4uZ2V0IiwiY2hhbGxlbmdl...\",\n \"attestationObject\": \"o2NmbXRkbm9uZWdhdHRTdG10oGhhdXRoRGF0YVjfSZYN...\",\n \"transports\": [\n \"internal\"\n ]\n }\n}"

response = http.request(request)
puts response.read_body
{
  "credential_id": "aSDinaTvuI8gbWludGxpZnk=",
  "user_id": "c339547d-e17d-4ba7-8a1d-b3d5a4d17c1c"
}
{
"code": 400,
"message": "Bad Request"
}
{
"code": 500,
"message": "Internal Server Error"
}
Deprecated. Please use the Flow API instead. What’s the Flow API?.
Finalize a registration with Webauthn using the WebAuthn API response to a navigator.credentials.create() call.
The Webauthn API uses binary data represented by ArrayBuffers for certain input/output values. The Hanko API returns these values as base64url-encoded, so they must be converted to ArrayBuffers when passed to the Webauthn API. Similarly, Webauthn API output must be converted to base64url-encoded values when passed to the Hanko API (e.g. using the webauthn-json library).

Authorizations

hanko
string
cookie
required

Body

application/json

Challenge response

WebAuthn API response to a navigator.credentials.create() call

id
string
Example:

"_18q6IjW09tiM4NSbsZjocUtGx00Muv5mN6LZCelCMDD..."

rawId
string
Example:

"_18q6IjW09tiM4NSbsZjocUtGx00Muv5mN6LZCelCMDD..."

type
enum<string>
Available options:
public-key
Example:

"public-key"

response
object

Response

Successful registration

credential_id
file

The ID of the created credential

user_id
string<uuid4>

The ID of the user on whose behalf a credential was created

Example:

"c339547d-e17d-4ba7-8a1d-b3d5a4d17c1c"