> ## 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.

# Upload Metric Data

Request to upload metric data in CSV format.

<h4 id="header-2">
  Header
</h4>

The `Content-Type` in the Request Header uses multipart/form-data.

```header-multipart theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
Content-Type: multipart/form-data; charset=utf-8
```

<h4 id="csv-file-format-and-schema-2">
  CSV file format and schema
</h4>

##### Content rules and schema of ad spend CSV files

<div style={{ overflowX: 'auto' }}>
  <table style={{ display: 'table' }}>
    <thead>
      <tr>
        <th>
          Category
        </th>

        <th>
          Column Name
        </th>

        <th>
          Type
        </th>

        <th>
          Description
        </th>

        <th>
          Required
        </th>
      </tr>
    </thead>

    <tbody>
      <tr>
        <td>
          Group by
        </td>

        <td>
          date
        </td>

        <td>
          string
        </td>

        <td>
          The date the spend was incurred.<br />The date must be in the format 'YYYY-MM-DD' This date should correspond with the timezone set in the Airbridge app. Future dates are not permitted. Upload requests that violate this condition will not be processed.
        </td>

        <td>
          **Required**
        </td>
      </tr>

      <tr>
        <td>
          Group by
        </td>

        <td>
          channel
        </td>

        <td>
          string
        </td>

        <td>
          The channel.
        </td>

        <td>
          **Required**
        </td>
      </tr>

      <tr>
        <td>
          Group by
        </td>

        <td>
          event\_category
        </td>

        <td>
          string
        </td>

        <td>
          The event category.<br />It is viewed as a metric name in the report.
        </td>

        <td>
          **Required**
        </td>
      </tr>

      <tr>
        <td>
          Metric
        </td>

        <td>
          event\_value
        </td>

        <td>
          double
        </td>

        <td>
          The event value.
        </td>

        <td>
          **Required**
        </td>
      </tr>

      <tr>
        <td>
          Group by
        </td>

        <td>
          campaign
        </td>

        <td>
          string
        </td>

        <td>
          The campaign.
        </td>

        <td>
          Optional
        </td>
      </tr>

      <tr>
        <td>
          Group by
        </td>

        <td>
          ad\_group
        </td>

        <td>
          string
        </td>

        <td>
          The ad group.
        </td>

        <td>
          Optional
        </td>
      </tr>

      <tr>
        <td>
          Group by
        </td>

        <td>
          ad\_creative
        </td>

        <td>
          string
        </td>

        <td>
          The ad creative.
        </td>

        <td>
          Optional
        </td>
      </tr>

      <tr>
        <td>
          Group by
        </td>

        <td>
          content
        </td>

        <td>
          string
        </td>

        <td>
          The content.
        </td>

        <td>
          Optional
        </td>
      </tr>

      <tr>
        <td>
          Group by
        </td>

        <td>
          event\_source
        </td>

        <td>
          string
        </td>

        <td>
          The event source.<br />`app`, `web`, `tracking_link`, `sms_link` (case-sensitive)
        </td>

        <td>
          Optional
        </td>
      </tr>

      <tr>
        <td>
          Group by
        </td>

        <td>
          os\_name
        </td>

        <td>
          string
        </td>

        <td>
          The OS Name.<br />Be aware that data in columns with a type defined as 'string' is case-sensitive.<br />e.g. Android, iOS
        </td>

        <td>
          Optional
        </td>
      </tr>

      <tr>
        <td>
          Group by
        </td>

        <td>
          term
        </td>

        <td>
          string
        </td>

        <td>
          The term.
        </td>

        <td>
          Optional
        </td>
      </tr>

      <tr>
        <td>
          Group by
        </td>

        <td>
          country
        </td>

        <td>
          string
        </td>

        <td>
          2-digit lowercase country value.<br />e.g. kr, us, gb, fr
        </td>

        <td>
          Optional
        </td>
      </tr>

      <tr>
        <td>
          Group by
        </td>

        <td>
          currency
        </td>

        <td>
          string
        </td>

        <td>
          The currency.<br />Must use capitalized, three-letter currency codes that comply with ISO 4217.<br />e.g. KRW, USD
        </td>

        <td>
          Optional
        </td>
      </tr>

      <tr>
        <td>
          Group by
        </td>

        <td>
          sub\_publisher
        </td>

        <td>
          string
        </td>

        <td>
          The sub publisher.
        </td>

        <td>
          Optional
        </td>
      </tr>

      <tr>
        <td>
          Group by
        </td>

        <td>
          sub\_sub\_publisher\_1
        </td>

        <td>
          string
        </td>

        <td>
          The sub-sub publisher 1.
        </td>

        <td>
          Optional
        </td>
      </tr>

      <tr>
        <td>
          Group by
        </td>

        <td>
          sub\_sub\_publisher\_2
        </td>

        <td>
          string
        </td>

        <td>
          The sub-sub publisher 2.
        </td>

        <td>
          Optional
        </td>
      </tr>

      <tr>
        <td>
          Group by
        </td>

        <td>
          sub\_sub\_publisher\_3
        </td>

        <td>
          string
        </td>

        <td>
          The sub-sub publisher 3.
        </td>

        <td>
          Optional
        </td>
      </tr>

      <tr>
        <td>
          Group by
        </td>

        <td>
          is\_first\_event\_per\_device\_id
        </td>

        <td>
          boolean
        </td>

        <td>
          Whether the first event is based on device ID.<br />true or false (case-sensitive)
        </td>

        <td>
          Optional
        </td>
      </tr>

      <tr>
        <td>
          Group by
        </td>

        <td>
          is\_first\_event\_per\_user\_id
        </td>

        <td>
          boolean
        </td>

        <td>
          Whether the first event is based on user ID.<br />true or false (case-sensitive)
        </td>

        <td>
          Optional
        </td>
      </tr>
    </tbody>
  </table>
</div>

<h4 id="sample-csv-file-2">
  Sample CSV File
</h4>

* [Example CSV File](https://static.airbridge.io/samples/Self-serve_sample.csv)

<h4 id="a-case-sensitivity-2">
  🚧 Case Sensitivity
</h4>

Please be aware that data in columns with a type defined as 'string' is case-sensitive.

Note that Airbridge records mobile OS names as 'Android' and 'iOS'. When uploading your data, it's essential to use 'Android' and 'iOS' for OS names. Failure to do so may result in separate rows in the dashboard when data is grouped by results. Please adhere to this naming convention for consistency and accurate data representation.

<h3 id="overwrite-previously-ingested-metric-data">
  **Overwrite Previously Ingested Metric Data**
</h3>

Previously ingested metric data can be overwritten by using CSV files that contain data with the identical key of data previously ingested.

The key is formed from the 'date', 'channel', and 'event\_category' fields. If the keys match, data ingested last overwrites data previously ingested.

##### \[Example A]

**1. 2022-08-03:** Upload for date, channel, campaign and ad\_group.

| date       | channel        | campaign              | ad\_group    | event\_category | event\_value |
| ---------- | -------------- | --------------------- | ------------ | --------------- | ------------ |
| 2022-08-01 | owned\_website | retargeting\_campaign | 2030\_female | self\_event     | 100000       |
| 2022-08-01 | owned\_website | retargeting\_campaign | 2030\_male   | self\_event     | 80000        |

**2. 2022-08-04:** Upload for date, channel and campaign.

| date       | channel        | campaign              | event\_category | event\_value |
| ---------- | -------------- | --------------------- | --------------- | ------------ |
| 2022-08-01 | owned\_website | retargeting\_campaign | self\_event     | 150000       |

**3. Result:** Spend data from '2022-08-03' was overwritten by data from '2022-08-04' because '2022-08-04' was last ingested and the identical key is the same. (ad group is overwritten null)

| date       | channel        | campaign              | event\_category | event\_value |
| ---------- | -------------- | --------------------- | --------------- | ------------ |
| 2022-08-01 | owned\_website | retargeting\_campaign | self\_event     | 150000       |

##### \[Example B]

**1. 2022-08-03:** Upload for date, channel and campaign.

| date       | channel        | campaign              | event\_category | event\_value |
| ---------- | -------------- | --------------------- | --------------- | ------------ |
| 2022-08-01 | owned\_website | retargeting\_campaign | self\_event     | 100000       |

**2. 2022-08-04:** Upload for date, channel, campaign and ad\_group.

| date       | channel        | campaign              | ad\_group    | event\_category | event\_value |
| ---------- | -------------- | --------------------- | ------------ | --------------- | ------------ |
| 2022-08-01 | owned\_website | retargeting\_campaign | 2030\_female | self\_event     | 150000       |

**3. Result:** Based on the values 'date', 'channel', and 'campaign', the data was overwritten by '2022-08-04' (ad\_group value are also updated.)

| date       | channel        | campaign              | ad\_group    | event\_category | event\_value |
| ---------- | -------------- | --------------------- | ------------ | --------------- | ------------ |
| 2022-08-01 | owned\_website | retargeting\_campaign | 2030\_female | self\_event     | 150000       |

##### \[Example C]

**1. 2022-08-03:** Upload for date, channel, campaign and ad\_group.

| date       | channel        | campaign              | ad\_group    | event\_category | event\_value |
| ---------- | -------------- | --------------------- | ------------ | --------------- | ------------ |
| 2022-08-01 | owned\_website | promotion\_campaign   | 2030\_female | self\_event     | 10000        |
| 2022-08-01 | owned\_website | retargeting\_campaign | 2030\_female | self\_event     | 100000       |
| 2022-08-01 | owned\_website | retargeting\_campaign | 2030\_male   | self\_event2    | 80000        |

**2. 2022-08-04:** Upload for date, channel, campaign and ad\_group.

| date       | channel        | campaign              | ad\_group    | event\_category | event\_value |
| ---------- | -------------- | --------------------- | ------------ | --------------- | ------------ |
| 2022-08-01 | owned\_website | retargeting\_campaign | 2030\_male   | self\_event     | 90000        |
| 2022-08-01 | owned\_website | ua\_campaign          | 2030\_female | self\_event     | 120000       |

**3. Result:** Based on the values 'date', 'channel', and 'campaign', the data was overwritten by '2022-08-04'

| date       | channel        | campaign              | ad\_group    | event\_category | event\_value |
| ---------- | -------------- | --------------------- | ------------ | --------------- | ------------ |
| 2022-08-01 | owned\_website | retargeting\_campaign | 2030\_male   | self\_event2    | 80000        |
| 2022-08-01 | owned\_website | retargeting\_campaign | 2030\_male   | self\_event     | 90000        |
| 2022-08-01 | owned\_website | ua\_campaign          | 2030\_female | self\_event     | 120000       |

<h4 id="archive-data">
  Archive Data
</h4>

If you want a previously uploaded metric to be invisible in a report, please request it through your CSM.

<h3 id="note-2">
  Note
</h3>

* Only be used as an API token for Owner, In-house Marketer permission accounts.
* The order of the columns in the CSV file does not affect the upload functionality.
* The maximum size of a CSV file in a single request is 1 MB.
* Column values of type string are limited to at least one character and up to 256 characters.
* Ensure there are no spaces before or after the column name and value.
* event\_category can accept alphabets and numbers.
* event\_category cannot contain , " .
* New data registered during upload (e.g. self\_serve\_test\_campaign for campaign) will not be visible in the selection options when using a filter. You can use it by entering it in freeform.
* If the CSV file has rows where both the groupBy and the event category are the same, the data is displayed in the report as summed values for the same row.
* Upload data

| date       | channel        | campaign              | event\_category | event\_Value |
| ---------- | -------------- | --------------------- | --------------- | ------------ |
| 2022-08-01 | owned\_website | retargeting\_campaign | self\_event     | 150000       |
| 2022-08-01 | owned\_website | retargeting\_campaign | self\_event     | 100000       |
| 2022-08-01 | owned\_website | retargeting\_campaign | self\_event     | 10000        |

* Display report

| date       | channel        | campaign              | event\_category | event\_value |
| ---------- | -------------- | --------------------- | --------------- | ------------ |
| 2022-08-01 | owned\_website | retargeting\_campaign | self\_event     | 251000       |

<Card title="Try API Request" icon="rectangle-api" horizontal href="https://www.postman.com/airbridge-engineering/workspace/airbridge-api/request/22395869-840b210b-7ed2-4166-966d-3a3ecb76a5bf" />

```text POST theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
https://api.airbridge.io/self-serve-data/v1/metric/requests
```

<h2 id="upload-metric-data-request">
  Request
</h2>

***

<h3 id="upload-metric-data-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>

<RequestExample>
  ```shellscript Request theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
  curl -X POST 'https://api.airbridge.io/self-serve-data/v1/metric/requests' \
    -H 'Accept-Language: ko' \
    -H 'Content-Type: application/json' \
    -H 'Authorization: Bearer {AIRBRIDGE-API-TOKEN}'
  ```
</RequestExample>

<h2 id="upload-metric-data-response">
  Response
</h2>

***

### 200

| Name       | Description                           | Example                              |
| ---------- | ------------------------------------- | ------------------------------------ |
| requestId  | The request ID.                       | 08844672-62d8-4da8-9d48-e14961651e0c |
| status     | The progress for the upload request.  | ingested                             |
| prevStatus | The status before the current status. | validated                            |
| reason     | The reason the upload failed.         | \{"date": \["invalid date"]}         |
| createdAt  | The date that request was created.    | 2022-08-09T08:59:15                  |
| updatedAt  | The date that request was updated.    | 2022-08-09T08:59:15                  |

<ResponseExample>
  ```json 200 theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
  {
    "reason": null,
    "status": "uploaded",
    "createdAt": "2023-01-01T09:00:00",
    "requestId": "08844672-62d8-4da8-9d48-e14961651e0c",
    "updatedAt": "2023-01-01T09:00:00",
    "prevStatus": null
  }
  ```
</ResponseExample>
