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

# Send events

> Sends a list of events to the Insights API.

**Required ACL:** `search`

You can include up to 1,000 events in a single request,
but the request body must be smaller than 2 MB.

## Usage

<CodeGroup>
  ```cs C# theme={"system"}
  // Initialize the client
  var client = new InsightsClient(
    new InsightsConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", "ALGOLIA_APPLICATION_REGION")
  );

  // Call the API
  var response = await client.PushEventsAsync(
    new InsightsEvents
    {
      Events = new List<EventsItems>
      {
        new EventsItems(
          new ClickedObjectIDsAfterSearch
          {
            EventType = Enum.Parse<ClickEvent>("Click"),
            EventName = "Product Clicked",
            Index = "products",
            UserToken = "user-123456",
            AuthenticatedUserToken = "user-123456",
            Timestamp = 1641290601962L,
            ObjectIDs = new List<string> { "9780545139700", "9780439784542" },
            QueryID = "43b15df305339e827f0ac0bdc5ebcaa7",
            Positions = new List<int> { 7, 6 },
          }
        ),
      },
    }
  );

  // print the response
  Console.WriteLine(response);
  ```

  ```dart Dart theme={"system"}
  // Initialize the client
  final client = InsightsClient(
      appId: 'ALGOLIA_APPLICATION_ID',
      apiKey: 'ALGOLIA_API_KEY',
      region: 'ALGOLIA_APPLICATION_REGION');

  // Call the API
  final response = await client.pushEvents(
    insightsEvents: InsightsEvents(
      events: [
        ClickedObjectIDsAfterSearch(
          eventType: ClickEvent.fromJson("click"),
          eventName: "Product Clicked",
          index: "products",
          userToken: "user-123456",
          authenticatedUserToken: "user-123456",
          timestamp: 1641290601962,
          objectIDs: [
            "9780545139700",
            "9780439784542",
          ],
          queryID: "43b15df305339e827f0ac0bdc5ebcaa7",
          positions: [
            7,
            6,
          ],
        ),
      ],
    ),
  );

  // print the response
  print(response);
  ```

  ```go Go theme={"system"}
  // Initialize the client with your application region, eg. insights.ALGOLIA_APPLICATION_REGION
  client, err := insights.NewClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", insights.US)
  if err != nil {
    // The client can fail to initialize if you pass an invalid parameter.
    panic(err)
  }

  // Call the API
  response, err := client.PushEvents(client.NewApiPushEventsRequest(

    insights.NewEmptyInsightsEvents().SetEvents(
      []insights.EventsItems{*insights.ClickedObjectIDsAfterSearchAsEventsItems(
        insights.NewEmptyClickedObjectIDsAfterSearch().SetEventType(insights.ClickEvent("click")).SetEventName("Product Clicked").SetIndex("products").SetUserToken("user-123456").SetAuthenticatedUserToken("user-123456").SetTimestamp(1641290601962).SetObjectIDs(
          []string{"9780545139700", "9780439784542"}).SetQueryID("43b15df305339e827f0ac0bdc5ebcaa7").SetPositions(
          []int32{7, 6}))})))
  if err != nil {
    // handle the eventual error
    panic(err)
  }


  // print the response
  print(response)
  ```

  ```java Java theme={"system"}
  // Initialize the client
  InsightsClient client = new InsightsClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", "ALGOLIA_APPLICATION_REGION");

  // Call the API
  EventsResponse response = client.pushEvents(
    new InsightsEvents().setEvents(
      Arrays.asList(
        new ClickedObjectIDsAfterSearch()
          .setEventType(ClickEvent.CLICK)
          .setEventName("Product Clicked")
          .setIndex("products")
          .setUserToken("user-123456")
          .setAuthenticatedUserToken("user-123456")
          .setTimestamp(1641290601962L)
          .setObjectIDs(Arrays.asList("9780545139700", "9780439784542"))
          .setQueryID("43b15df305339e827f0ac0bdc5ebcaa7")
          .setPositions(Arrays.asList(7, 6))
      )
    )
  );

  // print the response
  System.out.println(response);
  ```

  ```js JavaScript theme={"system"}
  // Initialize the client
  // Replace 'us' with your Algolia Application Region
  const client = algoliasearch('ALGOLIA_APPLICATION_ID', 'ALGOLIA_API_KEY').initInsights({ region: 'us' });

  // Call the API
  const response = await client.pushEvents({
    events: [
      {
        eventType: 'click',
        eventName: 'Product Clicked',
        index: 'products',
        userToken: 'user-123456',
        authenticatedUserToken: 'user-123456',
        timestamp: 1641290601962,
        objectIDs: ['9780545139700', '9780439784542'],
        queryID: '43b15df305339e827f0ac0bdc5ebcaa7',
        positions: [7, 6],
      },
    ],
  });


  // print the response
  console.log(response);
  ```

  ```kotlin Kotlin theme={"system"}
  // Initialize the client
  val client =
    InsightsClient(
      appId = "ALGOLIA_APPLICATION_ID",
      apiKey = "ALGOLIA_API_KEY",
      region = "ALGOLIA_APPLICATION_REGION",
    )

  // Call the API
  var response =
    client.pushEvents(
      insightsEvents =
        InsightsEvents(
          events =
            listOf(
              ClickedObjectIDsAfterSearch(
                eventType = ClickEvent.entries.first { it.value == "click" },
                eventName = "Product Clicked",
                index = "products",
                userToken = "user-123456",
                authenticatedUserToken = "user-123456",
                timestamp = 1641290601962L,
                objectIDs = listOf("9780545139700", "9780439784542"),
                queryID = "43b15df305339e827f0ac0bdc5ebcaa7",
                positions = listOf(7, 6),
              )
            )
        )
    )


  // print the response
  println(response)
  ```

  ```php PHP theme={"system"}
  // Initialize the client
  $client = InsightsClient::create('ALGOLIA_APPLICATION_ID', 'ALGOLIA_API_KEY', 'ALGOLIA_APPLICATION_REGION');

  // Call the API
  $response = $client->pushEvents(
      ['events' => [
          ['eventType' => 'click',
              'eventName' => 'Product Clicked',
              'index' => 'products',
              'userToken' => 'user-123456',
              'authenticatedUserToken' => 'user-123456',
              'timestamp' => 1641290601962,
              'objectIDs' => [
                  '9780545139700',

                  '9780439784542',
              ],
              'queryID' => '43b15df305339e827f0ac0bdc5ebcaa7',
              'positions' => [
                  7,

                  6,
              ],
          ],
      ],
      ],
  );


  // print the response
  var_dump($response);
  ```

  ```python Python theme={"system"}
  # Initialize the client
  # In an asynchronous context, you can use InsightsClient instead, which exposes the exact same methods.
  client = InsightsClientSync(
      "ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", "ALGOLIA_APPLICATION_REGION"
  )

  # Call the API
  response = client.push_events(
      insights_events={
          "events": [
              {
                  "eventType": "click",
                  "eventName": "Product Clicked",
                  "index": "products",
                  "userToken": "user-123456",
                  "authenticatedUserToken": "user-123456",
                  "timestamp": 1641290601962,
                  "objectIDs": [
                      "9780545139700",
                      "9780439784542",
                  ],
                  "queryID": "43b15df305339e827f0ac0bdc5ebcaa7",
                  "positions": [
                      7,
                      6,
                  ],
              },
          ],
      },
  )


  # print the response
  print(response)
  ```

  ```ruby Ruby theme={"system"}
  # Initialize the client
  client = Algolia::InsightsClient.create("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", "ALGOLIA_APPLICATION_REGION")

  # Call the API
  response = client.push_events(
    Algolia::Insights::InsightsEvents.new(
      events: [
        Algolia::Insights::ClickedObjectIDsAfterSearch.new(
          event_type: "click",
          event_name: "Product Clicked",
          index: "products",
          user_token: "user-123456",
          authenticated_user_token: "user-123456",
          timestamp: 1641290601962,
          object_ids: ["9780545139700", "9780439784542"],
          query_id: "43b15df305339e827f0ac0bdc5ebcaa7",
          positions: [7, 6]
        )
      ]
    )
  )


  # print the response
  puts(response)
  ```

  ```scala Scala theme={"system"}
  // Initialize the client
  val client = InsightsClient(
    appId = "ALGOLIA_APPLICATION_ID",
    apiKey = "ALGOLIA_API_KEY",
    region = Option("ALGOLIA_APPLICATION_REGION")
  )

  // Call the API
  val response = Await.result(
    client.pushEvents(
      insightsEvents = InsightsEvents(
        events = Seq(
          ClickedObjectIDsAfterSearch(
            eventType = ClickEvent.withName("click"),
            eventName = "Product Clicked",
            index = "products",
            userToken = "user-123456",
            authenticatedUserToken = Some("user-123456"),
            timestamp = Some(1641290601962L),
            objectIDs = Seq("9780545139700", "9780439784542"),
            queryID = "43b15df305339e827f0ac0bdc5ebcaa7",
            positions = Seq(7, 6)
          )
        )
      )
    ),
    Duration(100, "sec")
  )

  // print the response
  println(response)
  ```

  ```swift Swift theme={"system"}
  // Initialize the client
  let client = try InsightsClient(appID: "ALGOLIA_APPLICATION_ID", apiKey: "ALGOLIA_API_KEY", region: .us)

  // Call the API
  let response = try await client
      .pushEvents(insightsEvents: InsightsEvents(events: [EventsItems
              .clickedObjectIDsAfterSearch(ClickedObjectIDsAfterSearch(
                  eventName: "Product Clicked",
                  eventType: ClickEvent.click,
                  index: "products",
                  objectIDs: ["9780545139700", "9780439784542"],
                  positions: [7, 6],
                  queryID: "43b15df305339e827f0ac0bdc5ebcaa7",
                  userToken: "user-123456",
                  authenticatedUserToken: "user-123456",
                  timestamp: Int64(1_641_290_601_962)
              ))]))

  // print the response
  print(response)
  ```
</CodeGroup>

<Card icon="folder-code" horizontal="true" title="See the full API reference" arrow="true" href="/doc/rest-api/insights/push-events">
  For more details about input parameters
  and response fields.
</Card>
