I am designing an API and trying to stick to json-api for the output format. I need to provide a service endpoint like: resource/1/do-something-complicated
. I was wondering if there are any best practices for the response format to send to this sort of request since it does not do traditional CRUD on a "resource". Doesn't need to be json-api specific. Just wondering in general.
The spec website seems to have some vague suggestions on asynchronous processing. That looks to boil down to a POST /resource
and response of 202 Accepted
and then a Content-Location
header on where to check status. The payload itself is not described at all.
I would try something like accepting a POST
at your /resource
a payload such as
{
"data": {
"attributes": {
"type": "some-complicated-process",
"id": 1
}
}
}
This would then return a url for checking the status of the job.