Export sessions
Export sessions from an application.
Example
Here is an example of how to export events:
import {Configuration, ExportApi} from '@croct/export';
async function exportSessions(): Promise<void> {const api = new ExportApi(new Configuration({apiKey: '<API KEY>'}));
let cursor: string | undefined = undefined;let running = true;
while (running) {const {data: {items: sessions, nextCursor}} = await api.exportSessions({pageSize: 100,cursor: cursor,start: 1440990000000,end: 1441076400000,});
console.log(sessions);
cursor = nextCursor;running = sessions.length > 0;}}Headers
This endpoint requires the following HTTP headers:
Parameters
This endpoint accepts the following query parameters:
- start(optional)integer
The earliest session close time to include, in milliseconds since epoch.
Only sessions closed at or after this time are included.
- end(optional)integer
The latest session close time to include, in milliseconds since epoch.
Only sessions closed before this time are included. If not provided, there is no upper time limit.
- pageSize(optional)integer
The maximum number of sessions returned per request.
Must be between 1 and 1000.
Default:100- cursor(optional)string
A cursor for retrieving the next page of results.
If omitted, export starts from the beginning of the specified time window.
Response
This endpoint returns a JSON response with the following properties:
- dataobject
The response containing exported sessions and pagination information.
- itemsobject[]
The list of exported sessions.
- sessionIdstring
The ID that uniquely identifies the session across the application in UUID format.
- userIdstring
The ID that uniquely identifies the user across the workspace in UUID format.
- parentIdstring|null
The ID of the session that superseded this session.
Usually set when a user is identified, causing the current anonymous session to end and a new identified session to begin.
- externalUserIdstring|null
The external user ID used to identify the user on the application side.
Always null for anonymous users.
- windowobject
- closeTimeinteger
The time from which the session is closed for new events.
May be extended if new events arrive before the session is fully closed.
- referrerstring|null
The URI of the content that linked to the page that started the session.
- landingPageUrlstring|null
The page URL that started the session.
- campaignobject|null
The available information about the campaign.
- namestring|null
A unique identifier for the campaign. It is usually a short string, such as "summer-sale" or "new-product-launch".
- sourcestring|null
The advertiser, site, or publication generating the traffic. For example, "google", "facebook", or "newsletter".
- mediumstring|null
The advertising or marketing channel used to reach the user. For example, "email", "video", or "social".
- contentstring|null
An identification of the specific ad or content the user interacted with. For example, "main-banner" or "newsletter-cta".
- termstring|null
The keyword or term that triggered the ad. For example, "running shoes" or "tennis racket".
- name
- locationobject|null
The available information about the user's location.
- continentstring|null
The continent code where the location is situated. The possible values are:
Value Description AF Africa AN Antarctica AS Asia EU Europe NA North America OC Oceania SA South America - countrystring|null
The country code following the ISO 3166-1 alpha-2 standard, in upper case.
For example, "US" for United States.
- regionobject|null
The primary administrative division within the country, such as a state or province.
- namestring
The name of the region in English.
For example, "California" or "New York".
- codestring|null
The code is based on the ISO 3166-2 standard or official codes whenever available, in upper case.
For example, "CA" for California.
- name
- citystring|null
The incorporated city or town political entity.
For example, "New York", "Mexico City" or "São Paulo".
- districtstring|null
The district, county, or department within the region.
For example, "Los Angeles County" or "Greater London".
- timezonestring|null
The time zone name as specified in the IANA Time Zone Database.
For example, "America/New_York" or "America/Sao_Paulo".
- coordinatesobject|null
- sourcestring
The sources of location information. The possible values are:
Value Description IP Location inferred based on the IP address. GPS Location inferred based on the GPS data. BROWSER Location inferred based on the browser information. INPUT Location provided by the application. UNKNOWN An unknown source. - currencyobject|null
- phoneCodestring|null
The international dialing code for this location.
For example, "+1" for the United States or Canada, or "+55" for Brazil.
- populationnumber|null
The approximate population within the boundaries of the returned location.
If the location refers to a city, this value reflects the city's population. If it refers to a broader area, such as a region, it reflects the population of that region.
- postalCodestring|null
The postal or ZIP code associated with the location.
The value follows a valid format (e.g., "90210", "SW1A 1AA", or "28430-000"), but may represent an approximate or example code for the region rather than an exact or specific address. In some areas, it may reflect the beginning of a postal range.
- languagesarray<string>|null
A list of locale codes of the languages spoken in the location as specified in the ISO 639-1 and ISO 3166-1.
For example, ["en", "en-CA", "fr-CA"] indicates that English and French are spoken in Canada, with English being more prevalent.
One or more tags describing the location, such as natural features or climate.
For example, a lake in a warm, touristic area might include tags like "warm", "lake" and "tourism".
Tags related to the type of place or area:
Tag Description urban Related to cities or densely populated areas residential Areas where housing and living spaces are concentrated rural Countryside or sparsely populated regions outside urban centers remote Locations distant from major settlements or infrastructure park Public or protected areas with greenery or open space island Land surrounded by water on all sides Tags denoting social roles, institutions, and public services:
Tag Description government Locations related to public services, institutions, or administration politics Places associated with political activity or governance military Locations used for defense, training, or armed service operations religion Sites with religious or spiritual significance education Places where people study and learn Tags related to economic activity:
Tag Description business Areas with commercial presence or economic activity industry Zones involving manufacturing, logistics, or production agriculture Areas with fields, pastures, or crops Tags related to transportation, utilities, and built environments:
Tag Description transport Locations supporting transit or logistics facility Places built for specific purposes, often supporting operations or services waterway Navigable or managed water routes such as rivers or canals airport Locations related to aircraft takeoff and landing road Infrastructure for vehicular travel railway Locations involving rail transport infrastructure seaport Ports where ships may dock, load, or unload goods or passengers Tags for areas commonly used for sports and outdoor activities:
Tag Description fishing Areas where fishing or related activity may take place surfing Coastal areas with waves that may support surfing swimming Areas where people may swim or engage with water safely hiking Outdoor spaces where hiking might occur skiing Areas where snow allows skiing or similar activities Tags highlighting cultural, recreational, or scenic appeal:
Tag Description entertainment Places that can offer cultural or recreational activities scenery Locations appreciated for their natural beauty or view landmark Notable spots or features that help identify a place recreation Areas intended for outdoor activities, sports, or leisure tourism Places people visit for culture, nature, or history Tags describing natural features and landscapes:
Tag Description mountain Elevated terrain rising above surroundings lake Bodies of still water surrounded by land river Naturally flowing body of water that may lead to lakes or oceans canyon Natural formations shaped by erosion desert Dry regions with little rainfall or vegetation ocean Coastal or open-sea areas facing large saltwater bodies coast Edges of land meeting a sea or ocean beach Shoreline with sand or pebbles, often near water bodies forest Areas with dense tree cover Tags related to climate and weather conditions:
Tag Description warm Regions with generally tropical or temperate climates cold Regions characterized by low temperatures snowy Areas with frequent snow or icy conditions
- continent
- clientobject
The available information about the client.
- deviceobject
The device used by the client.
- namestring|null
The name of the device. For example, "iPhone 11 Pro" or "MacBook Pro".
- vendorstring|null
The vendor or manufacturer of the device. For example, "Apple" or "Samsung".
- categorystring
The category of the device. The possible values are:
Value Description desktop A desktop computer. tablet A tablet device. mobile A mobile phone. bot Bots or crawlers. other Any other device. unknown An unknown device. - operatingSystemobject
- name
- browserobject
The browser used by the client.
- namestring|null
The browser's name. For example, "Chrome", "Safari", or "Firefox".
- versionstring|null
The browser's version. For example, "78.0.3904.108", "13", or "71.0".
- typestring
The browser type. The possible values are:
Value Description web A standard web browser. in-app A browser embedded in an application. crawler A search engine bot or crawler. other Any other browser, like proxies or feed readers. unknown An unknown browser type.
- name
- device
- attributesobject
Custom attributes associated with the session.
- statisticsobject
- sessionId
- nextCursorstring
A cursor for retrieving the next page of results.
If omitted, export starts from the beginning of the specified time window.
- items
Example response
Here is an example of a JSON response from this endpoint:
{ "items": [ { "sessionId": "12345678-1234-1234-1234-123456789012", "userId": "87654321-4321-4321-4321-210987654321", "parentId": null, "externalUserId": "user-123", "window": { "start": 1440990000000, "end": 1441000000000 }, "closeTime": 1441001000000, "referrer": "https://google.com", "landingPageUrl": "https://example.com/home", "campaign": { "name": "summer-sale", "source": "google", "medium": "cpc", "content": "banner-ad", "term": "running shoes" }, "location": { "continent": "NA", "country": "US", "region": { "name": "California", "code": "CA" }, "city": "San Francisco", "timezone": "America/Los_Angeles" }, "client": { "device": { "name": "iPhone 12", "vendor": "Apple", "category": "MOBILE", "operatingSystem": { "name": "iOS", "version": "14.4" } }, "browser": { "name": "Safari", "version": "14.0", "type": "WEB" } }, "attributes": { "customField": "value" }, "statistics": { "pageViews": 5, "tabViews": 2, "orders": 1 } } ], "nextCursor": "eyJzZXNzaW9uSWQiOiIxMjM0NSIsImNsb3NlVGltZSI6MTYwOTQ1OTMwMDAwMH0"}