- List (
/package-builder) — existing packages, optional merge. - Create wizard (
/package-builder/create) — multi-step form. - Results (
/package-builder/results/:packageId) — status polling, evaluation, exports.
Prerequisites
- An authenticated user with
Permissions.backhaul. X-Preferred-Partner-Idset.
1. List
Call chain
On mount:| # | Method | Path | Purpose |
|---|---|---|---|
| 1 | GET | /package_builder/packages/ | All packages for the partner. |
Response
INITIALIZING, INPROGRESS, DONE, FAILED, EXPIRED.
Actions
| Action | Endpoint |
|---|---|
| Open a package | navigate to /package-builder/results/:id |
| Merge selected | POST /package_builder/packages/merge?packages_ids=A&packages_ids=B (repeated query params, no body) |
| Create | navigate to /package-builder/create |
2. Create wizard
The wizard has three steps: Select Events → Targeting + Customer Segmentation → Preview.Call chain
On mount: nothing — wizard state is hydrated fromlocalStorage["packageBuilderState"].
During the wizard:
| Step | Method | Path | Purpose |
|---|---|---|---|
| Event search | GET | /events?search=&page=&since= | Autocomplete picker. |
| (optional) Customer NL prompt | GET | /nlq/ids_from_nl_description?description=&result_type=&language= | Resolve a natural-language customer filter into IDs. |
| Method | Path | Purpose |
|---|---|---|
| POST | /package_builder/packages | Create the package (async). |
Create payload
num_packages: 3, n_top_events: 3. Don’t
copy this if your UX gives the user real control.
Response:
/package-builder/results/pkg_555. The package is in
INITIALIZING state on creation.
3. Results
Call chain
On mount with:packageId:
| # | Method | Path | Purpose |
|---|---|---|---|
| 1 | GET | /package_builder/packages/{id} | Package payload (status, content, events, …). |
| 2 | GET | /package_builder/packages/{id}/backhaul_evaluation_details | Current attribution settings. |
| 3 | GET | /package_builder/packages/{id}/backhaul_evaluation | Evaluation results. |
Status polling
If the package’sstatus is INITIALIZING or INPROGRESS, poll:
setTimeout chain.
Package payload
Evaluation (Backhaul attribution)
evaluationReloadKey counter to invalidate.
See Attribution for the model semantics.
Per-cluster actions
| Action | Endpoint |
|---|---|
| Download CSV | GET /package_builder/packages/{id}/{tc}/customer_list — blob response, trigger a.download client-side. |
| Export to CRM | Routed via your data-integrations layer. Payload: { crm_name, secret_id, container_name, packageId, tc }. |
| Regenerate (EXPIRED only) | POST /package_builder/packages/{id}/regenerate — re-enters INITIALIZING. |
Reference implementation — CSV download
tc is URL-encoded; do not slugify it for this endpoint.
Reference implementation — Results page
Gotchas
Polling without unmount cancellation
Polling without unmount cancellation
The reference webapp’s bug, not a feature. Gate your loop on a mounted
flag — see the implementation above.
merge_id encodes constituent packages
merge_id encodes constituent packages
A
merge_id of "123_456_789" means this package was merged from
packages 123, 456, 789. Split client-side; no separate API call.`tc` in customer_list path is raw, not slugified
`tc` in customer_list path is raw, not slugified
URL-encode but do not slugify. The campaign-side endpoints have a
different convention — see IDs and Hierarchy.
`evaluationReloadKey` is a manual cache buster
`evaluationReloadKey` is a manual cache buster
The reference webapp increments a counter to re-run the evaluation
fetches. If you use React Query or SWR, invalidate the query keys
instead.
Demo accounts short-circuit to mock data
Demo accounts short-circuit to mock data
If your partner is on a demo account, the reference webapp skips the
API entirely and renders
src/mock/packageBuilderResultsV2.json.
Replicate only if you need demo parity.Reducer key is `previousPackages.message`, not `.items`
Reducer key is `previousPackages.message`, not `.items`
Legacy naming in the reference webapp. Doesn’t matter for your client
— but if you read the source for reference, don’t be confused.
Related
- Concepts: Campaigns and Packages.
- Attribution — Backhaul models.
- File uploads cookbook — for CSV download patterns.
- Polling long-running jobs.