REST API - Login and Logout User

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

Create

To login user, send a POST request to /api/sessions

HTTP request

POST /api/sessions

Parameters

Parameter Type Description Required Notes
form_name String Name of the form configuration Required
form SessionForm User email and password Required

Session Parameters

Parameter Type Description Required Notes
email String User's email address Required
password String User password Required

Example request

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

{
  "form_name": "reference_rest_api_create_sessions",
  "form": {
    "email": "example1@example.com",
    "password": "somepassword"
  }
}
Element Type Description Required?
form_name String Name of the defined Form Required
form SessionForm User email and password Required

Example response

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

{}

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

Delete

To logout user, send a DELETE request to /api/sessions

HTTP request

DELETE /api/sessions

Parameters

Parameter Type Description Required Notes
form_name String Name of the form configuration Required

Example request

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

{
  "form_name": "reference_rest_api_delete_sessions"
}
Element Type Description Required?
form_name String Name of the defined 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
406 Not Acceptable Wrong parameters passed

Questions?

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