Pagination {#tms-pagination}
============================

Responses can indicate pagination if you include the **limit** and **offset** fields in your request.

| Parameter | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
|:----------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `limit`   | Controls the maximum number of items that can be returned for a single request. The default is 20; the maximum is 100. If you set a limit greater than 100, the following error results: ``` Http Status: 400 Bad Request Body { "errors": [ { "type": "invalidParameters", "message": "Invalid parameter values", "details": [ { "name": "limit" } ] } ] } ```                                                                                                                                |
| `offset`  | Controls the starting point within the collection of results. Defaults to `0`. Setting a zero offset retrieves the first item in the collection. For example, if you have a collection of 15 items to be retrieved from a resource, and you specify `limit=5` , you can retrieve the entire set of results in three successive requests by varying the offset value: `offset=0`, `offset=5`, and `offset=10`. An offset greater than the number of results does not return an embedded object. |

Pagination Response Header {#tms-pagination_id18AIF000WL7}
----------------------------------------------------------

| Header          | Description                                           |
|:----------------|:------------------------------------------------------|
| `X-total-count` | Returns total records count regardless of pagination. |

Pagination Response Body Fields {#tms-pagination_id18AIF0000TS}
---------------------------------------------------------------

| Field                   | Description                                         |
|:------------------------|:----------------------------------------------------|
| `"object":"collection"` | Shows that the response is a collection of objects. |
| `"offset": 40`          | The offset parameter used in the request.           |
| `"limit": 20`           | The limit parameter used in the request.            |
| `"count": 20`           | The number of objects returned.                     |
| `"total": 87`           | The total number of objects.                        |

Examples {#tms-pagination_id18AIF0030NW}
----------------------------------------

**Pagination Example 1**  
This example shows a request for objects 41 to 60.  
**Request**

```keyword
GET https://api.visaacceptance.com/tms/v1/instrumentidentifiers/5BAAD18F8091052CE0539399D30AAB2F/paymentinstruments?offset=40&limit=20
```

> IMPORTANT
>
> * If you are on the first collection, the previous link would not be included.
> * If you are on the last collection, the next link would not be included.

* All other links are always included. For example, if there was only one collection of results, the URL for ` self `, ` first `, and ` last ` links would be the same.  
  **Response**

```keyword
{
  "_links": {
    "self": {
      "href": "https://api.visaacceptance.com/tms/v1/instrumentidentifiers/5BAAD18F8091052CE0539399D30AAB2F/paymentinstruments?offset=40&limit=20"
    },
    "first": {
      "href": "https://api.visaacceptance.com/tms/v1/instrumentidentifiers/5BAAD18F8091052CE0539399D30AAB2F/paymentinstruments?offset=0&limit=20"
    },
    "prev": {
      "href": "https://api.visaacceptance.com/tms/v1/instrumentidentifiers/5BAAD18F8091052CE0539399D30AAB2F/paymentinstruments?offset=20&limit=20"
    },
    "next": {
      "href": "https://api.visaacceptance.com/tms/v1/instrumentidentifiers/5BAAD18F8091052CE0539399D30AAB2F/paymentinstruments?offset=60&limit=20"
    },
    "last": {
      "href": "https://api.visaacceptance.com/tms/v1/instrumentidentifiers/5BAAD18F8091052CE0539399D30AAB2F/paymentinstruments?offset=80&limit=20"
    }
  },
  "object":"collection",
  "offset": 40,
  "limit": 20,
  "count": 20,
  "total": 87,
  "_embedded": {
    &lt;array data&gt;
  }
}
```

**Pagination Example 2 - Offset to Limit Relationship**  
This example shows a request for objects 3 to 6, from a total of 8 objects.  
The example below shows the second collection of results and highlights that the previous page link will not change the user's original limit parameter value.  
This means that the previous collection will contain objects 0-3, and therefore collection 1 and collection 2 will both contain object 3.  
**Request**

```keyword
GET https://api.visaacceptance.com/tms/v1/instrumentidentifiers/5BAAD18F8091052CE0539399D30AAB2F/paymentinstruments?offset=3&limit=4
```

#### Figure:

Offset to Limit Relationship ![](/content/dam/new-documentation/documentation/en-us/topics/payments-processing/payment-services/tms/images/offset-limit-600x160.svg/jcr:content/renditions/original)  
**Response**

```keyword
{
  "_links": {
    "self": {
      "href": "https://api.visaacceptance.com/tms/v1/instrumentidentifiers/5BAAD18F8091052CE0539399D30AAB2F/paymentinstruments?offset=3&limit=4"
    },
    "first": {
      "href": "https://api.visaacceptance.com/tms/v1/instrumentidentifiers/5BAAD18F8091052CE0539399D30AAB2F/paymentinstruments?offset=0&limit=4"
    },
    "prev": {
      "href": "https://api.visaacceptance.com/tms/v1/instrumentidentifiers/5BAAD18F8091052CE0539399D30AAB2F/paymentinstruments?offset=0&limit=4"
    },
    "next": {
      "href": "https://api.visaacceptance.com/tms/v1/instrumentidentifiers/5BAAD18F8091052CE0539399D30AAB2F/paymentinstruments?offset=7&limit=4"
    },
    "last": {
      "href": "https://api.visaacceptance.com/tms/v1/instrumentidentifiers/5BAAD18F8091052CE0539399D30AAB2F/paymentinstruments?offset=7&limit=4"
    }
  },
  "object":"collection",
  "offset": 3,
  "limit": 4,
  "count": 4,
  "total": 8,
  "_embedded": {
    &lt;array data&gt;
  }
}
```

