I'm building an application in which there are jobs
and each job
has some emails
sent corresponding to it.
I've got the following URL structure
GET /jobs # Get all the jobs
GET /jobs/{jobId} # Get a job by ID
GET /jobs/{jobId}/emails # Get all emails corresponding to given job ID
POST /jobs # Create a job
PUT /jobs/{jobId} # To Create/update a particular job by ID
POST /jobs/_search # To get a large number of jobs with job IDs in the request body
Now my question is, what should be the URL to get all the emails for a given list of job IDs?
For example.
I use GET /jobs
to get a list of jobs which contains the job IDs in it. Now I would like to get all the emails for the list of job IDs.
Is it a correct REST structure to use
POST /jobs/emails/_search # To get all emails corresponding to each job ID in the request body
POST /jobs/emails/_count # To get the counts of emails corresponding to each job ID in the request body
Or should it be just
POST /emails/_search
POST /emails/_count
Or whether both the patterns are wrong? The first syntax seems correct to me because emails cannot exist without jobs.
The POST
search syntax to get multiple resources is taken from this SO answer. The underscores are inspired by the elasticsearch api.
Any help is greatly appreciated. Thanks!