I'm trying to figure out if it's possible to eject certain subscribers mid-journey (in a currently active journey). I want to eject the subscribers where a certain data extension field equals "something". Possible? Thinking Journey Builder API?


What I would do is to set up an automation that has a SQL Query (to gather the subscribers that match your requirement) and then a Script Activity, followed by another SQL Query.

The SQL would be something like:

SELECT Subscriberkey
FROM [myJourneyDE]
WHERE field = 'something'
AND journeystatus = 'active'

Which will target using myJourneyExitDE to push all those that meet your criteria.

You then will want to use the Journey Builder API to remove these contacts from the Journey inside a Script Activity.

Here is a good sample of the API call:

Host: https://YOUR_SUBDOMAIN.rest.marketingcloudapis.com
POST /interaction/v1/interactions/contactexit
Content-Type: application/json
Authorization: Bearer YOUR_ACCESS_TOKEN

        "ContactKey": "CONTACTKEY 1",
        "DefinitionKey": "DEFINITIONKEY"
        "ContactKey": "CONTACTKEY 2",
        "DefinitionKey": "INVALID DEFINITIONKEY",
        "Versions" :[1,2]

Please note that you will need the ContactKey (which usually is synonomous with SubscriberKey) and the DefinitionKey(of your Journey) in order to utilize this.

@AdamSpriggs gives a good example of doing a REST API call in SSJS that should help get you started.

The final query is then used to mark all those that you removed from the journey as 'exited' or similar status in the journeystatus field.

SELECT Subscriberkey
, 'exited' as journeystatus
FROM [myJourneyExitDE]

and have it target [myJourneyDE] as update.

This will then ensure you do not get these records returned in the next call. Depending on your use-case and/or current setup, you may need to adjust this accordingly.

| improve this answer | |

Well - why not use exit criteria, and point to your "exit data extension" in Contact Data? This will IMHO be the simplest way. Indeed, this will not happen immediately, but exit criteria are evaluated upon exiting from each wait step, hence e.g. subsequent emails will not be sent. Remember you should avoid using decisions in JB with one-to-many cardinalities in data designer.

Only very rarely I find it necessary to "kick" someone out of a journey in real time.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.