---
title: "BulkCSVUpload"
method: POST
path: "/collect/bulk/{stream}"
tags: ["DataUpload"]
---

# BulkCSVUpload

`POST /collect/bulk/{stream}`

## Request

- Base URL: `https://api.lytics.io`
- URL: `https://api.lytics.io/collect/bulk/{stream}`
- Auth: API key in header `Authorization`

Upload CSV files (may be gzipped). They MUST contain headers: either
in first row (by default) OR in **headers** querystring field.
If the file contains a timestamp field you want us to use
see **timestamp_field** querystring parameter for how we extract it.

*Note Domain* this api is on a different domain *https://bulk.lytics.io* because the *api.lytics.io* domain
is limited to 10MB file uploads.

```sh
# the "user_regdata" is the STREAM (ie Type) of data, if there
# is multiple different types of data (userdata, emaildata, events)
# they would have different streams.

# user data
export LIODATAKEY="YOURKEY"
curl -s -H "Authorization: $LIOKEY" \
  -H 'Content-type: application/csv' \
  --data-binary @users.csv \
  "https://bulk.lytics.io/collect/bulk/user_regdata?timestamp_field=register_date" \
 | jq '.'


# only do a dry-run to see if it is formatted correctly
curl -s "https://bulk.lytics.io/collect/bulk/user_regdata?access_token=$LIODATAKEY&timestamp_field=register_date&dryrun=true" \
    --data-binary @users.csv -H 'Content-type: application/csv' | jq '.'

# append fields to each row
#  where   append = urlencode({"source":"crm"})
#  often used when file-name contains information

curl -s "https://bulk.lytics.io/collect/bulk/user_regdata?append=%7B%22source%22%3A%22crm%22%7D&access_token=$LIODATAKEY" \
    --data-binary @users.csv -H 'Content-type: application/csv' | jq '.'


# full example uploading gzipped file

echo 'user_id,email,reg_date,item_count
7456,email@email.com,"2012-10-17T17:29:39.738Z",82
1234,email2@email.com,"2012-12-11T19:53:31.547Z",82' > users.csv

gzip users.csv

curl -s "https://bulk.lytics.io/collect/bulk/user_regdata?access_token=$LIODATAKEY&timestamp_field=reg_date&dryrun=true&filename=users.csv" \
    --data-binary @users.csv.gz \
    -H 'Content-type: application/csv' | jq '.'
```

## Path parameters

- `stream` string, required

## Query parameters

- `account_id` string
- `access_token` string
- `dryrun` boolean
- `timestamp_field` string
- `headers` string
- `delimiter` string
- `append` string
- `droperrors` boolean
- `filename` string

## Response `200`

OK

- BulkdCSVUploadModel
  - `status` number
  - `message` string
  - `data` object
    - `message_count` number
    - `rejected_count` number
    - `content-type` string
    - `droperrors` boolean
    - `dryrun` boolean
    - `timestamp_field` string
    - `filename` string

---

[API](https://skmtc.dev/lytics/apis/v1-lytics-api.md) - [All operations](https://skmtc.dev/lytics/apis/v1-lytics-api/llms.txt) - [OpenAPI document](https://skmtc.dev/lytics/apis/v1-lytics-api/revisions/339fd1d88486?raw)
