Users
List users visible to the authenticated user. If the user is not an admin, they will only be able to see their own user, unless they have custom permissions to see other users. If the user is an admin then they can see all users.
GET /api/v1/users
Users are paginated and can be iterated through by passing along a page
parameter:
GET /api/v1/users?page=2
Response
{"users": [{"id": 1,"email": "boxid@example.com","login": "boxid@example.com","spree_api_key": null,"created_at": "Fri, 01 Feb 2013 20:38:57 UTC +00:00","updated_at": "Fri, 01 Feb 2013 20:38:57 UTC +00:00"}],"count": 25,"pages": 5,"current_page": 1}
A single user
To view the details for a single user, make a request using that user’s id:
GET /api/v1/users/1
Successful Response
{"id": 1,"email": "boxid@example.com","login": "boxid@example.com","spree_api_key": null,"created_at": "Fri, 01 Feb 2013 20:38:57 UTC +00:00","updated_at": "Fri, 01 Feb 2013 20:38:57 UTC +00:00"}
Not Found Response
{"error": "The resource you were looking for could not be found."}
Pre-creation of a user
You can learn about the potential attributes (required and non-required) for a user by making this request:
GET /api/v1/users/new
Response
{
"attributes": ["<attribute1>", "<attribute2>"],
"required_attributes": []
}
Creating a new new
To create a new user through the API, make this request with the necessary parameters:
POST /api/v1/users
For instance, a request to create a new user with the email ”boxid@example.com” and password ”password” would look like this:
POST /api/v1/users?user[email]=boxid@example.com&user[password]=password
Successful response
Failed response
{
"error": "Invalid resource. Please fix errors and try again.",
"errors": {
"email": ["can't be blank"]
}
}
Updating a user
To update a user’s details, make this request with the necessary parameters:
PUT /api/v1/users/1
For instance, to update a user’s password, send it through like this:
PUT /api/v1/users/1?user[password]=password
Successful response
Failed response
{
"error": "Invalid resource. Please fix errors and try again.",
"errors": {
"email": ["can't be blank"]
}
}
Deleting a user
To delete a user, make this request:
DELETE /api/v1/users/1