Create an in-app survey session
Decide whether to show an in-app survey to a signed-in person, and mint the signed embed URL if so. Call it from your backend, never from a browser: a request that carries an Origin header is refused with 403, and cross-origin preflight requests are refused too. (Browser code uses a signed identity token with the in-app SDK instead. See the in-app SDK guide.) It returns 200 for both outcomes. When the person qualifies you get eligible: true, an embedUrl that is valid for one hour, a sessionId and the configured delayMs. Otherwise you get eligible: false and a reason: disabled (survey not active or in-app collection off), cooldown, recently_dismissed, not_sampled, snoozed, already_seen, minimum_age, minimum_sessions, display_limit, or, when the survey has targeting, page_not_targeted, not_targeted or awaiting_trigger. A survey with page rules needs context.url; without it the reason is page_not_targeted. A person who passes the earlier checks gets one recorded session per UTC day, and those count toward minSessions. parentOrigin must be listed in settings.inApp.allowedOrigins, or the call returns 403. The person must exist, be active and belong to accountId, or the call returns 404. Send subject to tie the survey to a deal, ticket, plan or custom record; a record GainTrace can’t link returns 422. Any invalid or malformed body, or an invalid survey id, returns 422. Requires a secret server key (gt_live_). Publishable keys (gt_pub_) return 403.
Scope: write:surveys
Authorizations
Bearer API key. Secret server keys start with gt_live_; client-safe browser keys start with gt_pub_ (write-only, origin-pinned). Create and scope keys in Settings → API Keys.
Path Parameters
The survey's UUID.
Body
Field names follow the code: contactId is a person id and accountId is a company id.
The signed-in person's id in GainTrace.
The id of that person's company. It must match the person.
The exact origin of the page that will show the survey, such as https://app.example.com. It must be listed in the survey's settings.inApp.allowedOrigins.
255test skips eligibility rules and records nothing, so you can preview the survey.
survey, test What the person is doing right now. Send it when the survey has page rules or a trigger under settings.inApp.targeting.
The deal, ticket, plan or custom record this survey asks about. Responses to the embed carry it as their subject. The record must belong to the same Company as the person. The record a response is about: a deal, ticket, plan or custom record. Name it by its GainTrace id, or, for a deal or ticket, by the id it has in your CRM or help desk (externalId, with source when more than one connection holds that id). For a custom record, send the data model's model slug and the record's externalId. The record must exist, must not be archived, and must belong to the same Company as the person.
- Option 1
- Option 2
- Option 3
A language tag such as es or pt-BR. The survey shows in this language when it has a translation for it. It wins over the person's locale or language trait and the browser.
35Response
The session decision.
- Option 1
- Option 2