Responses and paging

v2 responses have a consistent structure: the actual content is always in the data field.

This page applies to the v2 API.

Response structure

A single row:

{ "data": { "code": "J05385", "itemCode": "N1" } }

A list:

{ "data": [{ "code": "J05385" }, { "code": "J05386" }] }

A search (POST /<resource>/filter) also returns paging information:

{
  "data": [{ "code": "J05385" }, { "code": "J05386" }],
  "pageNumber": 1,
  "pageSize": 100,
  "totalRecords": 2
}

A successful response has Content-Type: application/json. Error responses are described on the Errors page.

Paging

  • pageNumber starts from one.
  • pageSize defaults to 100.
  • totalRecords is the total number of rows that match the search criteria.

Fetch the next page while pageNumber × pageSize < totalRecords. Do not detect the last page from an empty response.

page 1: pageNumber=1, pageSize=100  →  totalRecords=250
page 2: pageNumber=2, pageSize=100
page 3: pageNumber=3, pageSize=100  →  3 × 100 ≥ 250, done

Use the same sort order on every page. Without a sort order, the order of rows across pages is not guaranteed.

Keep the page size small enough for the response to stay under the size limit, see Limits.

Make your integration tolerant to change

  • Ignore unknown fields. New fields can be added to responses, and a new field must not break your integration.
  • Request only the fields you need. In searches, sf limits the response to the fields your integration uses.
  • Expect a field value to be missing or null.