skip to Main Content

I am creating a system that requires a user to validate using a SMS Code in order to create an account. The system will have a RESTful API to access the other resources of the system but I am wondering if the account creation stage is suitable for a RESTful API. The high level sequence that I am trying to achieve is:

enter image description here

If I was to express this using REST Principles I would implement is as follows:

enter image description here

where RegistrationItem would look like:

class RegistrationItem
{
    public string SmsCode {get;set;}

    public int RegistrationId {get;set;}

    public string PhoneNumber {get;set;}
}

Does this seem a reasonable design or do account creation and RESTful API’s not normally co-exist? I notice that most API’s I looked at (facebook, foursquare, twillio) don’t seem to support it.

3

Answers


  1. There’s no reason you couldn’t do account creation from a RESTful API. I might name things differently, but the flow seems reasonable.

    Since you asked, I would probably do:

    POST /registration-requests
    -> { "phoneNumber": "555-1212" }
    

    The response would have the id. If you’re striving for HATEOAS, then it should also have a URI for user creation, either as a Link in the header or as part of the response. Then to create the user,

    POST /users
    -> { "registrationId": 12345, "smsCode": 67890 } 
    

    and make it return a new user instance. If these APIs can get called from a browser, you should strongly consider using the Post-Redirect-Get pattern.

    Login or Signup to reply.
  2. REST models get, create, update and delete operations. Register is a type of create operation. So, yes REST is suitable–unless there’s some other criteria or question you have.

    Login or Signup to reply.
  3. Yes. Nelibur could really help you to create appropriate API.

    Good tutorial:http://www.codeproject.com/Articles/712689/Building-RESTful-Message-Based-Web-Services-with-W

    Hope this help;

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search