# List gateway request logs

> For the complete machine-readable documentation index, see [llms.txt](https://apidocs.chargebee.com/llms.txt).


[Eventually Consistent](/docs/api/read-consistency)

Retrieves the requests that Chargebee sent to payment gateways for the site, newest first.

Use this operation to investigate gateway activity, such as failed payment or refund calls, for a specific [customer](/docs/api/customers), [invoice](/docs/api/invoices), [transaction](/docs/api/transactions), or gateway. Filter by `invocation_time` to limit the results to a time range.

### Implementation Notes

-   Results are sorted by `invocation_time` in descending order. Pass `sort_by[asc]` as `invocation_time` to list the oldest logs first.
-   Pagination can reach at most the first 10,000 matching logs: `offset` plus `limit` can't exceed 10,000. Once the next page would go past 10,000 logs, `next_offset` isn't returned, even if more logs match. To page further back, narrow the time range with the `invocation_time` filter.
-   Only the filters listed on this page are supported. Any other filter parameter returns an error instead of being ignored.
-   When Multi Business Entity is enabled and a business entity is in context, only logs for that business entity are returned.

## Sample Request

#### Chargebee CLI

```bash
chargebee gateway-request-log list \
    -d limit=2 \
    -d 'gateway[is]=stripe'
```

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/gateway_request_logs \
     -G  \
     -u {site_api_key}:\
     --data-urlencode limit=2 \
     --data-urlencode "gateway[is]"="stripe"
```

#### .NET

```dotnet
using ChargeBee.Api;
using ChargeBee.Models;

ApiConfig.Configure("{site}","{site_api_key}");
ListResult result = GatewayRequestLog.List()
		.Limit(2)
		.Gateway().Is("stripe")
		.Request();

foreach (var listItem in result.List){
  GatewayRequestLog gatewayRequestLog = listItem.GatewayRequestLog;
}
```

#### Go

```go
package main
import (
    "fmt"
    "github.com/chargebee/chargebee-go/v3"
    "github.com/chargebee/chargebee-go/v3/filter"
    gatewayrequestlogAction "github.com/chargebee/chargebee-go/v3/actions/gatewayrequestlog"
    "github.com/chargebee/chargebee-go/v3/models/gatewayrequestlog"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := gatewayrequestlogAction.List(&gatewayrequestlog.ListRequestParams{
        Limit : chargebee.Int32(2),
        Gateway : &filter.StringFilter{
            Is : "stripe",
        },
    }).ListRequest()
    if err != nil {
        fmt.Println(err)
    } else {
        for idx := 0; idx < len(res.List); idx++ {
            GatewayRequestLog := res.List[idx].GatewayRequestLog
        }
    }
}
```

#### Go

```go
package main

import (
  "fmt"
  "github.com/chargebee/chargebee-go/v4"
)

func main() {
  config := &chargebee.ClientConfig{
    SiteName: "{site}",
    ApiKey: "{site_api_key}",
  }    
  client := chargebee.NewClient(config)
  req := &chargebee.GatewayRequestLogListRequest{
    Limit : chargebee.Int32(2),
    Gateway : &chargebee.StringFilter{
        Is : "stripe",
    },
}
  res, err := client.GatewayRequestLog.List(req)
      if err != nil {
        fmt.Println(err)
    } else {
        for idx := 0; idx < len(res.List); idx++ {
            GatewayRequestLog := res.List[idx].GatewayRequestLog
        }
    }
}
```

#### Java

```java
import com.chargebee.*;
import com.chargebee.ListResult;
import com.chargebee.models.*;
import com.chargebee.models.enums.*;
import java.io.IOException;
import java.util.List;

public class Sample {

    public static void main(String args[]) throws IOException, Exception {
        Environment.configure("{site}", "{site_api_key}");
        ListResult result = GatewayRequestLog.list()
            .limit(2)
            .gateway().is(GatewayRequestLog.Gateway.STRIPE)
            .request();

        for (ListResult.Entry entry : result) {
            GatewayRequestLog gatewayRequestLog = entry.gatewayRequestLog();
        }
    }
}
```

#### Java

```java
import com.chargebee.v4.client.ChargebeeClient;
import com.chargebee.v4.models.gatewayRequestLog.GatewayRequestLog;
import com.chargebee.v4.models.gatewayRequestLog.params.GatewayRequestLogListParams;
import com.chargebee.v4.models.gatewayRequestLog.responses.GatewayRequestLogListResponse;
import java.util.List;

public class GatewayRequestLogList {

    public static void main(String[] args) {
        ChargebeeClient client = ChargebeeClient.builder()
            .apiKey("{site_api_key}")
            .siteName("{site}")
            .build();

        GatewayRequestLogListParams params = GatewayRequestLogListParams.builder()
            .limit(2)
            .gateway()
            .is("stripe")
            .build();

        GatewayRequestLogListResponse response = client.gatewayRequestLogs().list(params);
    }
}
```

#### Node.js

```node
import Chargebee from "chargebee";

const chargebee = new Chargebee({
    site: "{site}",
    apiKey: "{site_api_key}",
});

try {
    const result = await chargebee.gatewayRequestLog.list({
        limit: 2,
        gateway: {
            is: "stripe"
        }
    });
    result.list.forEach((entry) => {
        console.log(entry);
        const gatewayRequestLog = entry.gateway_request_log;
    });
} catch (err) {
    console.log(err);
}
```

#### PHP

```php
<?php

require __DIR__ . '/vendor/autoload.php';

use Chargebee\ChargebeeClient;

$chargebee = new ChargebeeClient(options: [
    "site" => "{site}",
    "apiKey" => "{site_api_key}",
]);
$result = $chargebee->gatewayRequestLog()->all([
    "limit" => 2,
    "gateway" => [
        "is" => "stripe"
    ]
]);
foreach($result->list as $entry) {
    $gatewayRequestLog = $entry->gateway_request_log;
}
```

#### Python

```python
from chargebee import Chargebee, Filters

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
entries = cb_client.GatewayRequestLog.list(
    cb_client.GatewayRequestLog.ListParams(
        limit=2,
        gateway=Filters.StringFilter(IS="stripe")
    )
)
for entry in entries.list:
    gateway_request_log = entry.gateway_request_log
```

#### Ruby

```ruby
require 'chargebee'

ChargeBee.configure(:site => "{site}",
  :api_key => "{site_api_key}")

list = ChargeBee::GatewayRequestLog.list({
  :limit => 2,
  "gateway[is]" => "stripe"
})

list.each do |entry|
  gateway_request_log = entry.gateway_request_log
end
```

## Sample Response

```json
{
  "list": [
    {
      "gateway_request_log": {
        "log_id": "Xk2pR40BlZ7aQ1sYdE9f",
        "url": "https://api.stripe.com/v1/payment_intents",
        "status_code": "200",
        "method": "POST",
        "request_body": "{amount=2500, currency=usd, customer=cus_QxSaMpLe1, payment_method=pm_************4242, confirm=true}",
        "response_body": "{\"id\":\"pi_SaMpLe1\",\"object\":\"payment_intent\",\"status\":\"succeeded\",\"amount\":2500,\"currency\":\"usd\"}",
        "request_headers": "{\"Authorization\":\"********\"}",
        "response_headers": "{\"Content-Type\":\"application/json\",\"Request-Id\":\"req_SaMpLe123\"}",
        "gateway": "stripe",
        "customer_handle": "__test__KyVnHhSBWlC1T2cj",
        "invoice_handle": "__demo_inv__1",
        "transaction_handle": "txn___test__KyVnHhSBWlxBX2qV",
        "payment_method_handle": "pm___test__KyVnHhSBWlC4q2cn",
        "gateway_credential_handle": "gw___test__KyVnHhSBWl6sk2bY",
        "payment_method_name": "Card",
        "operation_name": "PAYMENT",
        "operation_type": "PAYMENT",
        "source": "API",
        "invocation_time": 1762099200,
        "response_received_at": 1762099201,
        "response_time": 842,
        "object": "gateway_request_log"
      }
    },
    {..}
  ],
  "next_offset": "2"
}
```

## URL Format

**GET** https://[site].chargebee.com/api/v2/gateway_request_logs

## Input Parameters

- `limit` (optional, integer, default=10, min=1, max=100)
  The number of resources to be returned.
  
  **Constraints**
  
  -   `offset` plus `limit` can't exceed 10,000.

- `offset` (optional, string, max chars=1000)
  Determines your position in the list for pagination. To ensure that the next page is retrieved correctly, always set `offset` to the value of `next_offset` obtained in the previous iteration of the API call.
  
  **Constraints**
  
  -   `offset` plus `limit` can't exceed 10,000. To page further back, narrow the time range with the `invocation_time` filter.

## Returns

- `next_offset` (optional, string, max chars=1000)
  Returned only when more resources are present and the next page stays within the first 10,000 matching logs. To fetch the next set of resources, use this value for the input parameter `offset`.

- `gateway_request_log` (Gateway request log object)
  Resource object representing gateway\_request\_log
