XM Discover API: Export API v2 Usage Examples
About Export API Usage Examples
This topic provides usage examples of Export API with sample requests and responses.
- Example 1: Get all documents with all attributes and fields available
- Example 2: Get all sentences with all attributes and fields available
- Example 3: Get all sentences from a specific verbatim
- Example 4: Get all records from several specific documents
- Example 5: Get details on a specific sentence
Tip: You need to substitute the
https://export.cbplatform.com/part of the URL in the examples below with the Export API URL that matches your host environment, and the75b12bc9-b0e2-4c9b-a444-9f4065677b65key with the API key that matches your project.
Note: All special characters like spaces, ampersands, square brackets, and quotes in parameter values need to be percent-encoded (see the HTML URL Encoding Reference for details).
Sample Dataset
All examples in this topic are based on the following sample dataset.

Example 1: Get All Documents With All Attributes and Fields Available
Use the documents endpoint and set both the attributes and the fields parameters to all.
Sample request
curl --location --request GET 'https://export.cbplatform.com/v2/export/documents?attributes=all&fields=all' \
--header 'Authorization: Bearer 75b12bc9-b0e2-4c9b-a444-9f4065677b65'
Sample response
{
"documents": [
{
"document_id": 2,
"session_id": 11112,
"source": "tripguru",
"document_date": "2019-12-19T06:00:00.000Z",
"created_date": 1585568798194,
"natural_id": "102",
"content_type": "contentful",
"content_subtype": "contentful",
"cb_date_updated": 1585568841488,
"attributes": {
"cb_document_word_count": 20,
"city": "chicago",
"author": "paul",
"rating": 5,
"_doc_date": "2019-12-19",
"time_of_day": "06:00",
"hotel": "acme grand"
}
},
{
"document_id": 3,
"session_id": 11112,
"source": "tripguru",
"document_date": "2019-12-20T09:00:00.000Z",
"created_date": 1585568798196,
"natural_id": "103",
"content_type": "contentful",
"content_subtype": "contentful",
"cb_date_updated": 1585568841570,
"attributes": {
"cb_document_word_count": 13,
"city": "detroit",
"author": "mary",
"rating": 3,
"_doc_date": "2019-12-20",
"time_of_day": "09:00",
"hotel": "acme inn"
}
},
{
"document_id": 1,
"session_id": 11112,
"source": "tripguru",
"document_date": "2019-12-19T06:00:00.000Z",
"created_date": 1585568798190,
"natural_id": "101",
"content_type": "contentful",
"content_subtype": "contentful",
"cb_date_updated": 1585568841307,
"attributes": {
"cb_document_word_count": 26,
"city": "chicago",
"author": "john",
"rating": 4,
"_doc_date": "2019-12-19",
"time_of_day": "06:00",
"hotel": "acme inn"
}
}
],
"total_count": 3,
"page_size": 3,
"scroll_id": "c2NhbjswOzE7dG90YWxfaGl0czozOw=="
}
Example 2: Get All Sentences With All Attributes and Fields Available
Use the sentences endpoint and set both the attributes and the fields parameters to all.
Sample request
curl --location --request GET 'https://export.cbplatform.com/v2/export/sentences?attributes=all&fields=all' \
--header 'Authorization: Bearer 75b12bc9-b0e2-4c9b-a444-9f4065677b65'
Sample response
{
"sentences": [
{
"verbatim_id": 3,
"sentence_id": 4,
"verbatim_type": "response",
"processed_language": "english",
"autodetected_language": "not attempted",
"cb_date_updated": 1585568841488,
"sentiment": 0.0,
"sentence_start_pos": 0,
"sentence_end_pos": 21,
"sentence": "No response provided.",
"document_id": 2,
"session_id": 11112,
"source": "tripguru",
"document_date": "2019-12-19T06:00:00.000Z",
"created_date": 1585568798194,
"natural_id": "102",
"content_type": "contentful",
"content_subtype": "contentful",
"attributes": {
"cb_document_word_count": 20,
"city": "chicago",
"rating": 5,
"cb_sentence_word_count": 3,
"hotel": "acme grand",
"author": "paul",
"_doc_date": "2019-12-19",
"cb_sentence_quartile": 1,
"time_of_day": "06:00"
}
},
{
"verbatim_id": 4,
"sentence_id": 6,
"verbatim_type": "review",
"processed_language": "english",
"autodetected_language": "not attempted",
"cb_date_updated": 1585568841488,
"sentiment": 0.0,
"sentence_start_pos": 58,
"sentence_end_pos": 88,
"sentence": "$40 per person for the buffet!",
"document_id": 2,
"session_id": 11112,
"source": "tripguru",
"document_date": "2019-12-19T06:00:00.000Z",
"created_date": 1585568798194,
"natural_id": "102",
"content_type": "contentful",
"content_subtype": "contentful",
"attributes": {
"cb_document_word_count": 20,
"city": "chicago",
"rating": 5,
"cb_bc_detected": [
"currency"
],
"cb_sentence_word_count": 6,
"cb_bc_currency": [
"$40"
],
"hotel": "acme grand",
"author": "paul",
"_doc_date": "2019-12-19",
"cb_sentence_quartile": 3,
"time_of_day": "06:00"
}
},
{
"verbatim_id": 4,
"sentence_id": 5,
"verbatim_type": "review",
"processed_language": "english",
"autodetected_language": "not attempted",
"cb_date_updated": 1585568841488,
"sentiment": -1.0,
"sentence_start_pos": 0,
"sentence_end_pos": 57,
"sentence": "Breakfast was a bit pricey so I would suggest eating out.",
"document_id": 2,
"session_id": 11112,
"source": "tripguru",
"document_date": "2019-12-19T06:00:00.000Z",
"created_date": 1585568798194,
"natural_id": "102",
"content_type": "contentful",
"content_subtype": "contentful",
"attributes": {
"cb_document_word_count": 20,
"city": "chicago",
"rating": 5,
"cb_sentence_word_count": 11,
"hotel": "acme grand",
"author": "paul",
"_doc_date": "2019-12-19",
"cb_sentence_quartile": 1,
"time_of_day": "06:00"
}
},
{
"verbatim_id": 1,
"sentence_id": 1,
"verbatim_type": "response",
"processed_language": "english",
"autodetected_language": "not attempted",
"cb_date_updated": 1585568841307,
"sentiment": 0.0,
"sentence_start_pos": 0,
"sentence_end_pos": 15,
"sentence": "Thank you sent.",
"document_id": 1,
"session_id": 11112,
"source": "tripguru",
"document_date": "2019-12-19T06:00:00.000Z",
"created_date": 1585568798190,
"natural_id": "101",
"content_type": "contentful",
"content_subtype": "contentful",
"attributes": {
"cb_document_word_count": 26,
"city": "chicago",
"rating": 4,
"cb_sentence_word_count": 3,
"hotel": "acme inn",
"author": "john",
"_doc_date": "2019-12-19",
"cb_sentence_quartile": 1,
"time_of_day": "06:00",
"cb_sentence_type": [
"thanks"
]
}
},
{
"verbatim_id": 2,
"sentence_id": 2,
"verbatim_type": "review",
"processed_language": "english",
"autodetected_language": "not attempted",
"cb_date_updated": 1585568841307,
"sentiment": 0.0,
"sentence_start_pos": 0,
"sentence_end_pos": 35,
"sentence": "The service here is second to none.",
"document_id": 1,
"session_id": 11112,
"source": "tripguru",
"document_date": "2019-12-19T06:00:00.000Z",
"created_date": 1585568798190,
"natural_id": "101",
"content_type": "contentful",
"content_subtype": "contentful",
"attributes": {
"cb_document_word_count": 26,
"city": "chicago",
"rating": 4,
"cb_sentence_word_count": 7,
"hotel": "acme inn",
"author": "john",
"_doc_date": "2019-12-19",
"cb_sentence_quartile": 1,
"time_of_day": "06:00"
}
},
{
"verbatim_id": 5,
"sentence_id": 7,
"verbatim_type": "response",
"processed_language": "english",
"autodetected_language": "not attempted",
"cb_date_updated": 1585568841570,
"sentiment": 0.0,
"sentence_start_pos": 0,
"sentence_end_pos": 13,
"sentence": "Apology sent.",
"document_id": 3,
"session_id": 11112,
"source": "tripguru",
"document_date": "2019-12-20T09:00:00.000Z",
"created_date": 1585568798196,
"natural_id": "103",
"content_type": "contentful",
"content_subtype": "contentful",
"attributes": {
"cb_document_word_count": 13,
"city": "detroit",
"rating": 3,
"cb_sentence_word_count": 2,
"hotel": "acme inn",
"author": "mary",
"_doc_date": "2019-12-20",
"cb_sentence_quartile": 1,
"time_of_day": "09:00"
}
},
{
"verbatim_id": 6,
"sentence_id": 8,
"verbatim_type": "review",
"processed_language": "english",
"autodetected_language": "not attempted",
"cb_date_updated": 1585568841570,
"sentiment": -2.0,
"sentence_start_pos": 0,
"sentence_end_pos": 55,
"sentence": "I must agree with other reviews that it is quite noisy.",
"document_id": 3,
"session_id": 11112,
"source": "tripguru",
"document_date": "2019-12-20T09:00:00.000Z",
"created_date": 1585568798196,
"natural_id": "103",
"content_type": "contentful",
"content_subtype": "contentful",
"attributes": {
"cb_document_word_count": 13,
"city": "detroit",
"rating": 3,
"cb_sentence_word_count": 11,
"hotel": "acme inn",
"author": "mary",
"_doc_date": "2019-12-20",
"cb_sentence_quartile": 1,
"time_of_day": "09:00"
}
},
{
"verbatim_id": 2,
"sentence_id": 3,
"verbatim_type": "review",
"processed_language": "english",
"autodetected_language": "not attempted",
"cb_date_updated": 1585568841307,
"sentiment": 0.5,
"sentence_start_pos": 36,
"sentence_end_pos": 123,
"sentence": "My wife and I enjoyed our spacious room and would not hesitate to recommend this hotel.",
"document_id": 1,
"session_id": 11112,
"source": "tripguru",
"document_date": "2019-12-19T06:00:00.000Z",
"created_date": 1585568798190,
"natural_id": "101",
"content_type": "contentful",
"content_subtype": "contentful",
"attributes": {
"cb_document_word_count": 26,
"city": "chicago",
"rating": 4,
"cb_sentence_word_count": 16,
"hotel": "acme inn",
"author": "john",
"_doc_date": "2019-12-19",
"cb_sentence_quartile": 2,
"time_of_day": "06:00"
}
}
],
"total_count": 8,
"page_size": 8,
"scroll_id": "c2NhbjswOzE7dG90YWxfaGl0czo4Ow=="
}
Example 3: Get All Sentences From a Specific Verbatim
Use the sentences endpoint and set the query parameter to match a specific Verbatim ID (_id_verbatim).
Sample request
curl --location --request GET 'https://export.cbplatform.com/v2/export/sentences?query=_id_verbatim:2&fields=all' \
--header 'Authorization: Bearer 75b12bc9-b0e2-4c9b-a444-9f4065677b65'
Sample response
{
"sentences": [
{
"verbatim_id": 2,
"sentence_id": 2,
"verbatim_type": "review",
"processed_language": "english",
"autodetected_language": "not attempted",
"cb_date_updated": 1585568841307,
"sentiment": 0.0,
"sentence_start_pos": 0,
"sentence_end_pos": 35,
"sentence": "The service here is second to none.",
"document_id": 1,
"session_id": 11112,
"source": "tripguru",
"document_date": "2019-12-19T06:00:00.000Z",
"created_date": 1585568798190,
"natural_id": "101",
"content_type": "contentful",
"content_subtype": "contentful"
},
{
"verbatim_id": 2,
"sentence_id": 3,
"verbatim_type": "review",
"processed_language": "english",
"autodetected_language": "not attempted",
"cb_date_updated": 1585568841307,
"sentiment": 0.5,
"sentence_start_pos": 36,
"sentence_end_pos": 123,
"sentence": "My wife and I enjoyed our spacious room and would not hesitate to recommend this hotel.",
"document_id": 1,
"session_id": 11112,
"source": "tripguru",
"document_date": "2019-12-19T06:00:00.000Z",
"created_date": 1585568798190,
"natural_id": "101",
"content_type": "contentful",
"content_subtype": "contentful"
}
],
"total_count": 2,
"page_size": 2,
"scroll_id": "c2NhbjswOzE7dG90YWxfaGl0czoyOw=="
}
Example 4: Get All Records From Several Specific Documents
Use the documents endpoint and set the query parameter to match several Natural IDs (natural_id).
Sample request
curl --location --request GET 'https://export.cbplatform.com/v2/export/documents?query=natural_id:102%20OR%20natural_id:103&attributes=all&fields=all' \
--header 'Authorization: Bearer 75b12bc9-b0e2-4c9b-a444-9f4065677b65'
Sample response
{
"documents": [
{
"document_id": 2,
"session_id": 11112,
"source": "tripguru",
"document_date": "2019-12-19T06:00:00.000Z",
"created_date": 1585568798194,
"natural_id": "102",
"content_type": "contentful",
"content_subtype": "contentful",
"cb_date_updated": 1585568841488,
"attributes": {
"cb_document_word_count": 20,
"city": "chicago",
"author": "paul",
"rating": 5,
"_doc_date": "2019-12-19",
"time_of_day": "06:00",
"hotel": "acme grand"
}
},
{
"document_id": 3,
"session_id": 11112,
"source": "tripguru",
"document_date": "2019-12-20T09:00:00.000Z",
"created_date": 1585568798196,
"natural_id": "103",
"content_type": "contentful",
"content_subtype": "contentful",
"cb_date_updated": 1585568841570,
"attributes": {
"cb_document_word_count": 13,
"city": "detroit",
"author": "mary",
"rating": 3,
"_doc_date": "2019-12-20",
"time_of_day": "09:00",
"hotel": "acme inn"
}
}
],
"total_count": 2,
"page_size": 2,
"scroll_id": "c2NhbjswOzE7dG90YWxfaGl0czoyOw=="
}
Example 5: Get Details on a Specific Sentence
Use the sentences endpoint and set the query parameter to match a specific Sentence ID (_id_sentence).
Sample request
curl --location --request GET 'https://export.cbplatform.com/v2/export/sentences?query=_id_sentence:4&attributes=all&fields=all' \
--header 'Authorization: Bearer 75b12bc9-b0e2-4c9b-a444-9f4065677b65'
Sample response
{
"sentences": [
{
"verbatim_id": 3,
"sentence_id": 4,
"verbatim_type": "response",
"processed_language": "english",
"autodetected_language": "not attempted",
"cb_date_updated": 1585568841488,
"sentiment": 0.0,
"sentence_start_pos": 0,
"sentence_end_pos": 21,
"sentence": "No response provided.",
"document_id": 2,
"session_id": 11112,
"source": "tripguru",
"document_date": "2019-12-19T06:00:00.000Z",
"created_date": 1585568798194,
"natural_id": "102",
"content_type": "contentful",
"content_subtype": "contentful",
"attributes": {
"cb_document_word_count": 20,
"city": "chicago",
"rating": 5,
"cb_sentence_word_count": 3,
"hotel": "acme grand",
"author": "paul",
"_doc_date": "2019-12-19",
"cb_sentence_quartile": 1,
"time_of_day": "06:00"
}
}
],
"total_count": 1,
"page_size": 1,
"scroll_id": "c2NhbjswOzE7dG90YWxfaGl0czoxOw=="
}