APIDeveloperUserRelease NotesDemoContact Us
  • Api

    • Summary
    • Address
    • Checkouts
    • Countries
    • Customer Returns
    • Line Items
    • Option Types
    • Option Values
    • Orders
    • Payments
    • Product Images
    • Product Properties
    • Products
    • Return Authorizations
    • Shipments
    • States
    • Stock Items
    • Stock Locations
    • Stock Movements
    • Taxonomies
    • Users
    • Variants
    • Zones

Table Of Contents

ResponseA single userSuccessful ResponseNot Found ResponsePre-creation of a userResponseCreating a new newSuccessful responseFailed responseUpdating a userSuccessful responseFailed responseDeleting a userResponse

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

Status:
200 OK
{
"users": [
{
"id": 1,
"email": "[email protected]",
"login": "[email protected]",
"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

Status:
200 OK
{
"id": 1,
"email": "[email protected]",
"login": "[email protected]",
"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

Status:
404 Not Found
{
"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

Status:
200 OK
{
  "attributes": ["<attribute1>", "<attribute2>"],
  "required_attributes": []
}

Creating a new new

This action is only accessible by an admin user.

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 ”[email protected]” and password ”password” would look like this:

POST /api/v1/users?user[email][email protected]&user[password]=password

Successful response

Status:
201 Created

Failed response

Status:
422 Unprocessable Entity
{
  "error": "Invalid resource. Please fix errors and try again.",
  "errors": {
    "email": ["can't be blank"]
  }
}

Updating a user

This action is only accessible by an admin 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

Status:
201 Created

Failed response

Status:
422 Unprocessable Entity
{
  "error": "Invalid resource. Please fix errors and try again.",
  "errors": {
    "email": ["can't be blank"]
  }
}

Deleting a user

This action is only accessible by an admin user.

To delete a user, make this request:

DELETE /api/v1/users/1

Response

Status:
204 No Content
Propose changes to this page
Designed and developed bySpree Commerce & Ruby on Rails developers© Spree Commerce. 2021 All Rights Reserved.