Background - API1Created with Sketch.

Custom Response

What is Custom Response?

Custom Response allows return customization from our APIs to better attend your business.

Using the attribute selection approach, you can choose what data you want to receive, making integration more agile and easier to understand.

This is done by passing a query param with the name select, which allows you to choose which attributes will be present in the body of the response to your HTTP request. It can be used in any HTTP method (GET, POST, PUT, PATCH,DELETE) available at our endpoints.

You will receive data only for the attributes you give, disregarding the others. If no attributes are found, the return will be an empty JSON.

Request parameters

  • selectString

    List of attributes to be selected, their values ​​are separated by commas.

    If the attribute you need to select is inside an Object, for example, the country of a producer's address, you can assign the value address.country to query param select.

    If the attribute you need to select is within a Array, such as the name of a producer's products, you can assign the value products.name to query param select.

    In Pagination endpoints , you can simply assign query param select the attributes contained in items, being only these attributes that can be customized.

Data Selection

The example of the given answer has different types of data, in this case, we have id and name of the simple type, address as an object and products as an array of objects. To select each of these different types of data, you must do the following:

TypeQuery paramReturn
simpleselect=id,nameData of id and name
objectsselect=addressData of Object of address
arraysselect=productsData of Arrays of products

To select attributes of more complex structures such as objects and arrays, you should do the following:

AtributesQuery paramReturn
objectsselect=address.countryData of country of address
arraysselect=products.nameData of name of products
Response
{
  "id": 123,
  "name": "Producer 01",
  "address": {
    "country": "Brazil",
    "city": "Belo Horizonte"
  },
  "products": [
    {
      "id": 1,
      "name": "Product Name 01"
    },
    {
      "id": 2,
      "name": "Product Name 02"
    },
    {
      "id": 3,
      "name": "Product Name 03"
    }
  ]
}

isPageUseful.question