[thelist] HTTP Response for "not ready"

Bill Moseley moseley at hank.org
Mon Jan 2 04:26:28 CST 2012

I POST a new resource and get back a 201 Created with a Location: header of
the new resource.  That is:

POST /widget  { <widget data> }

201 Created
Location: http://example.com/widget/12345

I can then later GET /widget/12345 and fetch that widget back.

But, there's a period of time between the POST and the GET when the new
resource is not ready.  For example, the resource might have been created
(i.e. we know its new ID) but there's some background processing that must
be done.  (I suppose 202 Accepted might be more accurate, but a 202 doesn't
return the Location, IIRC, and doesn't even guarantee that it will every be

This post<http://stackoverflow.com/questions/6144164/what-http-code-should-rest-return-for-a-resource-that-is-not-ready-after-a-202-c>
returning a Location where to check the status but in this case I really
need to return the location of the resource itself.

I'd like to return some non-200 status code to indicate that the resource
exists, but is not ready.  Is that appropriate[1] and what code would you

What I'm currently doing is on the GET request returning a 200 with an
entity/body structure like:

    pending: 1

And when ready:

    pending: 0,
    payload: { ... }

Would you do that or would you use HTTP status to indicate pending?

[1] Sure it's appropriate, I guess.  It's my API so I can have it do what
ever it's documented to do...

Bill Moseley
moseley at hank.org

More information about the thelist mailing list