Im trying to start an API design using Django Rest Framework, and the problem Im trying to solve is the following: Request endpoint is like this: POST http://server:8080/api/v1/device attribute: create

When my server receives this API request, it will launch a backend process which takes around 20-60 seconds(Starts an SSH connection to a remote server and check periodically for status there.). I'm not sure how to respond to initial API request? Using a 200 OK indication that request is handled with a "starting" and then offer an endpoint to provide status?

What is the best architecture for this type of requests?

1 Answer 1


If the server blocks and responds only when the work is finished, HTTP 200 is indeed the way to go. Make sure you document the waiting time, since some clients may have shorter timeouts (and customers awaiting the reply may consider that something wrong happened).

Otherwise, you may return immediately, in which case HTTP 202 is the correct code:

HTTP 202 Accepted

The request has been accepted for processing, but the processing has not been completed.

Source: RFC 2616

Remark: instead of (or additionally to) making the endpoint which provides status, you may also consider WebSockets. This may reduce the bandwidth by freeing the client from sending repetitive requests for status: instead, the server will push to the client a notification when the process finishes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.