One of our APIs has a tasks
resource. Consumers of the API might create, delete and update a given task as they wish.
If a task is completed (i.e., its status is changed via PUT /tasks/<id>
), a new task might be created automatically as a result.
We are trying to keep it RESTful. What would be the correct way to tell the calling user that a new task has been created? The following solutions came to my mind, but all of them have weaknesses in my opinion:
- Include an additional field on the
PUT
response which contains information about an eventual new task. - Return only the updated task, and expect the user to call
GET /tasks
in order to check if any new tasks have been created.
Option 1 breaks the RESTful-ness in my opinion, since the API is expected to return only information regarding the updated entity. Option 2 expects the user to do stuff, but if he doesn't then no one will realize that a new task was created.
Thank you.
UPDATE: the PUT
call returns an HTTP 200 code along the full JSON representation of the updated task.
@tophallen suggests having a task tree so that (if I got it right) the returned entity in option 2 contains the new task as a direct child.