IN_PRODUCT_SURVEY Study. It contains the complete delivery
decision:
triggers: existing Events that can trigger the Study.audience: visitor conditions evaluated for eligibility.delaySeconds: how long to wait after the trigger before presentation.
SURVEY.
Create or replace targeting
PUT /v2/studies/{studyId}/targeting creates targeting when none exists and replaces the complete
resource on later calls. There is no separate create operation and no partial update.
- Read the Study and save its ETag.
- List Events and select at least one Event UUID.
- Optionally list Attribute definitions and compose an audience expression.
- Send the entire targeting document with
If-Match. - Save the new ETag returned by the
204response.
GET /v2/studies/{studyId}/targeting returns null when targeting has not been configured.
DELETE /v2/studies/{studyId}/targeting clears every trigger, audience rule, and delay without
deleting referenced Event, Attribute, or Group definitions.
Trigger Events
CallGET /v2/events to list Event definitions in the authenticated environment. A trigger
references the returned id, not an internal numeric Event ID or Event name.
Supported Event definitions are:
TRACKED: a code Event sent by a Sprig SDK.PAGE_URL: a page URL Event configured for Web delivery.
Audience expressions
Setaudience to null to make every visitor eligible after a trigger. Otherwise, provide one
condition or a nested group:
AND or OR and can contain conditions or more groups. The limits are:
- At most 5 expression levels.
- At most 20 direct children in one group.
- At most 100 conditions in the complete audience expression.
Condition reference
Numeric comparators are
EQUALS, GREATER_THAN, GREATER_THAN_OR_EQUAL, LESS_THAN, and
LESS_THAN_OR_EQUAL.
Attribute scalar comparison also supports NOT_EQUALS. Text comparison supports CONTAINS,
NOT_CONTAINS, STARTS_WITH, and ENDS_WITH.
Call GET /v2/attributes for valid Attribute keys and authoring value types. Definitions do not
include observed visitor values.
Reference fields have these limits:
- Attribute keys and Group IDs: 1–128 characters.
- Language or locale values: 1–35 characters.
- Session and page-view counts: integers from 1–999.
GROUP requires an existing environment Group ID. Study API V2 does not create or list Groups, so
an integration must already have the stable ID. If your integration does not have it, configure a
different supported condition or contact support@sprig.com.
Delivery delay
delaySeconds is an integer from 0 through 999. Use 0 to present immediately after a qualifying
trigger. A delay can protect a critical flow from interruption, but eligibility can change while the
timer runs.
Validation and compatibility
An in-product survey cannot launch without at least one trigger. The validation endpoint reportsTARGETING_REQUIRED at targeting/triggers when targeting is missing.
The API returns:
INVALID_STUDYwith detailed issues for an invalid expression or unresolved reference.STUDY_NOT_FOUNDwhen targeting is requested for a shareable survey.UNSUPPORTED_TARGETINGwhen existing legacy targeting cannot be represented safely.400 INVALID_VALUEfor a malformed or unquotedIf-Match,412 CONCURRENT_UPDATEfor a stale ETag, or428 CONCURRENT_UPDATEwhenIf-Matchis missing.
UNSUPPORTED_TARGETING; review the
Study in Sprig first.