openapi: 3.2.0 info: title: V1 Lytics Data Upload API version: 1.0.0 description: 'The Lytics API is a _restful_ *JSON* api that includes: * *Data Collection* api''s for collection, and upload of custom data.' servers: - url: https://api.lytics.io tags: - name: Data Upload description: APIs for collecting or uploading data. paths: /collect/bulk/{stream}: post: responses: '200': description: OK headers: {} content: application/json: schema: $ref: '#/components/schemas/BulkdCSVUploadModel' examples: response: value: status: 200 message: success data: message_count: 2 rejected_count: 0 content-type: application/json droperrors: false dryrun: false timestamp_field: event_created filename: myfile.csv security: - ApiKeyAuth: [] summary: BulkCSVUpload operationId: BulkCSVUpload description: '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Ɨtamp_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Ɨtamp_field=reg_date&dryrun=true&filename=users.csv" \ --data-binary @users.csv.gz \ -H ''Content-type: application/csv'' | jq ''.'' ```' tags: - Data Upload parameters: - name: account_id in: query description: Your Lytics account ID. required: false schema: type: string - name: stream in: path description: The DataType aka Table of type of data being uploaded. See Data, Streams in web admin. required: true example: user_db schema: type: string - name: access_token in: query description: The Lytics DATA API key. Not the management key. Or use Authorization Header. required: false schema: type: string - name: dryrun in: query description: '' required: false schema: type: boolean default: 'false' - name: timestamp_field in: query description: The name of the column or field in file that contains event timestamp. required: false schema: type: string - name: headers in: query description: CSV only, Comma delimited list of header columns for csv (if not first row) required: false schema: type: string - name: delimiter in: query description: CSV only, if not the default comma, either t=tab, or | may be accepted required: false schema: type: string - name: append in: query description: CSV only, JSON encoded object of additional name-value pairs to append to each record. required: false schema: type: string - name: droperrors in: query description: '' required: false schema: type: boolean default: 'false' - name: filename in: query description: Just for record-keeping in our event - stream. required: false example: '"myfile.csv"' schema: type: string /collect/bulk/{streamname}: post: responses: '200': description: OK headers: {} content: application/json: schema: $ref: '#/components/schemas/BulkJSONUploadModel' examples: response: value: status: 200 message: success data: message_count: 2 rejected_count: 0 content-type: application/json droperrors: false dryrun: false timestamp_field: event_created filename: myfile.json security: - ApiKeyAuth: [] summary: BulkJSONUpload operationId: BulkJSONUpload description: 'JSON formatting info. This JSON is ok: ```json {"order_ids":[1,2,3]} ``` This is not valid because it has objects nested inside arrays: ```json {"orders":[{"id":1,"price":22},{"id":2,"price":23}]} ```' tags: - Data Upload parameters: - name: account_id in: query description: Your Lytics account ID. required: false schema: type: string - name: streamname in: path description: The DataType, or "Table" of type of data being uploaded required: true example: user_db schema: type: string - name: access_token in: query description: The Lytics DATA API key. Not the management key. Or use Authorization Header. required: false schema: type: string - name: dryrun in: query description: '' required: false schema: type: boolean default: 'false' - name: timestamp_field in: query description: The name of the column or field in file that contains event timestamp. required: false schema: type: string - name: filename in: query description: Just for record-keeping in our event - stream. required: false example: '"myfile.json"' schema: type: string /collect/json/{stream}: post: responses: '200': description: OK headers: {} content: application/json: schema: $ref: '#/components/schemas/DataUploadModel' examples: response: value: status: 200 message: success data: message_count: 2 rejected_count: 0 content-type: application/json droperrors: false dryrun: false timestamp_field: event_created filename: myfile.json security: - ApiKeyAuth: [] summary: Data JSON Upload operationId: DataJSONUpload description: '' tags: - Data Upload parameters: - name: account_id in: query description: Your Lytics account ID. required: false schema: type: string - name: stream in: path description: The DataType, or "Table" of type of data being uploaded required: true example: user_db schema: type: string - name: access_token in: query description: The Lytics DATA API key (not management key) required: true schema: type: string - name: dryrun in: query description: '' required: false schema: type: boolean default: 'false' - name: timestamp_field in: query description: The name of the column or field in file that contains event timestamp. required: false schema: type: string - name: filename in: query description: Just for record-keeping in our event - stream. required: false example: '"myfile.json"' schema: type: string x-operation-id-source: normalized x-operation-id-original: Data JSON Upload components: schemas: BulkJSONUploadModel: type: object properties: status: type: number message: type: string data: type: object properties: message_count: type: number rejected_count: type: number content-type: type: string droperrors: type: boolean dryrun: type: boolean timestamp_field: type: string filename: type: string example: status: 200 message: success data: message_count: 2 rejected_count: 0 content-type: application/json droperrors: false dryrun: false timestamp_field: event_created filename: myfile.json DataUploadModel: type: object properties: status: type: number message: type: string data: type: object properties: message_count: type: number rejected_count: type: number content-type: type: string droperrors: type: boolean dryrun: type: boolean timestamp_field: type: string filename: type: string example: status: 200 message: success data: message_count: 2 rejected_count: 0 content-type: application/json droperrors: false dryrun: false timestamp_field: event_created filename: myfile.json BulkdCSVUploadModel: type: object properties: status: type: number message: type: string data: type: object properties: message_count: type: number rejected_count: type: number content-type: type: string droperrors: type: boolean dryrun: type: boolean timestamp_field: type: string filename: type: string example: status: 200 message: success data: message_count: 2 rejected_count: 0 content-type: application/json droperrors: false dryrun: false timestamp_field: event_created filename: myfile.csv securitySchemes: ApiKeyAuth: in: header name: Authorization type: apiKey x-readme: explorer-enabled: true proxy-enabled: true