> For the complete documentation index, see [llms.txt](https://apidocs.akinon.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://apidocs.akinon.com/commerce-openapis/users/module-2/user.md).

# User

User account management endpoints

## Activate Currency

> Sets the active currency for the user's session.\
> \
> \*\*Business Logic:\*\*\
> \- Validates the currency code against available currencies.\
> \- Updates the session with the new currency.\
> \
> \*\*Dynamic Settings:\*\*\
> \- \`AVAILABLE\_CURRENCIES\`: List of valid currency codes (e.g., \`\['TRY', 'USD', 'EUR']\`).

```json
{"openapi":"3.1.0","info":{"title":"User API","version":"1.0.0"},"tags":[{"name":"User","description":"User account management endpoints"}],"servers":[{"description":"Server base URL","url":"https://{commerce_url}","variables":{"commerce_url":{"default":"sandbox.akinon.com","description":"Commerce server URL"}}}],"security":[],"paths":{"/users/activate-currency/":{"post":{"tags":["User"],"summary":"Activate Currency","description":"Sets the active currency for the user's session.\n\n**Business Logic:**\n- Validates the currency code against available currencies.\n- Updates the session with the new currency.\n\n**Dynamic Settings:**\n- `AVAILABLE_CURRENCIES`: List of valid currency codes (e.g., `['TRY', 'USD', 'EUR']`).","operationId":"activateCurrency","parameters":[{"$ref":"#/components/parameters/CSRFTokenHeader"},{"$ref":"#/components/parameters/CookieHeader"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ActivateCurrencyRequest"}}}},"responses":{"204":{"description":"Currency activated successfully"},"400":{"description":"Invalid currency code","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationErrorResponse"}}}}}}}},"components":{"parameters":{"CSRFTokenHeader":{"name":"X-CSRFToken","in":"header","description":"CSRF token for write operations (POST, PUT, PATCH, DELETE).\nRequired for security when using session authentication.\nObtain token from cookie 'csrftoken' or meta tag in HTML.","required":true,"schema":{"type":"string"}},"CookieHeader":{"name":"Cookie","in":"header","description":"Session ID and CSRF token cookies.\nFormat: `sessionid=<id>; osessionid=<id>; csrftoken=<token>`","required":true,"schema":{"type":"string"}}},"schemas":{"ActivateCurrencyRequest":{"type":"object","required":["currency_code"],"properties":{"currency_code":{"type":"string","description":"The currency code to activate (e.g., 'TRY', 'USD'). Must be one of the available currencies."}}},"ValidationErrorResponse":{"type":"object","description":"Standard DRF validation error response","additionalProperties":{"type":"array","items":{"type":"string"}}}}}}
```

## Anonymize User

> Anonymizes the current user account.\
> \
> \*\*Business Logic:\*\*\
> \- Requires \`SELF\_ANONYMIZATION\_ENABLED\` setting to be true.\
> \- Marks the user as anonymized and logs them out.\
> \- No request body is required as the operation targets the authenticated user.

```json
{"openapi":"3.1.0","info":{"title":"User API","version":"1.0.0"},"tags":[{"name":"User","description":"User account management endpoints"}],"servers":[{"description":"Server base URL","url":"https://{commerce_url}","variables":{"commerce_url":{"default":"sandbox.akinon.com","description":"Commerce server URL"}}}],"security":[{"cookieAuth":[]}],"components":{"securitySchemes":{"cookieAuth":{"type":"apiKey","in":"cookie","name":"sessionid"}},"parameters":{"CSRFTokenHeader":{"name":"X-CSRFToken","in":"header","description":"CSRF token for write operations (POST, PUT, PATCH, DELETE).\nRequired for security when using session authentication.\nObtain token from cookie 'csrftoken' or meta tag in HTML.","required":true,"schema":{"type":"string"}},"CookieHeader":{"name":"Cookie","in":"header","description":"Session ID and CSRF token cookies.\nFormat: `sessionid=<id>; osessionid=<id>; csrftoken=<token>`","required":true,"schema":{"type":"string"}}},"schemas":{"DetailErrorResponse":{"type":"object","properties":{"detail":{"type":"string"}}}}},"paths":{"/users/anonymize/":{"patch":{"tags":["User"],"summary":"Anonymize User","description":"Anonymizes the current user account.\n\n**Business Logic:**\n- Requires `SELF_ANONYMIZATION_ENABLED` setting to be true.\n- Marks the user as anonymized and logs them out.\n- No request body is required as the operation targets the authenticated user.","operationId":"anonymizeUser","parameters":[{"$ref":"#/components/parameters/CSRFTokenHeader"},{"$ref":"#/components/parameters/CookieHeader"}],"responses":{"200":{"description":"User anonymized successfully"},"403":{"description":"Self-anonymization is disabled","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DetailErrorResponse"}}}}}}}}}
```

## Validate Password Reset Token

> Checks if the password reset link (UID and token) is valid.

```json
{"openapi":"3.1.0","info":{"title":"User API","version":"1.0.0"},"tags":[{"name":"User","description":"User account management endpoints"}],"servers":[{"description":"Server base URL","url":"https://{commerce_url}","variables":{"commerce_url":{"default":"sandbox.akinon.com","description":"Commerce server URL"}}}],"security":[],"paths":{"/users/api-reset/{uidb64}/{token}/":{"get":{"tags":["User"],"summary":"Validate Password Reset Token","description":"Checks if the password reset link (UID and token) is valid.","operationId":"validatePasswordResetToken","parameters":[{"name":"uidb64","in":"path","required":true,"schema":{"type":"string"},"description":"Base64 encoded user ID"},{"name":"token","in":"path","required":true,"schema":{"type":"string"},"description":"Password reset token"}],"responses":{"200":{"description":"Validation result","content":{"application/json":{"schema":{"type":"object","properties":{"validlink":{"type":"boolean"}}}}}}}}}}}
```

## Reset Password

> Resets the user's password using the provided token and new password.\
> \
> \*\*Business Logic:\*\*\
> \- Validates the \`uidb64\` and \`token\` to ensure the reset link is valid.\
> \- Validates that \`new\_password1\` and \`new\_password2\` match.\
> \- Validates \`new\_password1\` against configured password validators (\`AUTH\_PASSWORD\_VALIDATORS\`).\
> \- Updates the user's password and saves the old password in history.\
> \- Sets the user type to 'registered'.

```json
{"openapi":"3.1.0","info":{"title":"User API","version":"1.0.0"},"tags":[{"name":"User","description":"User account management endpoints"}],"servers":[{"description":"Server base URL","url":"https://{commerce_url}","variables":{"commerce_url":{"default":"sandbox.akinon.com","description":"Commerce server URL"}}}],"security":[],"paths":{"/users/api-reset/{uidb64}/{token}/":{"post":{"tags":["User"],"summary":"Reset Password","description":"Resets the user's password using the provided token and new password.\n\n**Business Logic:**\n- Validates the `uidb64` and `token` to ensure the reset link is valid.\n- Validates that `new_password1` and `new_password2` match.\n- Validates `new_password1` against configured password validators (`AUTH_PASSWORD_VALIDATORS`).\n- Updates the user's password and saves the old password in history.\n- Sets the user type to 'registered'.","operationId":"resetPassword","parameters":[{"$ref":"#/components/parameters/CSRFTokenHeader"},{"$ref":"#/components/parameters/CookieHeader"},{"name":"uidb64","in":"path","required":true,"schema":{"type":"string"},"description":"Base64 encoded user ID"},{"name":"token","in":"path","required":true,"schema":{"type":"string"},"description":"Password reset token"}],"requestBody":{"required":true,"content":{"application/x-www-form-urlencoded":{"schema":{"$ref":"#/components/schemas/PasswordResetRequest"}}}},"responses":{"200":{"description":"Password reset successfully"},"400":{"description":"Invalid token or password mismatch","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PasswordResetErrorResponse"}}}}}}}},"components":{"parameters":{"CSRFTokenHeader":{"name":"X-CSRFToken","in":"header","description":"CSRF token for write operations (POST, PUT, PATCH, DELETE).\nRequired for security when using session authentication.\nObtain token from cookie 'csrftoken' or meta tag in HTML.","required":true,"schema":{"type":"string"}},"CookieHeader":{"name":"Cookie","in":"header","description":"Session ID and CSRF token cookies.\nFormat: `sessionid=<id>; osessionid=<id>; csrftoken=<token>`","required":true,"schema":{"type":"string"}}},"schemas":{"PasswordResetRequest":{"type":"object","required":["new_password1","new_password2"],"properties":{"new_password1":{"type":"string","format":"password","description":"The new password. Validated against the system's password validators (e.g., minimum length, common passwords)."},"new_password2":{"type":"string","format":"password","description":"Confirmation of the new password. Must match 'new_password1'."}}},"PasswordResetErrorResponse":{"type":"object","properties":{"validlink":{"type":"boolean"},"errors":{"type":"object","additionalProperties":{"type":"array","items":{"type":"string"}}}}}}}}
```

## Change User City

> Updates the user's city preference.\
> \
> \*\*Business Logic:\*\*\
> \- Updates the 'city' attribute in the user's profile or session.

```json
{"openapi":"3.1.0","info":{"title":"User API","version":"1.0.0"},"tags":[{"name":"User","description":"User account management endpoints"}],"servers":[{"description":"Server base URL","url":"https://{commerce_url}","variables":{"commerce_url":{"default":"sandbox.akinon.com","description":"Commerce server URL"}}}],"security":[],"paths":{"/users/change_city/":{"post":{"tags":["User"],"summary":"Change User City","description":"Updates the user's city preference.\n\n**Business Logic:**\n- Updates the 'city' attribute in the user's profile or session.","operationId":"changeUserCity","parameters":[{"$ref":"#/components/parameters/CSRFTokenHeader"},{"$ref":"#/components/parameters/CookieHeader"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserCityRequest"}}}},"responses":{"200":{"description":"City updated successfully","content":{"application/json":{"schema":{"type":"object","properties":{"city":{"type":"integer","description":"ID of the updated city."}}}}}},"400":{"description":"City not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationErrorResponse"}}}}}}}},"components":{"parameters":{"CSRFTokenHeader":{"name":"X-CSRFToken","in":"header","description":"CSRF token for write operations (POST, PUT, PATCH, DELETE).\nRequired for security when using session authentication.\nObtain token from cookie 'csrftoken' or meta tag in HTML.","required":true,"schema":{"type":"string"}},"CookieHeader":{"name":"Cookie","in":"header","description":"Session ID and CSRF token cookies.\nFormat: `sessionid=<id>; osessionid=<id>; csrftoken=<token>`","required":true,"schema":{"type":"string"}}},"schemas":{"UserCityRequest":{"type":"object","required":["city"],"properties":{"city":{"type":"string","description":"City name or ID. Validated against available cities in the system."}}},"ValidationErrorResponse":{"type":"object","description":"Standard DRF validation error response","additionalProperties":{"type":"array","items":{"type":"string"}}}}}}
```

## Revoke Phone Number Change (Click-Through)

> Same operation as the \`POST\`, for the one-click link in the notice SMS.\
> The token travels as the \`token\` query parameter.

```json
{"openapi":"3.1.0","info":{"title":"User API","version":"1.0.0"},"tags":[{"name":"User","description":"User account management endpoints"}],"servers":[{"description":"Server base URL","url":"https://{commerce_url}","variables":{"commerce_url":{"default":"sandbox.akinon.com","description":"Commerce server URL"}}}],"security":[],"paths":{"/users/phone-change/revoke/":{"get":{"tags":["User"],"summary":"Revoke Phone Number Change (Click-Through)","description":"Same operation as the `POST`, for the one-click link in the notice SMS.\nThe token travels as the `token` query parameter.","operationId":"revokePhoneChangeClickThrough","parameters":[{"name":"token","in":"query","required":true,"schema":{"type":"string"},"description":"Revoke token, taken verbatim from the link"}],"responses":{"200":{"description":"Change reverted (empty body)"},"406":{"$ref":"#/components/responses/PhoneRevokeNotAllowed"},"429":{"$ref":"#/components/responses/Throttled"}}}}},"components":{"responses":{"PhoneRevokeNotAllowed":{"description":"The revoke token is invalid, expired, already used, or the number has\nchanged again since it was issued. One code covers all of them.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CodedErrorResponse"}}}},"Throttled":{"description":"Request was throttled (scope rate limit exceeded).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DetailErrorResponse"}}}}},"schemas":{"CodedErrorResponse":{"type":"object","description":"Business-error payload, returned with HTTP 406. `error_code` is stable —\nbranch on it, not on the translated message.","properties":{"non_field_errors":{"type":"string"},"error_code":{"type":"string"}}},"DetailErrorResponse":{"type":"object","properties":{"detail":{"type":"string"}}}}}}
```

## Revoke Phone Number Change (Kill-Switch)

> Restores the previous phone number from the signed token delivered by SMS\
> to the OLD number after a completed change.\
> \
> Unlike email, a phone change applies as soon as it is accepted on\
> \`PATCH /users/profile/\` — there is no confirmation link — so this is the\
> only undo path.\
> \
> \*\*Business Logic:\*\*\
> \- Single-use, and only valid within\
> &#x20; \`SECURE\_PHONE\_CHANGE\_REVOKE\_WINDOW\_DAYS\` (default 7).\
> \- Also refused when the number has changed again since the token was\
> &#x20; issued: a later legitimate change must not be clobbered by an older\
> &#x20; revoke link.\
> \- Unauthenticated by design (the token is the authorization).\
> \- Sends a "change reverted" SMS to the restored number.\
> \- Makes the account's current password \*\*unusable\*\* and starts the normal\
> &#x20; phone-based password-reset flow, texting a reset link to the restored\
> &#x20; number. A revoke means the change is presumed to have been an\
> &#x20; attacker's, so the password it was made with can no longer be trusted;\
> &#x20; the SMS tells the user this. Live sessions and the DRF auth token are\
> &#x20; left untouched. Delivery of the reset SMS requires the project to ship\
> &#x20; an \`sms/account/reset-password.html\` template — as with every SMS body,\
> &#x20; none are bundled, and a missing one is skipped silently.\
> \
> \*\*Notes:\*\*\
> \- The endpoint is always routed, but revoke tokens are only issued when the\
> &#x20; \`phone-change\` purpose is enabled in \`VERIFICATION\_TOKEN\_CONF\` — the\
> &#x20; kill-switch rides on the same switch as the step-up gate, there is no\
> &#x20; separate setting. Without that, no valid token exists and every call is\
> &#x20; refused with \`406\`.\
> \- Throttling scope: \`secure-phone-change-revoke\` (10 per hour per IP).

```json
{"openapi":"3.1.0","info":{"title":"User API","version":"1.0.0"},"tags":[{"name":"User","description":"User account management endpoints"}],"servers":[{"description":"Server base URL","url":"https://{commerce_url}","variables":{"commerce_url":{"default":"sandbox.akinon.com","description":"Commerce server URL"}}}],"security":[],"paths":{"/users/phone-change/revoke/":{"post":{"tags":["User"],"summary":"Revoke Phone Number Change (Kill-Switch)","description":"Restores the previous phone number from the signed token delivered by SMS\nto the OLD number after a completed change.\n\nUnlike email, a phone change applies as soon as it is accepted on\n`PATCH /users/profile/` — there is no confirmation link — so this is the\nonly undo path.\n\n**Business Logic:**\n- Single-use, and only valid within\n  `SECURE_PHONE_CHANGE_REVOKE_WINDOW_DAYS` (default 7).\n- Also refused when the number has changed again since the token was\n  issued: a later legitimate change must not be clobbered by an older\n  revoke link.\n- Unauthenticated by design (the token is the authorization).\n- Sends a \"change reverted\" SMS to the restored number.\n- Makes the account's current password **unusable** and starts the normal\n  phone-based password-reset flow, texting a reset link to the restored\n  number. A revoke means the change is presumed to have been an\n  attacker's, so the password it was made with can no longer be trusted;\n  the SMS tells the user this. Live sessions and the DRF auth token are\n  left untouched. Delivery of the reset SMS requires the project to ship\n  an `sms/account/reset-password.html` template — as with every SMS body,\n  none are bundled, and a missing one is skipped silently.\n\n**Notes:**\n- The endpoint is always routed, but revoke tokens are only issued when the\n  `phone-change` purpose is enabled in `VERIFICATION_TOKEN_CONF` — the\n  kill-switch rides on the same switch as the step-up gate, there is no\n  separate setting. Without that, no valid token exists and every call is\n  refused with `406`.\n- Throttling scope: `secure-phone-change-revoke` (10 per hour per IP).","operationId":"revokePhoneChange","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RevokeRequest"}}}},"responses":{"200":{"description":"Change reverted; the previous number is restored (empty body)"},"400":{"description":"`revoke_token` missing or malformed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationErrorResponse"}}}},"406":{"$ref":"#/components/responses/PhoneRevokeNotAllowed"},"429":{"$ref":"#/components/responses/Throttled"}}}}},"components":{"schemas":{"RevokeRequest":{"type":"object","required":["revoke_token"],"properties":{"revoke_token":{"type":"string","maxLength":1024,"description":"Signed token from the notice email/SMS, taken verbatim."}}},"ValidationErrorResponse":{"type":"object","description":"Standard DRF validation error response","additionalProperties":{"type":"array","items":{"type":"string"}}},"CodedErrorResponse":{"type":"object","description":"Business-error payload, returned with HTTP 406. `error_code` is stable —\nbranch on it, not on the translated message.","properties":{"non_field_errors":{"type":"string"},"error_code":{"type":"string"}}},"DetailErrorResponse":{"type":"object","properties":{"detail":{"type":"string"}}}},"responses":{"PhoneRevokeNotAllowed":{"description":"The revoke token is invalid, expired, already used, or the number has\nchanged again since it was issued. One code covers all of them.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CodedErrorResponse"}}}},"Throttled":{"description":"Request was throttled (scope rate limit exceeded).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DetailErrorResponse"}}}}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://apidocs.akinon.com/commerce-openapis/users/module-2/user.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
