POST Register ~~~~~~~~~~~~~ .. code-block:: http POST /api/v1/user/register HTTP/1.1 Registers a new user with the details included in the specified request body. If the request is valid and a new user successfully created then a ``201 - Created`` status code will be returned and the response will contain the details of the created user including their unique ID so it can be uniquely identified on the server. It is important to use the details returned in the response rather than those sent in the response as they may be changed by the server to make them valid. User registered with this method will always have the ``account_type`` of ``customer`` rather than ``driver`` as drivers will always be registered on the admin and not via the app. Registering this way is only for public users. Request ------- A request can either be submitted as formatted as ``application/json``. .. csv-table:: :header: Property, Type, Required, Description :widths: 20,10,10,60 username, string, required, The username which the user wishes to use for the account being registered. email_address, string, required, The email address which the user wishes to use for the account being registered. password, string, required, The password that the user wishes to use to access their account. Request Example ----------------- .. code-block:: json { "username": "tim1990", "email": "tim.smith12@aol.com", "password": "il1kep1es", } Response -------- The response from a successful request return a ``201 - Created`` status code and will include the following fields. Note that the password field for a user is not included in the response as it would a security concern, but the api_token needed for further requests is. .. csv-table:: :header: Property, Type, Nullable, Description :widths: 20,10,10,60 id, integer, NO, The unique identifier for the user as they are identified on the server. username, string, NO, The username for the user. email_address, string, NO, The email address for the user. account_type, string, NO, The type of account that the user holds. This will be the value ``customer``. api_token, string, NO, The API token for they user which is used to authenticate them in other restricted requests made to the server. Response Example ---------------- .. code-block:: json { "results": { "id": 412, "username": "tim1990", "email": "tim.smith12@aol.com", "api_token": "de305d5475b4431badb2eb6b9e546014", "account_type": "customer" }, "message": "New user successfully registered", "error": null, "error_code": 0, "status": 201 } Error ----------- The app can return the following reasons as to why the request failed and a new user was not registered. A response that contains one of these error codes will have a status code of ``400 - Bad Request``. ========== =========== Error Code Description ========== =========== -1 Username already exists for a different account -2 Email address already used to register an account -3 Password invalid (too weak) -4 Missing attributes needed for registering ========== ===========