REST API Route Structure

Having some trouble deciding which route is more RESTful. To give a quick rundown, I'm building an API for a sweepstakes application. The highest level is client, next is sweepstakes, and following is a submission.

I'm confused on what route would be best for creating a new sweepstakes, and submission.

Option 1

POST /sweepstakes [passing along client_id as a parameter]

Option 2

POST /clients/:client_id/sweepstakes [using client id in route to create]

Here is a GIST of all my routes. Hopefully someone can help me out. https://gist.github.com/4504221

I would not bother making the REST URIs represent the hierarchical structure.

/client/:client_id should return a list of the client's sweepstakes URIs (among other data.)
/sweepstakes/:sweepstakes_id will return a list of all submissions URIs for that sweepstakes id (among other data.)
/submission/:submission_id is exactly what you think.

This is simple, but I can't think of a reason to make the URIs more complex. Let me know if I am missing something.

Edit: Oh you were referring to creating a resource:

I'd still go with the above URIs.

POST /client/
POST /sweepstakes/
POST /submission/

Pass the data needed in the request body and return the id in the response. Update with PUT:

PUT /client/:client_id

etc.

The answer is nearly related to what will be the URI of the resource you will create:

  • POST / to create /:id
  • POST /sweepstakes/ to create /sweepstakes/:id
  • POST /clients/:id_a/sweepstakes/ to create /clients/:id_a/sweepstakes/:id_b