For a delete, return 204 or 200. For a long-running job, return 202 Accepted with a link to a status resource.
For DELETE:
- Return 204 No Content when there is nothing useful to send back.
- Return 200 OK with a body if you send back the deleted resource or a summary.
- Return 202 Accepted if the deletion is only queued. This is the honest answer.
For a long-running job like a video export, return 202 Accepted right away. 202 means the server accepted the request for processing, but the work is not finished. It makes no promise about the result. Include a way to track the job. Usually this is a Location header, or a link in the body, to a status resource like /exports/91.
The client polls that resource, which means it asks again every few seconds. The status resource reports pending, running, done or failed. When the job is done, it links to the result. You can also:
- send a
Retry-Afterheader to suggest how long to wait between polls - notify the client with a webhook (a call from your server to the client's URL) when the job ends
- For DELETE, return 204 with no body, or 200 with a body.
- For long-running work, return 202 Accepted.
- Give a status resource through a
Locationheader or a link. - The client polls the status resource, or gets a webhook when the job is done.
Read more
- 202 Accepted (MDN) (https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/202)developer.mozilla.org
- 204 No Content (MDN) (https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/204)developer.mozilla.org