> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mangopay.com/llms.txt
> Use this file to discover all available pages before exploring further.

# List all Events

<Note>
  **Note**

  Events are returned up to 45 days after they occur. Any request attempting to access an event older than 45 days will result in an HTTP 400 - error.
</Note>

### Query parameters

<ParamField query="EventType" type="string" required>
  **Allowed values:** An `EventType` listed in the <a href="/webhooks/event-types">event types list</a>

  The type of the event.
</ParamField>

<ParamField query="BeforeDate" type="Unix timestamp">
  The date before which the event was created (based on the event’s `CreationDate` parameter). You can filter on a specific time range by using both the `AfterDate` and `BeforeDate` query parameters.
</ParamField>

<ParamField query="AfterDate" type="Unix timestamp">
  The date after which the event was created (based on the event’s `CreationDate` parameter). You can filter on a specific time range by using both the `AfterDate` and `BeforeDate` query parameters.
</ParamField>

### Responses

<AccordionGroup>
  <Accordion title="200">
    <ResponseField name="Array (Events)" type="array">
      The list of events created by the platform.

      <Expandable title="properties">
        <ResponseField name="Object" type="object">
          The Event object created by the platform.

          <Expandable title="properties">
            <ResponseField name="ResourceId" type="string">
              Max. length: 255 characters

              The unique identifier of the event.
            </ResponseField>

            <ResponseField name="Date" type="Unix timestamp">
              The date and time the event occured.
            </ResponseField>

            <ResponseField name="EventType" type="string">
              **Returned values:** An `EventType` listed in the <a href="/webhooks/event-types">event types list</a>

              The type of the event.
            </ResponseField>
          </Expandable>
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Accordion>

  <Accordion title="400 - Events older than 45 days not retrievable">
    ```json theme={null}
    {
        "Message": "One or several required parameters are missing or incorrect. An incorrect resource ID also raises this kind of error.",
        "Type": "param_error",
        "Id": "9fb282aa-7c7e-462c-9f5c-df5f8714b39f",
        "Date": 1715350291.0,
        "errors": {
            "AfterDate": "Events older than 45 days can not be searched",
            "BeforeDate": "Events older than 45 days can not be searched"
        }
    }
    ```
  </Accordion>
</AccordionGroup>

<ResponseExample>
  ```json 200 theme={null}
  [
      {
          "ResourceId": "144085929",
          "EventType": "UBO_DECLARATION_CREATED",
          "Date": 1655891453
      },
      {
          "ResourceId": "144086566",
          "EventType": "KYC_CREATED",
          "Date": 1655891893
      }
  ]  

  ```
</ResponseExample>

<RequestExample>
  ```php PHP theme={null}
  <?php 

  require_once 'vendor/autoload.php';

  use MangoPay\MangoPayApi;
  use MangoPay\Libraries\ResponseException as MGPResponseException;
  use MangoPay\Libraries\Exception as MGPException;

  $api = new MangoPayApi();

  $api->Config->ClientId = 'your-client-id';
  $api->Config->ClientPassword = 'your-api-key';
  $api->Config->TemporaryFolder = 'tmp/';

  try {
      $response = $api->Events->GetAll();

      print_r($response);
  } catch(MGPResponseException $e) {
      print_r($e);
  } catch(MGPException $e) {
      print_r($e);
  }  
  ```

  ```javascript NodeJS   theme={null}
  const mangopayInstance = require('mangopay4-nodejs-sdk')
  const mangopay = new mangopayInstance({
    clientId: 'your-client-id',
    clientApiKey: 'your-api-key',
  })

  const listEvents = async () => {
    return await mangopay.Events.getAll()
      .then((response) => {
        console.info(response)
        return response
      })
      .catch((err) => {
        console.log(err)
        return false
      })
  }

  listEvents()  
  ```

  ```ruby Ruby   theme={null}
  require 'mangopay'

  MangoPay.configure do |client|
      client.preproduction = true
      client.client_id = 'your-client-id'
      client.client_apiKey = 'your-api-key'
      client.log_file = File.join(Dir.pwd, 'mangopay.log')
  end

  def listEvents()
      begin
          response = MangoPay::Event.fetch()
          puts response
          return response
      rescue MangoPay::ResponseError => error
          puts "Failed to fetch events: #{error.message}"
          puts "Error details: #{error.details}"
          return false
      end
  end


  listEvents()  
  ```

  ```java Java  theme={null}
  import java.util.List;
  import com.google.gson.Gson;
  import com.google.gson.GsonBuilder;
  import com.mangopay.MangoPayApi;
  import com.mangopay.core.FilterEvents;
  import com.mangopay.core.Pagination;
  import com.mangopay.entities.Event;
  import com.mangopay.core.enumerations.EventType;

  public class ListEvents {
      public static void main(String[] args) throws Exception {
          MangoPayApi mangopay = new MangoPayApi();
          mangopay.getConfig().setClientId("your-client-id");
          mangopay.getConfig().setClientPassword("your-api-key");

          FilterEvents eventsFilter = new FilterEvents();
          eventsFilter.setType(EventType.PAYIN_NORMAL_CREATED);
          
          List<Event> events = mangopay.getEventApi().get(eventsFilter, new Pagination(1, 100), null);

          Gson prettyPrint = new GsonBuilder().setPrettyPrinting().create();
          String prettyJson = prettyPrint.toJson(events);

          System.out.println(prettyJson);   
      }
  }
  ```

  ```python Python   theme={null}
  from pprint import pprint
  import mangopay

  mangopay.client_id='your-client-id'
  mangopay.apikey='your-api-key'

  from mangopay.api import APIRequest
  handler = APIRequest(sandbox=True)

  from mangopay.resources import Event

  events = Event.all()

  for event in events:
      pprint(event._data)
      print()  
  ```

  ```csharp .NET  theme={null}
  using MangoPay.SDK;
  using Newtonsoft.Json;

  class Program
  {
      static async Task Main(string[] args)
      {
          MangoPayApi api = new MangoPayApi();

          api.Config.ClientId = "your-client-id";
          api.Config.ClientPassword = "your-api-key";

          var events = await api.Events.GetAllAsync(null);

          string prettyPrint = JsonConvert.SerializeObject(events, Formatting.Indented);
          Console.WriteLine(prettyPrint);
      }
  }
  ```
</RequestExample>
