Endpoints reference
The Data Export API provides endpoints to create and manage export jobs, list job runs, and download extraction files.
Create an export job
Section titled Create an export jobPOST /v1/exports
This endpoint allows for creating a new export job.
Request parameters
namestring RequiredThe name of the export. Must not be empty.
formatstring RequiredThe file format of the export output.
Possible values:
JSONL, orCSV.scopestring (<= 255 chars)The scope of the export.
frequencyobject RequiredThe frequency of the export.
valuestringThe frequency value.
Possible values:
once,daily, orhourly.dateRange.fromstringRequired only if frequency.value is "once". The value must be a valid ISO 8601 date string. It should be anterior to frequency.dateRange.to, but not anterior to the project data retention period
dateRange.tostringRequired only if frequency.value is "once". The value must be a valid ISO 8601 date string. It should be posterior but not more than 7 days after frequency.dateRange.from.
fieldsobject RequiredThe list of fields to export. To list the exportable fields for a given scope, see the dedicated endpoint.
fieldNamestring RequiredA valid
fieldNamecorresponding to the name property of the fields that can be listed via the /v1/exportable-fields endpoint. You cannot specify afieldNamemore than once, except for the special valuescustom_varanddynamic_var(used to export custom or dynamic variables).aliasNamestringAn alias that will be used to rename the exported field in the output file.
customVarPositionstringRequired only if
custom_varis specified asfieldName. The custom variable position. Must be between 1 and 20 inclusive. To learn more about custom variables, see Sending custom vars. To list custom variables available on the authenticated project, see the /v1/custom_vars endpoint.dynamicVarKeystringRequired only if
dynamic_varis specified asfieldName. The dynamic variable key. To learn more about dynamic variables, see Sending dynamic vars. To list dynamic variables available on the authenticated project, see the /v1/dynamic_var_keys endpoint.deviceLabelstring RequiredA device filter.
Possible values:
all,desktop,mobile, ortablet.segmentIdstringA valid
segmentId. If no segment is provided, the data for all users will be exported. To retrieve the list of available segments for the project, you can call the /v1/segment endpoint.
Request example 1
curl --location --request POST 'https://api.contentsquare.com/v1/exports' \--header 'Authorization: Bearer <your_access_token>' \--header 'Content-Type: application/json' \--data-raw '{ "name": "Test API POST", "format": "JSONL", "scope": "sessions", "frequency": { "value": "daily" }, "fields": [ { "fieldName": "project_id", }, { "fieldName": "session_id", } ], "deviceLabel": "all", "segmentId": 123}'Request example 2
curl --location --request POST 'https://api.contentsquare.com/v1/exports' \--header 'Authorization: Bearer <your_access_token>' \--header 'Content-Type: application/json' \--data-raw '{ "name": "Test API POST", "format": "CSV", "scope": "views", "frequency": { "value": "once", "dateRange": { "from": "2023-02-14T00:00:00.000Z", "to": "2023-02-15T23:59:59.999Z" } }, "fields": [ { "fieldName": "session_id", "aliasName": "Session ID" }, { "fieldName": "view_number", "aliasName": "View number in session" }, { "fieldName": "custom_var", "customVarPosition": 2, "aliasName": "My Custom Variable of index 2" }, { "fieldName": "dynamic_var", "dynamicVarKey": "AB Test", "aliasName": "Experiment" } ], "deviceLabel": "desktop", "segmentId": 123}'Response example
{ "payload": { "jobId": 1372 }, "success": true}Get the list of all export jobs
Section titled Get the list of all export jobsGET /v1/exports
This endpoint provides the list of all the available export jobs (be they in status active, suspended, computing, or completed).
Query parameters
formatstringTo filter based on the export format (see Enumerations)
frequencystringTo filter based on the export frequency (see Enumerations)
limitintegerTo change the page size of results (25 by default, 100 max).
orderstringTo change the order of the results list ("ASC" or "DESC", "DESC" by default). Ordering is based on the
jobId.pageintegerThe page of results to retrieve.
scopestringTo filter based on the job scope (see Enumerations).
statestringTo filter based on the job status (see Enumerations)
Request example
curl --location --request GET 'https://api.contentsquare.com/v1/exports?state=completed' \--header 'Authorization: Bearer <your_access_token>'Response example
{ "payload": [ { "jobId": 0, "name": "string", "ownerId": 0, "lastUpdatorId": 0, "accountId": 0, "nextFrom": "2021-05-02T16:22:43.439Z", "nextTo": "2021-05-02T16:22:43.439Z", "projectIds": [0], "state": "ACTIVE", "createdAt": "2021-05-02T16:22:43.439Z", "format": "JSON", "scope": "views", "frequency": "string", "fields": [ { "fieldName": "string", "aliasName": "string" } ], "lastRunTime": "2021-05-02T16:22:43.439Z", "nextRunTime": "2021-05-02T16:22:43.439Z", "updatedAt": "2021-05-02T16:22:43.439Z", "filters": { "deviceId": 0 } } ], "success": true}nextFrom and nextTo represent the next date range that will be extracted, while lastRunTime and nextRunTime indicate when the last and next execution started / will start.
Get the list of all successful job runs
Section titled Get the list of all successful job runsGET /v1/exports/successful-runs
This endpoint provides the list of all the jobs runs that completed successfully. Use it to find which jobs have generated extraction files to be downloaded.
Query parameters
pageintegerThe page of results to retrieve.
orderstringTo change the order of the results list ("ASC" or "DESC", "DESC" by default). Ordering is based on the
jobId.limitintegerTo change the page size of results (25 by default, 100 max).
Request example
curl --location --request GET 'https://api.contentsquare.com/v1/exports/successful-runs' \--header 'Authorization: Bearer <your_access_token>'Response example
{ "payload": [ { "jobId": 0, "jobRunId": 0, "name": "string", "projectIds": [0], "from": "2021-05-02T16:40:14.022Z", "to": "2021-05-02T16:40:14.022Z", "completionTime": "2021-05-02T16:40:14.022Z", "format": "JSONL", "scope": "views", "frequency": "string", "nbOfFiles": 0 } ], "success": true}Get a specific job
Section titled Get a specific jobGET /v1/exports/{jobId}
This endpoint allows for retrieving a specific job with its ID.
Path parameters
jobIdinteger RequiredThe Job ID.
Request example
curl --location --request GET 'https://api.contentsquare.com/v1/exports/1234' \--header 'Authorization: Bearer <your_access_token>'Response example
{ "payload": { "jobId": 0, "name": "string", "ownerId": 0, "lastUpdatorId": 0, "accountId": 0, "nextFrom": "2021-05-02T16:50:29.301Z", "nextTo": "2021-05-02T16:50:29.301Z", "projectIds": [0], "state": "ACTIVE", "createdAt": "2021-05-02T16:50:29.301Z", "format": "JSONL", "scope": "views", "frequency": "string", "fields": [ { "fieldName": "string", "aliasName": "string" } ], "lastRunTime": "2021-05-02T16:50:29.301Z", "nextRunTime": "2021-05-02T16:50:29.301Z", "updatedAt": "2021-05-02T16:50:29.301Z", "filters": { "deviceId": 0 } }, "success": true}nextFrom and nextTo represent the next date range that will be extracted, while lastRunTime and nextRunTime indicate when the last and next execution started / will start.
Get the list of all job runs of a job
Section titled Get the list of all job runs of a jobGET /v1/exports/{jobId}/runs
This endpoint provides the list of all the job runs related to a specific job.
Path parameters
jobIdinteger RequiredThe Job ID.
Query parameters
limitintegerTo change the page size of results (25 by default, 100 max).
orderstringTo change the order of the results list ("ASC" or "DESC", "DESC" by default). Ordering is based on the
jobId.pageintegerThe page of results to retrieve.
statestringTo filter based on the job status (see Enumerations).
Request example
curl --location --request GET 'https://api.contentsquare.com/v1/exports/1354/runs' \--header 'Authorization: Bearer <your_access_token>'Response example
{ "payload": [ { "jobRunId": 0, "startDate": "2021-05-02T16:51:51.004Z", "state": "CREATED", "endDate": "2021-05-02T16:51:51.004Z", "completionRate": 0 } ], "success": true}Get a specific job run
Section titled Get a specific job runGET /v1/exports/{jobId}/runs/{runId}
This endpoint allows for retrieving a specific job run with its ID. The response includes all the extraction files available for download if any (in the files field). The files can be downloaded via the provided URL in the url field. Files will not be available for download after the expirationDate.
Path parameters
jobIdinteger RequiredThe Job ID.
runIdinteger RequiredThe Job Run ID.
Request example
curl --location --request GET 'https://api.contentsquare.com/v1/exports/1354/runs/67226' \--header 'Authorization: Bearer <your_access_token>'Response example
{ "payload": { "jobRunId": 0, "startDate": "2021-05-02T16:54:55.983Z", "state": "CREATED", "files": [ { "partId": 0, "fileSize": 0, "url": "string", "expirationDate": "2021-05-02T16:54:55.983Z" } ], "endDate": "2021-05-02T16:54:55.983Z", "completionRate": 0 }, "success": true}Get the list of all exportable fields
Section titled Get the list of all exportable fieldsGET /v1/exportable-fields
This endpoint allows for retrieving all fields that can be extracted for a specified scope (the list of fields will depend on the scope).
Query parameters
scopestring RequiredTo filter based on the job scope (see Enumerations)
Request example
curl --location --request GET 'https://api.contentsquare.com/v1/exportable-fields?scope=sessions' \--header 'Authorization: Bearer <your_access_token>'Response example
{ "payload": [ { "name": "string", "description": "string", "example": "string", "aliases": ["string"], "parameters": ["string"] } ], "success": true}Get the list of custom variables
Section titled Get the list of custom variablesGET /v1/custom-vars
This endpoint allows for retrieving all the custom variables available on a project. To learn more about custom variables, see Sending custom vars.
Request example
curl --location --request GET 'https://api.contentsquare.com/v1/custom-vars' \--header 'Authorization: Bearer <your_access_token>'Response example
{ "payload": [ { "position": 2, "key": "dataType", "values": [ "journey", "recording", "zoning" ] }, { "position": 3, "key": "pageType", "values": [ "checkoutstep 1" "checkoutstep 2", "checkoutstep 3", ] }, { "position": 1, "key": "Goal achieved", "values": [ "false", "true" ] } ], "success": true}Get the list of dynamic variables
Section titled Get the list of dynamic variablesGET /v1/dynamic-var-keys
This endpoint allows for retrieving all the dynamic variables available on a project between two dates. To learn more about dynamic variables, see Sending dynamic variables.
Query parameters
fromISO 8601 date stringStart date of the query date range.
toISO 8601 date stringEnd date of the query date range.
Request example
curl --location --request GET 'https://api.contentsquare.com/v1/dynamic-var-keys?from=2023-02-10T00:00:00&to=2023-02-17T00:00:00' \--header 'Authorization: Bearer <your_access_token>'Response example
{ "payload": [ { "key": "AB Test", "type": "string" }, { "key": "Traffic Source", "type": "string" }, { "key": "VoC feedback score", "type": "string" }, { "key": "Web Analytics Segment", "type": "string" } ], "success": true}
