[SalesForce] way to retrieve Journey History for contact using REST API

I'm looking for a way to retrieve journey contact history – basically the same information that is on Journey Builder – History tab (Contact key, Journey Name, Activity name, Status, Timestamp) via SFMC API. I browsed the REST API documentation but couldn't find anything regarding getting that data. Has anyone ever done something like this and can push me in the right direction?

Best Answer

You can retrieve Journey History by POSTing to this endpoint /interaction/v1/interactions/traceevents/search

It is the same endpoint used in the History tab in Journey Builder.

Example of the request payload without any filter (apart from time)

{"from":0,"size":100,"filter":{"fquery":{"query":{"query_string":{"query":"(transactionTime:[2017-08-29T13:20:45.101Z TO *])"}}}}}

Example of the request paypload with a filter on a journey

{"from":0,"size":100,"filter":{"fquery":{"query":{"query_string":{"query":"(definitionId:74d00b19-f28f-4533-abb2-xxxxxxxxxxxx) AND (transactionTime:[2017-08-29T13:20:45.101Z TO *])"}}}}}

I suggest you use google developer tools (in Network tab) or any other monitoring tool to monitor the network traffic within the History tab of Journey Builder and learn more about this endpoint especially how to perform complex queries.

Please note that this is not officially available for use as it is not documented in the official documentation

[EDIT - 11/10/2017] You can now also use Journey Builder Data Views to retrieve Journey activity.

[EDIT - 31/12/2021] You can use POST /interaction/v1/interactions/journeyhistory/search or POST /interaction/v1/interactions/journeyhistory/filter or POST /interaction/v1/interactions/journeyhistory/download endpoints. For more information you can find all available endpoints by looking into the discovery endpoint GET /interaction/v1/rest

Related Topic