Users API¶
Sylius users API endpoint is /api/users and it allows for browsing, creating & editing user data.
Index of all users¶
To browse all users available in the store you should call the following GET request:
GET /api/users/
Parameters¶
- page
- Number of the page, by default = 1
- limit
- Number of items to display per page
- criteria[query]
- Username, email or first & last names
Response¶
Response will contain a paginated list of users.
STATUS: 200 OK
{
"page":1,
"limit":10,
"pages":10,
"total":100,
"_links":{
"self":{
"href":"\/api\/users\/?page=1"
},
"first":{
"href":"\/api\/users\/?page=1"
},
"last":{
"href":"\/api\/users\/?page=12"
},
"next":{
"href":"\/api\/users\/?page=2"
}
},
"_embedded":{
"items":[
{
"credentials_expired": false,
"email": "chelsie.witting@example.com",
"email_canonical": "chelsie.witting@example.com",
"enabled": true,
"expired": false,
"groups": [],
"id": 481,
"locked": false,
"password": "EbOLtGHYxJKotA+bdb9BElhXPd8qZsnlo8CjDdCk+qFR22EEZJoOTntBX/M5GUXw2vnEqOKIEVPaJr66yxXqqQ==",
"roles": [],
"salt": "h9ltmmawvdsk08oocogkws4sg040k04",
"username": "chelsie.witting@example.com",
"username_canonical": "chelsie.witting@example.com"
}
]
}
}
Getting a single user¶
You can view a single user by executing the following request:
GET /api/users/481
Response¶
STATUS: 200 OK
{
"credentials_expired": false,
"email": "chelsie.witting@example.com",
"email_canonical": "chelsie.witting@example.com",
"enabled": true,
"expired": false,
"groups": [],
"id": 481,
"locked": false,
"password": "EbOLtGHYxJKotA+bdb9BElhXPd8qZsnlo8CjDdCk+qFR22EEZJoOTntBX/M5GUXw2vnEqOKIEVPaJr66yxXqqQ==",
"roles": [],
"salt": "h9ltmmawvdsk08oocogkws4sg040k04",
"username": "chelsie.witting@example.com",
"username_canonical": "chelsie.witting@example.com"
}
Create an user¶
To create a new user, you can execute the following request:
POST /api/users/
Parameters¶
- firstName
- Firstname of the customer
- lastName
- Lastname of the customer
- User e-mail
- plainPassword
- Password string
- enabled (optional)
- User account status (boolean)
Response¶
STATUS: 201 CREATED
{
"credentials_expired": false,
"email": "chelsie.witting@example.com",
"email_canonical": "chelsie.witting@example.com",
"enabled": true,
"expired": false,
"groups": [],
"id": 481,
"locked": false,
"password": "EbOLtGHYxJKotA+bdb9BElhXPd8qZsnlo8CjDdCk+qFR22EEZJoOTntBX/M5GUXw2vnEqOKIEVPaJr66yxXqqQ==",
"roles": [],
"salt": "h9ltmmawvdsk08oocogkws4sg040k04",
"username": "chelsie.witting@example.com",
"username_canonical": "chelsie.witting@example.com"
}
Updating a user¶
You can update an existing user using PUT or PATCH method:
PUT /api/users/481
PATCH /api/users/481
Parameters¶
- firstName
- Firstname of the customer
- lastName
- Lastname of the customer
- User e-mail
- plainPassword
- Password string
- enabled (optional)
- User account status (boolean)
Response¶
STATUS: 204 NO CONTENT
Deleting a user¶
You can delete (soft) a user from the system by making the following DELETE call:
DELETE /api/users/24
Response¶
STATUS: 204 NO CONTENT
Request password resetting¶
You can create a new password resetting request by calling the following API endpoint:
POST /api/password-resetting-requests/
Parameters¶
- username
- Username or e-mail
Response¶
The successful response will contain the user object with a confirmation token and date of password request.
STATUS: 200 OK
{
"confirmation_token": "dzOeNrmdnn20IVHBW2Uaq-yAYsO2sY2hCXhfKdYl_xM",
"credentials_expired": false,
"email": "sylius@example.com",
"email_canonical": "sylius@example.com",
"enabled": true,
"expired": false,
"groups": [],
"id": 1,
"last_login": "2014-12-08T13:08:02+0000",
"locked": false,
"password_requested_at": "2014-12-08T14:19:26+0000",
"roles": [
"ROLE_SYLIUS_ADMIN"
],
"username": "sylius@example.com",
"username_canonical": "sylius@example.com"
}