Registration and Authentication
For Application developers if you wish to provide user access to the BookDirect.com interface via API. Methods for user sign up, login and password reset.
Sign Up
Register a new user in the system.
Request:
POST https://staging.bookdirect.com/api/v1/sign_upQuery body (JSON):
{
"user" : {
"email": "[email protected]",
"name": "BookDirect User",
"password": "password",
"password_confirmation": "password"
}
}Success Response Example
Status Code: 200 OK
{
"meta": {
"message": "You are successfully logged in! Add this token to authorization header to make authorized requests."
},
"data": {
"type": "session",
"attributes": {
"token": "AUTH_TOKEN"
},
"relationships": {
"user": {
"data": {
"type": "user",
"id": "2cd26047-db52-4c54-8c28-98099021c480",
"attributes": {
"id": "2cd26047-db52-4c54-8c28-98099021c480",
"email": "[email protected]",
"name": "BookDirect User",
"system_role": "user"
}
}
}
}
}
}Validation Error Response
Status Code: 422 Unprocessable Entity
Method requires a valid User Registration object as incoming argument represented as type user.
Fields
email [required]
String with a valid email address.
Note: User will use this email address to login into the system.
name [required]
Any non-empty string with maximum length of 50 symbols.
Note: The user will be represented in the system under that name.
password [required]
Non empty string with at least 8 symbols of length. Any symbols are allowed. (Required Field)
Note: User will use this password to login into the system.
password_confirmation [required]
Non empty string with at least 8 symbols of length. Should be equal to password field value.
Note: Please check password confirmation as we will throw a validation error if password does not match.
Returns
Success
Method can return a Success result with 200 OK HTTP Code if operation is successful. Will contain a Session object in the answer.
Validation Error
Method can return a Validation Error result with 422 Unprocessable Entity HTTP Code if any validation rule is failed.
Sign In
Authenticate a user at the system.
Request:
Query body (JSON):
Success Response Example
Status Code: 200 OK
Unauthorised Error Response
Status Code: 401 Unauthorized
Method requires a valid User Authentication object as incoming argument represented as type user.
Fields
email [required]
String with a valid email address.
password [required]
Non empty string with at least 8 symbols of length. Any symbols are allowed.
Returns
Success
Method can return a Success result with 200 OK HTTP Code if operation is successful. Will contain a Session object in the answer.
Unauthorised Error
Method can return Unauthorised Error result with 401 Unauthorized HTTP Code if email or password is not valid. By security reason, if provided email is not represented at system we will return a Unauthorised error also.
Request Restore Password Instructions
Request sending restore password instructions to user email.
Request:
Query body (JSON):
Success Response Example
Status Code: 200 OK
Method require valid User object as incoming argument represented as type user.
Fields
email [required]
String with valid email address.
Returns
Success
Method can return Success result with 200 OK HTTP Code if operation is successful. Will contain meta object with message.
For security reasons this method will return Success result for each request.
Restore Password
Set new user password
Request:
Query body (JSON):
Success Response Example
Status Code: 200 OK
Bad Request Error Response
Status Code: 400 Bad Request
Validation Error Response
Status Code: 422 Unprocessable Entity
Method requires a valid User object as incoming argument represented as type user.
Fields
restore_password_token [required]
String value. restore_password_token will be sent via email when user calls Request Restore Password Instructions.
password [required]
Non empty string with at least 8 symbols of length. Any symbols is allowed.
User will use this password to login into the system.
password_confirmation [required]
Non empty string with at least 8 symbols of length. Should be equal to password field value.
Returns
Success
Method can return Success result with 200 OK HTTP Code if operation is successful. Will contain meta object with message.
Bad Request Error
Method can return a Bad Request Error result with 400 Bad Request HTTP Code if restore_password_token is invalid.
Validation Error
Method can return Validation Error result with 422 Unprocessable Entity HTTP Code if any validation rule is failed.
Confirm Registration
Confirm user registration by sending a token to the users email address and validating it is a valid email address.
Request:
Success Response Example
Status Code: 200 OK
Bad Request Error Response
Status Code: 400 OK
Method require valid Confirmation Token passed as GET argument.
Fields
token [required]
String value. token will be sent to email after registration with the Sign Up method.
Returns
Success
Method can return Success result with 200 OK HTTP Code if operation is successfully finished. Will contain Session object at answer.
Bad Request Error
Method can return Bad Request Error result with 400 Bad Request HTTP Code if token is invalid.
Last updated
Was this helpful?