Sending enrichment data batches to Contentsquare

Once the Provider has collected the required Contentsquare session identifiers, they can start enriching the Contentsquare data with their own data.

Sending a batch of enrichment data falls into 2 steps:

  • Authenticating and retrieving the right enrichment endpoint dynamically
  • Sending the enrichment data to this endpoint with a valid JWT

See the dedicated Authentication section.

Sending data to the enrichment endpoint

Section titled Sending data to the enrichment endpoint
  • Step 3: the Provider must have the knowledge of which Contentsquare project ID and sessions the data will enrich
  • Step 4.1: the Provider must have a valid JWT and base URL for the enrichment endpoint
  • All the enrichments of a batch sent to the enrichment endpoint have to match the schema version of the integration provided in the request (if an enrichment gets rejected, then the full batch will be rejected)
  • Endpoint (returned by the authentication call in step 4.1):
    https://enrichment-api.{cloud}.contentsquare.com/v1/enrichments
  • Method: POST
  • Header: Authorization: Bearer {JWT access token}
  • Body:
{
"integrationVersion": 1, // required, provided by Contentsquare when creating a new schema
"projectId": 1, // retrieved in step 3
"enrichments": [
{
"userId": "{USER_ID}", // string, retrieved in step 3
"sessionNumber": {SESSION_NUMBER}, // integer, retrieved in step 3
"enrichmentNumber": 1, // integer, max 3, optional (will be 1 if not specified)
"enrichment": {
"field1": "Some string",
"field2": 42,
"field3": 3.14,
"field4": "2022-03-23T00:10:30Z",
"field5": true
}
}
]
}
  • integrationVersion: a schema version for the integration must be specified so that Contentsquare can know which schema the data must match. Every time a new schema is created, Contentsquare provides the provider with a new integration version. The Provider must take care of sending data that match the right schema version. If the Provider has only one schema registered, then the integrationVersion should remain 1 by default.
  • enrichmentNumber: as a Contentsquare session can be enriched with up to 3 enrichments, each enrichment must be indexed so that it can potentially be updated later (see the dedicated section on how to update an enrichment). Index should start at 1 and can be max 3. If no enrichment number is specified by the Provider, it will be considered as 1 by default (meaning that if the Provider never specifies any enrichment number, any new enrichment for a session will overwrite the previous one and there will be only 1 enrichment per session - with index 1)

Success 200

(Empty body)

Unauthorized: 401: invalid JWT token
Section titled Unauthorized: 401: invalid JWT token
{
"message": "Unauthorized"
}
Bad request 400: data validation failed
Section titled Bad request 400: data validation failed
{
"message": "enrichments don't match expected payload"
}
Bad request 400: bad integration version
Section titled Bad request 400: bad integration version
{
"message": "bad integration version"
}
Terminal window
curl --location --request POST 'https://enrichment-api.ba.contentsquare.com/v1/enrichments' \
--header 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IktJRCJ9.eyJpc3MiOiJlbnJpY2htZW50SW50ZWdyYXRpb24iLCJpYXQiOiJJQVQiLCJleHAiOiJFWFAiLCJ2ZXJzaW9uIjoiMSIsInByb2plY3RJZCI6MTYyLCJpbnRlZ3JhdGlvbklkIjoxMDB9' \
--data-raw '{
"integrationVersion": 1,
"projectId": 162,
"enrichments": [
{
"userId": "aaa-aaa-aaa",
"sessionNumber": 5,
"enrichmentNumber": 1,
"enrichment": {
"has_called": true,
"call_duration": 3532,
"call_client_rating": 4.5,
"call_center_name": "RENNES",
"call_date": "2022-01-01T20:02:22Z"
}
},
{
"userId": "aaa-aaa-aaa",
"sessionNumber": 5,
"enrichmentNumber": 2,
"enrichment": {
"has_called": true,
"call_duration": 2293,
"call_client_rating": 2,
"call_center_name": "RENNES",
"call_date": "2022-01-01T18:09:54"
}
}
]
}'

Success 200

  • EnrichmentNumber:
    • Min: 1
    • Max: 3
  • Number of enrichments per batch: max 200
  • Sessions that started more than 7 days ago cannot be enriched (enrichment for those sessions will not be rejected but no data will be available in the Contentsquare platform in the end)