# Recommendation viewed

- Operation ID: `publishAiCompatRecommendationViewUsingPOST`
- HTTP method: `POST`
- Path: `/v4/events/ai-compat/recommendation.view`
- [Human-readable API reference](https://hub.synerise.com/api-reference/data-management#tag/AI-Events/operation/publishAiCompatRecommendationViewUsingPOST)

## Self-contained OpenAPI method

The fenced document below contains this method's documentation and all of its local references. It is self-contained; no category or master specification fetch is required.

```yaml
openapi: 3.0.0
info:
  title: Synerise Public API
  version: 1.9.1
paths:
  /v4/events/ai-compat/recommendation.view:
    post:
      security:
        - JWT: []
        - TrackerKey: []
      tags:
        - AI Events
      summary: Recommendation viewed
      description: |
        Upload a recommendation.view event to the AI engine.

        ---

        **API consumers:** <a href="/api-reference/authorization?tag=Authorization&amp;operationId=profileLogin" target="_blank" rel="noopener">Workspace (Business Profile)</a>, <a href="/api-reference/authorization?tag=Authorization&amp;operationId=authenticateUsingPOST_v3" target="_blank" rel="noopener">Profile (Client)</a>, <a href="/api-reference/authorization?tag=Authorization&amp;operationId=LogInAnonymouslyV3" target="_blank" rel="noopener">Anonymous Profile</a>, <a href="/docs/settings/tool/tracking_codes" target="_blank" rel="noopener" title="Pass your tracker key in the request header">Web SDK Tracker</a>, <span title="Deprecated">AI API key (legacy)</span>

        **API key permission required:** `API_RECOMMENDATION_VIEW_EVENT_CREATE`
      operationId: publishAiCompatRecommendationViewUsingPOST
      requestBody:
        content:
          application/json:
            schema:
              title: recommendation.view
              type: object
              required:
                - correlationId
                - clientUUID
                - items
              properties:
                correlationId:
                  type: string
                  description: |
                    `correlationId` of the request which this event relates to, for example a recommendation or search request (the parameter is included in the response to that request).
                clientUUID:
                  type: string
                  description: |
                    UUID of the Profile. It is a unique identifier.

                    The value can't include any characters that match the pattern (ECMA flavor): `/([\uD800-\uDBFF][\uDC00-\uDFFF])|([\r\n\u2028\u2029\u00AD]|[\uFE00-\uFE0F]|[\u0000])/`

                    **Upcoming breaking change (effective July 6, 2026):** Synerise is introducing changes to how user identifiers and UUIDs are handled. These changes may affect profiles with accented or diacritical characters in identifiers, profiles with leading or trailing whitespace in identifiers, and profiles with duplicate UUIDs. For details and recommended actions, see [Upcoming changes to identifier and UUID handling](https://hub.synerise.com/docs/settings/configuration/identifier-standardization/).
                  example: 07243772-008a-42e1-ba37-c3807cebde8f
                items:
                  type: array
                  description: An array of items included in the recommendation. The items are identified by their `itemId` (also called `sku`, `productId`, and `retailer_part_no` in other APIs and SDKs)
                  minItems: 0
                  items:
                    type: string
                    description: itemId (also called `sku`, `productId`, and `retailer_part_no` in other APIs and SDKs) of the item
                EventTimestamp:
                  type: string
                  description: |
                    Time when the event occurred, in [ISO 8601](https://wikipedia.org/wiki/ISO_8601). 

                    This time isn't affected and doesn't affect the timezone of your workspace - you can send events with a timezone different than that of the workspace. Synerise calculates the times into UTC standard when saving events in the database.

                    If not defined, the backend inserts the time of receiving the event.

                    A time with a "Z" at the end (for example, `2022-10-14T12:02:06Z`) denotes a time in the UTC standard.

                    If you want to send time in a different timezone, you can do this by appending `{+|-}hh:mm` at the end of the string.  

                    Note that if the timezone is ahead (+) of UTC, the UTC time is calculated by subtraction. When the timezone is behind (-) UTC, the UTC time is calculated by addition.  
                    For example:
                      - if your timezone is UTC+1, append `+01:00`. When you send `2022-10-14T15:00:000+01:00`, it is saved in the database as `2022-10-14T14:00:000Z`
                      - if your timezone is UTC-8, append `-08:00`. When you send `2022-10-14T22:00:000-08:00`, it is saved in the database as `2022-10-15T06:00:000Z` (note that the date also changes between timezones in this example)

                    **IMPORTANT**: If you send an event with a future time, the parameter is rejected and the time of receiving the event is saved as the occurrence time. For example, if your timezone is UTC+1 and you send the event at 15:00 local time, future times are:  
                    - later than 15:00 local time
                    - later than 14:00 UTC

                    When you retrieve an event, its time is always shown as UTC. The original time string that you sent (even if it was a future time and was rejected) can be retrieved with the [activities](https://developers.synerise.com/DataManagement/DataManagement.html#tag/Activities) endpoints, as `snr-original-time`.
                  example: 2019-02-07T09:53:56.999+00:00
                campaignId:
                  type: string
                  description: ID of the campaign related to the event
              additionalProperties:
                description: |
                  Additional parameters. Remember that you can use [event enrichment](https://hub.synerise.com/docs/assets/events/adding-event-parameters/) to add the data automatically from a catalog.

                  Events accept custom, free-form parameters, with the following restrictions:

                    <span style="color:red"><strong>WARNING:</strong></span>
                    - If you want to send the `email` param, it must be exactly the same as the email of the profile which generated the event.
                    - Some params are reserved for system use. If you send them, they are ignored or overwritten with system-assigned values:<br>
                    <code>modifiedBy</code><br>
                    <code>apiKey</code><br>
                    <code>eventUUID</code><br>
                    <code>ip</code><br>
                    <code>time</code><br>
                    <code>businessProfileId</code>
      responses:
        "204":
          description: No Content
        "400":
          description: "Bad request: input data missing or malformed"
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: Summary of the error
                  status:
                    type: integer
                    format: int32
                    description: Status code
                  timestamp:
                    type: string
                    description: Time when the message was sent
                  path:
                    type: string
                    description: URL of the requested resource
                  message:
                    type: string
                    description: Description of the problem
                  errors:
                    type: array
                    description: Additional details of the errors, if applicable
                    items:
                      type: object
                      properties:
                        code:
                          type: integer
                          format: int32
                          example: 12082
                          description: A numeric identifier of the error type
                        field:
                          type: string
                          example: countryCode
                          description: Field in the request body that caused the error
                        message:
                          type: string
                          example: Country Code must have 0 or 3 characters as per ISO format.
                          description: A detailed description of the problem
                        rejectedValue:
                          type: string
                          example: Poland
                          description: The value that caused the error
              example:
                timestamp: 2018-06-07T07:28:26.078+00:00
                status: 400
                error: Bad Request
                message: Version header content is invalid
                path: /path_of_the_endpoint
        "401":
          description: "Unauthorized: wrong consumer scope; token missing/expired/invalid; invalid API key; etc."
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: Summary of the error
                  status:
                    type: integer
                    format: int32
                    description: Status code
                  timestamp:
                    type: string
                    description: Time when the message was sent
                  path:
                    type: string
                    description: URL of the requested resource
                  message:
                    type: string
                    description: Description of the problem
                  errors:
                    type: array
                    description: Additional details of the errors, if applicable
                    items:
                      type: object
                      properties:
                        code:
                          type: integer
                          format: int32
                          example: 12082
                          description: A numeric identifier of the error type
                        field:
                          type: string
                          example: countryCode
                          description: Field in the request body that caused the error
                        message:
                          type: string
                          example: Country Code must have 0 or 3 characters as per ISO format.
                          description: A detailed description of the problem
                        rejectedValue:
                          type: string
                          example: Poland
                          description: The value that caused the error
              example:
                error: Bad Request
                status: 400
                timestamp: 2020-10-29T13:08:16.235Z
                path: /exampleEndpoint
                message: Some fields did not pass validation
                errors:
                  - code: 120
                    field: exampleField
                    message: "120"
                    rejectedValue: exampleValue
        "403":
          description: Forbidden; insufficient permissions (when PII protection is enabled, PII permissions are required in addition to the permissions listed in the method description)
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: Summary of the error
                  status:
                    type: integer
                    format: int32
                    description: Status code
                  timestamp:
                    type: string
                    description: Time when the message was sent
                  path:
                    type: string
                    description: URL of the requested resource
                  message:
                    type: string
                    description: Description of the problem
                  errors:
                    type: array
                    description: Additional details of the errors, if applicable
                    items:
                      type: object
                      properties:
                        code:
                          type: integer
                          format: int32
                          example: 12082
                          description: A numeric identifier of the error type
                        field:
                          type: string
                          example: countryCode
                          description: Field in the request body that caused the error
                        message:
                          type: string
                          example: Country Code must have 0 or 3 characters as per ISO format.
                          description: A detailed description of the problem
                        rejectedValue:
                          type: string
                          example: Poland
                          description: The value that caused the error
              example:
                timestamp: 2018-06-07T07:29:27.489+00:00
                status: 403
                error: Forbidden
                message: Forbidden
                path: /path_of_the_endpoint
        "415":
          description: Unsupported Media Type
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: Summary of the error
                  status:
                    type: integer
                    format: int32
                    description: Status code
                  timestamp:
                    type: string
                    description: Time when the message was sent
                  path:
                    type: string
                    description: URL of the requested resource
                  message:
                    type: string
                    description: Description of the problem
                  errors:
                    type: array
                    description: Additional details of the errors, if applicable
                    items:
                      type: object
                      properties:
                        code:
                          type: integer
                          format: int32
                          example: 12082
                          description: A numeric identifier of the error type
                        field:
                          type: string
                          example: countryCode
                          description: Field in the request body that caused the error
                        message:
                          type: string
                          example: Country Code must have 0 or 3 characters as per ISO format.
                          description: A detailed description of the problem
                        rejectedValue:
                          type: string
                          example: Poland
                          description: The value that caused the error
              example:
                timestamp: 2018-06-07T07:27:23.136+00:00
                status: 415
                error: Unsupported Media Type
                message: Content type 'application/xml' not supported
                path: /path_of_the_endpoint
      x-snr-doc-urls:
        - /api-reference/data-management#tag/AI-Events/operation/publishAiCompatRecommendationViewUsingPOST
      x-codeSamples:
        - lang: cURL
          label: cURL
          source: |-
            curl --request POST \
              --url https://api.synerise.com/v4/events/ai-compat/recommendation.view \
              --header 'Authorization: Bearer REPLACE_BEARER_TOKEN' \
              --header 'content-type: application/json' \
              --data '{"correlationId":"string","clientUUID":"07243772-008a-42e1-ba37-c3807cebde8f","items":["string"],"EventTimestamp":"2019-02-07T09:53:56.999+00:00","campaignId":"string","property1":null,"property2":null}'
        - lang: Python
          label: Python
          source: |-
            import http.client

            conn = http.client.HTTPSConnection("api.synerise.com")

            payload = "{\"correlationId\":\"string\",\"clientUUID\":\"07243772-008a-42e1-ba37-c3807cebde8f\",\"items\":[\"string\"],\"EventTimestamp\":\"2019-02-07T09:53:56.999+00:00\",\"campaignId\":\"string\",\"property1\":null,\"property2\":null}"

            headers = {
                'Authorization': "Bearer REPLACE_BEARER_TOKEN",
                'content-type': "application/json"
                }

            conn.request("POST", "/v4/events/ai-compat/recommendation.view", payload, headers)

            res = conn.getresponse()
            data = res.read()

            print(data.decode("utf-8"))
        - lang: JavaScript
          label: JavaScript
          source: |-
            const data = JSON.stringify({
              "correlationId": "string",
              "clientUUID": "07243772-008a-42e1-ba37-c3807cebde8f",
              "items": [
                "string"
              ],
              "EventTimestamp": "2019-02-07T09:53:56.999+00:00",
              "campaignId": "string",
              "property1": null,
              "property2": null
            });

            const xhr = new XMLHttpRequest();
            xhr.withCredentials = true;

            xhr.addEventListener("readystatechange", function () {
              if (this.readyState === this.DONE) {
                console.log(this.responseText);
              }
            });

            xhr.open("POST", "https://api.synerise.com/v4/events/ai-compat/recommendation.view");
            xhr.setRequestHeader("Authorization", "Bearer REPLACE_BEARER_TOKEN");
            xhr.setRequestHeader("content-type", "application/json");

            xhr.send(data);
        - lang: Node.js
          label: Node.js
          source: |-
            const http = require("https");

            const options = {
              "method": "POST",
              "hostname": "api.synerise.com",
              "port": null,
              "path": "/v4/events/ai-compat/recommendation.view",
              "headers": {
                "Authorization": "Bearer REPLACE_BEARER_TOKEN",
                "content-type": "application/json"
              }
            };

            const req = http.request(options, function (res) {
              const chunks = [];

              res.on("data", function (chunk) {
                chunks.push(chunk);
              });

              res.on("end", function () {
                const body = Buffer.concat(chunks);
                console.log(body.toString());
              });
            });

            req.write(JSON.stringify({
              correlationId: 'string',
              clientUUID: '07243772-008a-42e1-ba37-c3807cebde8f',
              items: ['string'],
              EventTimestamp: '2019-02-07T09:53:56.999+00:00',
              campaignId: 'string',
              property1: null,
              property2: null
            }));
            req.end();
        - lang: PHP
          label: PHP
          source: |-
            <?php

            $request = new HttpRequest();
            $request->setUrl('https://api.synerise.com/v4/events/ai-compat/recommendation.view');
            $request->setMethod(HTTP_METH_POST);

            $request->setHeaders([
              'Authorization' => 'Bearer REPLACE_BEARER_TOKEN',
              'content-type' => 'application/json'
            ]);

            $request->setBody('{"correlationId":"string","clientUUID":"07243772-008a-42e1-ba37-c3807cebde8f","items":["string"],"EventTimestamp":"2019-02-07T09:53:56.999+00:00","campaignId":"string","property1":null,"property2":null}');

            try {
              $response = $request->send();

              echo $response->getBody();
            } catch (HttpException $ex) {
              echo $ex;
            }
        - lang: Java
          label: Java
          source: |-
            HttpResponse<String> response = Unirest.post("https://api.synerise.com/v4/events/ai-compat/recommendation.view")
              .header("Authorization", "Bearer REPLACE_BEARER_TOKEN")
              .header("content-type", "application/json")
              .body("{\"correlationId\":\"string\",\"clientUUID\":\"07243772-008a-42e1-ba37-c3807cebde8f\",\"items\":[\"string\"],\"EventTimestamp\":\"2019-02-07T09:53:56.999+00:00\",\"campaignId\":\"string\",\"property1\":null,\"property2\":null}")
              .asString();
servers:
  - description: Microsoft Azure EU
    url: https://api.synerise.com
  - description: Microsoft Azure USA
    url: https://api.azu.synerise.com
  - description: Google Cloud Platform
    url: https://api.geb.synerise.com
tags:
  - name: AI Events
components:
  securitySchemes:
    JWT:
      type: http
      scheme: bearer
      description: |-
        JWT Bearer token. The header looks like this: `Bearer {JWT}`

        Remember to include the space between 'Bearer' and the token.

        Generate a token via the **Authorization** endpoints.
    TrackerKey:
      type: apiKey
      name: token
      in: query
      description: Authorization by tracker key sent as a query parameter. This is the same key as used in the website tracking code.
```
