<!-- llms.txt: https://workos.com/llms.txt -->

# Pagination

List operations in the Widgets API support bulk fetches. For instance, you can [list organization members](https://workos.com/docs/widgets-api/organizations/organization-memberships), [list directory users](https://workos.com/docs/widgets-api/directory-sync/directory-users), and [list audit events](https://workos.com/docs/widgets-api/audit-logs/audit-events). These operations share a common structure, taking at least these four arguments: `limit`, `order`, `after`, and `before`.

The Widgets API paginates via the `after` and `before` arguments. Both take a cursor from the `listMetadata` object of a previous response and return records in either ascending or descending order by creation time. Because cursors reference a specific record rather than a position, adding or removing records between requests will not cause a record to be skipped or repeated the way an offset would.

:::code-group

```graphql language="graphql" title="Query" tab="1"
query OrganizationMemberships($after: String) {
  organizationMemberships(limit: 25, order: Desc, after: $after) {
    data {
      id
      email
    }
    listMetadata {
      after
      before
    }
  }
}
```

```json language="json" title="Response" tab="2"
{
  "data": {
    "organizationMemberships": {
      "data": [
        {
          "id": "user_01EHWNCE74X7JSDV0X3SZ3KJNY",
          "email": "marcelina@foo-corp.com"
        },
        {
          "id": "user_01E2NPPCT7XQ2MVVYDHWGK1WN4",
          "email": "lucia@foo-corp.com"
        }
      ],
      "listMetadata": {
        "after": "user_01E2NPPCT7XQ2MVVYDHWGK1WN4",
        "before": null
      }
    }
  }
}
```

:::

### listMetadata

#### Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `before` | String | No | A cursor that defines your place in the list. When the value is not present, you are at the end of the list. For example, if you make a list request and receive 25 records, ending with `"user_123"`, your subsequent call can include `before="user_123"` to fetch a new batch of records before `"user_123"`. |
| `after` | String | No | A cursor that defines your place in the list. When the value is not present, you are at the end of the list. For example, if you make a list request and receive 25 records, ending with `"user_123"`, your subsequent call can include `after="user_123"` to fetch a new batch of records after `"user_123"`. |
| `limit` | Int | No | Upper limit on the number of records to return. The default value is `10`. |
| `order` | PaginationOrder | No | Order the results by creation time. Supported values are `Asc` and `Desc` for showing older and newer records first respectively. Default order is descending. |

#### Returns

| Field | Type | Description |
| --- | --- | --- |
| `before` | String | A cursor that defines your place in the list. When the value is not present, you are at the end of the list. For example, if you make a list request and receive 25 records, ending with `"user_123"`, your subsequent call can include `before="user_123"` to fetch a new batch of records before `"user_123"`. |
| `after` | String | A cursor that defines your place in the list. When the value is not present, you are at the end of the list. For example, if you make a list request and receive 25 records, ending with `"user_123"`, your subsequent call can include `after="user_123"` to fetch a new batch of records after `"user_123"`. |