REST API - Users

Last edit: Aug 16, 2019
  • Contributors:
  • Slashek
  • pavelloz

Create

To create a user, send a POST request to /api/users

HTTP request

POST /api/users

Parameters

Parameter Type Description Required Notes
form_name String Name of the form configuration Required
form UserForm UserForm parameters that corresponds with Form configuration Required

User Parameters

Parameter Type Description Required Notes
email String User's email address Required Default validation for presence, uniqueness, email format
external_id String custom external ID for the user, example in a third party database Optional
featured Boolean Whether the user is featured Optional
first_name String User's first name Optional
last_name String User's last name Optional
middle_name String User's middle name Optional
name String Name of the user Optional
password String password for the user Optional Default validation minimum 6 chars
profiles Hash[String=>UserProfileForm] Form for updating profiles for this user Optional
public_profile Boolean whether the profile has been marked as public Optional
transactables Hash[String=>TransactableForm] Form for updating a user's transactable(s) Optional

Example request

"Authorization: Token token=[YOUR API TOKEN]"
"Accept: application/json"
"Content-Type: application/json"

{
  "form_name": "reference_rest_api_create_user",
  "form": {
    "first_name": "Example",
    "email": "example1@example.com",
    "password": "somepassword"
  }
}
Element Type Description Required?
form_name String Name of the defined Form Required
form UserForm Attributes for user, should match configuration defined in corresponding Form Required

Example response

HTTP/1.1 201 Created
Content-Type: application/vnd.api+json

{
  "id": 1,
  "errors": {}
}

Element Type Description
id Integer Object identifier
errors Object Validation errors

Error and Status Codes

Code Message Meaning
201 Created Resource was created
401 Unathorized Invalid Authentication
406 Not Acceptable Wrong parameters passed
422 Unprocessable Entity Wrong values, not matched validations

Update

To update an user, send a PUT request to /api/users/:user_id

HTTP request

PUT /api/users/:user_id

Parameters

Parameter Type Description Required Notes
form_name String Name of the form configuration Required
form UserForm UserForm parameters that corresponds with Form configuration Required

User Parameters

Parameter Type Description Required Notes
email String User's email address Required Default validation for presence, uniqueness, email format
external_id String custom external ID for the user, example in a third party database Optional
featured Boolean Whether the user is featured Optional
first_name String User's first name Optional
last_name String User's last name Optional
middle_name String User's middle name Optional
name String Name of the user Optional
password String password for the user Optional Default validation minimum 6 chars
profiles Hash[String=>UserProfileForm] Form for updating profiles for this user Optional
public_profile Boolean whether the profile has been marked as public Optional
transactables Hash[String=>TransactableForm] Form for updating a user's transactable(s) Optional

Example request

"Authorization: Token token=[YOUR API TOKEN]"
"Accept: application/json"
"Content-Type: application/json"

{
  "form_name": "reference_rest_api_update_user",
  "form": {
    "first_name": "Example"
  }
}
Element Type Description Required?
form_name String Name of the defined Form Required
form UserForm Attributes for user, should match configuration defined in corresponding Form Required

Example response

HTTP/1.1 201 Created
Content-Type: application/vnd.api+json

{}

Error and Status Codes

Code Message Meaning
204 No Content Successfully fulfilled request
401 Unathorized Invalid Authentication
404 Not Found Can't find given resource
406 Not Acceptable Wrong parameters passed

Questions?

We are always happy to help with any questions you may have.