Skip to main content

Function: terminate_if and terminate

Filtering respondents that don't qualify

Updated over 3 weeks ago

When and Why to Use

Use these to disqualify respondents based on logic at any point in the survey.

  • terminate_if() allows you to specify a condition to check inline

  • terminate() immediately ends the survey with a given reason

Best for:

  • Screening out respondents who don’t meet key criteria

  • Enforcing business logic (e.g., device ownership, past usage)

  • Ending surveys early while still recording a clear disqualification reason

terminate_if(condition, reason)

Parameter

Type

Required

Description

condition

bool

yes

If True, the respondent will be terminated

reason

str

yes

Message shown to the respondent and recorded in the response log

Example Code

has_xbox = s.boolean_question("Do you own an Xbox?") s.terminate_if( condition=not has_xbox, reason="Sorry, you don't qualify for this survey because you don't have an Xbox." )

Notes

  • Only the first true condition encountered will trigger termination

  • Termination reason should be clear and respondent-friendly

  • Use terminate() directly if the condition has already been evaluated elsewhere

Related: terminate(reason)

Use this to force a termination unconditionally or outside of an if expression.

s.terminate("This survey is now closed to new participants.")
  • Typically used in fallback logic or forced re-routes

  • Still logs the reason and ends the session cleanly

Did this answer your question?