Can restful POST api send back two different resources in the API response based on request body parameter?

Viewed 1523

We have a website to connect buyer and seller of goods.

We are designing POST API to capture interest of buyers on any seller product. The API Uri and request body looks like:

/api/lead/
{
   "name":"xyz",
   "mobile": "00984343",
   "stockid":4
}

The API is POST since we will save this information in database.

Currently, if "stockid" is stock belonging to our premium customer, the API sends back seller details in API response body:

{
  "sellername":"abc",
  "sellermobile":"75654647",
  "selleraddress": "faje street, curl"
}

If "stockid" is stock belonging to our normal customer, the API sends back complete details of that product in API response body (and DO NOT send back seller details)

{
  "description": "good 2nd hand mobile",
  "purchasedate": "24 july,2017",
  "purchaseprice": "10000"
}

The same POST API is sending back 2 different types of resources (one is seller details, other is stock details) based on the stock id.

Is it restful to design API this way i.e. POST API sending back multiple types of responses based on some request body parameter?

1 Answers
Related