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

# Send In-web Events

Send In-Web events in a server-to-server method.

rate limit : 1000 requests per minute.

<h3 id="user-identifiers-2">
  User Identifiers
</h3>

<div id="attention-2" />

<Danger>
  **Attention**

  It is recommended to send all available user identifiers as they are crucial for accurate attribution, postback, cohort analysis etc.
</Danger>

<h4 id="a-1-cookie-id-browser-clientid">
  **1. Cookie ID(`browser.clientID`)**
</h4>

Cookie IDs can be retrieved through the SDK(refer to the [data fetching guide](/en/developers/fetching-guide)).
The following attribution data must be sent along with the Cookie ID for proper attribution.

| Request Body Key               | Data Fetching Field            | Description           |
| ------------------------------ | ------------------------------ | --------------------- |
| eventData.shortID              | Attribution Short ID           | Campaign Parameter ID |
| eventData.trackingData.channel | Default Attribution Channel    | Campaign Channel      |
| eventData.trackingData.params  | Default Attribution Parameters | Campaign Parameters   |

<Accordion title="Request Example">
  ```json lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
  {
    ...

    "browser": {
      "clientID": "05609013-bb5a-4594-bbc3-832cb1b87072"
    },
    "eventData": {
      "shortID": "aef04",
      "trackingData": {
        "channel": "blog",
        "params": {
          "ad_creative": "ad_creative",
          "ad_group": "ad_group",
          "campaign": "ad_campaign",
          "content": "ad_content",
          "medium": "ad_medium",
          "tracking_template_id": "ad_tracking_template_id"
        }
      }
    },
    "user": {
      "externalUserID": "19443",
      "externalUserEmail": "example@ab180.co",
      "externalUserPhone": "821012341234"
    }
    
    ...
  }
  ```
</Accordion>

<h4 id="a-2-user-id-user-externaluserid-2">
  **2. User ID(`user.externalUserID`)**
</h4>

User IDs may be sent without Cookie IDs if data fetching is inconvenient.
In such cases, Airbridge processes events based on the Cookie IDs mapped to the provided User ID.
However, if no mapping is found, this may lower the accuracy of reports.

<Accordion title="Request Example">
  ```json lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
  {
      ...
      
      "user": {
          "externalUserID": "19443",
          "externalUserEmail": "example@ab180.co",
          "externalUserPhone": "821012341234"
      }

      ...
  }

  ```
</Accordion>

<Card title="Try API Request" icon="rectangle-api" horizontal href="https://www.postman.com/airbridge-engineering/workspace/airbridge-api/request/22395869-c04f0ec2-cd2e-4e28-b7e9-04b57fae50ed" />

```text POST theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
https://api.airbridge.io/events/v2/apps/{app_name}/web/9320
```

<h2 id="send-in-web-events-request">
  Request
</h2>

***

<h3 id="send-in-web-events-headers">
  Headers
</h3>

<ParamField header="Accept-Language" type="string">
  You can specify the language to use for API requests and responses. It follows the ISO-639-1 format.
</ParamField>

<ParamField header="Content-Type" type="string">
  Represents the media type of the resource. Defaults to `application/json`.
</ParamField>

<ParamField header="Authorization" type="string">
  The key value to use for API requests. Instructions for getting API keys are in "[how to generate API Keys](/en/references/introduction#authorization)".
</ParamField>

<ParamField header="X-Forwarded-For" type="string" required>
  You can send the user's IP in the X-Forwarded-For header. Without X-Forwarded-For, user behavior is logged with the IP of the server that requested the Server To Server API, not the user's IP (client request IP).

  We accept values in the form of ipv4 (`123.123.123.123`), ipv6 (`2001:e60:87e3:81d4:cd57:5d52:ee2e:ff8d`).
</ParamField>

<h3 id="send-in-web-events-path-params">
  Path Params
</h3>

<ParamField path="app_name" type="string" required>
  Airbridge App Name. (Unique ID)
</ParamField>

<h3 id="send-in-web-events-body-params">
  Body Params
</h3>

<ParamField body="eventUUID" type="string">
  Random UUID v4 string.

  Accepts a random string in UUID4 format.

  The event uuid is used for duplication as a unique ID for the event, and will be generated automatically by the event api if not provided.
</ParamField>

<ParamField body="eventTimestamp" type="number">
  The time the event occurred. (default: current timestamp)

  A Unix timestamp in milliseconds (13 digits in Unixtime).

  **If the eventTimestamp is older than 24 hours from the time the event was sent, it will not be processed by the server.**
</ParamField>

<ParamField body="user" type="object">
  User information.

  <Expandable title="child attributes">
    <ParamField body="user.externalUserID" type="string">
      User ID.

      Required when: required if device.deviceUUID is not sent.
    </ParamField>

    <ParamField body="user.externalUserEmail" type="string">
      User email.
    </ParamField>

    <ParamField body="user.externalUserPhone" type="string">
      User phone number.
    </ParamField>

    <ParamField body="user.attributes" type="object">
      Custom user attributes.

      Accepts data in JSON format.

      `{ "age_group": "30", "brand": "Nike" }`
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="browser" type="object">
  Browser Information.

  <Expandable title="child attributes">
    <ParamField body="browser.clientID" type="string" required>
      Browser cookie ID fetched from the SDK. \[[Docs](/en/developers/fetching-guide-for-web-sdk#cookie-id)]

      If data fetching isn't possible, sending the User ID(`user.externalUserID`) will make this field optional.
    </ParamField>

    <ParamField body="browser.userAgent" type="string">
      Browser's user agent fetched from the sdk. \[[Docs](/en/developers/fetching-guide-for-web-sdk#cookie-id)]

      This field is used to decide the platform, OS name and OS version of the event.
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="eventData" type="object" required>
  Event information.

  <Expandable title="child attributes">
    <ParamField body="eventData.shortID" type="string" required>
      Attribution campaign parameter Short ID. Provide the value fetched from the Airbridge SDK([Android](https://developers.airbridge.io/v1.1-en/docs/data-fetching-guide-for-android-sdk#version) [iOS](https://developers.airbridge.io/v1.1-en/docs/data-fetching-guide-for-ios-sdk#application-version)).

      **NOTE:** This value must be sent to the Airbridge server without processing or filtering.

      If data fetching is not an option, sending the User ID(`user.externalUserID`) will make this field optional.
    </ParamField>

    <ParamField body="eventData.trackingData" type="object" required>
      Tracking data from SDK.

      <Expandable title="child attributes">
        <ParamField body="eventData.trackingData.channel" type="string" required>
          Attribution campaign channel. Provide the value fetched from the Airbridge SDK([Android](https://developers.airbridge.io/v1.1-en/docs/data-fetching-guide-for-android-sdk#version) [iOS](https://developers.airbridge.io/v1.1-en/docs/data-fetching-guide-for-ios-sdk#application-version)).

          **NOTE:** This value must be sent to the Airbridge server without processing or filtering. (eg. values such as `airbridge.websdk` must also be sent)

          If data fetching is not an option, sending the User ID(`user.externalUserID`) will make this field optional.
        </ParamField>

        <ParamField body="eventData.trackingData.params" type="object" required>
          Attribution campaign parameters. Accepts data in JSON format.

          Provide the value fetched from the Airbridge SDK([Android](https://developers.airbridge.io/v1.1-en/docs/data-fetching-guide-for-android-sdk#version) [iOS](https://developers.airbridge.io/v1.1-en/docs/data-fetching-guide-for-ios-sdk#application-version)).

          **NOTE:** This value must be sent to the Airbridge server without processing or filtering.

          If data fetching is not an option, sending the User ID(`user.externalUserID`) will make this field optional.
        </ParamField>
      </Expandable>
    </ParamField>

    <ParamField body="eventData.goal" type="object" required>
      An object that can contain information about an event. It can contain categories, actions, labels, values, and semantic attributes. ([Related Guide](/en/guides/airbridge-event))

      <Expandable title="child attributes">
        <ParamField body="eventData.goal.category" type="string" required>
          [The name of the Airbridge event ](/en/guides/airbridge-event-types)
        </ParamField>

        <ParamField body="eventData.goal.value" type="number">
          Event's value.

          This may represent the product value of purchase events, or revenue for ad impressions etc.
        </ParamField>

        <ParamField body="eventData.goal.customAttributes" type="object">
          Custom event attribute.

          `{ "color": "red" }`
        </ParamField>

        <ParamField body="eventData.goal.semanticAttributes" type="object">
          [Semantic Attributes.](https://abit.ly/recomended-semantic-attributes) Predefined attributes for which Airbridge is supposed to collect data.

          <Expandable title="child attributes">
            <ParamField body="eventData.goal.semanticAttributes.action" type="string">
              Airbridge event property 1
            </ParamField>

            <ParamField body="eventData.goal.semanticAttributes.label" type="string">
              Airbridge event property 2
            </ParamField>

            <ParamField body="eventData.goal.semanticAttributes.query" type="string">
              User search query.
            </ParamField>

            <ParamField body="eventData.goal.semanticAttributes.productListID" type="string">
              Product list ID.
            </ParamField>

            <ParamField body="eventData.goal.semanticAttributes.cartID" type="string">
              Cart ID.
            </ParamField>

            <ParamField body="eventData.goal.semanticAttributes.transactionID" type="string">
              Transaction ID.
            </ParamField>

            <ParamField body="eventData.goal.semanticAttributes.inAppPurchased" type="boolean">
              In-app purchases or not.

              `true` for in-app purchase, `false` for not an in-app purchase.
            </ParamField>

            <ParamField body="eventData.goal.semanticAttributes.currency" type="string">
              The currency for the payment event. You can use the currency used for the actual payment, as it will be converted to the currency set in your dashboard during event processing.
            </ParamField>

            <ParamField body="eventData.goal.semanticAttributes.products" type="object[]">
              Product list.

              <Expandable title="child attributes">
                <ParamField body="eventData.goal.semanticAttributes.products[0].position" type="string">
                  Product position.
                </ParamField>

                <ParamField body="eventData.goal.semanticAttributes.products[0].productID" type="string">
                  Product ID.
                </ParamField>

                <ParamField body="eventData.goal.semanticAttributes.products[0].name" type="string">
                  Product name.
                </ParamField>

                <ParamField body="eventData.goal.semanticAttributes.products[0].price" type="number">
                  Product Price.
                </ParamField>

                <ParamField body="eventData.goal.semanticAttributes.products[0].quantity" type="integer">
                  Product quantity.
                </ParamField>

                <ParamField body="eventData.goal.semanticAttributes.products[0].currency" type="string">
                  Currency.
                </ParamField>
              </Expandable>
            </ParamField>
          </Expandable>
        </ParamField>
      </Expandable>
    </ParamField>
  </Expandable>
</ParamField>

<RequestExample>
  ```shellscript Request theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
  curl -X POST 'https://api.airbridge.io/events/v2/apps/{app_name}/web/9320' \
    -H 'Accept-Language: ko' \
    -H 'Content-Type: application/json' \
    -H 'Authorization: Bearer {AIRBRIDGE-API-TOKEN}' \
    -H 'X-Forwarded-For: 2001:e60:87e3:81d4:cd57:5d52:ee2e:ff8d' \
    -d '{
    "eventUUID": "9b4b3e4e-2162-4ae6-8986-91ee84644262",
    "user": {
      "externalUserID": "19443",
      "externalUserEmail": "example@ab180.co",
      "externalUserPhone": "821012341234"
    },
    "browser": {
      "clientID": "05609013-bb5a-4594-bbc3-832cb1b87072",
      "userAgent": "Mozilla/5.0 (iPhone; CPU iPhone OS 11_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E302"
    },
    "eventData": {
      "shortID": "aef04",
      "trackingData": {
        "channel": "blog"
      },
      "goal": {
        "category": "airbridge.ecommerce.product.addedToCart",
        "value": 159990,
        "semanticAttributes": {
          "action": "shoes",
          "label": "nike",
          "query": "나이키",
          "transactionID": "12939172",
          "inAppPurchased": true,
          "currency": "KRW",
          "products": [
            {
              "position": "1",
              "productID": "30372425",
              "name": "나이키 커스텀",
              "price": 10990,
              "quantity": 1,
              "currency": "KRW"
            }
          ]
        }
      }
    }
  }'
  ```
</RequestExample>

<h2 id="send-in-web-events-response">
  Response
</h2>

***

### 200

### 400

Invalid requests (timestamp, sdk signature, app name, etc.).

### 401

When using an invalid authentication token.

<ResponseExample>
  ```json 200 theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
  {
    "at": "2020-02-06 16:06:49",
    "data": "Event(9320) is successfully proccessed."
  }
  ```

  ```json 400 theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
  {
    "at": "2020-02-06 16:06:49",
    "error": "invalid_request",
    "ingested": 0
  }
  ```

  ```json 401 theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
  {
    "at": "2020-02-06 16:06:49",
    "error": "unauthorized",
    "ingested": 0
  }
  ```
</ResponseExample>
