Limit API response to specific field across entire collection

#1

If I have a collection, and I only want to return the field “name” across the entire collection - is that possible?

For example, let’s say I have the following collection and fields:

employees

  • name
  • job title
  • phone
  • email

Instead of the entire object for the collection “employees” can I return only the field “name” for each entry?

#2

Of course. Send {"fields":{"name":true,"_id":false}} with your request. If you don’t set _id to false, it always sends the id field, too.

https://getcockpit.com/documentation/api/collections