Token-based pagination example

This guide demonstrates a practical example of navigating through transaction results using token-based pagination. You'll learn how to retrieve the initial page, move forward to the next page, and navigate backward to the previous page.

Prerequisites

Before following this example, make sure you understand:

Scenario

In this example, we'll retrieve transactions from an account that had 83 transactions in the year 2025. We'll use a limit of 5 results per page, which gives us 17 pages total. We'll demonstrate:

  1. Fetching the first page (transactions 1-5)
  2. Moving to the second page using the next parameter
  3. Returning to the first page using the prev parameter

Note: Remember that token_page and next_token values must be URL-encoded when used as query parameters. See the URL Encoding section for details.


⚠️

IMPORTANT

To follow the steps below, it is essential to have the corresponding Authorization Token. For more information, please refer to the following documentation page: Authorization Token

Step 1: Fetch the First Page (Transactions 1-5)

Let's start by fetching the first 5 transactions with query param limit=5: GET /api/transactions?limit=5&created_at[from]=2025-01-01&created_at[to]=2025-12-31

Request

postman request 'http://localhost:9000/api/transactions?limit=5&created_at[from]=2025-01-01&created_at[to]=2025-12-31' \
  --header 'Authorization: eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY4YTRjMzE1MGIyOGE5NTg0MzA1YTJhYSIsImFjY291bnRfaWQiOiI2OGE0YzMxNTBiMjhhOTU4NDMwNWEyYTYiLCJhY2NvdW50Ijp7ImVtYWlsIjoiaHVnby5tb3JpbkBlY2FydHBheS5jb20iLCJmaXJzdF9uYW1lIjoiSHVnbyIsImxhc3RfbmFtZSI6Ik1vcsOtbiIsInBob25lIjoiNTI........'

Response

{
    "count": 83,
    "docs": [
        {
            "id": "6950926005cbfa6601c0dda2",
            "account_id": "68a4c3150b28a9584305a2a6",
            "refund_id": "6950925f05cbfa6601c0dd93",
            "transaction_id": "TR0000016663",
            "type": "charge",
            "status": "paid",
            "amount": 50,
            "fee": 0,
            "fee_details": {
                "fixed": 0,
                "percent": 0,
                "tax": 0,
                "percent_amount": 0,
                "msi_percent": 0,
                "msi_amount": 0,
                "fixed_installments_amount": 0,
                "fixed_installments_percent": 0,
                "installments_fee": 0
            },
            "installments": 1,
            "total": 50,
            "previous": -4387.99,
            "current": -4437.99,
            "currency": "MXN",
            "gateway": "ecartpay",
            "exchange": 1,
            "reference_id": "6950926005cbfa6601c0dd9f",
            "reference": "6950926005cbfa6601c0dda0",
            "reason": "refund",
            "custom_keys": false,
            "charges": [],
            "available_at": "2025-12-28T02:13:52.510Z",
            "b2b_metadata": {
                "b2b_transactions": []
            },
            "created_at": "2025-12-28T02:13:52.633Z",
            "updated_at": "2025-12-28T02:13:53.275Z"
        },
        {
            "id": "69509252a0526f0bc30befe2",
            "account_id": "68a4c3150b28a9584305a2a6",
            "affiliation_number": "SANDBOX-10-12-17",
            "activity_id": "69509250a0526f0bc30befcd",
            "order_id": "69509246a0526f0bc30befb7",
            "customer_id": "68dea001d3d53b7a568e2686",
            "account_customer_id": "68dea146d3d53b7a568e2779",
            "transaction_id": "TR0000016662",
            "type": "payment",
            "status": "refunded",
            "amount": 44.14,
            "fee": 5.86,
            "fee_details": {
                "fixed": 3.6,
                "percent": 2.9,
                "tax": 0.81,
                "percent_amount": 1.45,
                "msi_percent": 0,
                "msi_amount": 0,
                "fixed_installments_amount": 0,
                "fixed_installments_percent": 0,
                "installments_fee": 0
            },
            "installments": 1,
            "total": 50,
            "previous": -4432.13,
            "current": -4387.99,
            "currency": "MXN",
            "gateway": "ecartpay",
            "exchange": 1,
            "reference_id": "69509252a0526f0bc30befde",
            "reference": "69509252a0526f0bc30befdf",
            "custom_keys": false,
            "order": {
                "number": "OR0000043925",
                "status": "refunded",
                "first_name": "Hugo",
                "last_name": "Isaid",
                "email": "[email protected]",
                "phone": "9876543210"
            },
            "charges": [
                {
                    "id": "6203c3fc",
                    "folio": "7e7ff20d",
                    "reference": "0d3d5556",
                    "status": "paid",
                    "type": "card",
                    "currency": "MXN",
                    "amount": 5000,
                    "gateway": "mit",
                    "method": {
                        "name": "Hugo Isaíd",
                        "exp_month": "01",
                        "exp_year": "2050",
                        "type": "credit",
                        "last4": "2235",
                        "brand": "mastercard",
                        "bankname": "ecartpay",
                        "domestic": true
                    },
                    "affiliation_number": "SANDBOX-10-12-17"
                }
            ],
            "available_at": "2025-12-28T02:13:38.177Z",
            "b2b_metadata": {
                "b2b_transactions": []
            },
            "created_at": "2025-12-28T02:13:38.334Z",
            "updated_at": "2025-12-28T02:13:53.275Z"
        },
        {
            "id": "692f1b0cd10221b63a5afe5a",
            "account_id": "68a4c3150b28a9584305a2a6",
            "affiliation_number": "SANDBOX-10-12-17",
            "activity_id": "692f1b0cd10221b63a5afe46",
            "order_id": "692f1ae1d10221b63a5afda1",
            "transaction_id": "TR0000015520",
            "type": "payment",
            "status": "paid",
            "amount": 92.46,
            "fee": 7.54,
            "fee_details": {
                "fixed": 3.6,
                "percent": 2.9,
                "tax": 1.04,
                "percent_amount": 2.9,
                "msi_percent": 0,
                "msi_amount": 0,
                "fixed_installments_amount": 0,
                "fixed_installments_percent": 0,
                "installments_fee": 0
            },
            "installments": 1,
            "total": 100,
            "previous": -4524.59,
            "current": -4432.13,
            "currency": "MXN",
            "gateway": "ecartpay",
            "exchange": 1,
            "reference_id": "692f1b0cd10221b63a5afe56",
            "reference": "692f1b0cd10221b63a5afe57",
            "custom_keys": false,
            "order": {
                "number": "OR0000041825",
                "status": "paid",
                "first_name": "John",
                "last_name": "Doe",
                "email": "[email protected]",
                "phone": "529999999999"
            },
            "charges": [
                {
                    "id": "c13fb710",
                    "folio": "7e761d4f",
                    "reference": "189dac22",
                    "status": "paid",
                    "type": "card",
                    "currency": "MXN",
                    "amount": 10000,
                    "gateway": "mit",
                    "method": {
                        "name": "John Doe",
                        "exp_month": "01",
                        "exp_year": "2050",
                        "type": "credit",
                        "last4": "2151",
                        "brand": "mastercard",
                        "bankname": "ecartpay",
                        "domestic": true
                    },
                    "affiliation_number": "SANDBOX-10-12-17"
                }
            ],
            "available_at": "2025-12-02T16:59:56.420Z",
            "b2b_metadata": {
                "b2b_transactions": []
            },
            "created_at": "2025-12-02T16:59:56.431Z",
            "updated_at": "2025-12-02T16:59:56.431Z"
        },
        {
            "id": "692f199fd10221b63a5afb55",
            "account_id": "68a4c3150b28a9584305a2a6",
            "affiliation_number": "SANDBOX-10-12-17",
            "activity_id": "692f199fd10221b63a5afb41",
            "order_id": "692f194cd10221b63a5afaa4",
            "template_id": "692f1493d33762531c20f54b",
            "transaction_id": "TR0000015511",
            "type": "payment",
            "status": "paid",
            "amount": 189.1,
            "fee": 10.9,
            "fee_details": {
                "fixed": 3.6,
                "percent": 2.9,
                "tax": 1.5,
                "percent_amount": 5.8,
                "msi_percent": 0,
                "msi_amount": 0,
                "fixed_installments_amount": 0,
                "fixed_installments_percent": 0,
                "installments_fee": 0
            },
            "installments": 1,
            "total": 200,
            "previous": -4713.69,
            "current": -4524.59,
            "currency": "MXN",
            "gateway": "ecartpay",
            "exchange": 1,
            "reference_id": "692f199fd10221b63a5afb51",
            "reference": "692f199fd10221b63a5afb52",
            "custom_keys": false,
            "order": {
                "number": "OR0000041812",
                "status": "paid",
                "first_name": "Hugo",
                "last_name": "Morín",
                "email": "[email protected]",
                "phone": "529999999999"
            },
            "charges": [
                {
                    "id": "7238e04b",
                    "folio": "2e4701a9",
                    "reference": "c8d1989e",
                    "status": "paid",
                    "type": "card",
                    "currency": "MXN",
                    "amount": 20000,
                    "gateway": "mit",
                    "method": {
                        "name": "Mastercard Test",
                        "exp_month": "01",
                        "exp_year": "2050",
                        "type": "credit",
                        "last4": "2235",
                        "brand": "mastercard",
                        "bankname": "ecartpay",
                        "domestic": true
                    },
                    "affiliation_number": "SANDBOX-10-12-17"
                }
            ],
            "available_at": "2025-12-02T16:53:51.681Z",
            "b2b_metadata": {
                "b2b_transactions": []
            },
            "created_at": "2025-12-02T16:53:51.692Z",
            "updated_at": "2025-12-02T16:53:51.692Z"
        },
        {
            "id": "692f1798d10221b63a5af6c5",
            "account_id": "68a4c3150b28a9584305a2a6",
            "affiliation_number": "SANDBOX-10-12-17",
            "activity_id": "692f1798d10221b63a5af6b1",
            "order_id": "692f168fd10221b63a5af570",
            "template_id": "692f1493d33762531c20f54b",
            "transaction_id": "TR0000015500",
            "type": "payment",
            "status": "paid",
            "amount": 189.1,
            "fee": 10.9,
            "fee_details": {
                "fixed": 3.6,
                "percent": 2.9,
                "tax": 1.5,
                "percent_amount": 5.8,
                "msi_percent": 0,
                "msi_amount": 0,
                "fixed_installments_amount": 0,
                "fixed_installments_percent": 0,
                "installments_fee": 0
            },
            "installments": 1,
            "total": 200,
            "previous": -4902.79,
            "current": -4713.69,
            "currency": "MXN",
            "gateway": "ecartpay",
            "exchange": 1,
            "reference_id": "692f1798d10221b63a5af6c1",
            "reference": "692f1798d10221b63a5af6c2",
            "custom_keys": false,
            "order": {
                "number": "OR0000041793",
                "status": "paid",
                "first_name": "John",
                "last_name": "Doe",
                "email": "[email protected]",
                "phone": "529999999999"
            },
            "charges": [
                {
                    "id": "25981571",
                    "folio": "9bfffa32",
                    "reference": "7d329b95",
                    "status": "paid",
                    "type": "card",
                    "currency": "MXN",
                    "amount": 20000,
                    "gateway": "mit",
                    "method": {
                        "name": "John Doe",
                        "exp_month": "01",
                        "exp_year": "2050",
                        "type": "credit",
                        "last4": "4242",
                        "brand": "visa",
                        "bankname": "ecartpay",
                        "domestic": true
                    },
                    "affiliation_number": "SANDBOX-10-12-17"
                }
            ],
            "available_at": "2025-12-02T16:45:12.523Z",
            "b2b_metadata": {
                "b2b_transactions": []
            },
            "created_at": "2025-12-02T16:45:12.535Z",
            "updated_at": "2025-12-02T16:45:12.535Z"
        }
    ],
    "pages": 17,
    "token_page": "CN7XARoJKXnJu2KbAQAAIg5aDGlQkmAFy/pmAcDdog==",
    "next_token": "CPPOARoJKdcr9N+aAQAAIg5aDGkvF5jRAiG2Olr2xQ=="
}

Key points

  • count: 83 - Total number of transactions matching your query
  • pages: 17 - Total number of pages available (83 transactions ÷ 5 per page)
  • token_page: The pagination token for this result set as CN7XARoJKXnJu2KbAQAAIg5aDGlQkmAFy/pmAcDdog==. Save this value for URL encoding the next request.
  • next_token: The pagination token for this result set as CPPOARoJKdcr9N+aAQAAIg5aDGkvF5jRAiG2Olr2xQ==. Save this value for URL encoding the next request.
  • docs - Array containing 5 transaction objects




Step 2: Fetch the Next Page (Transactions 6-10)

To go forward, take the next_token from Step 1 and send it as the next query parameter. But first, we need to do the Base64 URL encode with the previously obtained toke_page and next_token.

CharacterURL Encoded
+%2B
/%2F
=%3D
&%26

The Encoded Tokens

  • token_page: CN7XARoJKXnJu2KbAQAAIg5aDGlQkmAFy%2FpmAcDdog%3D%3D
  • next_token: CPPOARoJKdcr9N%2BaAQAAIg5aDGkvF5jRAiG2Olr2xQ%3D%3D

Now we can proceed with the request

Request

We preserve the created_at[from] and created_at[to] as in the initial request from step 1.

postman request 'http://localhost:9000/api/transactions?limit=5&next=CPPOARoJKdcr9N%2BaAQAAIg5aDGkvF5jRAiG2Olr2xQ%3D%3D&created_at[from]=2025-01-01&created_at[to]=2025-12-31' \
  --header 'Authorization: eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY4YTRjMzE1MGIyOGE5NTg0MzA1YTJhYSIsImFjY291bnRfaWQiOiI2OGE0YzMxNTBiMjhhOTU4NDMwNWEyYTYiLCJhY2NvdW50Ijp7ImVtYWlsIjoiaHVnby5tb3JpbkBlY2FydHBheS5jb20iLCJmaXJzdF9uYW1lIjoiSHVnbyIsImxhc3RfbmFtZSI6Ik1vcsOtbiIsInBob25lIjoiNTI.......'

Response

Now the endpoint returns the next 5 transactions out of the 83 total.

{
    "count": 83,
    "docs": [
        {
            "id": "692f13add10221b63a5af032",
            "account_id": "68a4c3150b28a9584305a2a6",
            "affiliation_number": "SANDBOX-10-12-17",
            "activity_id": "692f13add10221b63a5af01e",
            "order_id": "692f134ed10221b63a5aefa5",
            "transaction_id": "TR0000015489",
            "type": "payment",
            "status": "paid",
            "amount": 92.46,
            "fee": 7.54,
            "fee_details": {
                "fixed": 3.6,
                "percent": 2.9,
                "tax": 1.04,
                "percent_amount": 2.9,
                "msi_percent": 0,
                "msi_amount": 0,
                "fixed_installments_amount": 0,
                "fixed_installments_percent": 0,
                "installments_fee": 0
            },
            "installments": 1,
            "total": 100,
            "previous": -4995.25,
            "current": -4902.79,
            "currency": "MXN",
            "gateway": "ecartpay",
            "exchange": 1,
            "reference_id": "692f13add10221b63a5af02e",
            "reference": "692f13add10221b63a5af02f",
            "custom_keys": false,
            "order": {
                "number": "OR0000041766",
                "status": "paid",
                "first_name": "Hugo",
                "last_name": "Morín",
                "email": "[email protected]",
                "phone": "529999999999"
            },
            "charges": [
                {
                    "id": "d2fc12bc",
                    "folio": "0a77434d",
                    "reference": "3d9da393",
                    "status": "paid",
                    "type": "card",
                    "currency": "MXN",
                    "amount": 10000,
                    "gateway": "mit",
                    "method": {
                        "name": "John Doe",
                        "exp_month": "01",
                        "exp_year": "2050",
                        "type": "credit",
                        "last4": "4242",
                        "brand": "visa",
                        "bankname": "ecartpay",
                        "domestic": true
                    },
                    "affiliation_number": "SANDBOX-10-12-17"
                }
            ],
            "available_at": "2025-12-02T16:28:29.850Z",
            "b2b_metadata": {
                "b2b_transactions": []
            },
            "created_at": "2025-12-02T16:28:29.863Z",
            "updated_at": "2025-12-02T16:28:29.863Z"
        },
        {
            "id": "692f1313d10221b63a5aee96",
            "account_id": "68a4c3150b28a9584305a2a6",
            "affiliation_number": "SANDBOX-10-12-17",
            "activity_id": "692f1312d10221b63a5aee82",
            "order_id": "692f12bfd10221b63a5aed8f",
            "transaction_id": "TR0000015483",
            "type": "payment",
            "status": "paid",
            "amount": 92.46,
            "fee": 7.54,
            "fee_details": {
                "fixed": 3.6,
                "percent": 2.9,
                "tax": 1.04,
                "percent_amount": 2.9,
                "msi_percent": 0,
                "msi_amount": 0,
                "fixed_installments_amount": 0,
                "fixed_installments_percent": 0,
                "installments_fee": 0
            },
            "installments": 1,
            "total": 100,
            "previous": -5087.71,
            "current": -4995.25,
            "currency": "MXN",
            "gateway": "ecartpay",
            "exchange": 1,
            "reference_id": "692f1313d10221b63a5aee92",
            "reference": "692f1313d10221b63a5aee93",
            "custom_keys": false,
            "order": {
                "number": "OR0000041760",
                "status": "paid",
                "first_name": "Hugo",
                "last_name": "Morín",
                "email": "[email protected]",
                "phone": "529999999999"
            },
            "charges": [
                {
                    "id": "9554dae5",
                    "folio": "1d44a2c6",
                    "reference": "70f770b2",
                    "status": "paid",
                    "type": "card",
                    "currency": "MXN",
                    "amount": 10000,
                    "gateway": "mit",
                    "method": {
                        "name": "Mastercard Test",
                        "exp_month": "01",
                        "exp_year": "2050",
                        "type": "credit",
                        "last4": "2235",
                        "brand": "mastercard",
                        "bankname": "ecartpay",
                        "domestic": true
                    },
                    "affiliation_number": "SANDBOX-10-12-17"
                }
            ],
            "available_at": "2025-12-02T16:25:55.026Z",
            "b2b_metadata": {
                "b2b_transactions": []
            },
            "created_at": "2025-12-02T16:25:55.037Z",
            "updated_at": "2025-12-02T16:25:55.037Z"
        },
        {
            "id": "6928e64036f6061008208f66",
            "account_id": "68a4c3150b28a9584305a2a6",
            "affiliation_number": "SANDBOX-10-12-17",
            "activity_id": "6928e63e36f6061008208f51",
            "order_id": "6928e63d36f6061008208f49",
            "customer_id": "68dea001d3d53b7a568e2686",
            "account_customer_id": "68dea146d3d53b7a568e2779",
            "transaction_id": "TR0000015147",
            "type": "payment",
            "status": "paid",
            "amount": 44.14,
            "fee": 5.86,
            "fee_details": {
                "fixed": 3.6,
                "percent": 2.9,
                "tax": 0.81,
                "percent_amount": 1.45,
                "msi_percent": 0,
                "msi_amount": 0,
                "fixed_installments_amount": 0,
                "fixed_installments_percent": 0,
                "installments_fee": 0
            },
            "installments": 1,
            "total": 50,
            "previous": -5131.85,
            "current": -5087.71,
            "currency": "MXN",
            "gateway": "ecartpay",
            "exchange": 1,
            "reference_id": "6928e64036f6061008208f62",
            "reference": "6928e64036f6061008208f63",
            "custom_keys": false,
            "order": {
                "number": "OR0000041308",
                "status": "paid",
                "first_name": "Hugo",
                "last_name": "Isaid",
                "email": "[email protected]",
                "phone": "9876543210"
            },
            "charges": [
                {
                    "id": "b4b93cc1",
                    "folio": "5531e5dc",
                    "reference": "a2464979",
                    "status": "paid",
                    "type": "card",
                    "currency": "MXN",
                    "amount": 5000,
                    "gateway": "mit",
                    "method": {
                        "name": "Hugo Isaíd",
                        "exp_month": "01",
                        "exp_year": "2050",
                        "type": "credit",
                        "last4": "2235",
                        "brand": "mastercard",
                        "bankname": "ecartpay",
                        "domestic": true
                    },
                    "affiliation_number": "SANDBOX-10-12-17"
                }
            ],
            "available_at": "2025-11-28T00:01:04.084Z",
            "b2b_metadata": {
                "b2b_transactions": []
            },
            "created_at": "2025-11-28T00:01:04.218Z",
            "updated_at": "2025-11-28T00:01:04.218Z"
        },
        {
            "id": "691756a64a288506cc259ca4",
            "account_id": "68a4c3150b28a9584305a2a6",
            "affiliation_number": "SANDBOX-10-12-17",
            "activity_id": "691756a54a288506cc259c90",
            "order_id": "691756a44a288506cc259c7e",
            "customer_id": "68efc519bc1737f0b3e5b003",
            "account_customer_id": "68dea146d3d53b7a568e2779",
            "transaction_id": "TR0000014309",
            "type": "payment",
            "status": "paid",
            "amount": 1446.32,
            "fee": 54.67,
            "fee_details": {
                "fixed": 3.6,
                "percent": 2.9,
                "tax": 7.54,
                "percent_amount": 43.53,
                "msi_percent": 0,
                "msi_amount": 0,
                "fixed_installments_amount": 0,
                "fixed_installments_percent": 0,
                "installments_fee": 0
            },
            "installments": 1,
            "total": 1500.99,
            "previous": -6578.17,
            "current": -5131.85,
            "currency": "MXN",
            "gateway": "ecartpay",
            "exchange": 1,
            "reference_id": "691756a64a288506cc259ca0",
            "reference": "691756a64a288506cc259ca1",
            "custom_keys": false,
            "order": {
                "number": "OR0000039694",
                "status": "paid",
                "first_name": "Hugo",
                "last_name": "Isaid",
                "email": "[email protected]",
                "phone": "9876543210"
            },
            "charges": [
                {
                    "id": "d8cb0de8",
                    "folio": "d443d9cc",
                    "reference": "4653dd40",
                    "status": "paid",
                    "type": "card",
                    "currency": "MXN",
                    "amount": 150099,
                    "gateway": "mit",
                    "method": {
                        "name": "Mastercard Test",
                        "exp_month": "01",
                        "exp_year": "2050",
                        "type": "credit",
                        "last4": "2235",
                        "brand": "mastercard",
                        "bankname": "ecartpay",
                        "domestic": true
                    },
                    "affiliation_number": "SANDBOX-10-12-17"
                }
            ],
            "available_at": "2025-11-14T16:19:50.630Z",
            "b2b_metadata": {
                "b2b_transactions": []
            },
            "created_at": "2025-11-14T16:19:50.750Z",
            "updated_at": "2025-11-14T16:19:50.750Z"
        },
        {
            "id": "6913797912b4dee56a54038f",
            "account_id": "68a4c3150b28a9584305a2a6",
            "affiliation_number": "SANDBOX-10-12-17",
            "activity_id": "6913797712b4dee56a54037b",
            "order_id": "6913797612b4dee56a540369",
            "customer_id": "68efc519bc1737f0b3e5b003",
            "account_customer_id": "68dea146d3d53b7a568e2779",
            "transaction_id": "TR0000014075",
            "type": "payment",
            "status": "paid",
            "amount": 1446.32,
            "fee": 54.67,
            "fee_details": {
                "fixed": 3.6,
                "percent": 2.9,
                "tax": 7.54,
                "percent_amount": 43.53,
                "msi_percent": 0,
                "msi_amount": 0,
                "fixed_installments_amount": 0,
                "fixed_installments_percent": 0,
                "installments_fee": 0
            },
            "installments": 1,
            "total": 1500.99,
            "previous": -8024.49,
            "current": -6578.17,
            "currency": "MXN",
            "gateway": "ecartpay",
            "exchange": 1,
            "reference_id": "6913797812b4dee56a54038b",
            "reference": "6913797812b4dee56a54038c",
            "custom_keys": false,
            "order": {
                "number": "OR0000039121",
                "status": "paid",
                "first_name": "Hugo",
                "last_name": "Isaid",
                "email": "[email protected]",
                "phone": "9876543210"
            },
            "charges": [
                {
                    "id": "24c42fab",
                    "folio": "439ae9d5",
                    "reference": "5f75962c",
                    "status": "paid",
                    "type": "card",
                    "currency": "MXN",
                    "amount": 150099,
                    "gateway": "mit",
                    "method": {
                        "name": "Mastercard Test",
                        "exp_month": "01",
                        "exp_year": "2050",
                        "type": "credit",
                        "last4": "2235",
                        "brand": "mastercard",
                        "bankname": "ecartpay",
                        "domestic": true
                    },
                    "affiliation_number": "SANDBOX-10-12-17"
                }
            ],
            "available_at": "2025-11-11T17:59:21.013Z",
            "b2b_metadata": {
                "b2b_transactions": []
            },
            "created_at": "2025-11-11T17:59:21.088Z",
            "updated_at": "2025-11-11T17:59:21.088Z"
        }
    ],
    "pages": 17,
    "token_page": "CPLOARoJKSff5N+aAQAAIg5aDGkvE63RAiG2OlrwMg==",
    "next_token": "CPrDARoJKQCBEnSaAQAAIg5aDGkTeXkStN7lalQDjw=="
}

Why this works

The next_token represents the last transaction in the current page, which tells the database where to continue the search.

Key points

  • The response contains the next 5 transactions (transactions 6-10)
  • The count remains 83 (total hasn't changed)
  • A new token_page and next_tokenare provided for subsequent navigation
  • The query returned different transactions than Step 1




Step 3: Return to the Previous Page (Transactions 1-5)

Let's navigate back to the first page using the prev parameter with the token_page value (CPLOARoJKSff5N+aAQAAIg5aDGkvE63RAiG2OlrwMg==) from Step 2.

Remember to URL encode the token_page to look like thise CPLOARoJKSff5N%2BaAQAAIg5aDGkvE63RAiG2OlrwMg%3D%3D.

Request

postman request 'http://localhost:9000/api/transactions?limit=5&prev=CPLOARoJKSff5N%2BaAQAAIg5aDGkvE63RAiG2OlrwMg%3D%3D&created_at[from]=2025-01-01&created_at[to]=2025-12-31' \
  --header 'Authorization: eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY4YTRjMzE1MGIyOGE5NTg0MzA1YTJhYSIsImFjY291bnRfaWQiOiI2OGE0YzMxNTBiMjhhOTU4NDMwNWEyYTYiLCJhY2NvdW50Ijp7ImVtYWlsIjoiaHVnby5tb3JpbkBlY2FydHBheS5jb20iLCJmaXJzdF9uYW1lIjoiSHVnbyIsImxhc3RfbmFtZSI6Ik1vcsOtbiIsInBob25lIjoiNTI.......'

Response

{
    "count": 83,
    "docs": [
        {
            "id": "6950926005cbfa6601c0dda2",
            "account_id": "68a4c3150b28a9584305a2a6",
            "refund_id": "6950925f05cbfa6601c0dd93",
            "transaction_id": "TR0000016663",
            "type": "charge",
            "status": "paid",
            "amount": 50,
            "fee": 0,
            "fee_details": {
                "fixed": 0,
                "percent": 0,
                "tax": 0,
                "percent_amount": 0,
                "msi_percent": 0,
                "msi_amount": 0,
                "fixed_installments_amount": 0,
                "fixed_installments_percent": 0,
                "installments_fee": 0
            },
            "installments": 1,
            "total": 50,
            "previous": -4387.99,
            "current": -4437.99,
            "currency": "MXN",
            "gateway": "ecartpay",
            "exchange": 1,
            "reference_id": "6950926005cbfa6601c0dd9f",
            "reference": "6950926005cbfa6601c0dda0",
            "reason": "refund",
            "custom_keys": false,
            "charges": [],
            "available_at": "2025-12-28T02:13:52.510Z",
            "b2b_metadata": {
                "b2b_transactions": []
            },
            "created_at": "2025-12-28T02:13:52.633Z",
            "updated_at": "2025-12-28T02:13:53.275Z"
        },
        {
            "id": "69509252a0526f0bc30befe2",
            "account_id": "68a4c3150b28a9584305a2a6",
            "affiliation_number": "SANDBOX-10-12-17",
            "activity_id": "69509250a0526f0bc30befcd",
            "order_id": "69509246a0526f0bc30befb7",
            "customer_id": "68dea001d3d53b7a568e2686",
            "account_customer_id": "68dea146d3d53b7a568e2779",
            "transaction_id": "TR0000016662",
            "type": "payment",
            "status": "refunded",
            "amount": 44.14,
            "fee": 5.86,
            "fee_details": {
                "fixed": 3.6,
                "percent": 2.9,
                "tax": 0.81,
                "percent_amount": 1.45,
                "msi_percent": 0,
                "msi_amount": 0,
                "fixed_installments_amount": 0,
                "fixed_installments_percent": 0,
                "installments_fee": 0
            },
            "installments": 1,
            "total": 50,
            "previous": -4432.13,
            "current": -4387.99,
            "currency": "MXN",
            "gateway": "ecartpay",
            "exchange": 1,
            "reference_id": "69509252a0526f0bc30befde",
            "reference": "69509252a0526f0bc30befdf",
            "custom_keys": false,
            "order": {
                "number": "OR0000043925",
                "status": "refunded",
                "first_name": "Hugo",
                "last_name": "Isaid",
                "email": "[email protected]",
                "phone": "9876543210"
            },
            "charges": [
                {
                    "id": "6203c3fc",
                    "folio": "7e7ff20d",
                    "reference": "0d3d5556",
                    "status": "paid",
                    "type": "card",
                    "currency": "MXN",
                    "amount": 5000,
                    "gateway": "mit",
                    "method": {
                        "name": "Hugo Isaíd",
                        "exp_month": "01",
                        "exp_year": "2050",
                        "type": "credit",
                        "last4": "2235",
                        "brand": "mastercard",
                        "bankname": "ecartpay",
                        "domestic": true
                    },
                    "affiliation_number": "SANDBOX-10-12-17"
                }
            ],
            "available_at": "2025-12-28T02:13:38.177Z",
            "b2b_metadata": {
                "b2b_transactions": []
            },
            "created_at": "2025-12-28T02:13:38.334Z",
            "updated_at": "2025-12-28T02:13:53.275Z"
        },
        {
            "id": "692f1b0cd10221b63a5afe5a",
            "account_id": "68a4c3150b28a9584305a2a6",
            "affiliation_number": "SANDBOX-10-12-17",
            "activity_id": "692f1b0cd10221b63a5afe46",
            "order_id": "692f1ae1d10221b63a5afda1",
            "transaction_id": "TR0000015520",
            "type": "payment",
            "status": "paid",
            "amount": 92.46,
            "fee": 7.54,
            "fee_details": {
                "fixed": 3.6,
                "percent": 2.9,
                "tax": 1.04,
                "percent_amount": 2.9,
                "msi_percent": 0,
                "msi_amount": 0,
                "fixed_installments_amount": 0,
                "fixed_installments_percent": 0,
                "installments_fee": 0
            },
            "installments": 1,
            "total": 100,
            "previous": -4524.59,
            "current": -4432.13,
            "currency": "MXN",
            "gateway": "ecartpay",
            "exchange": 1,
            "reference_id": "692f1b0cd10221b63a5afe56",
            "reference": "692f1b0cd10221b63a5afe57",
            "custom_keys": false,
            "order": {
                "number": "OR0000041825",
                "status": "paid",
                "first_name": "John",
                "last_name": "Doe",
                "email": "[email protected]",
                "phone": "529999999999"
            },
            "charges": [
                {
                    "id": "c13fb710",
                    "folio": "7e761d4f",
                    "reference": "189dac22",
                    "status": "paid",
                    "type": "card",
                    "currency": "MXN",
                    "amount": 10000,
                    "gateway": "mit",
                    "method": {
                        "name": "John Doe",
                        "exp_month": "01",
                        "exp_year": "2050",
                        "type": "credit",
                        "last4": "2151",
                        "brand": "mastercard",
                        "bankname": "ecartpay",
                        "domestic": true
                    },
                    "affiliation_number": "SANDBOX-10-12-17"
                }
            ],
            "available_at": "2025-12-02T16:59:56.420Z",
            "b2b_metadata": {
                "b2b_transactions": []
            },
            "created_at": "2025-12-02T16:59:56.431Z",
            "updated_at": "2025-12-02T16:59:56.431Z"
        },
        {
            "id": "692f199fd10221b63a5afb55",
            "account_id": "68a4c3150b28a9584305a2a6",
            "affiliation_number": "SANDBOX-10-12-17",
            "activity_id": "692f199fd10221b63a5afb41",
            "order_id": "692f194cd10221b63a5afaa4",
            "template_id": "692f1493d33762531c20f54b",
            "transaction_id": "TR0000015511",
            "type": "payment",
            "status": "paid",
            "amount": 189.1,
            "fee": 10.9,
            "fee_details": {
                "fixed": 3.6,
                "percent": 2.9,
                "tax": 1.5,
                "percent_amount": 5.8,
                "msi_percent": 0,
                "msi_amount": 0,
                "fixed_installments_amount": 0,
                "fixed_installments_percent": 0,
                "installments_fee": 0
            },
            "installments": 1,
            "total": 200,
            "previous": -4713.69,
            "current": -4524.59,
            "currency": "MXN",
            "gateway": "ecartpay",
            "exchange": 1,
            "reference_id": "692f199fd10221b63a5afb51",
            "reference": "692f199fd10221b63a5afb52",
            "custom_keys": false,
            "order": {
                "number": "OR0000041812",
                "status": "paid",
                "first_name": "Hugo",
                "last_name": "Morín",
                "email": "[email protected]",
                "phone": "529999999999"
            },
            "charges": [
                {
                    "id": "7238e04b",
                    "folio": "2e4701a9",
                    "reference": "c8d1989e",
                    "status": "paid",
                    "type": "card",
                    "currency": "MXN",
                    "amount": 20000,
                    "gateway": "mit",
                    "method": {
                        "name": "Mastercard Test",
                        "exp_month": "01",
                        "exp_year": "2050",
                        "type": "credit",
                        "last4": "2235",
                        "brand": "mastercard",
                        "bankname": "ecartpay",
                        "domestic": true
                    },
                    "affiliation_number": "SANDBOX-10-12-17"
                }
            ],
            "available_at": "2025-12-02T16:53:51.681Z",
            "b2b_metadata": {
                "b2b_transactions": []
            },
            "created_at": "2025-12-02T16:53:51.692Z",
            "updated_at": "2025-12-02T16:53:51.692Z"
        },
        {
            "id": "692f1798d10221b63a5af6c5",
            "account_id": "68a4c3150b28a9584305a2a6",
            "affiliation_number": "SANDBOX-10-12-17",
            "activity_id": "692f1798d10221b63a5af6b1",
            "order_id": "692f168fd10221b63a5af570",
            "template_id": "692f1493d33762531c20f54b",
            "transaction_id": "TR0000015500",
            "type": "payment",
            "status": "paid",
            "amount": 189.1,
            "fee": 10.9,
            "fee_details": {
                "fixed": 3.6,
                "percent": 2.9,
                "tax": 1.5,
                "percent_amount": 5.8,
                "msi_percent": 0,
                "msi_amount": 0,
                "fixed_installments_amount": 0,
                "fixed_installments_percent": 0,
                "installments_fee": 0
            },
            "installments": 1,
            "total": 200,
            "previous": -4902.79,
            "current": -4713.69,
            "currency": "MXN",
            "gateway": "ecartpay",
            "exchange": 1,
            "reference_id": "692f1798d10221b63a5af6c1",
            "reference": "692f1798d10221b63a5af6c2",
            "custom_keys": false,
            "order": {
                "number": "OR0000041793",
                "status": "paid",
                "first_name": "John",
                "last_name": "Doe",
                "email": "[email protected]",
                "phone": "529999999999"
            },
            "charges": [
                {
                    "id": "25981571",
                    "folio": "9bfffa32",
                    "reference": "7d329b95",
                    "status": "paid",
                    "type": "card",
                    "currency": "MXN",
                    "amount": 20000,
                    "gateway": "mit",
                    "method": {
                        "name": "John Doe",
                        "exp_month": "01",
                        "exp_year": "2050",
                        "type": "credit",
                        "last4": "4242",
                        "brand": "visa",
                        "bankname": "ecartpay",
                        "domestic": true
                    },
                    "affiliation_number": "SANDBOX-10-12-17"
                }
            ],
            "available_at": "2025-12-02T16:45:12.523Z",
            "b2b_metadata": {
                "b2b_transactions": []
            },
            "created_at": "2025-12-02T16:45:12.535Z",
            "updated_at": "2025-12-02T16:45:12.535Z"
        }
    ],
    "pages": 17,
    "token_page": "CN7XARoJKXnJu2KbAQAAIg5aDGlQkmAFy/pmAcDdog==",
    "next_token": "CPPOARoJKdcr9N+aAQAAIg5aDGkvF5jRAiG2Olr2xQ=="
}

Why this works

The token_page represents the first transaction of the current page, which allows the database to return results before that position.


Summary

  • Use next_token with the next parameter to move forward.
  • Use token_page with the prev parameter to move backward.
  • Tokens are only valid if filters and date ranges remain identical.
  • Always URL-encode tokens in query parameters.