# API Call

## send events to Frenzy AI

<mark style="color:green;">`POST`</mark> `https://xyz.search.frenzy.ai /events`

The request body will include an array of event objects.

#### Headers

| Name                                                     | Type   | Description                                       |
| -------------------------------------------------------- | ------ | ------------------------------------------------- |
| X-Frenzy-Authorization<mark style="color:red;">\*</mark> | string | API key provided at the time of account creation. |
| Content-type<mark style="color:red;">\*</mark>           | string | application/json                                  |
| X-Shop                                                   | string | Shopify's myshopify url. (without https\://)      |

#### Request Body

| Name                                          | Type   | Description                                                                                                                                    |
| --------------------------------------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| event\_name<mark style="color:red;">\*</mark> | string | Type of event to share e.g. Add to Cart, etc.                                                                                                  |
| user\_id<mark style="color:red;">\*</mark>    | string | User id that triggered the event.                                                                                                              |
| session\_id                                   | string | Session id associated with the request.                                                                                                        |
| config\_id                                    | string | Configuration id for the widget.                                                                                                               |
| query\_id                                     | string | Query ID sent in the response of search, recommendation, etc calls.                                                                            |
| sku                                           | string | Affected sku.                                                                                                                                  |
| creation\_date                                | string | <p>Time of event occurrence UTC format. (e.g. </p><p>2021-02-13 17:00:02) </p><p>If not provided will use the arrival time of the request.</p> |
| query                                         | string | user entered query                                                                                                                             |
| filters                                       | json   | user selected filters                                                                                                                          |
| shop                                          | string | Shopify's myshopify url. (without https\://)                                                                                                   |
| company\_id                                   | string | Shopify B2B company id.                                                                                                                        |
| location\_id                                  | string | Shopify B2B location id.                                                                                                                       |
| country                                       | string | Country code.                                                                                                                                  |
| state                                         | string | State code.                                                                                                                                    |

{% tabs %}
{% tab title="200: OK Sending the Events to Frenzy AI." %}
{% tabs %}
{% tab title="Success" %}

```
{'status': 'Event saved', 'success': true}}
```

{% endtab %}

{% tab title="Failure" %}

```
{'error': 'server_error'}
```

{% endtab %}
{% endtabs %}
{% endtab %}
{% endtabs %}

### Event Names

Below is a list of acceptable Event names-

{% file src="/files/778uBKnCe2Kb0D0e6aFT" %}

| Event Name                                       | Usage                                                                                               |
| ------------------------------------------------ | --------------------------------------------------------------------------------------------------- |
| collection\_product\_click                       | When the user clicks the product from the collection page.                                          |
| search\_product\_click                           | When the user clicks the product from the search page.                                              |
| suggest\_query\_hover                            | When the user hovers over the suggest query on auto-suggest.                                        |
| suggest\_query\_click                            | When the user clicks over the suggest query on auto-suggest.                                        |
| suggest\_search\_product\_click                  | When the user clicks over the product from suggest auto-suggest.                                    |
| default\_suggest\_query\_click                   | When the user clicks over the suggest query on auto-suggest when default results are displayed.     |
| default\_suggest\_search\_product\_click         | When the user clicks over the product from suggest auto-suggest when default results are displayed. |
| pdp\_carousel\_product\_click                    | When the user clicks the product from the pdp page carousel.                                        |
| landing\_page\_carousel\_product\_click          | When the user clicks the product from the pdp page carousel.                                        |
| similar\_product\_carousel\_product\_click       | When the user clicks the product from the similar product carousel.                                 |
| cross\_sell\_carousel\_product\_click            | When the user clicks the product from the cross-sell carousel.                                      |
| personalized\_homepage\_carosuel\_product\_click | When the user clicks the product from the personalized home page carousel.                          |
| most\_clicked\_skus\_carousel\_product\_click    | When the user clicks the product from the most clicked home page carousel.                          |
| bundle\_product\_click                           | When the user clicks the product from the bundle.                                                   |
| add\_cart\_product\_click                        | When the user clicks the product from the cart drawer carousel.                                     |
| add\_to\_cart                                    | When the user adds products to the cart.                                                            |
| add\_to\_wishlist                                | When the user adds products to the wishlist.                                                        |
| product\_view                                    | When the user views the product on the PDP page.                                                    |

### Response Object

| status                                                                                  | success                                            |
| --------------------------------------------------------------------------------------- | -------------------------------------------------- |
| String- describing if the event is saved. In case of failure, return the error message. | Boolean- describing if the event was saved or not. |

### Example Request

```
curl --location --request POST 'https://xyz.search.frenzy.ai/events' \
--header 'Content-Type: application/json' \
--header 'X-Frenzy-Authorization: API_KEY' \
--data-raw '[{
    "event_name":"add to cart",
    "user_id": "1234",
    "sku":"PSS-123-12345"
}]'

```

{% hint style="info" %}
NOTE: Historic events can be shared over the API. Please add the time of event occurrence in the request.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.frenzy.ai/api-functions/sharing-event-data/api-call.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
