API reference OpenAPI 3.1
POST /auth/password/change

Change password

Authenticated password change (Bearer). Allowed even under the forced-change flag; clears must_change_password on success. Data calls made under the flag 403 with code auth.password_change_required.

Bearer API key or staff session application/json operation passwordChange

Request

Content type: application/json · required

FieldTypeRequiredDescription
current_password string Yes —
new_password string Yes —
curl -X POST "$MONICHEK_API/auth/password/change" \
  -H "Authorization: Bearer $MONICHEK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "current_password": "<password>",
  "new_password": "<password>"
}'
const res = await fetch(`${MONICHEK_API}/auth/password/change`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${MONICHEK_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "current_password": "<password>",
    "new_password": "<password>"
  }),
});

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

res = requests.post(
    f"{os.environ['MONICHEK_API']}/auth/password/change",
    headers={"Authorization": f"Bearer {os.environ['MONICHEK_API_KEY']}"},
    json={
      "current_password": "<password>",
      "new_password": "<password>"
    },
)
print(res.json())
$ch = curl_init(getenv('MONICHEK_API') . '/auth/password/change');
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([
        'current_password' => '<password>',
        'new_password' => '<password>',
    ]),
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;

Responses

200 OK changed application/json
{
  "object": "password_change",
  "must_change_password": false
}

Error responses

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

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