User
User management is a critical aspect of any e-commerce system. Sleekshop provides a range of endpoints to manage user accounts efficiently. On this page, we'll explore the different user endpoints you can use to register, verify, and authenticate users.
The user model
The user model in Sleekshop contains all the information about a user account, including authentication details and personal information.
Properties
- Name
id_user
- Type
- integer
- Description
Unique identifier for the user.
- Name
username
- Type
- string
- Description
The username of the user.
- Name
email
- Type
- string
- Description
The email address of the user.
- Name
default_language
- Type
- string
- Description
The default language code for the user.
- Name
reg_date
- Type
- string
- Description
The date when the user registered.
- Name
first_login
- Type
- string
- Description
The date of the user's first login.
- Name
last_login
- Type
- string
- Description
The date of the user's most recent login.
- Name
security_level
- Type
- integer
- Description
The security level of the user, determining their access rights.
Register user
This endpoint allows you to create a new user account.
Required attributes
- Name
language
- Type
- string
- Description
The language code for the user.
- Name
args
- Type
- object
- Description
An object containing user registration details.
Args object properties
- Name
username
- Type
- string
- Description
The unique username (4-60 characters, a-z A-Z 0-9 !@$).
- Name
passwd1
- Type
- string
- Description
The user's password (3-30 characters, a-z A-Z 0-9 !@$).
- Name
passwd2
- Type
- string
- Description
Confirmation of the password (must match passwd1).
- Name
email
- Type
- string
- Description
A valid email address for the user.
- Name
class
- Type
- string
- Description
Optional. The class to use for creating the user. If not specified, the default 'user' class will be used.
Request
curl https://demo.sleekshop.net/srv/service/ \
-d licence_username='demo_NBSqhrcrhMci15Ir9UWI' \
-d licence_password='s9vmrbwT23B7bmjR4Vmz' \
-d request='register_user' \
-d language='de_DE' \
-d args='{"username":"testuser123","passwd1":"thesecret","passwd2":"thesecret","email":"info@sleekcommerce.com"}'
Response
{
"object": "register_user",
"status": "SUCCESS",
"id_user": 26,
"session_id": "UvZABz5GKvOLtyYPC6wQ"
}
Verify user
This endpoint is used to verify a newly created user account. The account must be verified before the user can log in.
Required attributes
- Name
id_user
- Type
- integer
- Description
The ID of the user to verify.
- Name
session_id
- Type
- string
- Description
The session ID generated during user registration.
Request
curl https://demo.sleekshop.net/srv/service/ \
-d licence_username='demo_NBSqhrcrhMci15Ir9UWI' \
-d licence_password='s9vmrbwT23B7bmjR4Vmz' \
-d request='verify_user' \
-d id_user=1 \
-d session_id="asddsaasddas"
Response
{
"object": "verify_user",
"status": "SUCCESS"
}
Login user
This endpoint allows you to authenticate a user and create a new session.
Required attributes
- Name
username
- Type
- string
- Description
The username of the user to log in.
- Name
password
- Type
- string
- Description
The password of the user.
- Name
session
- Type
- string
- Description
Optional. An existing session ID to associate with this login.
Request
curl https://demo.sleekshop.net/srv/service/ \
-d licence_username='demo_NBSqhrcrhMci15Ir9UWI' \
-d licence_password='s9vmrbwT23B7bmjR4Vmz' \
-d request='login_user' \
-d username='testuser' \
-d password="thesecret123" \
-d session="asddsaasddsa"
Response
{
"object": "login_user",
"status": "SUCCESS",
"id_user": 1,
"session_id": "uXu6SddddsdsaqO8UA74qdGZMUDk",
"username": "root",
"email": "info@xyz.de",
"default_language": "de_DE",
"reg_date": "2016-03-22 11:08:58",
"first_login": "2016-03-22 11:41:07",
"last_login": "2018-11-05 15-17-40",
"security_level": 1001
}
Logout user
This endpoint allows you to log out a user from their current session.
Required attributes
- Name
session
- Type
- string
- Description
A valid session with a logged-in user.
Request
curl https://demo.sleekshop.net/srv/service/ \
-d licence_username='demo_NBSqhrcrhMci15Ir9UWI' \
-d licence_password='s9vmrbwT23B7bmjR4Vmz' \
-d request='logout_user' \
-d session="asddsaasd123321s"
Response
{
"object": "logout_user",
"status": "SUCCESS"
}
Set user password
This endpoint allows a logged-in user to change their password.
Required attributes
- Name
session
- Type
- string
- Description
A session of a logged-in user.
- Name
old_passwd
- Type
- string
- Description
The current password of the logged-in user.
- Name
new_passwd1
- Type
- string
- Description
The new password.
- Name
new_passwd2
- Type
- string
- Description
Repetition of the new password for confirmation.
Request
curl https://demo.sleekshop.net/srv/service/ \
-d licence_username='demo_NBSqhrcrhMci15Ir9UWI' \
-d licence_password='s9vmrbwT23B7bmjR4Vmz' \
-d session='valid_session' \
-d request='set_user_password' \
-d old_passwd='old_password' \
-d new_passwd1="thesecret123" \
-d new_passwd2="thesecret123"
Response
{
"object": "set_user_password",
"status": "SUCCESS"
}
Reset user password (init)
This is the first step in the password reset process. It initiates the password reset for a given email address.
Required attributes
- Name
args
- Type
- object
- Description
An object containing the email address for password reset.
Args object properties
- Name
email
- Type
- string
- Description
The email address of the user requesting a password reset.
Request
curl https://demo.sleekshop.net/srv/service/ \
-d licence_username='demo_NBSqhrcrhMci15Ir9UWI' \
-d licence_password='s9vmrbwT23B7bmjR4Vmz' \
-d request='reset_user_password' \
-d args='{"email":"email@domain.com"}'
Response
{
"object": "reset_user_password",
"status": "init",
"id_user": 13,
"session_id": "SG6mLKG2ml1WPsssySg3vLW",
"username": "the_username",
"email": "email@domain.com",
"default_language": "de_DE"
}
Reset user password (success)
This is the second step in the password reset process. It completes the password reset using the information received from the init step.
Required attributes
- Name
args
- Type
- object
- Description
An object containing the necessary information to reset the password.
Args object properties
- Name
session_id
- Type
- string
- Description
The unique session_id delivered by the init process.
- Name
id_user
- Type
- integer
- Description
The id of the user you want to reset the password for.
- Name
new_passwd1
- Type
- string
- Description
The new password for the user.
- Name
new_passwd2
- Type
- string
- Description
Confirmation of the new password.
Request
curl https://demo.sleekshop.net/srv/service/ \
-d licence_username='demo_NBSqhrcrhMci15Ir9UWI' \
-d licence_password='s9vmrbwT23B7bmjR4Vmz' \
-d request='reset_user_password' \
-d args='{"session_id":"valid_session","id_user":13,"new_passwd1":"secret123","new_passwd2":"secret123"}'
Response
{
"object": "reset_user_password",
"status": "success",
"id_user": 13,
"session_id": "SG6mLKG2ml1WPsssySg3vLW",
"username": "the_username",
"email": "email@domain.com",
"default_language": "de_DE"
}
Get user orders
This endpoint allows you to retrieve all orders for a logged-in user.
Required attributes
- Name
session
- Type
- string
- Description
The session where the user is logged in.
Request
curl https://demo.sleekshop.net/srv/service/ \
-d licence_username='demo_NBSqhrcrhMci15Ir9UWI' \
-d licence_password='s9vmrbwT23B7bmjR4Vmz' \
-d request='get_user_orders' \
-d session='SESSION'
Response
{
"object": "get_user_orders",
"orders": [
{
"id": 63,
"order_number": 63,
"creation_date": "2019-01-01 21:03:57",
"order_delivery_companyname": "",
"order_delivery_department": "",
"order_delivery_salutation": "Herr",
"order_delivery_firstname": "test",
"order_delivery_lastname": "user",
// More order details...
"cart": {
"creation_date": "2019-01-01 21:02:16",
"sum": 17.5,
"contents": [
// Cart contents...
],
"delivery_costs": {
"sum": 0,
"positions": []
}
},
"parcels": []
}
]
}
Get user data
This endpoint allows you to retrieve all data for a logged-in user.
Required attributes
- Name
session
- Type
- string
- Description
The session of the logged-in user.
Request
curl https://demo.sleekshop.net/srv/service/ \
-d licence_username='demo_NBSqhrcrhMci15Ir9UWI' \
-d licence_password='s9vmrbwT23B7bmjR4Vmz' \
-d request='get_user_data' \
-d session='SESSION'
Response
{
"object": "get_user_data",
"status": "active",
"id_user": 29,
"session_id": "JUPozxdbsBtQSlEtb1Lp",
"username": "testuser",
"email": "info@sleekshop.io",
"default_language": "de_DE",
"reg_date": "2019-01-01 21:03:01",
"first_login": "2019-01-01 21:03:16",
"last_login": "2019-01-01 21:04:25",
"attributes": {
"salutation": {
"name": "salutation",
"value": "Herr"
},
// More attributes...
},
"additional_attributes": {
// Additional attributes...
},
"addresses": []
}
Get user by ID
This endpoint allows you to retrieve user data by user ID.
Required attributes
- Name
id_user
- Type
- integer
- Description
The ID of the user.
Request
curl https://demo.sleekshop.net/srv/service/ \
-d licence_username='demo_NBSqhrcrhMci15Ir9UWI' \
-d licence_password='s9vmrbwT23B7bmjR4Vmz' \
-d request='get_user_by_id' \
-d id_user=1
Response
{
"object": "get_user_data",
"status": "active",
"id_user": 29,
"session_id": "JUPozxdbsBtQSlEtb1Lp",
"username": "testuser",
"email": "info@sleekshop.io",
"default_language": "de_DE",
"reg_date": "2019-01-01 21:03:01",
"first_login": "2019-01-01 21:03:16",
"last_login": "2019-01-01 21:04:25",
"attributes": {
// User attributes...
},
"additional_attributes": {
// Additional attributes...
},
"addresses": []
}
Set user data
This endpoint allows you to set or update user data for a logged-in user.
Required attributes
- Name
session
- Type
- string
- Description
The session of the logged-in user.
- Name
attributes
- Type
- object
- Description
An object containing the user data to be updated.
Attributes object properties
- Name
email
- Type
- string
- Description
A valid email address for the user.
- Name
salutation
- Type
- string
- Description
The salutation of the user.
- Name
firstname
- Type
- string
- Description
The first name of the user.
- Name
lastname
- Type
- string
- Description
The last name of the user.
- Name
companyname
- Type
- string
- Description
The company name of the user.
- Name
department
- Type
- string
- Description
The department of the user.
- Name
street
- Type
- string
- Description
The street address of the user.
- Name
number
- Type
- string
- Description
The house number of the user.
- Name
zip
- Type
- string
- Description
The zip code of the user.
- Name
city
- Type
- string
- Description
The city of the user.
- Name
state
- Type
- string
- Description
The state of the user.
- Name
country
- Type
- string
- Description
A valid country code for the user.
Request
curl https://demo.sleekshop.net/srv/service/ \
-d licence_username='demo_NBSqhrcrhMci15Ir9UWI' \
-d licence_password='s9vmrbwT23B7bmjR4Vmz' \
-d request='set_user_data' \
-d session='SESSION' \
-d attributes='{"department":"test", "firstname":"my_firstname", "lastname":"my_lastname"}'
Response
{
"object": "set_user_data",
"status": "SUCCESS"
}
Update user data
This endpoint allows you to update an existing user's data by user ID.
Required attributes
- Name
id_user
- Type
- integer
- Description
The ID of the user to update.
- Name
attributes
- Type
- object
- Description
An object containing the user data to be updated.
Request
curl https://demo.sleekshop.net/srv/service/ \
-d licence_username='demo_NBSqhrcrhMci15Ir9UWI' \
-d licence_password='s9vmrbwT23B7bmjR4Vmz' \
-d licence_secret_key='your_secret_key' \
-d request='update_user_data' \
-d id_user=1 \
-d attributes='{"name":"Test"}'
Response
{
"object": "update_user_data",
"status": "success"
}
Instant login
This endpoint allows for instant login of users from the backend into remote applications communicating with the API.
Required attributes
- Name
token
- Type
- string
- Description
The token delivered to the iframe.
- Name
application_token
- Type
- string
- Description
The application token generated when creating the application in the backend.
Request
curl https://demo.sleekshop.net/srv/service/ \
-d licence_username='demo_NBSqhrcrhMci15Ir9UWI' \
-d licence_password='s9vmrbwT23B7bmjR4Vmz' \
-d request='instant_login' \
-d token='asddsaasddasdasdasdasd' \
-d application_token="asdalskdjlasjdlkasdlasjdkasjd"
Response
{
"object": "login_user",
"status": "SUCCESS",
"id_user": 1,
"session_id": "uXu6SddddsdsaqO8UA74qdGZMUDk",
"remote_session": "aslkjdlaksjdlkajdlkajsdkljasdlkjsa",
"username": "root",
"email": "info@xyz.de",
"default_language": "de_DE",
"reg_date": "2016-03-22 11:08:58",
"first_login": "2016-03-22 11:41:07",
"last_login": "2018-11-05 15-17-40"
}