API reference OpenAPI 3.1
POST /auth/mfa/enroll

Mfa enroll

Requires a live staff session. The factor is bound to the session user; the optional legacy user_id body field is rejected when it differs.

Bearer API key or staff session application/json operation mfaEnroll

Request

Content type: application/json

FieldTypeRequiredDescription
user_id string No Optional legacy field; must match the session user
curl -X POST "$MONICHEK_API/auth/mfa/enroll" \
  -H "Authorization: Bearer $MONICHEK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "user_id": "id_01M3R..."
}'
const res = await fetch(`${MONICHEK_API}/auth/mfa/enroll`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${MONICHEK_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "user_id": "id_01M3R..."
  }),
});

const data = await res.json();
import os
import requests

res = requests.post(
    f"{os.environ['MONICHEK_API']}/auth/mfa/enroll",
    headers={"Authorization": f"Bearer {os.environ['MONICHEK_API_KEY']}"},
    json={
      "user_id": "id_01M3R..."
    },
)
print(res.json())
$ch = curl_init(getenv('MONICHEK_API') . '/auth/mfa/enroll');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('MONICHEK_API_KEY'),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => json_encode([
        'user_id' => 'id_01M3R...',
    ]),
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;

Responses

200 OK totp uri application/json

No response example is published for this status.

Error responses

StatusMeaningBody
401 Unauthorized RFC 9457 problem
403 Forbidden RFC 9457 problem
409 Conflict RFC 9457 problem
422 Unprocessable Entity RFC 9457 problem

Errors use the RFC 9457 problem format with a stable code.