User Profile & Segment Management
GET
User Full Profile
This endpoint returns detailed information about the logged-in user, including their personal details such as name, email, phone number, gender, date of birth, and language preferences. It also includes settings for communication preferences and other attributes related to the user profile.
Path: /users/profile/
Authentication Required: Yes
Headers:
Accept-Language: <iso_language_code>
Cookie: <cookie-name>=<session_id>
Example Request
import requests
url = "https://{commerce_url}/users/profile/"
headers = {
'Accept-Language': '<iso_language_code>',
'Cookie': '<cookie-name>=<session_id>'
}
response = requests.get(url, headers=headers)
print(response.text)
Example Response (200 OK)
{
"id": 6471,
"first_name": "John",
"last_name": "Doe",
"email_allowed": true,
"sms_allowed": true,
"call_allowed": true,
"avatar": null,
"email": "example@example.com",
"phone": "0000000000",
"date_of_birth": "2000-01-01",
"gender": "male",
"genders": [
{
"value": "female",
"label": "female"
},
{
"value": "male",
"label": "male"
}
],
"language_code": "en-us",
"attributes": {
"register_client_type": "anonymous",
"logged_ip": "0.0.0.0",
"kvkk_flat_page_version": "000",
"confirm": true
},
"date_joined": "2024-01-01T00:00:00.000000Z"
}
Response Parameters:
Property | Data Type | Description |
---|---|---|
email_allowed | Boolean | Indicates whether the user has allowed receiving emails. |
sms_allowed | Boolean | Indicates whether the user has allowed receiving SMS. |
call_allowed | Boolean | Indicates whether the user has allowed receiving phone calls. |
GET
User Detail
This endpoint retrieves the details of the authenticated user, including their username, email, and full name.
Path: /users/user/
Authentication Required: Yes
Headers:
Accept-Language: <iso_language_code>
Cookie: <cookie-name>=<session_id>
Example Request
import requests
url = "https://{commerce_url}/users/user/"
headers = {
'Accept-Language': '<iso_language_code>',
'Cookie': '<cookie-name>=<session_id>'
}
response = requests.get(url, headers=headers)
print(response.status_code)
Example Response (200 OK)
{
"username": "test-user",
"email": "test@akinon.com",
"first_name": "TestFirstName",
"last_name": "TestLastName"
}
PATCH
Update User Profile
This method is used to update the user profile information.
Path: /users/profile/
Authentication Required: Yes
Headers:
Content-Type: application/json
Cookie: <cookie-name>=<session_id>
Accept-Language: <iso_language_code>
x-csrftoken: <token>
Body Parameters
Property | Data Type | Required | Description |
---|---|---|---|
first_name | String | False | The first name of the user. |
last_name | String | False | The last name of the user |
email_allowed | Boolean | False | Indicates if the user consents to receiving emails. |
sms_allowed | Boolean | False | Indicates if the user consents to receiving SMS messages. |
call_allowed | Boolean | False | Indicates if the user consents to receiving phone calls. |
gender | String | False | Enum type representing the user's gender (male , female ). |
date_of_birth | Datefield | False | The user's date of birth, formatted as YYYY-MM-DD . |
phone | String | True | The user's phone number, validated and required for updates. |
attributes | Dict | False | Additional customizable user attributes in key-value pairs. |
language_code | String | False | The user's preferred language code (e.g., en , de ). |
avatar | Image | False | The profile image of the user. |
code | String | False | The verification code required for phone number changes. This parameter is used in UserProfileKvkkViewSet and UserProfileSMSOtpView. |
resend | Boolean | False | Indicates if an verification code should be resent. This parameter is used in UserProfileKvkkViewSet and UserProfileSMSOtpView. |
Request Body
{
"first_name": "John",
"last_name": "Doe",
"email_allowed": true,
"sms_allowed": true,
"call_allowed": false
}
Example Request
import requests
import json
url = "https://{commerce_url}/users/otp-login/"
headers = {
'Content-Type': 'application/json',
'Cookie': '<cookie-name>=<session_id>'
'Accept-Language': '<iso_language_code>',
'x-csrftoken': '<token>'
}
payload = json.dumps({
"first_name": "John",
"last_name": "Doe",
"email_allowed": true,
"sms_allowed": true,
"call_allowed": false
})
response = requests.patch(url, headers=headers, data=payload)
print(response.text)
Example Response (200 OK)
{
"id": 1234,
"first_name": "John",
"last_name": "Doe",
"email_allowed": true,
"sms_allowed": true,
"call_allowed": null,
"avatar": null,
"email": "john.doe@example.com",
"phone": "0123456789",
"date_of_birth": "2000-01-01",
"gender": "male",
"genders": [
{
"value": "female",
"label": "female"
},
{
"value": "male",
"label": "male"
}
],
"language_code": "en-us",
"attributes": {
"register_client_type": "default",
"logged_ip": "0.0.0.0",
"kvkk_flat_page_version": "999",
"confirm": true
},
"date_joined": "2024-01-01T00:00:00.000000Z"
}
Example Response (202 Accepted)
{
"email_allowed": true,
"sms_allowed": true,
"call_allowed": null,
"avatar": null,
"email": "john.doe@example.com",
"date_of_birth": "2000-01-01",
"language_code": "en-us",
"date_joined": "2024-01-01T00:00:00.000000Z"
}
Example Response (406 Not Acceptable)
{
"non_field_errors": "Mismatch confirmation data {phone}, {sms_allowed}, {email_allowed}, {call_allowed}, {email}.",
"error_code": "kvkk_service_100_2"
}
{
"non_field_errors": "Sms otp code expired. Please resend code.",
"error_code": "sms_verification_100_4"
}
{
"non_field_errors": "Phone numbers do not match.",
"error_code": "sms_verification_100_1"
}
{
"non_field_errors": "Verification codes do not match.",
"error_code": "sms_verification_100_2"
}
GET
User Profile Information with Loyalty Card Account
This endpoint allows authenticated loyalty card users to retrieve their profile information.
Path: /users/profile-with-loyalty/
Authentication Required: Yes
Headers:
Content-Type: application/json
Accept-Language: <iso_language_code>
Cookie: <cookie-name>=<session_id>
Example Request
import requests
import json
url = "https://{commerce_url}/users/profile-with-loyalty/"
headers = {
'Content-Type': 'application/json',
'Accept-Language': '<iso_language_code>',
'Cookie': '<cookie-name>=<session_id>'
}
response = requests.get(url, headers=headers)
print(response.text)
Example Response (200 OK)
{
"id": 1234,
"first_name": "John",
"last_name": "Doe",
"email_allowed": false,
"sms_allowed": true,
"call_allowed": false,
"avatar": "https://example.com/avatar.png",
"email": "john.doe@example.com",
"phone": "0123456789",
"date_of_birth": "1990-05-15",
"gender": "male",
"genders": [
{
"value": "female",
"label": "female"
},
{
"value": "male",
"label": "male"
}
],
"language_code": "en-gb",
"attributes": {
"register_client_type": "mobile",
"logged_ip": "192.168.1.1",
"kvkk_flat_page_version": "101",
"confirm": false
},
"date_joined": "2023-06-01T12:30:45.123456Z"
}
PATCH
Update User Profile with Loyalty Card Account
This endpoint allows authenticated users to update their profile information. Updates can include changes to the phone number, which may require optional SMS verification, and synchronization with a linked loyalty card account.
The CUSTOMER_LOYALTY_CARD_SERVICE
dynamic setting must be configured to communicate with the 3rd party loyalty card service.
The system validates the phone number to ensure its uniqueness.
If a phone number change is requested:
- The system requires an SMS verification code (via the
code
field). - If the
resend
is set to true, a new SMS verification code will be sent.
Path: /users/profile-with-loyalty/
Authentication Required: Yes
Headers:
Content-Type: application/json
Cookie: <cookie-name>=<session_id>
Accept-Language: <iso_language_code>
x-csrftoken: <token>
Body Parameters
Property | Data Type | Required | Description |
---|---|---|---|
first_name | String | False | The first name of the user. |
last_name | String | False | The last name of the user |
email_allowed | Boolean | False | Indicates if the user consents to receiving emails. |
sms_allowed | Boolean | False | Indicates if the user consents to receiving SMS messages. |
call_allowed | Boolean | False | Indicates if the user consents to receiving phone calls. |
gender | String | False | Enum type representing the user's gender (male , female ). |
date_of_birth | Datefield | True | The user's date of birth, formatted as YYYY-MM-DD . |
phone | String | True | The user's phone number, validated and required for updates. |
attributes | Dict | False | Additional customizable user attributes in key-value pairs. |
language_code | String | False | The user's preferred language code (e.g., en , de ). |
code | String | False | The SMS verification code required for phone number changes. |
resend | Boolean | False | Indicates if an SMS verification code should be resent. |
Request Body
{
"phone": "5555555555",
"code": "123456",
"resend": false,
"date_of_birth": "1990-01-01",
"gender": "male",
"attributes": {"preferred_language": "English"}
}
Example Request
import requests
import json
url = "https://{commerce_url}/users/otp-login/"
headers = {
'Content-Type': 'application/json',
'Cookie': '<cookie-name>=<session_id>'
'Accept-Language': '<iso_language_code>',
'x-csrftoken': '<token>'
}
payload = json.dumps({
"phone": "5555555555",
"code": "123456",
"resend": false,
"date_of_birth": "1990-01-01",
"gender": "male",
"attributes": {"preferred_language": "English"}
})
response = requests.patch(url, headers=headers, data=payload)
print(response.text)
Example Response (202 Accepted)
SMS verification is required, and a code has been sent to the new phone number:
{
"id": 1234,
"first_name": "John",
"last_name": "Doe",
"email_allowed": false,
"sms_allowed": true,
"call_allowed": false,
"avatar": "https://example.com/avatar.png",
"email": "john.doe@example.com",
"phone": "0123456789",
"date_of_birth": "1990-05-15",
"gender": "male",
"genders": [
{
"value": "female",
"label": "female"
},
{
"value": "male",
"label": "male"
}
],
"language_code": "en-gb",
"attributes": {
"register_client_type": "mobile",
"logged_ip": "192.168.1.1",
"kvkk_flat_page_version": "101",
"confirm": false
},
"date_joined": "2023-06-01T12:30:45.123456Z"
}
Example Response (200 OK)
{
"id": 1234,
"first_name": "John",
"last_name": "Doe",
"email_allowed": false,
"sms_allowed": true,
"call_allowed": false,
"avatar": "https://example.com/avatar.png",
"email": "john.doe@example.com",
"phone": "0123456789",
"date_of_birth": "1990-05-15",
"gender": "male",
"genders": [
{
"value": "female",
"label": "female"
},
{
"value": "male",
"label": "male"
}
],
"language_code": "en-gb",
"attributes": {
"register_client_type": "mobile",
"logged_ip": "192.168.1.1",
"kvkk_flat_page_version": "101",
"confirm": false
},
"date_joined": "2023-06-01T12:30:45.123456Z"
}
When resend
is True:
{
"message": "success"
}
Example Response (406 Not Acceptable)
{
"non_field_errors": "Phone numbers do not match.",
"error_code": "sms_verification_100_1"
}
{
"non_field_errors": "Verification codes do not match.",
"error_code": "sms_verification_100_2"
}
Example Response (400 Bad Request)
{
"phone": [
"This field is required."
]
}
POST
User Register with Loyalty Card Account
This endpoint allows users to register a new account, with the option to link their account to a loyalty card. The registration process includes SMS verification for the phone number and, if requested, loyalty account synchronization.
The CUSTOMER_LOYALTY_CARD_SERVICE
dynamic setting must be configured to communicate with the third-party loyalty card service.
- The system validates the phone number to ensure it is unique.
- The system requires an SMS verification code, provided in the
code
field. - If resend is set to true, a new SMS verification code is sent.
- If add_loyalty is set to true, a loyalty card is created and synchronized with the user's account.
Path: /users/register-with-loyalty/
Authentication Required: No
Headers:
Content-Type: application/json
Accept-Language: <iso_language_code>
x-csrftoken: <token>
Body Parameters
Property | Data Type | Required | Description |
---|---|---|---|
first_name | String | True | The first name of the user. |
last_name | String | True | The last name of the user |
String | True | The email address of the user. | |
password | String | True | The password of the user |
phone | String | True | The user's phone number, validated and required for updates. |
email_allowed | Boolean | False | Indicates if the user consents to receiving emails. |
sms_allowed | Boolean | False | Indicates if the user consents to receiving SMS messages. |
call_allowed | Boolean | False | Indicates if the user consents to receiving phone calls. |
gender | String | False | Enum type representing the user's gender (male , female ). |
date_of_birth | String | True | The user's date of birth, formatted as YYYY-MM-DD . |
attributes | Dict | False | Additional customizable user attributes in key-value pairs. |
language_code | String | False | The user's preferred language code (e.g., en , de ). |
code | String | False | The SMS verification code required for phone number changes. |
resend | Boolean | False | Indicates if an SMS verification code should be resent. |
add_loyalty | Boolean | False | Indicates whether a loyalty card should be created and linked to the user. |
Request Body
{
"first_name": "John",
"last_name": "Doe",
"email": "john.doe@example.com",
"password": "SecurePassword123",
"phone": "+1234567890",
"date_of_birth": "1990-01-01",
"gender": "male",
"add_loyalty": true,
"email_allowed": true,
"sms_allowed": true,
"call_allowed": false
}
Example Request
import requests
import json
url = "https://{commerce_url}/users/otp-login/"
headers = {
'Content-Type': 'application/json',
'Accept-Language': '<iso_language_code>',
'x-csrftoken': '<token>'
}
payload = json.dumps({
"first_name": "John",
"last_name": "Doe",
"email": "john.doe@example.com",
"password": "SecurePassword123",
"phone": "+1234567890",
"date_of_birth": "1990-01-01",
"gender": "male",
"add_loyalty": true,
"email_allowed": true,
"sms_allowed": true,
"call_allowed": false
})
response = requests.post(url, headers=headers, data=payload)
print(response.text)
Example Response (201 Created)
{
"id": 1234,
"first_name": "John",
"last_name": "Doe",
"email_allowed": false,
"sms_allowed": true,
"call_allowed": false,
"avatar": "https://example.com/avatar.png",
"email": "john.doe@example.com",
"phone": "0123456789",
"date_of_birth": "1990-05-15",
"gender": "male",
"genders": [
{
"value": "female",
"label": "female"
},
{
"value": "male",
"label": "male"
}
],
"language_code": "en-gb",
"attributes": {
"register_client_type": "mobile",
"logged_ip": "192.168.1.1",
"kvkk_flat_page_version": "101",
"confirm": false
},
"date_joined": "2023-06-01T12:30:45.123456Z"
}
Example Response (202 Accepted)
{
"id": 1234,
"first_name": "John",
"last_name": "Doe",
"email_allowed": false,
"sms_allowed": true,
"call_allowed": false,
"avatar": "https://example.com/avatar.png",
"email": "john.doe@example.com",
"phone": "0123456789",
"date_of_birth": "1990-05-15",
"gender": "male",
"genders": [
{
"value": "female",
"label": "female"
},
{
"value": "male",
"label": "male"
}
],
"language_code": "en-gb",
"attributes": {
"register_client_type": "mobile",
"logged_ip": "192.168.1.1",
"kvkk_flat_page_version": "101",
"confirm": false
},
"date_joined": "2023-06-01T12:30:45.123456Z"
}
Example Response (200 OK)
When resend
is True:
{
"message": "success"
}
Example Response (406 Not Acceptable)
{
"non_field_errors": "Phone numbers do not match.",
"error_code": "sms_verification_100_1"
}
{
"non_field_errors": "Verification codes do not match.",
"error_code": "sms_verification_100_2"
}
GET
List User Segments
Lists all segments that are assigned to the authenticated user. Segments are typically used for categorizing users based on different attributes like roles, behaviors, or preferences.
Path: /users/segments/
Authentication Required: Yes
Headers:
Accept-Language: <iso_language_code>
Cookie: <cookie-name>=<session_id>
Example Request
import requests
url = "https://{commerce_url}/users/segments/"
headers = {
'Accept-Language: '<iso_language_code>',
'Cookie': '<cookie-name>=<session_id>'
}
response = requests.get(url, headers=headers)
print(response.text)
Example Response (200 OK)
[
{
"priority": 0,
"pk": 107,
"name": "Employee Segment"
},
{
"priority": 1,
"pk": 108,
"name": "Manager Segment"
}
]
Response Parameters:
Property | Data Type | Description |
---|---|---|
pk | Integer | The unique ID of the segment. |
priority | Integer | The priority of the segment, which may affect its ordering. |
name | String | The name of the segment. |
POST
Set User Segment
This endpoint is used to assign a specific segment to the authenticated user. Segments are typically used for categorizing users based on different attributes like roles, behaviors, or preferences.
Set a specific segment for the authenticated user.
Path: /users/segments/<segment_id>/set/
Authentication Required: Yes
Headers:
Accept-Language: <iso_language_code>
Cookie: <cookie-name>=<session_id>
x-csrftoken: <token>
Example Request
import requests
url = "https://{commerce_url}/segments/<pk>/set/"
headers = {
'Accept-Language: '<iso_language_code>',
'Cookie': '<cookie-name>=<session_id>',
'x-csrftoken': '<token>'
}
response = requests.post(url, headers=headers)
print(response.json())
Example Response (200 OK)
{
"priority": 0,
"pk": 109,
"price_list": {
"pk": 73,
"name": "Default Price List",
"code": "T123",
"currency": "usd"
},
"name": "Employee Segment"
}
Example Response (406 Not Acceptable)
{
"non_field_errors": "Segment with ID 12 is not available for user 10.",
"error_code": "segment_100_1"
}