Thankly SDK for JavaScript
    Preparing search index...

    Interface ThanklyServerApi

    Privileged, server-side calls against the Thankly API.

    interface ThanklyServerApi {
        createExperience: (
            body: CreateExperienceBody,
        ) => Promise<CreateExperienceResponse>;
        deletePlaybook: (playbookId: string) => Promise<void>;
        fetchCatalog: (slug: string) => Promise<Catalog>;
        fetchProduct: (
            slug: string,
            productId: string,
            purchaseContext?: PurchaseContext,
        ) => Promise<CatalogProduct>;
        fetchProducts: (
            slug: string,
            params?: ProductQueryParams,
        ) => Promise<ProductListResponse>;
        getBrandConfig: () => Promise<BrandConfig>;
        getBrandConfigVersions: () => Promise<BrandConfigVersion[]>;
        getCustomerProfile: (
            externalCustomerId: string,
        ) => Promise<CustomerProfile>;
        getEngagementDecision: (
            decisionId: string,
        ) => Promise<EngagementDecisionWidgetsResponse>;
        getPlaybook: (playbookId: string) => Promise<Playbook>;
        getPresignedUrl: (
            contentType: string,
            purpose?: UploadPurpose,
        ) => Promise<PresignedUrlResponse>;
        ingestSignals: (batch: SignalBatch) => Promise<SignalIngestResult>;
        invokeEngagementDecision: (
            externalCustomerId: string,
            playbookId: string,
            options?: {
                callback?: EngagementCallback;
                journeyDay?: number;
                overrides?: EngagementOverrides;
                postalCode?: string;
            },
        ) => Promise<EngagementDecisionResponse>;
        listPlaybooks: () => Promise<Playbook[]>;
        reportOutcome: (
            decisionId: string,
            outcome?: OutcomeReport,
        ) => Promise<OutcomeResult>;
        rollbackBrandConfig: (version: number) => Promise<BrandConfig>;
        setBrandConfig: (config: Record<string, unknown>) => Promise<BrandConfig>;
        uploadFile: (
            presignedResponse: PresignedUrlResponse,
            file: File,
            onProgress?: (percent: number) => void,
            signal?: AbortSignal,
        ) => Promise<void>;
        upsertPlaybook: (playbook: PlaybookBody) => Promise<Playbook>;
        waitForEngagementDecision: (
            decisionId: string,
            options?: { maxRetries?: number; retryIntervalMs?: number },
        ) => Promise<EngagementDecisionWidgetsResponse>;
    }
    Index
    createExperience: (
        body: CreateExperienceBody,
    ) => Promise<CreateExperienceResponse>

    Create a new experience with the specified context and capabilities

    deletePlaybook: (playbookId: string) => Promise<void>

    Soft-delete a playbook (sets active=false).

    fetchCatalog: (slug: string) => Promise<Catalog>

    Fetch catalog metadata

    fetchProduct: (
        slug: string,
        productId: string,
        purchaseContext?: PurchaseContext,
    ) => Promise<CatalogProduct>

    Fetch one product from a catalog

    fetchProducts: (
        slug: string,
        params?: ProductQueryParams,
    ) => Promise<ProductListResponse>

    Fetch products from a catalog

    getBrandConfig: () => Promise<BrandConfig>

    Fetch the org's current active brand config.

    getBrandConfigVersions: () => Promise<BrandConfigVersion[]>

    List the org's brand config version history, newest first.

    getCustomerProfile: (externalCustomerId: string) => Promise<CustomerProfile>

    Return the L2 CustomerProfile for a customer, scoped to the caller's org.

    getEngagementDecision: (
        decisionId: string,
    ) => Promise<EngagementDecisionWidgetsResponse>

    Poll one engagement decision's assembled widget set (the decision widget + its enrichment widgets), scoped to decisionId (the decision_id returned by invokeEngagementDecision). status is PENDING until every widget is terminal.

    getPlaybook: (playbookId: string) => Promise<Playbook>

    Fetch a single playbook by its partner-chosen playbook_id.

    getPresignedUrl: (
        contentType: string,
        purpose?: UploadPurpose,
    ) => Promise<PresignedUrlResponse>

    Get a presigned URL for file upload

    ingestSignals: (batch: SignalBatch) => Promise<SignalIngestResult>

    Ingest a batch of behavioural signals for the caller's org. Writes L1 customer_signals and re-derives L2 customer_profiles incrementally.

    invokeEngagementDecision: (
        externalCustomerId: string,
        playbookId: string,
        options?: {
            callback?: EngagementCallback;
            journeyDay?: number;
            overrides?: EngagementOverrides;
            postalCode?: string;
        },
    ) => Promise<EngagementDecisionResponse>

    Invoke an engagement decision for a customer against a named playbook. Returns 202 with status=PENDING (async) or status=COMPLETED (cache hit). On COMPLETED, widget_data is populated and polling can be skipped.

    listPlaybooks: () => Promise<Playbook[]>

    List active playbooks for the caller's org.

    reportOutcome: (
        decisionId: string,
        outcome?: OutcomeReport,
    ) => Promise<OutcomeResult>

    Report a delivery outcome against the decision_id returned by invokeEngagementDecision. Updates L2 features and stores an attribution row.

    rollbackBrandConfig: (version: number) => Promise<BrandConfig>

    Re-publish a prior brand config version as the new head.

    setBrandConfig: (config: Record<string, unknown>) => Promise<BrandConfig>

    Create or full-replace the org's brand config (bumps version).

    uploadFile: (
        presignedResponse: PresignedUrlResponse,
        file: File,
        onProgress?: (percent: number) => void,
        signal?: AbortSignal,
    ) => Promise<void>

    Upload a file using a presigned URL response

    upsertPlaybook: (playbook: PlaybookBody) => Promise<Playbook>

    Create or fully replace a playbook for the caller's org. If no playbook with this playbook_id exists it is created; otherwise the current version is archived and all fields are replaced.

    waitForEngagementDecision: (
        decisionId: string,
        options?: { maxRetries?: number; retryIntervalMs?: number },
    ) => Promise<EngagementDecisionWidgetsResponse>

    Poll getEngagementDecision until the decision's widget set has settled: every widget is terminal AND (if the decision planned enrichment) the enrichment widgets have appeared. Handles the spawn gap — the decision widget can be COMPLETED before the continuation has created the enrichment sessions, so a bare "until not PENDING" would return too early. Falls back to the last response after maxRetries (e.g. a planned block that dropped on spawn), so it never hangs.