# Confirm the password before adding a passkey. Lasts 10 minutes for this session.

```http
POST /api/sessions/confirm
```

## Authorization

- **session**: `Authorization: Bearer <token>`. The session token from signing in (or the session cookie in a browser on the same origin).

## Request body

- **password** `string`: At most 200 characters

## Response

**200**: It worked

- **ok** `true` (required)

Other answers:

- **4XX**: Refused, with a message to show the person

## Example request

````tabs
tab: cURL
```bash
curl -X POST 'https://your-hatch-server/api/sessions/confirm' \
  -H 'Authorization: Bearer <token>' \
  -H 'Content-Type: application/json' \
  -d '{
  "password": "string"
}'
```

tab: JavaScript
```js
const res = await fetch("https://your-hatch-server/api/sessions/confirm", {
  method: "POST",
  headers: {
    Authorization: "Bearer <token>",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "password": "string"
  }),
})
const data = await res.json()
```

tab: Python
```python
import requests

res = requests.request("POST", "https://your-hatch-server/api/sessions/confirm", headers={"Authorization": "Bearer <token>", "Content-Type": "application/json"}, json={
    "password": "string",
})
data = res.json()
```

tab: Go
```go
package main

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

func main() {
	body := strings.NewReader(`{
	  "password": "string"
	}`)
	req, err := http.NewRequest("POST", "https://your-hatch-server/api/sessions/confirm", body)
	if err != nil {
		panic(err)
	}
	req.Header.Set("Authorization", "Bearer <token>")
	req.Header.Set("Content-Type", "application/json")
	res, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer res.Body.Close()
	data, _ := io.ReadAll(res.Body)
	fmt.Println(string(data))
}
```

tab: Ruby
```ruby
require "net/http"
require "json"

uri = URI('https://your-hatch-server/api/sessions/confirm')
req = Net::HTTP::Post.new(uri)
req['Authorization'] = 'Bearer <token>'
req['Content-Type'] = 'application/json'
req.body = JSON.generate({
  'password' => 'string'
})

res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") do |http|
  http.request(req)
end
puts res.body
```

tab: PHP
```php
<?php

$ch = curl_init('https://your-hatch-server/api/sessions/confirm');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer <token>',
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => '{
      "password": "string"
    }',
]);

$response = curl_exec($ch);
echo $response;
```

tab: Java
```java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://your-hatch-server/api/sessions/confirm"))
    .header("Authorization", "Bearer <token>")
    .header("Content-Type", "application/json")
    .method("POST", HttpRequest.BodyPublishers.ofString("{\"password\":\"string\"}"))
    .build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
```
````

## Example response

````tabs
tab: 200
```json
{
  "ok": true
}
```

tab: 4XX
```json
{
  "message": "string",
  "code": "string",
  "retryable": true,
  "requestId": "string"
}
```
````
