# 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"}}}}}}
```


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

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

The question should be specific, self-contained, and written in natural language.
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.
