@proveanything/smartlinks 2.1.41 → 2.1.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/README.md +754 -754
  2. package/dist/README.md +573 -573
  3. package/dist/adminCardsView.js +55 -55
  4. package/dist/adminViews.js +1 -1
  5. package/dist/api/index.d.ts +1 -0
  6. package/dist/api/index.js +1 -0
  7. package/dist/api/product.d.ts +2 -1
  8. package/dist/api/product.js +2 -1
  9. package/dist/api/subscriptions.d.ts +97 -0
  10. package/dist/api/subscriptions.js +178 -0
  11. package/dist/baseline.css +194 -194
  12. package/dist/docs/API_SUMMARY.md +1135 -832
  13. package/dist/docs/admin-cards.md +189 -189
  14. package/dist/docs/admin-views.md +9 -4
  15. package/dist/docs/agent-tools.md +156 -156
  16. package/dist/docs/ai-tools-and-skills.md +180 -180
  17. package/dist/docs/ai.md +1721 -1721
  18. package/dist/docs/analytics.md +39 -39
  19. package/dist/docs/app-data-storage.md +277 -277
  20. package/dist/docs/app-docs.md +73 -73
  21. package/dist/docs/app-manifest.md +852 -852
  22. package/dist/docs/app-records-pattern.md +388 -388
  23. package/dist/docs/appConfig.md +550 -550
  24. package/dist/docs/assistant-apps.md +172 -172
  25. package/dist/docs/assistant-context.md +119 -119
  26. package/dist/docs/bookings.md +442 -442
  27. package/dist/docs/comms.md +686 -686
  28. package/dist/docs/connectors.md +340 -340
  29. package/dist/docs/css-baseline.md +133 -133
  30. package/dist/docs/customer-guide.md +70 -70
  31. package/dist/docs/deploying-apps.md +340 -340
  32. package/dist/docs/entitlements.md +90 -90
  33. package/dist/docs/files.md +69 -69
  34. package/dist/docs/host-dependency-contract.md +210 -210
  35. package/dist/docs/i18n.md +9 -0
  36. package/dist/docs/integrations.md +322 -322
  37. package/dist/docs/interactions.md +545 -545
  38. package/dist/docs/item-context.md +181 -181
  39. package/dist/docs/knowledge.md +102 -102
  40. package/dist/docs/lots.md +111 -111
  41. package/dist/docs/loyalty.md +352 -352
  42. package/dist/docs/members.md +183 -182
  43. package/dist/docs/memberships.md +149 -0
  44. package/dist/docs/mobile-admin-container.md +693 -693
  45. package/dist/docs/operations.md +281 -281
  46. package/dist/docs/overview.md +483 -482
  47. package/dist/docs/proof-comms-triggers.md +142 -142
  48. package/dist/docs/proof-ownership-transfer.md +155 -155
  49. package/dist/docs/proof-product-data-scoping.md +462 -462
  50. package/dist/docs/proof-share-grants.md +305 -305
  51. package/dist/docs/realtime.md +138 -138
  52. package/dist/docs/records-admin-pattern.md +304 -304
  53. package/dist/docs/server-functions.md +1 -0
  54. package/dist/docs/standard-query.md +187 -187
  55. package/dist/docs/tag-codes.md +97 -97
  56. package/dist/docs/theme-tokens.md +252 -252
  57. package/dist/docs/wallet-passes.md +107 -107
  58. package/dist/docs/websites.md +123 -123
  59. package/dist/i18n.d.ts +6 -0
  60. package/dist/i18n.js +10 -0
  61. package/dist/openapi.yaml +426 -3
  62. package/dist/theme-boot.js +82 -78
  63. package/dist/theme.css +75 -75
  64. package/dist/types/appManifest.d.ts +32 -0
  65. package/dist/types/index.d.ts +1 -0
  66. package/dist/types/index.js +1 -0
  67. package/dist/types/subscriptions.d.ts +195 -0
  68. package/dist/types/subscriptions.js +9 -0
  69. package/docs/API_SUMMARY.md +1135 -832
  70. package/docs/admin-cards.md +189 -189
  71. package/docs/admin-views.md +9 -4
  72. package/docs/agent-tools.md +156 -156
  73. package/docs/ai-tools-and-skills.md +180 -180
  74. package/docs/ai.md +1721 -1721
  75. package/docs/analytics.md +39 -39
  76. package/docs/app-data-storage.md +277 -277
  77. package/docs/app-docs.md +73 -73
  78. package/docs/app-manifest.md +852 -852
  79. package/docs/app-records-pattern.md +388 -388
  80. package/docs/appConfig.md +550 -550
  81. package/docs/assistant-apps.md +172 -172
  82. package/docs/assistant-context.md +119 -119
  83. package/docs/bookings.md +442 -442
  84. package/docs/comms.md +686 -686
  85. package/docs/connectors.md +340 -340
  86. package/docs/css-baseline.md +133 -133
  87. package/docs/customer-guide.md +70 -70
  88. package/docs/deploying-apps.md +340 -340
  89. package/docs/entitlements.md +90 -90
  90. package/docs/files.md +69 -69
  91. package/docs/host-dependency-contract.md +210 -210
  92. package/docs/i18n.md +9 -0
  93. package/docs/integrations.md +322 -322
  94. package/docs/interactions.md +545 -545
  95. package/docs/item-context.md +181 -181
  96. package/docs/knowledge.md +102 -102
  97. package/docs/lots.md +111 -111
  98. package/docs/loyalty.md +352 -352
  99. package/docs/members.md +183 -182
  100. package/docs/memberships.md +149 -0
  101. package/docs/mobile-admin-container.md +693 -693
  102. package/docs/operations.md +281 -281
  103. package/docs/overview.md +483 -482
  104. package/docs/proof-comms-triggers.md +142 -142
  105. package/docs/proof-ownership-transfer.md +155 -155
  106. package/docs/proof-product-data-scoping.md +462 -462
  107. package/docs/proof-share-grants.md +305 -305
  108. package/docs/realtime.md +138 -138
  109. package/docs/server-functions.md +1 -0
  110. package/docs/standard-query.md +187 -187
  111. package/docs/tag-codes.md +97 -97
  112. package/docs/theme-lookbook.v1.json +120 -120
  113. package/docs/theme-tokens.md +252 -252
  114. package/docs/wallet-passes.md +107 -107
  115. package/docs/websites.md +123 -123
  116. package/openapi.yaml +426 -3
  117. package/package.json +87 -87
  118. package/scripts/headless-check.mjs +87 -87
  119. package/scripts/lib/bare-imports.mjs +57 -57
  120. package/scripts/lib/keyed-app-data.mjs +21 -21
  121. package/scripts/publish.mjs +272 -272
  122. package/scripts/register-release.mjs +91 -91
@@ -1,6 +1,6 @@
1
1
  # Smartlinks API Summary
2
2
 
3
- Version: 2.1.41 | Generated: 2026-11-22T10:02:53.863Z
3
+ Version: 2.1.43 | Generated: 2026-11-22T10:27:00.761Z
4
4
 
5
5
  This is a concise summary of all available API functions and types.
6
6
 
@@ -169,6 +169,7 @@ The Smartlinks SDK is organized into the following namespaces:
169
169
  - **research** - Functions for research operations
170
170
  - **secrets** - Functions for secrets operations
171
171
  - **shop** - Functions for shop operations
172
+ - **subscriptions** - Functions for subscriptions operations
172
173
  - **tagCodes** - Functions for tagCodes operations
173
174
  - **tags** - Functions for tags operations
174
175
  - **template** - Functions for template operations
@@ -2887,6 +2888,17 @@ interface ServerFunctionSl {
2887
2888
  };
2888
2889
  interactions: { record(event: ServerFunctionInteractionEvent): Promise<{ eventId: string }> };
2889
2890
  messages: { send(input: ServerFunctionMessage): Promise<ServerFunctionMessageResult> };
2891
+ subscriptions: {
2892
+ plans(): Promise<Array<import('./subscriptions').Plan & { prices: import('./subscriptions').PlanPrice[] }>>;
2893
+ list(params?: import('./subscriptions').SubscriptionListParams): Promise<import('./subscriptions').SubscriptionPage<import('./subscriptions').Membership>>;
2894
+ get(subscriptionId: string): Promise<import('./subscriptions').Membership | null>;
2895
+ mine(): Promise<import('./subscriptions').Membership[]>;
2896
+ memberOf(who?: { contactId?: string; userId?: string }): Promise<import('./subscriptions').MembershipStatus>;
2897
+ grant(input: import('./subscriptions').SubscriptionGrantInput): Promise<import('./subscriptions').Membership>;
2898
+ end(subscriptionId: string, opts?: { reason?: string }): Promise<import('./subscriptions').Membership>;
2899
+ cancel(subscriptionId: string, opts?: { atPeriodEnd?: boolean }): Promise<import('./subscriptions').Membership>;
2900
+ reapply(who: { contactId?: string; userId?: string }): Promise<{ level?: string | null; groups: string[] }>;
2901
+ };
2890
2902
  tools: { run<T = any>(name: string, args?: Record<string, any>): Promise<T> };
2891
2903
  assets: ServerFunctionAssets;
2892
2904
  ai: ServerFunctionAi;
@@ -7022,418 +7034,418 @@ interface TransactionalSendError {
7022
7034
 
7023
7035
  **EmailAttachmentSpec** = ``
7024
7036
 
7025
- **TransactionalSendResult** = `// src/types/comms.ts
7026
- // Communication and notification types for the Smartlinks API
7027
- import type { IdField } from './common'
7028
- import type { BroadcastChannel } from './broadcasts'
7029
-
7030
- /**
7031
- * Target subject for notifications (product, collection, etc.)
7032
- */
7033
- export interface NotificationSubjectTarget {
7034
- /** Type of target entity */
7035
- type: 'product' | 'collection' | 'user' | 'batch' | 'proof'
7036
- /** ID of the target entity */
7037
- id: string
7038
- }
7039
-
7040
-
7041
- // Analytics & logging (communication events)
7042
-
7043
- export interface CommunicationEvent {
7044
- orgId: string
7045
- broadcastId?: string
7046
- journeyId?: string
7047
- userId?: string
7048
- contactId?: string
7049
- channel?: string
7050
- timestamp: string
7051
- eventType: string
7052
- outcome?: string | null
7053
- templateId?: string | null
7054
- [k: string]: any
7055
- }
7056
-
7057
- export interface CommsQueryByUser {
7058
- userId?: string
7059
- contactId?: string
7060
- from?: string
7061
- to?: string
7062
- limit?: number
7063
- }
7064
-
7065
- export type RecipientId = string
7066
- export interface RecipientWithOutcome { id: string; outcome: string }
7067
-
7068
- export interface CommsRecipientIdsQuery {
7069
- broadcastId?: string
7070
- journeyId?: string
7071
- journeyStepId?: string
7072
- idField?: IdField
7073
- from?: string
7074
- to?: string
7075
- limit?: number
7076
- }
7077
-
7078
- export interface CommsRecipientsWithoutActionQuery {
7079
- broadcastId?: string
7080
- journeyId?: string
7081
- actionId?: string
7082
- appId?: string
7083
- idField?: IdField
7084
- from?: string
7085
- to?: string
7086
- limit?: number
7087
- }
7088
-
7089
- export interface CommsRecipientsWithActionQuery {
7090
- broadcastId?: string
7091
- journeyId?: string
7092
- actionId?: string
7093
- appId?: string
7094
- outcome?: string
7095
- idField?: IdField
7096
- includeOutcome?: boolean
7097
- from?: string
7098
- to?: string
7099
- limit?: number
7100
- }
7101
-
7102
- export interface LogCommunicationEventBody {
7103
- broadcastId?: string
7104
- journeyId?: string
7105
- userId?: string
7106
- contactId?: string
7107
- channel?: string
7108
- eventType: string
7109
- outcome?: string
7110
- templateId?: string
7111
- timestamp?: string
7112
- [k: string]: any
7113
- }
7114
-
7115
- export interface LogBulkCommunicationEventsBody {
7116
- params: { broadcastId?: string; journeyId?: string; [k: string]: any }
7117
- ids: string[]
7118
- idField?: IdField
7119
- }
7120
-
7121
- export interface AppendResult { success: true }
7122
- export interface AppendBulkResult { success: true; count: number }
7123
-
7124
- // Common recipient type used by segments and broadcasts
7125
- export type Recipient = import('./contact').Contact
7126
-
7127
- // Shared page response shape for recipient listings
7128
- export interface RecipientsPage {
7129
- items: Recipient[]
7130
- total: number
7131
- limit: number
7132
- offset: number
7133
- note?: string
7134
- }
7135
-
7136
- // Web Push (public client registration)
7137
-
7138
- export interface PushSubscriptionJSON {
7139
- endpoint: string
7140
- keys?: {
7141
- p256dh?: string
7142
- auth?: string
7143
- }
7144
- }
7145
-
7146
- export interface PushVapidResponse { publicKey: string }
7147
- export interface PushSubscribeResponse { ok: true; id: string }
7148
-
7149
- // Public: register a push contact method
7150
- export interface RegisterPushMethodRequest {
7151
- /** Optional: defaults to the signed-in user's own contact. Only collection admins may name another contact. */
7152
- contactId?: string
7153
- endpoint: string
7154
- keys: { p256dh: string; auth: string }
7155
- meta?: Record<string, any>
7156
- }
7157
-
7158
- // Admin Comms Settings
7159
-
7160
- export interface CommsSettings {
7161
- unsub?: {
7162
- requireToken?: boolean
7163
- /** Secret for token generation; omitted unless includeSecret=true */
7164
- secret?: string
7165
- /** Convenience flag indicating a secret is set (masked responses) */
7166
- hasSecret?: boolean
7167
- }
7168
- /** Map of topic keys to topic config */
7169
- topics?: Record<string, TopicConfig>
7170
- [k: string]: any
7171
- }
7172
-
7173
- export interface TopicConfig {
7174
- label?: string
7175
- description?: string
7176
- /** Optional UI-only grouping labels */
7177
- labels?: string[]
7178
- /** Classification for UI and default policy guidance */
7179
- classification?: 'transactional' | 'marketing'
7180
- defaults?: {
7181
- channels?: Partial<Record<BroadcastChannel, boolean>>
7182
- topics?: Record<string, boolean | undefined>
7183
- /** Default consent policy when explicit preferences are absent */
7184
- policy?: 'opt-in' | 'opt-out'
7185
- /** Per-channel default policy (overrides policy when present) */
7186
- byChannel?: Partial<Record<BroadcastChannel, 'opt-in' | 'opt-out'>>
7187
- }
7188
- rules?: {
7189
- allowChannels?: BroadcastChannel[]
7190
- allowUnsubscribe?: boolean
7191
- required?: boolean
7192
- }
7193
- [k: string]: any
7194
- }
7195
-
7196
- export interface CommsSettingsGetResponse {
7197
- ok: true
7198
- settings: CommsSettings
7199
- }
7200
-
7201
- export type CommsSettingsPatchBody = Partial<CommsSettings>
7202
-
7203
- // Public types listing (array form for public API)
7204
- export interface CommsPublicTopicsResponse { ok: true; topics: Record<string, TopicConfig> }
7205
-
7206
- export interface UnsubscribeQuery {
7207
- /** Optional: defaults to the signed-in user's own contact. Only collection admins may name another contact. */
7208
- contactId?: string
7209
- topic?: string
7210
- channel?: BroadcastChannel
7211
- token?: string
7212
- }
7213
-
7214
- export interface UnsubscribeResponse { ok: true; applied?: { channels?: Record<string, boolean>; topics?: Record<string, boolean> } }
7215
-
7216
- // Public sign-up (double opt-in)
7217
- export interface CommsSignupRequest {
7218
- email: string
7219
- /**
7220
- * Required: YOUR app's confirmation email — a template in this collection (SL.template) whose body
7221
- * uses `{{ action_url }}` for the confirm link (`{{ topics }}` lists what they signed up for). The
7222
- * platform sends no default sign-up email.
7223
- */
7224
- templateId: string
7225
- /** Topic ids from the collection's comm settings (e.g. ["newsletter"]). */
7226
- topics?: string[]
7227
- firstName?: string
7228
- /**
7229
- * The form's other answers — firstName/lastName/displayName/company/locale/timezone and
7230
- * `customFields`. Applied to the contact when the address is confirmed, and only where the contact
7231
- * has no value yet (never overwritten). Small: ~2 KB.
7232
- */
7233
- fields?: { firstName?: string; lastName?: string; displayName?: string; company?: string; locale?: string; timezone?: string; customFields?: Record<string, string | number | boolean> }
7234
- /** Your app id, recorded with the sent email. */
7235
- appId?: string
7236
- }
7237
- export interface CommsSignupResponse { ok: true; pending: true }
7238
-
7239
- // Public consent/preferences/subscribe
7240
- export type ConsentChannels = Partial<Record<BroadcastChannel, boolean>>
7241
- type SubjectType = import('./contact').SubjectType
7242
-
7243
- export interface CommsConsentUpsertRequest {
7244
- /** Optional: defaults to the signed-in user's own contact. Only collection admins may name another contact. */
7245
- contactId?: string
7246
- channels?: ConsentChannels
7247
- topics?: Record<string, boolean>
7248
- topicsByChannel?: Partial<Record<BroadcastChannel, Record<string, boolean>>>
7249
- }
7250
-
7251
- export interface CommsPreferencesUpsertRequest {
7252
- /** Optional: defaults to the signed-in user's own contact. Only collection admins may name another contact. */
7253
- contactId?: string
7254
- subject?: { type: SubjectType; id: string; productId?: string }
7255
- channels?: ConsentChannels
7256
- topics?: Record<string, boolean>
7257
- topicsByChannel?: Partial<Record<BroadcastChannel, Record<string, boolean>>>
7258
- }
7259
-
7260
- export interface CommsSubscribeRequest {
7261
- /** Optional: defaults to the signed-in user's own contact. Only collection admins may name another contact. */
7262
- contactId?: string
7263
- subject: { type: SubjectType; id: string; productId?: string }
7264
- subscribe: boolean
7265
- source?: string
7266
- }
7267
- export interface CommsSubscribeResponse { ok: true; subscriptionId: string }
7268
-
7269
- export interface CommsSubscriptionCheckQuery {
7270
- /** Optional: defaults to the signed-in user's own contact. Only collection admins may name another contact. */
7271
- contactId?: string
7272
- subjectType: SubjectType
7273
- subjectId: string
7274
- productId?: string
7275
- }
7276
- export interface CommsSubscriptionCheckResponse { ok: true; subscribed: boolean }
7277
-
7278
- export interface CommsListMethodsQuery {
7279
- /** Optional: defaults to the signed-in user's own contact. Only collection admins may name another contact. */
7280
- contactId?: string
7281
- type?: BroadcastChannel
7282
- }
7283
- export interface CommsListMethodsResponse { ok: true; methods: import('./contact').CommMethod[] }
7284
-
7285
- export interface RegisterEmailMethodRequest { contactId?: string; email?: string; userId?: string }
7286
- export interface RegisterSmsMethodRequest { contactId?: string; phone?: string; userId?: string }
7287
- export interface RegisterMethodResponse { ok: true; contactId: string }
7288
-
7289
- export interface SubscriptionsResolveRequest {
7290
- subject: { type: SubjectType; id: string; productId?: string }
7291
- hints: { userId?: string; pushEndpoint?: string; email?: string }
7292
- }
7293
- export interface SubscriptionsResolveResponse {
7294
- ok: true
7295
- subject: { type: SubjectType; id: string; productId?: string }
7296
- contacts: Array<{
7297
- contactId: string
7298
- subscribed: boolean
7299
- channels?: Partial<Record<BroadcastChannel, boolean>>
7300
- }>
7301
- anySubscribed: boolean
7302
- anyMethods: boolean
7303
- }
7304
-
7305
- // Transactional send (single-contact, single-message)
7306
-
7307
- /**
7308
- * Send a single message to one contact using a template.
7309
- * No broadcast record is created; the send is logged directly to the
7310
- * contact's communication history with sourceType: 'transactional'.
7311
- *
7312
- * POST /admin/collection/:collectionId/comm/send
7313
- */
7314
- export interface TransactionalSendRequest {
7315
- /** CRM contact UUID */
7316
- contactId: string
7317
- /** A saved template's id. Give this or `message`. */
7318
- templateId?: string
7319
- /**
7320
- * A typed message instead of a template: plain text, Liquid allowed (`{{ contact.firstName }}`).
7321
- * `sms` is the shorter text for SMS and WhatsApp (defaults to `body`).
7322
- */
7323
- message?: TypedMessage
7324
- /**
7325
- * Channel to send on. Defaults to 'preferred', which auto-selects the
7326
- * contact's best available channel respecting consent, suppression, and
7327
- * template availability.
7328
- */
7329
- channel?: 'email' | 'sms' | 'whatsapp' | 'push' | 'wallet' | 'preferred'
7330
- /** Extra Liquid variables merged into the top-level render context */
7331
- props?: Record<string, unknown>
7332
- /** Context objects to hydrate into the Liquid template */
7333
- include?: {
7334
- /** Hydrate {{ collection }}. Default: true */
7335
- collection?: boolean
7336
- /** Hydrate {{ product }} from this product ID */
7337
- productId?: string
7338
- /** Hydrate {{ proof }} (requires productId) */
7339
- proofId?: string
7340
- /** Hydrate {{ user }} from contact.userId */
7341
- user?: boolean
7342
- /** Hydrate {{ appCase }} from this case UUID */
7343
- appCase?: string
7344
- /** Hydrate {{ appThread }} from this thread UUID */
7345
- appThread?: string
7346
- /** Hydrate {{ appRecord }} from this record UUID */
7347
- appRecord?: string
7348
- }
7349
- /** Arbitrary label stored on the comms-events row (e.g. 'warranty-step-2') */
7350
- ref?: string
7351
- /** App context stored on the comms-events row */
7352
- appId?: string
7353
- /**
7354
- * What the message is about: the record it was sent for and the admin screen that shows it, so it is a
7355
- * link in Messages, on the contact's Activity, and on the conversation a reply opens. `appId` defaults
7356
- * to the sending app.
7357
- */
7358
- about?: MessageAbout
7359
- /**
7360
- * `'service'` (a confirmation, a reminder, an update): an asked-for channel the person turned off, or a
7361
- * suppressed email, is refused (`transactional.opted_out`). Marketing goes out as a campaign.
7362
- */
7363
- category?: 'service'
7364
- /**
7365
- * Files to attach (email only; at most 5, 10 MB in all). What can't be made is left out and listed in
7366
- * `attachmentsLeftOut` — the email still goes.
7367
- */
7368
- attach?: EmailAttachmentSpec[]
7369
- }
7370
-
7371
- /**
7372
- * One file for an email:
7373
- * - `'calendar'` — the booking's `.ics` calendar invite (needs `include.booking` and `appId`)
7374
- * - `{ asset }` — a file uploaded to this collection's assets
7375
- * - `{ function }` — the app's (`appId`) own server function makes it (see server-functions.md, "Making an email attachment")
7376
- * - `{ filename, contentType, content }` — a file you made, base64 (PDF, Office documents, images, text, CSV, calendar)
7377
- * - `{ filename, file }` — a private file you made (e.g. `pdf.create` with `return: 'signedUrl'`)
7378
- */
7379
- export type EmailAttachmentSpec =
7380
- | 'calendar'
7381
- | { asset: string }
7382
- | { function: string }
7383
- | { filename: string; contentType: string; content: string }
7384
- | { filename: string; contentType?: string; file: string }
7385
-
7386
- export interface TransactionalSendResponse {
7387
- ok: true
7388
- /** The channel the message was actually sent on */
7389
- channel: 'email' | 'sms' | 'whatsapp' | 'push' | 'wallet'
7390
- /** Provider message ID (email/SMS/WhatsApp); absent for push/wallet */
7391
- messageId?: string
7392
- /** Attachments that couldn't be made, and why (the email went without them) */
7393
- attachmentsLeftOut?: string[]
7394
- }
7395
-
7396
- /** A message written there and then rather than a saved template. */
7397
- export interface TypedMessage {
7398
- subject?: string
7399
- body: string
7400
- /** The shorter text for SMS and WhatsApp (defaults to `body`). */
7401
- sms?: string
7402
- }
7403
-
7404
- /**
7405
- * What a message is about (docs/comms.md, "What a message is about"). Ids only, never content.
7406
- * `view` and `params` name one of the app's admin views (manifest `adminViews`, docs/admin-views.md).
7407
- */
7408
- export interface MessageAbout {
7409
- appId?: string
7410
- /** What kind of record: `'booking'`, `'entry'`, `'case'`. */
7411
- type: string
7412
- id: string
7413
- view?: string
7414
- params?: Record<string, string>
7415
- /** A short label to show without looking the record up: `'Sat 3pm, table for 4'`. */
7416
- label?: string
7417
- }
7418
-
7419
- export interface TransactionalSendError {
7420
- ok: false
7421
- /**
7422
- * Error code. Known values:
7423
- * - `transactional.contact_not_found`
7424
- * - `transactional.template_not_found`
7425
- * - `transactional.no_channel_available`
7426
- * - `transactional.email_missing`
7427
- * - `transactional.phone_missing`
7428
- * - `transactional.whatsapp_missing`
7429
- * - `transactional.no_push_methods`
7430
- * - `transactional.no_wallet_passes` (`channel: 'wallet'`: the person has no wallet passes from this app)
7431
- * - `transactional.opted_out` (category `'service'`: the person turned that channel off, or the email is suppressed)
7432
- * - `transactional.template_or_message` / `transactional.message_invalid` / `transactional.about_invalid`
7433
- */
7434
- error: string
7435
- }
7436
-
7037
+ **TransactionalSendResult** = `// src/types/comms.ts
7038
+ // Communication and notification types for the Smartlinks API
7039
+ import type { IdField } from './common'
7040
+ import type { BroadcastChannel } from './broadcasts'
7041
+
7042
+ /**
7043
+ * Target subject for notifications (product, collection, etc.)
7044
+ */
7045
+ export interface NotificationSubjectTarget {
7046
+ /** Type of target entity */
7047
+ type: 'product' | 'collection' | 'user' | 'batch' | 'proof'
7048
+ /** ID of the target entity */
7049
+ id: string
7050
+ }
7051
+
7052
+
7053
+ // Analytics & logging (communication events)
7054
+
7055
+ export interface CommunicationEvent {
7056
+ orgId: string
7057
+ broadcastId?: string
7058
+ journeyId?: string
7059
+ userId?: string
7060
+ contactId?: string
7061
+ channel?: string
7062
+ timestamp: string
7063
+ eventType: string
7064
+ outcome?: string | null
7065
+ templateId?: string | null
7066
+ [k: string]: any
7067
+ }
7068
+
7069
+ export interface CommsQueryByUser {
7070
+ userId?: string
7071
+ contactId?: string
7072
+ from?: string
7073
+ to?: string
7074
+ limit?: number
7075
+ }
7076
+
7077
+ export type RecipientId = string
7078
+ export interface RecipientWithOutcome { id: string; outcome: string }
7079
+
7080
+ export interface CommsRecipientIdsQuery {
7081
+ broadcastId?: string
7082
+ journeyId?: string
7083
+ journeyStepId?: string
7084
+ idField?: IdField
7085
+ from?: string
7086
+ to?: string
7087
+ limit?: number
7088
+ }
7089
+
7090
+ export interface CommsRecipientsWithoutActionQuery {
7091
+ broadcastId?: string
7092
+ journeyId?: string
7093
+ actionId?: string
7094
+ appId?: string
7095
+ idField?: IdField
7096
+ from?: string
7097
+ to?: string
7098
+ limit?: number
7099
+ }
7100
+
7101
+ export interface CommsRecipientsWithActionQuery {
7102
+ broadcastId?: string
7103
+ journeyId?: string
7104
+ actionId?: string
7105
+ appId?: string
7106
+ outcome?: string
7107
+ idField?: IdField
7108
+ includeOutcome?: boolean
7109
+ from?: string
7110
+ to?: string
7111
+ limit?: number
7112
+ }
7113
+
7114
+ export interface LogCommunicationEventBody {
7115
+ broadcastId?: string
7116
+ journeyId?: string
7117
+ userId?: string
7118
+ contactId?: string
7119
+ channel?: string
7120
+ eventType: string
7121
+ outcome?: string
7122
+ templateId?: string
7123
+ timestamp?: string
7124
+ [k: string]: any
7125
+ }
7126
+
7127
+ export interface LogBulkCommunicationEventsBody {
7128
+ params: { broadcastId?: string; journeyId?: string; [k: string]: any }
7129
+ ids: string[]
7130
+ idField?: IdField
7131
+ }
7132
+
7133
+ export interface AppendResult { success: true }
7134
+ export interface AppendBulkResult { success: true; count: number }
7135
+
7136
+ // Common recipient type used by segments and broadcasts
7137
+ export type Recipient = import('./contact').Contact
7138
+
7139
+ // Shared page response shape for recipient listings
7140
+ export interface RecipientsPage {
7141
+ items: Recipient[]
7142
+ total: number
7143
+ limit: number
7144
+ offset: number
7145
+ note?: string
7146
+ }
7147
+
7148
+ // Web Push (public client registration)
7149
+
7150
+ export interface PushSubscriptionJSON {
7151
+ endpoint: string
7152
+ keys?: {
7153
+ p256dh?: string
7154
+ auth?: string
7155
+ }
7156
+ }
7157
+
7158
+ export interface PushVapidResponse { publicKey: string }
7159
+ export interface PushSubscribeResponse { ok: true; id: string }
7160
+
7161
+ // Public: register a push contact method
7162
+ export interface RegisterPushMethodRequest {
7163
+ /** Optional: defaults to the signed-in user's own contact. Only collection admins may name another contact. */
7164
+ contactId?: string
7165
+ endpoint: string
7166
+ keys: { p256dh: string; auth: string }
7167
+ meta?: Record<string, any>
7168
+ }
7169
+
7170
+ // Admin Comms Settings
7171
+
7172
+ export interface CommsSettings {
7173
+ unsub?: {
7174
+ requireToken?: boolean
7175
+ /** Secret for token generation; omitted unless includeSecret=true */
7176
+ secret?: string
7177
+ /** Convenience flag indicating a secret is set (masked responses) */
7178
+ hasSecret?: boolean
7179
+ }
7180
+ /** Map of topic keys to topic config */
7181
+ topics?: Record<string, TopicConfig>
7182
+ [k: string]: any
7183
+ }
7184
+
7185
+ export interface TopicConfig {
7186
+ label?: string
7187
+ description?: string
7188
+ /** Optional UI-only grouping labels */
7189
+ labels?: string[]
7190
+ /** Classification for UI and default policy guidance */
7191
+ classification?: 'transactional' | 'marketing'
7192
+ defaults?: {
7193
+ channels?: Partial<Record<BroadcastChannel, boolean>>
7194
+ topics?: Record<string, boolean | undefined>
7195
+ /** Default consent policy when explicit preferences are absent */
7196
+ policy?: 'opt-in' | 'opt-out'
7197
+ /** Per-channel default policy (overrides policy when present) */
7198
+ byChannel?: Partial<Record<BroadcastChannel, 'opt-in' | 'opt-out'>>
7199
+ }
7200
+ rules?: {
7201
+ allowChannels?: BroadcastChannel[]
7202
+ allowUnsubscribe?: boolean
7203
+ required?: boolean
7204
+ }
7205
+ [k: string]: any
7206
+ }
7207
+
7208
+ export interface CommsSettingsGetResponse {
7209
+ ok: true
7210
+ settings: CommsSettings
7211
+ }
7212
+
7213
+ export type CommsSettingsPatchBody = Partial<CommsSettings>
7214
+
7215
+ // Public types listing (array form for public API)
7216
+ export interface CommsPublicTopicsResponse { ok: true; topics: Record<string, TopicConfig> }
7217
+
7218
+ export interface UnsubscribeQuery {
7219
+ /** Optional: defaults to the signed-in user's own contact. Only collection admins may name another contact. */
7220
+ contactId?: string
7221
+ topic?: string
7222
+ channel?: BroadcastChannel
7223
+ token?: string
7224
+ }
7225
+
7226
+ export interface UnsubscribeResponse { ok: true; applied?: { channels?: Record<string, boolean>; topics?: Record<string, boolean> } }
7227
+
7228
+ // Public sign-up (double opt-in)
7229
+ export interface CommsSignupRequest {
7230
+ email: string
7231
+ /**
7232
+ * Required: YOUR app's confirmation email — a template in this collection (SL.template) whose body
7233
+ * uses `{{ action_url }}` for the confirm link (`{{ topics }}` lists what they signed up for). The
7234
+ * platform sends no default sign-up email.
7235
+ */
7236
+ templateId: string
7237
+ /** Topic ids from the collection's comm settings (e.g. ["newsletter"]). */
7238
+ topics?: string[]
7239
+ firstName?: string
7240
+ /**
7241
+ * The form's other answers — firstName/lastName/displayName/company/locale/timezone and
7242
+ * `customFields`. Applied to the contact when the address is confirmed, and only where the contact
7243
+ * has no value yet (never overwritten). Small: ~2 KB.
7244
+ */
7245
+ fields?: { firstName?: string; lastName?: string; displayName?: string; company?: string; locale?: string; timezone?: string; customFields?: Record<string, string | number | boolean> }
7246
+ /** Your app id, recorded with the sent email. */
7247
+ appId?: string
7248
+ }
7249
+ export interface CommsSignupResponse { ok: true; pending: true }
7250
+
7251
+ // Public consent/preferences/subscribe
7252
+ export type ConsentChannels = Partial<Record<BroadcastChannel, boolean>>
7253
+ type SubjectType = import('./contact').SubjectType
7254
+
7255
+ export interface CommsConsentUpsertRequest {
7256
+ /** Optional: defaults to the signed-in user's own contact. Only collection admins may name another contact. */
7257
+ contactId?: string
7258
+ channels?: ConsentChannels
7259
+ topics?: Record<string, boolean>
7260
+ topicsByChannel?: Partial<Record<BroadcastChannel, Record<string, boolean>>>
7261
+ }
7262
+
7263
+ export interface CommsPreferencesUpsertRequest {
7264
+ /** Optional: defaults to the signed-in user's own contact. Only collection admins may name another contact. */
7265
+ contactId?: string
7266
+ subject?: { type: SubjectType; id: string; productId?: string }
7267
+ channels?: ConsentChannels
7268
+ topics?: Record<string, boolean>
7269
+ topicsByChannel?: Partial<Record<BroadcastChannel, Record<string, boolean>>>
7270
+ }
7271
+
7272
+ export interface CommsSubscribeRequest {
7273
+ /** Optional: defaults to the signed-in user's own contact. Only collection admins may name another contact. */
7274
+ contactId?: string
7275
+ subject: { type: SubjectType; id: string; productId?: string }
7276
+ subscribe: boolean
7277
+ source?: string
7278
+ }
7279
+ export interface CommsSubscribeResponse { ok: true; subscriptionId: string }
7280
+
7281
+ export interface CommsSubscriptionCheckQuery {
7282
+ /** Optional: defaults to the signed-in user's own contact. Only collection admins may name another contact. */
7283
+ contactId?: string
7284
+ subjectType: SubjectType
7285
+ subjectId: string
7286
+ productId?: string
7287
+ }
7288
+ export interface CommsSubscriptionCheckResponse { ok: true; subscribed: boolean }
7289
+
7290
+ export interface CommsListMethodsQuery {
7291
+ /** Optional: defaults to the signed-in user's own contact. Only collection admins may name another contact. */
7292
+ contactId?: string
7293
+ type?: BroadcastChannel
7294
+ }
7295
+ export interface CommsListMethodsResponse { ok: true; methods: import('./contact').CommMethod[] }
7296
+
7297
+ export interface RegisterEmailMethodRequest { contactId?: string; email?: string; userId?: string }
7298
+ export interface RegisterSmsMethodRequest { contactId?: string; phone?: string; userId?: string }
7299
+ export interface RegisterMethodResponse { ok: true; contactId: string }
7300
+
7301
+ export interface SubscriptionsResolveRequest {
7302
+ subject: { type: SubjectType; id: string; productId?: string }
7303
+ hints: { userId?: string; pushEndpoint?: string; email?: string }
7304
+ }
7305
+ export interface SubscriptionsResolveResponse {
7306
+ ok: true
7307
+ subject: { type: SubjectType; id: string; productId?: string }
7308
+ contacts: Array<{
7309
+ contactId: string
7310
+ subscribed: boolean
7311
+ channels?: Partial<Record<BroadcastChannel, boolean>>
7312
+ }>
7313
+ anySubscribed: boolean
7314
+ anyMethods: boolean
7315
+ }
7316
+
7317
+ // Transactional send (single-contact, single-message)
7318
+
7319
+ /**
7320
+ * Send a single message to one contact using a template.
7321
+ * No broadcast record is created; the send is logged directly to the
7322
+ * contact's communication history with sourceType: 'transactional'.
7323
+ *
7324
+ * POST /admin/collection/:collectionId/comm/send
7325
+ */
7326
+ export interface TransactionalSendRequest {
7327
+ /** CRM contact UUID */
7328
+ contactId: string
7329
+ /** A saved template's id. Give this or `message`. */
7330
+ templateId?: string
7331
+ /**
7332
+ * A typed message instead of a template: plain text, Liquid allowed (`{{ contact.firstName }}`).
7333
+ * `sms` is the shorter text for SMS and WhatsApp (defaults to `body`).
7334
+ */
7335
+ message?: TypedMessage
7336
+ /**
7337
+ * Channel to send on. Defaults to 'preferred', which auto-selects the
7338
+ * contact's best available channel respecting consent, suppression, and
7339
+ * template availability.
7340
+ */
7341
+ channel?: 'email' | 'sms' | 'whatsapp' | 'push' | 'wallet' | 'preferred'
7342
+ /** Extra Liquid variables merged into the top-level render context */
7343
+ props?: Record<string, unknown>
7344
+ /** Context objects to hydrate into the Liquid template */
7345
+ include?: {
7346
+ /** Hydrate {{ collection }}. Default: true */
7347
+ collection?: boolean
7348
+ /** Hydrate {{ product }} from this product ID */
7349
+ productId?: string
7350
+ /** Hydrate {{ proof }} (requires productId) */
7351
+ proofId?: string
7352
+ /** Hydrate {{ user }} from contact.userId */
7353
+ user?: boolean
7354
+ /** Hydrate {{ appCase }} from this case UUID */
7355
+ appCase?: string
7356
+ /** Hydrate {{ appThread }} from this thread UUID */
7357
+ appThread?: string
7358
+ /** Hydrate {{ appRecord }} from this record UUID */
7359
+ appRecord?: string
7360
+ }
7361
+ /** Arbitrary label stored on the comms-events row (e.g. 'warranty-step-2') */
7362
+ ref?: string
7363
+ /** App context stored on the comms-events row */
7364
+ appId?: string
7365
+ /**
7366
+ * What the message is about: the record it was sent for and the admin screen that shows it, so it is a
7367
+ * link in Messages, on the contact's Activity, and on the conversation a reply opens. `appId` defaults
7368
+ * to the sending app.
7369
+ */
7370
+ about?: MessageAbout
7371
+ /**
7372
+ * `'service'` (a confirmation, a reminder, an update): an asked-for channel the person turned off, or a
7373
+ * suppressed email, is refused (`transactional.opted_out`). Marketing goes out as a campaign.
7374
+ */
7375
+ category?: 'service'
7376
+ /**
7377
+ * Files to attach (email only; at most 5, 10 MB in all). What can't be made is left out and listed in
7378
+ * `attachmentsLeftOut` — the email still goes.
7379
+ */
7380
+ attach?: EmailAttachmentSpec[]
7381
+ }
7382
+
7383
+ /**
7384
+ * One file for an email:
7385
+ * - `'calendar'` — the booking's `.ics` calendar invite (needs `include.booking` and `appId`)
7386
+ * - `{ asset }` — a file uploaded to this collection's assets
7387
+ * - `{ function }` — the app's (`appId`) own server function makes it (see server-functions.md, "Making an email attachment")
7388
+ * - `{ filename, contentType, content }` — a file you made, base64 (PDF, Office documents, images, text, CSV, calendar)
7389
+ * - `{ filename, file }` — a private file you made (e.g. `pdf.create` with `return: 'signedUrl'`)
7390
+ */
7391
+ export type EmailAttachmentSpec =
7392
+ | 'calendar'
7393
+ | { asset: string }
7394
+ | { function: string }
7395
+ | { filename: string; contentType: string; content: string }
7396
+ | { filename: string; contentType?: string; file: string }
7397
+
7398
+ export interface TransactionalSendResponse {
7399
+ ok: true
7400
+ /** The channel the message was actually sent on */
7401
+ channel: 'email' | 'sms' | 'whatsapp' | 'push' | 'wallet'
7402
+ /** Provider message ID (email/SMS/WhatsApp); absent for push/wallet */
7403
+ messageId?: string
7404
+ /** Attachments that couldn't be made, and why (the email went without them) */
7405
+ attachmentsLeftOut?: string[]
7406
+ }
7407
+
7408
+ /** A message written there and then rather than a saved template. */
7409
+ export interface TypedMessage {
7410
+ subject?: string
7411
+ body: string
7412
+ /** The shorter text for SMS and WhatsApp (defaults to `body`). */
7413
+ sms?: string
7414
+ }
7415
+
7416
+ /**
7417
+ * What a message is about (docs/comms.md, "What a message is about"). Ids only, never content.
7418
+ * `view` and `params` name one of the app's admin views (manifest `adminViews`, docs/admin-views.md).
7419
+ */
7420
+ export interface MessageAbout {
7421
+ appId?: string
7422
+ /** What kind of record: `'booking'`, `'entry'`, `'case'`. */
7423
+ type: string
7424
+ id: string
7425
+ view?: string
7426
+ params?: Record<string, string>
7427
+ /** A short label to show without looking the record up: `'Sat 3pm, table for 4'`. */
7428
+ label?: string
7429
+ }
7430
+
7431
+ export interface TransactionalSendError {
7432
+ ok: false
7433
+ /**
7434
+ * Error code. Known values:
7435
+ * - `transactional.contact_not_found`
7436
+ * - `transactional.template_not_found`
7437
+ * - `transactional.no_channel_available`
7438
+ * - `transactional.email_missing`
7439
+ * - `transactional.phone_missing`
7440
+ * - `transactional.whatsapp_missing`
7441
+ * - `transactional.no_push_methods`
7442
+ * - `transactional.no_wallet_passes` (`channel: 'wallet'`: the person has no wallet passes from this app)
7443
+ * - `transactional.opted_out` (category `'service'`: the person turned that channel off, or the email is suppressed)
7444
+ * - `transactional.template_or_message` / `transactional.message_invalid` / `transactional.about_invalid`
7445
+ */
7446
+ error: string
7447
+ }
7448
+
7437
7449
  export type TransactionalSendResult =`
7438
7450
 
7439
7451
  ### config
@@ -12206,41 +12218,257 @@ interface ShopRefundInput {
12206
12218
 
12207
12219
  **ShopOrderStatus** = `'pending-payment' | 'paid' | 'fulfilled' | 'partly-refunded' | 'refunded' | 'expired'`
12208
12220
 
12209
- ### tags
12221
+ ### subscriptions
12210
12222
 
12211
- **Tag** (interface)
12223
+ **PlanLength** (interface)
12212
12224
  ```typescript
12213
- interface Tag {
12214
- id: string // Internal UUID
12215
- orgId: string // Organisation ID
12216
- tagId: string // Physical tag identifier (NFC UID, QR code, etc.)
12217
- collectionId: string // Owning collection
12218
- productId: string | null // Linked product
12219
- variantId: string | null // Product variant
12220
- batchId: string | null // Production batch
12221
- proofId: string | null // Proof / serial number
12222
- refType: string | null
12223
- refId: string | null
12224
- containerId?: string | null
12225
- itemUid?: string | null
12226
- metadata: Record<string, any>
12227
- createdAt: string // ISO 8601
12228
- updatedAt: string // ISO 8601
12225
+ interface PlanLength {
12226
+ unit: 'month' | 'year'
12227
+ count: number
12229
12228
  }
12230
12229
  ```
12231
12230
 
12232
- **TagIndexEntry** (interface)
12231
+ **PlanGrants** (interface)
12233
12232
  ```typescript
12234
- interface TagIndexEntry {
12235
- tagId: string
12236
- collectionId: string
12233
+ interface PlanGrants {
12234
+ level?: string
12235
+ groups?: string[]
12236
+ rank?: number
12237
12237
  }
12238
12238
  ```
12239
12239
 
12240
- **TagEmbedded** (interface)
12240
+ **PlanIncludes** (interface)
12241
12241
  ```typescript
12242
- interface TagEmbedded {
12243
- products?: Record<string, any>
12242
+ interface PlanIncludes {
12243
+ items?: Array<{ productId: string; variantId?: string; quantity: number }>
12244
+ }
12245
+ ```
12246
+
12247
+ **Plan** (interface)
12248
+ ```typescript
12249
+ interface Plan {
12250
+ id: string
12251
+ collectionId: string
12252
+ name: string
12253
+ description: string | null
12254
+ image: string | null
12255
+ term: PlanTerm
12256
+ length: PlanLength | null
12257
+ grants: PlanGrants
12258
+ includes: PlanIncludes
12259
+ active: boolean
12260
+ sort: number
12261
+ metadata: Record<string, any>
12262
+ createdAt: string
12263
+ updatedAt: string
12264
+ }
12265
+ ```
12266
+
12267
+ **PlanInput** (interface)
12268
+ ```typescript
12269
+ interface PlanInput {
12270
+ name: string
12271
+ description?: string | null
12272
+ image?: string | null
12273
+ term?: PlanTerm
12274
+ length?: PlanLength
12275
+ grants?: PlanGrants
12276
+ includes?: PlanIncludes
12277
+ active?: boolean
12278
+ sort?: number
12279
+ metadata?: Record<string, any>
12280
+ }
12281
+ ```
12282
+
12283
+ **PlanPrice** (interface)
12284
+ ```typescript
12285
+ interface PlanPrice {
12286
+ id: string
12287
+ planId: string
12288
+ currency: string
12289
+ amount: number
12290
+ compareAtAmount: number | null
12291
+ interval: 'month' | 'year' | null
12292
+ intervalCount: number
12293
+ trialDays: number | null
12294
+ active: boolean
12295
+ sort: number
12296
+ }
12297
+ ```
12298
+
12299
+ **PlanPriceInput** (interface)
12300
+ ```typescript
12301
+ interface PlanPriceInput {
12302
+ currency?: string
12303
+ amount: number
12304
+ compareAtAmount?: number | null
12305
+ interval?: 'month' | 'year'
12306
+ intervalCount?: number
12307
+ trialDays?: number | null
12308
+ active?: boolean
12309
+ sort?: number
12310
+ }
12311
+ ```
12312
+
12313
+ **PublicPlan** (interface)
12314
+ ```typescript
12315
+ interface PublicPlan {
12316
+ id: string
12317
+ name: string
12318
+ description: string | null
12319
+ image: string | null
12320
+ term: PlanTerm
12321
+ length: PlanLength | null
12322
+ level: string | null
12323
+ prices: Array<Pick<PlanPrice, 'id' | 'currency' | 'amount' | 'compareAtAmount' | 'interval' | 'intervalCount' | 'trialDays'>>
12324
+ }
12325
+ ```
12326
+
12327
+ **Membership** (interface)
12328
+ ```typescript
12329
+ interface Membership {
12330
+ id: string
12331
+ collectionId: string
12332
+ contactId: string | null
12333
+ userId: string | null
12334
+ planId: string
12335
+ priceId: string | null
12336
+ source: SubscriptionSource
12337
+ status: SubscriptionStatus
12338
+ live: boolean
12339
+ currentPeriodStart: string | null
12340
+ currentPeriodEnd: string | null
12341
+ endsAt: string | null
12342
+ endedAt: string | null
12343
+ cancelReason: 'member' | 'staff' | 'payment_failed' | 'expired' | string | null
12344
+ cancelledBy: string | null
12345
+ pendingPriceId: string | null
12346
+ metadata: Record<string, any>
12347
+ createdAt: string
12348
+ updatedAt: string
12349
+ plan?: { id: string; name: string; grants: PlanGrants; term: PlanTerm }
12350
+ }
12351
+ ```
12352
+
12353
+ **MySubscription** (interface)
12354
+ ```typescript
12355
+ interface MySubscription {
12356
+ id: string
12357
+ planId: string
12358
+ priceId: string | null
12359
+ status: SubscriptionStatus
12360
+ live: boolean
12361
+ source: SubscriptionSource
12362
+ currentPeriodEnd: string | null
12363
+ endsAt: string | null
12364
+ pendingPriceId: string | null
12365
+ plan: { id: string; name: string; level: string | null } | null
12366
+ }
12367
+ ```
12368
+
12369
+ **SubscriptionStartInput** (interface)
12370
+ ```typescript
12371
+ interface SubscriptionStartInput {
12372
+ priceId: string
12373
+ successUrl?: string
12374
+ cancelUrl?: string
12375
+ }
12376
+ ```
12377
+
12378
+ **SubscriptionStartResult** (interface)
12379
+ ```typescript
12380
+ interface SubscriptionStartResult {
12381
+ checkoutUrl: string
12382
+ sessionId: string
12383
+ }
12384
+ ```
12385
+
12386
+ **SubscriptionListParams** (interface)
12387
+ ```typescript
12388
+ interface SubscriptionListParams {
12389
+ status?: SubscriptionStatus
12390
+ live?: boolean
12391
+ planId?: string
12392
+ contactId?: string
12393
+ userId?: string
12394
+ limit?: number
12395
+ offset?: number
12396
+ }
12397
+ ```
12398
+
12399
+ **SubscriptionGrantInput** (interface)
12400
+ ```typescript
12401
+ interface SubscriptionGrantInput {
12402
+ planId: string
12403
+ contactId?: string
12404
+ userId?: string
12405
+ endsAt?: string
12406
+ note?: string
12407
+ }
12408
+ ```
12409
+
12410
+ **SubscriptionPage<T>** (interface)
12411
+ ```typescript
12412
+ interface SubscriptionPage<T> {
12413
+ items: T[]
12414
+ total: number
12415
+ limit: number
12416
+ offset: number
12417
+ }
12418
+ ```
12419
+
12420
+ **MembershipStatus** (interface)
12421
+ ```typescript
12422
+ interface MembershipStatus {
12423
+ member: boolean
12424
+ level: string | null
12425
+ subscriptions: Membership[]
12426
+ }
12427
+ ```
12428
+
12429
+ **PlanTerm** = `'recurring' | 'fixed'`
12430
+
12431
+ **PlanUpdate** = `Partial<PlanInput>`
12432
+
12433
+ **SubscriptionStatus** = `'trialing' | 'active' | 'past_due' | 'cancelling' | 'ended'`
12434
+
12435
+ **SubscriptionSource** = `'stripe' | 'manual'`
12436
+
12437
+ ### tags
12438
+
12439
+ **Tag** (interface)
12440
+ ```typescript
12441
+ interface Tag {
12442
+ id: string // Internal UUID
12443
+ orgId: string // Organisation ID
12444
+ tagId: string // Physical tag identifier (NFC UID, QR code, etc.)
12445
+ collectionId: string // Owning collection
12446
+ productId: string | null // Linked product
12447
+ variantId: string | null // Product variant
12448
+ batchId: string | null // Production batch
12449
+ proofId: string | null // Proof / serial number
12450
+ refType: string | null
12451
+ refId: string | null
12452
+ containerId?: string | null
12453
+ itemUid?: string | null
12454
+ metadata: Record<string, any>
12455
+ createdAt: string // ISO 8601
12456
+ updatedAt: string // ISO 8601
12457
+ }
12458
+ ```
12459
+
12460
+ **TagIndexEntry** (interface)
12461
+ ```typescript
12462
+ interface TagIndexEntry {
12463
+ tagId: string
12464
+ collectionId: string
12465
+ }
12466
+ ```
12467
+
12468
+ **TagEmbedded** (interface)
12469
+ ```typescript
12470
+ interface TagEmbedded {
12471
+ products?: Record<string, any>
12244
12472
  proofs?: Record<string, any>
12245
12473
  containers?: Record<string, any>
12246
12474
  refs?: Record<string, any>
@@ -13007,36 +13235,36 @@ interface GuideStartOptions {
13007
13235
 
13008
13236
  **AppConfigOptions** (type)
13009
13237
  ```typescript
13010
- type AppConfigOptions = {
13011
- /** The app ID */
13012
- appId: string
13013
-
13014
- /** Collection ID (required for most operations) */
13015
- collectionId?: string
13016
- /** Product ID (optional - for product-scoped config) */
13017
- productId?: string
13018
- /** Variant ID (optional - for variant-scoped config) */
13019
- variantId?: string
13020
- /** Batch ID (optional - for batch-scoped config) */
13021
- batchId?: string
13022
-
13023
- /** Item ID - required for getDataItem/deleteDataItem */
13024
- itemId?: string
13025
-
13026
- /**
13027
- * Use admin endpoints instead of public.
13028
- * This selects which endpoint is called; it does not by itself make root-level config fields private.
13029
- */
13030
- admin?: boolean
13031
-
13032
- /**
13033
- * Configuration object for setConfig.
13034
- * For admin-only values in app config, store them under a top-level `admin` object.
13035
- * Public reads return the root config but omit `config.admin`.
13036
- */
13037
- config?: any
13038
- /** Data object for setDataItem. Best for small keyed scoped documents rather than richer app domain objects. */
13039
- data?: any
13238
+ type AppConfigOptions = {
13239
+ /** The app ID */
13240
+ appId: string
13241
+
13242
+ /** Collection ID (required for most operations) */
13243
+ collectionId?: string
13244
+ /** Product ID (optional - for product-scoped config) */
13245
+ productId?: string
13246
+ /** Variant ID (optional - for variant-scoped config) */
13247
+ variantId?: string
13248
+ /** Batch ID (optional - for batch-scoped config) */
13249
+ batchId?: string
13250
+
13251
+ /** Item ID - required for getDataItem/deleteDataItem */
13252
+ itemId?: string
13253
+
13254
+ /**
13255
+ * Use admin endpoints instead of public.
13256
+ * This selects which endpoint is called; it does not by itself make root-level config fields private.
13257
+ */
13258
+ admin?: boolean
13259
+
13260
+ /**
13261
+ * Configuration object for setConfig.
13262
+ * For admin-only values in app config, store them under a top-level `admin` object.
13263
+ * Public reads return the root config but omit `config.admin`.
13264
+ */
13265
+ config?: any
13266
+ /** Data object for setDataItem. Best for small keyed scoped documents rather than richer app domain objects. */
13267
+ data?: any
13040
13268
  }
13041
13269
  ```
13042
13270
 
@@ -13460,70 +13688,70 @@ Fire-and-forget tag analytics event. Uses `navigator.sendBeacon()` when availabl
13460
13688
 
13461
13689
  Workflow-oriented app objects for issues, requests, claims, and tasks that move through statuses and often need assignment or history.
13462
13690
 
13463
- **create**(collectionId: string,
13464
- appId: string,
13465
- input: CreateCaseInput,
13691
+ **create**(collectionId: string,
13692
+ appId: string,
13693
+ input: CreateCaseInput,
13466
13694
  admin: boolean = false) → `Promise<AppCase>`
13467
13695
  Create a new case POST /cases
13468
13696
 
13469
- **list**(collectionId: string,
13470
- appId: string,
13471
- params?: CaseListQueryParams,
13697
+ **list**(collectionId: string,
13698
+ appId: string,
13699
+ params?: CaseListQueryParams,
13472
13700
  admin: boolean = false) → `Promise<PaginatedResponse<AppCase>>`
13473
13701
  List cases with optional query parameters GET /cases
13474
13702
 
13475
- **get**(collectionId: string,
13476
- appId: string,
13477
- caseId: string,
13703
+ **get**(collectionId: string,
13704
+ appId: string,
13705
+ caseId: string,
13478
13706
  admin: boolean = false) → `Promise<AppCase>`
13479
13707
  Get a single case by ID GET /cases/:caseId
13480
13708
 
13481
- **update**(collectionId: string,
13482
- appId: string,
13483
- caseId: string,
13484
- input: UpdateCaseInput,
13709
+ **update**(collectionId: string,
13710
+ appId: string,
13711
+ caseId: string,
13712
+ input: UpdateCaseInput,
13485
13713
  admin: boolean = false) → `Promise<AppCase>`
13486
13714
  Update a case PATCH /cases/:caseId Admin can update any field, public (owner) can only update data and owner zones
13487
13715
 
13488
- **remove**(collectionId: string,
13489
- appId: string,
13490
- caseId: string,
13716
+ **remove**(collectionId: string,
13717
+ appId: string,
13718
+ caseId: string,
13491
13719
  admin: boolean = false) → `Promise<`
13492
13720
  Soft delete a case DELETE /cases/:caseId
13493
13721
 
13494
- **aggregate**(collectionId: string,
13495
- appId: string,
13496
- request: AggregateRequest,
13722
+ **aggregate**(collectionId: string,
13723
+ appId: string,
13724
+ request: AggregateRequest,
13497
13725
  admin: boolean = false) → `Promise<AggregateResponse>`
13498
13726
  Get aggregate statistics for cases POST /cases/aggregate
13499
13727
 
13500
- **summary**(collectionId: string,
13501
- appId: string,
13728
+ **summary**(collectionId: string,
13729
+ appId: string,
13502
13730
  request?: CaseSummaryRequest) → `Promise<CaseSummaryResponse>`
13503
13731
  Get case summary (admin only) POST /cases/summary
13504
13732
 
13505
- **appendHistory**(collectionId: string,
13506
- appId: string,
13507
- caseId: string,
13733
+ **appendHistory**(collectionId: string,
13734
+ appId: string,
13735
+ caseId: string,
13508
13736
  input: AppendHistoryInput) → `Promise<AppCase>`
13509
13737
  Append an entry to case history (admin only) POST /cases/:caseId/history
13510
13738
 
13511
- **related**(collectionId: string,
13512
- appId: string,
13739
+ **related**(collectionId: string,
13740
+ appId: string,
13513
13741
  caseId: string) → `Promise<RelatedResponse>`
13514
13742
  Get related threads and records for a case (admin only) GET /cases/:caseId/related
13515
13743
 
13516
13744
  ### app.options
13517
13745
 
13518
- **get**(collectionId: string,
13519
- appId: string,
13520
- source: string,
13746
+ **get**(collectionId: string,
13747
+ appId: string,
13748
+ source: string,
13521
13749
  opts: { q?: string; version?: string; admin?: boolean } = {},) → `Promise<import('../types/appOptions').AppOptionsResponse>`
13522
13750
  `source` = `type:<record type or declared type id>` | `list:<list id>`. Admins (`admin: true`) see every entry; the public API lists public records and lists the app declares public. Hold on to `version` and pass it back to get `{ unchanged: true }` when nothing changed.
13523
13751
 
13524
- **saveList**(collectionId: string,
13525
- appId: string,
13526
- listId: string,
13752
+ **saveList**(collectionId: string,
13753
+ appId: string,
13754
+ listId: string,
13527
13755
  values: import('../types/appOptions') → `void`
13528
13756
  Save a value list's values, in order (admins). Codes never change and are never lost: a value left out stays, switched off, at the end. → the list as saved.
13529
13757
 
@@ -13531,92 +13759,92 @@ Save a value list's values, in order (admins). Codes never change and are never
13531
13759
 
13532
13760
  General-purpose structured app objects. Use these when a simple scoped data item grows into something queryable, lifecycle-aware, or access-controlled.
13533
13761
 
13534
- **create**(collectionId: string,
13535
- appId: string,
13536
- input: CreateRecordInput,
13762
+ **create**(collectionId: string,
13763
+ appId: string,
13764
+ input: CreateRecordInput,
13537
13765
  admin: boolean = false) → `Promise<CreateRecordResponse>`
13538
13766
  Create a new record POST /records When called on the public endpoint (admin = false) with an anonymous caller, and the app's `publicCreate.records.anonymous.edit.editToken` policy is enabled, the response includes a one-time `editToken` string. Store it immediately — it is never returned again.
13539
13767
 
13540
- **query**(collectionId: string,
13541
- appId: string,
13768
+ **query**(collectionId: string,
13769
+ appId: string,
13542
13770
  body: StandardQuery = {}) → `Promise<QueryResult>`
13543
13771
  The standard query on an app's records (admin only): filter, sort, page, count and total in one call, reaching into a record's own fields by path, and following a record to its `product` and its `contact`. POST /admin/collection/:collectionId/app/:appId/records/query Fields: id, recordType, ref, status, visibility, customId, productId, variantId, batchId, proofId, contactId, authorId, parentType, parentId, createdAt, updatedAt, startsAt, expiresAt, and the documents data, owner and admin, reached by path: `"data.status"`, `"data.line.name"`. ```typescript // How many work orders by status, and how many units on each await app.records.query(collectionId, appId, { where: { recordType: 'work_order' }, groupBy: ['data.status'], aggregates: { orders: { count: true }, units: { sum: 'data.qty' } }, }) ```
13544
13772
 
13545
13773
  **queryFields**(collectionId: string, appId: string) → `Promise<QueryDescription>`
13546
13774
  What a records query can use: its fields, what each can filter, sort, group or total, and its links. GET /admin/collection/:collectionId/app/:appId/records/query
13547
13775
 
13548
- **list**(collectionId: string,
13549
- appId: string,
13550
- params?: RecordListQueryParams,
13776
+ **list**(collectionId: string,
13777
+ appId: string,
13778
+ params?: RecordListQueryParams,
13551
13779
  admin: boolean = false) → `Promise<PaginatedResponse<AppRecord>>`
13552
13780
  List records with optional query parameters GET /records Public/owner callers only receive records with `status: "active"`. Admin callers can query all statuses (for example `draft`/`archived`).
13553
13781
 
13554
- **get**(collectionId: string,
13555
- appId: string,
13556
- recordId: string,
13782
+ **get**(collectionId: string,
13783
+ appId: string,
13784
+ recordId: string,
13557
13785
  admin: boolean = false) → `Promise<AppRecord>`
13558
13786
  Get a single record by ID GET /records/:recordId
13559
13787
 
13560
- **update**(collectionId: string,
13561
- appId: string,
13562
- recordId: string,
13563
- input: UpdateRecordInput,
13788
+ **update**(collectionId: string,
13789
+ appId: string,
13790
+ recordId: string,
13791
+ input: UpdateRecordInput,
13564
13792
  admin: boolean = false) → `Promise<AppRecord>`
13565
13793
  Update a record PATCH /records/:recordId Admin can update any field, public (owner) can only update data and owner
13566
13794
 
13567
- **updateWithToken**(collectionId: string,
13568
- appId: string,
13569
- recordId: string,
13570
- data: Record<string, unknown>,
13795
+ **updateWithToken**(collectionId: string,
13796
+ appId: string,
13797
+ recordId: string,
13798
+ data: Record<string, unknown>,
13571
13799
  editToken: string) → `Promise<AppRecord>`
13572
13800
  Amend the `data` zone of a record using an anonymous edit token. PATCH /records/:recordId (public endpoint, no auth) This is the follow-up call after an anonymous `create()` that returned an `editToken`. Present the token via `X-Edit-Token` — the server validates it with a constant-time comparison and, if `windowMinutes` is configured in the policy, checks that the token has not expired. **Scope:** only the `data` zone may be modified via this path. `owner`, `admin`, `status`, `visibility`, and indexed fields are immutable to anonymous token holders. ```ts const record = await app.records.create(collectionId, appId, { recordType: 'payment', visibility: 'public', data: { amount: 9900, currency: 'USD' }, }) const { editToken } = record // store this immediately! // Later, once the payment gateway confirms: const updated = await app.records.updateWithToken( collectionId, appId, record.id, { amount: 9900, currency: 'USD', transactionId: 'txn_abc123' }, editToken, ) ``` ### Error codes | HTTP | `errorCode` | Meaning | |------|-----------------------|---------------------------------------------------| | 401 | `UNAUTHORIZED` | No auth token and no `X-Edit-Token` header | | 403 | `FORBIDDEN` | Policy not enabled, or token does not match | | 403 | `EDIT_WINDOW_EXPIRED` | `windowMinutes` elapsed since record creation | | 404 | `NOT_FOUND` | Record does not exist |
13573
13801
 
13574
- **remove**(collectionId: string,
13575
- appId: string,
13576
- recordId: string,
13802
+ **remove**(collectionId: string,
13803
+ appId: string,
13804
+ recordId: string,
13577
13805
  admin: boolean = false) → `Promise<`
13578
13806
  Soft delete a record DELETE /records/:recordId
13579
13807
 
13580
- **aggregate**(collectionId: string,
13581
- appId: string,
13582
- request: AggregateRequest,
13808
+ **aggregate**(collectionId: string,
13809
+ appId: string,
13810
+ request: AggregateRequest,
13583
13811
  admin: boolean = false) → `Promise<AggregateResponse>`
13584
13812
  Get aggregate statistics for records POST /records/aggregate
13585
13813
 
13586
- **restore**(collectionId: string,
13587
- appId: string,
13814
+ **restore**(collectionId: string,
13815
+ appId: string,
13588
13816
  recordId: string) → `Promise<AppRecord>`
13589
13817
  Restore a soft-deleted record. POST /records/:recordId/restore (admin only)
13590
13818
 
13591
- **upsert**(collectionId: string,
13592
- appId: string,
13819
+ **upsert**(collectionId: string,
13820
+ appId: string,
13593
13821
  input: UpsertRecordInput) → `Promise<UpsertRecordResponse>`
13594
13822
  Upsert a record by ref — creates if no record with that ref exists, otherwise updates. Scope, specificity, and ref are canonicalized on write. POST /records/upsert (admin only)
13595
13823
 
13596
- **match**(collectionId: string,
13597
- appId: string,
13598
- input: MatchRecordsInput,
13824
+ **match**(collectionId: string,
13825
+ appId: string,
13826
+ input: MatchRecordsInput,
13599
13827
  admin: boolean = false) → `Promise<MatchResult>`
13600
13828
  Match records against a runtime target scope. Returns records whose scope is satisfied by the target, ordered by specificity descending (most specific first). POST /records/match ```ts const { records, best } = await app.records.match(collectionId, appId, { target: { productId: 'prod_abc', facets: { tier: ['gold'] } }, strategy: 'best', recordType: 'nutrition', }, true); // best.nutrition → the single highest-specificity nutrition record ```
13601
13829
 
13602
- **bulkUpsert**(collectionId: string,
13603
- appId: string,
13830
+ **bulkUpsert**(collectionId: string,
13831
+ appId: string,
13604
13832
  records: BulkUpsertItem[]) → `Promise<BulkUpsertResult>`
13605
13833
  Upsert up to 500 records in a single transaction. Each row is individually error-isolated — a failure on one row does not abort the others. POST /records/bulk-upsert (admin only)
13606
13834
 
13607
- **bulkDelete**(collectionId: string,
13608
- appId: string,
13835
+ **bulkDelete**(collectionId: string,
13836
+ appId: string,
13609
13837
  input: BulkDeleteInput) → `Promise<BulkDeleteResult>`
13610
13838
  Soft-delete records in bulk. Supports two modes: - **refs mode**: explicit list of refs (max 1000) - **scope mode**: delete by scope anchor (productId / variantId / etc.) POST /records/bulk-delete (admin only) ```ts // Refs mode await app.records.bulkDelete(collectionId, appId, { refs: ['product:prod_abc', 'product:prod_xyz'], recordType: 'nutrition', }); // Scope mode await app.records.bulkDelete(collectionId, appId, { scope: { productId: 'prod_abc' }, }); ```
13611
13839
 
13612
- **resolveAll**(collectionId: string,
13613
- appId: string,
13614
- input: ResolveAllParams,
13840
+ **resolveAll**(collectionId: string,
13841
+ appId: string,
13842
+ input: ResolveAllParams,
13615
13843
  admin: boolean = false) → `Promise<ResolveAllResult>`
13616
13844
  Resolve every applicable record for a product context in one call. Returns records across all tiers (proof, batch, variant, product, rule, facet, collection) deduplicated and sorted by specificity descending. POST /records/resolve-all
13617
13845
 
13618
- **previewRule**(collectionId: string,
13619
- appId: string,
13846
+ **previewRule**(collectionId: string,
13847
+ appId: string,
13620
13848
  input: PreviewRuleParams) → `Promise<PreviewRuleResult>`
13621
13849
  Preview which products in the collection match a given facetRule. Admin only. Use for live "matches N products" feedback while authoring a rule. POST /records/preview-rule
13622
13850
 
@@ -13624,54 +13852,54 @@ Preview which products in the collection match a given facetRule. Admin only. Us
13624
13852
 
13625
13853
  Conversation-oriented app objects for comments, discussions, Q&A, and reply-driven experiences.
13626
13854
 
13627
- **create**(collectionId: string,
13628
- appId: string,
13629
- input: CreateThreadInput,
13855
+ **create**(collectionId: string,
13856
+ appId: string,
13857
+ input: CreateThreadInput,
13630
13858
  admin: boolean = false) → `Promise<AppThread>`
13631
13859
  Create a new thread POST /threads
13632
13860
 
13633
- **list**(collectionId: string,
13634
- appId: string,
13635
- params?: ThreadListQueryParams,
13861
+ **list**(collectionId: string,
13862
+ appId: string,
13863
+ params?: ThreadListQueryParams,
13636
13864
  admin: boolean = false) → `Promise<PaginatedResponse<AppThread>>`
13637
13865
  List threads with optional query parameters GET /threads
13638
13866
 
13639
- **get**(collectionId: string,
13640
- appId: string,
13641
- threadId: string,
13867
+ **get**(collectionId: string,
13868
+ appId: string,
13869
+ threadId: string,
13642
13870
  admin: boolean = false) → `Promise<AppThread>`
13643
13871
  Get a single thread by ID GET /threads/:threadId
13644
13872
 
13645
- **update**(collectionId: string,
13646
- appId: string,
13647
- threadId: string,
13648
- input: UpdateThreadInput,
13873
+ **update**(collectionId: string,
13874
+ appId: string,
13875
+ threadId: string,
13876
+ input: UpdateThreadInput,
13649
13877
  admin: boolean = false) → `Promise<AppThread>`
13650
13878
  Update a thread PATCH /threads/:threadId Admin can update any field, public (owner) can only update body, tags, data, owner
13651
13879
 
13652
- **remove**(collectionId: string,
13653
- appId: string,
13654
- threadId: string,
13880
+ **remove**(collectionId: string,
13881
+ appId: string,
13882
+ threadId: string,
13655
13883
  admin: boolean = false) → `Promise<`
13656
13884
  Soft delete a thread DELETE /threads/:threadId
13657
13885
 
13658
- **reply**(collectionId: string,
13659
- appId: string,
13660
- threadId: string,
13661
- input: ReplyInput,
13886
+ **reply**(collectionId: string,
13887
+ appId: string,
13888
+ threadId: string,
13889
+ input: ReplyInput,
13662
13890
  admin: boolean = false) → `Promise<AppThread>`
13663
13891
  Add a reply to a thread POST /threads/:threadId/reply Atomically appends to replies array, increments replyCount, updates lastReplyAt
13664
13892
 
13665
- **deleteReply**(collectionId: string,
13666
- appId: string,
13667
- threadId: string,
13668
- replyId: string,
13893
+ **deleteReply**(collectionId: string,
13894
+ appId: string,
13895
+ threadId: string,
13896
+ replyId: string,
13669
13897
  admin: boolean = false) → `Promise<AppThread>`
13670
13898
  Delete a single reply from a thread by its reply id (moderation). DELETE /threads/:threadId/reply/:replyId Authorised for the reply's author, the proof owner, or a collection admin.
13671
13899
 
13672
- **aggregate**(collectionId: string,
13673
- appId: string,
13674
- request: AggregateRequest,
13900
+ **aggregate**(collectionId: string,
13901
+ appId: string,
13902
+ request: AggregateRequest,
13675
13903
  admin: boolean = false) → `Promise<AggregateResponse>`
13676
13904
  Get aggregate statistics for threads POST /threads/aggregate
13677
13905
 
@@ -13706,19 +13934,19 @@ Set/create a keyed data item within a scope. Requires admin authentication. Use
13706
13934
  **deleteDataItem**(opts: AppConfigOptions) → `Promise<void>`
13707
13935
  Delete a keyed data item by ID within a scope. Requires admin authentication. ```typescript await appConfiguration.deleteDataItem({ appId: 'product-docs', collectionId: 'my-collection', productId: 'product-123', admin: true, itemId: 'manual-1' }); ```
13708
13936
 
13709
- **getWidgets**(collectionId: string,
13937
+ **getWidgets**(collectionId: string,
13710
13938
  options?: GetCollectionWidgetsOptions) → `Promise<CollectionWidgetsResponse>`
13711
13939
  Fetches ALL widget data (manifests + bundle files) for a collection in one call. Returns everything needed to render widgets with zero additional requests. This solves N+1 query problems by fetching manifests, JavaScript bundles, and CSS files in parallel on the server. ```typescript // Fetch all widget data for a collection const { apps } = await Api.AppConfiguration.getWidgets(collectionId); // Returns: [{ appId, manifest, widget, container, admin }, ...] // widget / container: { js: { umd?, esm? }, css?, source?, styles? } // source / styles - the bundle inlined (when small enough); js / css - URLs otherwise. // admin - URL of the app's app.admin.json (setup / tunable options), or null. // Bundles don't ship React: they resolve shared libraries from the HOST's globals // (host-dependency-contract.md), so loading one is a host's job. // // Inside a host (Portal / Hub), an app showing ANOTHER app's widget should not load // bundles itself - use the host-provided EmbeddedWidget prop: // <EmbeddedWidget appId="raffle" size="standard" /> (docs/widgets.md) // Force refresh all widgets const { apps } = await Api.AppConfiguration.getWidgets(collectionId, { force: true }); ```
13712
13940
 
13713
13941
  **resolveFeature**(system: SystemBlock | undefined, flag: string) → `boolean`
13714
13942
  Resolve whether a feature flag is on, applying the `accountType` default: `enterprise` accounts default every flag to **on** unless `features[flag]` is explicitly `false`; `standard` accounts (or missing `accountType`) default every flag to **off** unless `features[flag]` is explicitly `true`. An explicit value always wins over the default either way. This is the same logic `isFeatureEnabled()` / `isFeatureEnabledSync()` use internally — call those instead in normal code. `system.features` and `accountType` are public data (no admin-only feature-check path exists), so there's no reason to fetch differently for an admin surface. This is exposed separately only for the rare case where you already have a `system` block in hand from somewhere other than `getAppConfig()` (e.g. server-rendered props) and want to resolve a flag from it directly. ```typescript const enabled = appConfiguration.resolveFeature(someSystemBlock, 'custom_domain'); ```
13715
13943
 
13716
- **getAppConfig**(collectionId: string,
13944
+ **getAppConfig**(collectionId: string,
13717
13945
  options?: { force?: boolean }) → `Promise<AppsConfigResponse>`
13718
13946
  Fetch the collection's app catalog + `appConfig` entitlements data in one call — installed modules (`apps`), resolved entitlements (`system.features`, `system.meters`, etc.), and item-handling settings. This is `/public/collection/:id/app/config` (`collection.getAppsConfig()`), which now carries both; there's no need to separately call `appConfiguration.getConfig({ appId: 'appConfig' })` for public reads. Cached in-memory (and sessionStorage) for `ttl` so repeated calls across a page/session are cheap; pass `force` to bypass the cache after a mutation (e.g. after `entitlements-reconcile`). For admin-only data (`systemPrivate`), use `appConfiguration.getConfig({ collectionId, appId: 'appConfig', admin: true })` directly — this endpoint is public-only and never returns it. See docs/appConfig.md for the full contract. ```typescript const cfg = await appConfiguration.getAppConfig(collectionId); console.log(cfg.system?.features); ```
13719
13947
 
13720
- **isFeatureEnabled**(collectionId: string,
13721
- flag: string,
13948
+ **isFeatureEnabled**(collectionId: string,
13949
+ flag: string,
13722
13950
  options?: { force?: boolean }) → `Promise<boolean>`
13723
13951
  Check whether a feature flag is enabled for a collection, per `appConfig.system.features` — applying the `accountType` default (see `resolveFeature()`): enterprise accounts default every flag to on unless explicitly set to `false`. This is the standard way for subapps to gate features — it reads through the same cache as `getAppConfig`, so calling it repeatedly (e.g. once per component) does not re-fetch on every call. This is always async because the very first call for a collection has nothing to read yet. If you need a synchronous check (e.g. inside a render function), call this once during app init to warm the cache, then use `isFeatureEnabledSync()` afterwards. ```typescript if (await appConfiguration.isFeatureEnabled(collectionId, 'custom_domain')) { enableCustomDomainUI(); } ```
13724
13952
 
@@ -14350,13 +14578,13 @@ Delete a slot (admin; refused while places are booked).
14350
14578
 
14351
14579
  ### chat.completions
14352
14580
 
14353
- **create**(collectionId: string,
14581
+ **create**(collectionId: string,
14354
14582
  request: ChatCompletionRequest) → `Promise<ChatCompletionResponse | AsyncIterable<ChatCompletionChunk>>`
14355
14583
  Create a chat completion (streaming or non-streaming)
14356
14584
 
14357
14585
  ### chat.responses
14358
14586
 
14359
- **create**(collectionId: string,
14587
+ **create**(collectionId: string,
14360
14588
  request: ResponsesRequest) → `Promise<ResponsesResult | AsyncIterable<ResponsesStreamEvent>>`
14361
14589
  Create a Responses API request (streaming or non-streaming)
14362
14590
 
@@ -14532,86 +14760,86 @@ Invite a user to a collection by email (admin only). Creates or links their acco
14532
14760
  **getPushVapidPublicKey**(collectionId: string) → `Promise<import("../types/comms").PushVapidResponse>`
14533
14761
  Public: Get VAPID public key used for Web Push subscriptions. GET /public/collection/:collectionId/comm/push/vapidPublicKey Note: Key may be global; path is collection-scoped for consistency.
14534
14762
 
14535
- **registerPush**(collectionId: string,
14763
+ **registerPush**(collectionId: string,
14536
14764
  body: import("../types/comms") → `void`
14537
14765
  Public: Register a Web Push subscription under unified comms. POST /public/collection/:collectionId/comm/push/register
14538
14766
 
14539
- **getSettings**(collectionId: string,
14767
+ **getSettings**(collectionId: string,
14540
14768
  opts: { includeSecret?: boolean } = {}) → `Promise<import("../types/comms").CommsSettingsGetResponse>`
14541
14769
  Admin: Get current comms settings for a collection. GET /admin/collection/:collectionId/comm.settings Optional query: includeSecret=true to include unsub.secret in response.
14542
14770
 
14543
- **patchSettings**(collectionId: string,
14771
+ **patchSettings**(collectionId: string,
14544
14772
  body: import("../types/comms") → `void`
14545
14773
  Admin: Patch comms settings for a collection. PATCH /admin/collection/:collectionId/comm.settings
14546
14774
 
14547
14775
  **getPublicTopics**(collectionId: string) → `Promise<import("../types/comms").CommsPublicTopicsResponse>`
14548
14776
  Public: Fetch configured topics for a collection. GET /public/collection/:collectionId/comm/topics
14549
14777
 
14550
- **unsubscribe**(collectionId: string,
14778
+ **unsubscribe**(collectionId: string,
14551
14779
  query: import("../types/comms") → `void`
14552
14780
  Public: Unsubscribe a contact from a category or channel. GET /public/collection/:collectionId/comm/unsubscribe
14553
14781
 
14554
- **signup**(collectionId: string,
14782
+ **signup**(collectionId: string,
14555
14783
  body: import("../types/comms") → `void`
14556
14784
  Public: sign an email address up for topics (a newsletter, updates) — works signed out. Double opt-in: nothing is consented until the address's owner clicks the confirmation link SmartLinks emails them. Always answers `{ ok: true, pending: true }` (it never reveals whether the address is already known). Topics must be ones configured in the collection's comm settings. Set comm settings `signup.confirmedUrl` to send people to your own page after confirming. POST /public/collection/:collectionId/comm/signup
14557
14785
 
14558
- **upsertConsent**(collectionId: string,
14786
+ **upsertConsent**(collectionId: string,
14559
14787
  body: import("../types/comms") → `void`
14560
14788
  Public: Upsert default consent for a contact. POST /public/collection/:collectionId/comm/consent
14561
14789
 
14562
- **upsertPreferences**(collectionId: string,
14790
+ **upsertPreferences**(collectionId: string,
14563
14791
  body: import("../types/comms") → `void`
14564
14792
  Public: Upsert preferences for a specific subject (or default if subject omitted). POST /public/collection/:collectionId/comm/preferences
14565
14793
 
14566
- **subscribe**(collectionId: string,
14794
+ **subscribe**(collectionId: string,
14567
14795
  body: import("../types/comms") → `void`
14568
14796
  Public: Subscribe/unsubscribe contact to a subject. POST /public/collection/:collectionId/comm/subscribe
14569
14797
 
14570
- **checkSubscription**(collectionId: string,
14798
+ **checkSubscription**(collectionId: string,
14571
14799
  query: import("../types/comms") → `void`
14572
14800
  Public: Check subscription status for a subject. GET /public/collection/:collectionId/comm/subscription/check
14573
14801
 
14574
- **listMethods**(collectionId: string,
14802
+ **listMethods**(collectionId: string,
14575
14803
  query: import("../types/comms") → `void`
14576
14804
  Public: List registered contact methods. GET /public/collection/:collectionId/comm/methods
14577
14805
 
14578
- **registerEmail**(collectionId: string,
14806
+ **registerEmail**(collectionId: string,
14579
14807
  body: import("../types/comms") → `void`
14580
14808
  Public: Register email method for a contact. POST /public/collection/:collectionId/comm/email/register
14581
14809
 
14582
- **registerSms**(collectionId: string,
14810
+ **registerSms**(collectionId: string,
14583
14811
  body: import("../types/comms") → `void`
14584
14812
  Public: Register SMS method for a contact. POST /public/collection/:collectionId/comm/sms/register
14585
14813
 
14586
- **resolveSubscriptions**(collectionId: string,
14814
+ **resolveSubscriptions**(collectionId: string,
14587
14815
  body: import("../types/comms") → `void`
14588
14816
  Public: Resolve contacts for a subject with identity hints. POST /public/collection/:collectionId/comm/subscriptions/resolve
14589
14817
 
14590
- **queryByUser**(collectionId: string,
14818
+ **queryByUser**(collectionId: string,
14591
14819
  body: CommsQueryByUser = {}) → `Promise<CommunicationEvent[]>`
14592
14820
  Analytics: Query communication events by user or contact. POST /admin/collection/:collectionId/comm/query/by-user
14593
14821
 
14594
- **queryRecipientIds**(collectionId: string,
14822
+ **queryRecipientIds**(collectionId: string,
14595
14823
  body: CommsRecipientIdsQuery) → `Promise<RecipientId[]>`
14596
14824
  Analytics: Recipient IDs for a communication source. POST /admin/collection/:collectionId/comm/query/recipient-ids
14597
14825
 
14598
- **queryRecipientsWithoutAction**(collectionId: string,
14826
+ **queryRecipientsWithoutAction**(collectionId: string,
14599
14827
  body: CommsRecipientsWithoutActionQuery) → `Promise<RecipientId[]>`
14600
14828
  Analytics: Recipients who did not perform an action. POST /admin/collection/:collectionId/comm/query/recipients/without-action
14601
14829
 
14602
- **queryRecipientsWithAction**(collectionId: string,
14830
+ **queryRecipientsWithAction**(collectionId: string,
14603
14831
  body: CommsRecipientsWithActionQuery) → `Promise<RecipientId[] | RecipientWithOutcome[]>`
14604
14832
  Analytics: Recipients who performed an action, optionally with outcome. POST /admin/collection/:collectionId/comm/query/recipients/with-action
14605
14833
 
14606
- **sendTransactional**(collectionId: string,
14834
+ **sendTransactional**(collectionId: string,
14607
14835
  body: TransactionalSendRequest) → `Promise<TransactionalSendResult>`
14608
14836
  Send a single transactional message to one contact using a template. No broadcast record is created. The send is logged to the contact's communication history with sourceType: 'transactional'. POST /admin/collection/:collectionId/comm/send ```typescript const result = await comms.sendTransactional(collectionId, { contactId: 'e4f2a1b0-...', templateId: 'warranty-update', channel: 'preferred', props: { claimRef: 'CLM-0042', decision: 'approved' }, include: { productId: 'prod-abc123', appCase: 'c9d1e2f3-...' }, ref: 'warranty-decision-notification', appId: 'warrantyApp', }) if (result.ok) { console.log(`Sent via ${result.channel}`, result.messageId) } else { console.error('Send failed:', result.error) } ```
14609
14837
 
14610
- **logCommunicationEvent**(collectionId: string,
14838
+ **logCommunicationEvent**(collectionId: string,
14611
14839
  body: LogCommunicationEventBody) → `Promise<AppendResult>`
14612
14840
  Logging: Append a single communication event. POST /admin/collection/:collectionId/comm/log
14613
14841
 
14614
- **logBulkCommunicationEvents**(collectionId: string,
14842
+ **logBulkCommunicationEvents**(collectionId: string,
14615
14843
  body: LogBulkCommunicationEventsBody | ({ sourceId: string; ids: string[]; idField?: 'userId'|'contactId'; [k: string]: any }) → `void`
14616
14844
  Logging: Append many communication events for a list of IDs. POST /admin/collection/:collectionId/comm/log/bulk
14617
14845
 
@@ -14642,7 +14870,7 @@ Returns all proof type definitions. Proof types are templates that specify which
14642
14870
 
14643
14871
  ### contact
14644
14872
 
14645
- **query**(collectionId: string,
14873
+ **query**(collectionId: string,
14646
14874
  body: StandardQuery = {}) → `Promise<QueryResult>`
14647
14875
  The standard query on contacts (admin only): filter, sort, page, count and total in one call. POST /admin/collection/:collectionId/contacts/query Fields: contactId, userId, firstName, lastName, displayName, company, email, phone, tags, source, locale, createdAt, updatedAt. Email and phone are the contact's main one. Deleted and erased contacts are never returned. ```typescript await contact.query(collectionId, { where: { tags: { hasAny: ['vip', 'trade'] }, createdAt: { gte: '2026-01-01' } }, select: ['contactId', 'firstName', 'email'], count: true, }) await contact.query(collectionId, { groupBy: ['company'], aggregates: { people: { count: true } } }) ```
14648
14876
 
@@ -14652,62 +14880,62 @@ What a contacts query can use: its fields and what each can filter, sort, group
14652
14880
  **create**(collectionId: string, data: ContactCreateRequest) → `Promise<ContactResponse>`
14653
14881
  What a contacts query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/contacts/query
14654
14882
 
14655
- **list**(collectionId: string,
14883
+ **list**(collectionId: string,
14656
14884
  params?: { limit?: number; offset?: number; includeDeleted?: boolean }) → `Promise<ContactListResponse>`
14657
14885
  What a contacts query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/contacts/query
14658
14886
 
14659
- **search**({
14660
- collectionId,
14661
- q,
14662
- typeahead,
14663
- email,
14664
- phone,
14665
- id,
14666
- userId,
14667
- tags,
14668
- tagsAll,
14669
- source,
14670
- locale,
14671
- createdFrom,
14672
- createdTo,
14673
- externalIdKey,
14674
- externalIdValue,
14675
- customFieldKey,
14676
- customFieldValue,
14677
- limit,
14678
- offset,
14887
+ **search**({
14888
+ collectionId,
14889
+ q,
14890
+ typeahead,
14891
+ email,
14892
+ phone,
14893
+ id,
14894
+ userId,
14895
+ tags,
14896
+ tagsAll,
14897
+ source,
14898
+ locale,
14899
+ createdFrom,
14900
+ createdTo,
14901
+ externalIdKey,
14902
+ externalIdValue,
14903
+ customFieldKey,
14904
+ customFieldValue,
14905
+ limit,
14906
+ offset,
14679
14907
  }: ContactSearchParams) → `Promise<ContactSearchResponse>`
14680
14908
  What a contacts query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/contacts/query
14681
14909
 
14682
- **get**(collectionId: string,
14683
- contactId: string,
14910
+ **get**(collectionId: string,
14911
+ contactId: string,
14684
14912
  params?: { includeDeleted?: boolean }) → `Promise<ContactResponse>`
14685
14913
  What a contacts query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/contacts/query
14686
14914
 
14687
- **update**(collectionId: string,
14688
- contactId: string,
14915
+ **update**(collectionId: string,
14916
+ contactId: string,
14689
14917
  data: ContactUpdateRequest) → `Promise<ContactResponse>`
14690
14918
  What a contacts query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/contacts/query
14691
14919
 
14692
14920
  **remove**(collectionId: string, contactId: string) → `Promise<void>`
14693
14921
  What a contacts query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/contacts/query
14694
14922
 
14695
- **lookup**(collectionId: string,
14923
+ **lookup**(collectionId: string,
14696
14924
  params: { email?: string; phone?: string }) → `Promise<ContactResponse>`
14697
14925
  What a contacts query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/contacts/query
14698
14926
 
14699
- **upsert**(collectionId: string,
14927
+ **upsert**(collectionId: string,
14700
14928
  data: ContactCreateRequest) → `Promise<ContactResponse>`
14701
14929
  What a contacts query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/contacts/query
14702
14930
 
14703
- **publicUpsert**(collectionId: string,
14931
+ **publicUpsert**(collectionId: string,
14704
14932
  data: PublicContactUpsertRequest) → `Promise<PublicContactUpsertResponse>`
14705
14933
  What a contacts query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/contacts/query
14706
14934
 
14707
14935
  **publicGetMine**(collectionId: string) → `Promise<PublicGetMyContactResponse>`
14708
14936
  What a contacts query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/contacts/query
14709
14937
 
14710
- **publicUpdateMine**(collectionId: string,
14938
+ **publicUpdateMine**(collectionId: string,
14711
14939
  data: ContactPatch) → `Promise<PublicUpdateMyContactResponse>`
14712
14940
  What a contacts query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/contacts/query
14713
14941
 
@@ -14717,77 +14945,77 @@ Public: Get the contact schema for a collection. GET /public/collection/:collect
14717
14945
  **erase**(collectionId: string, contactId: string, body?: any) → `Promise<ContactResponse>`
14718
14946
  Public: Get the contact schema for a collection. GET /public/collection/:collectionId/contact/schema Returns a ContactSchemaResponse describing all publicly visible contact fields. Core fields and collection-defined custom fields are merged into a single flat schema. Fields not in `publicVisibleFields` are stripped entirely from the response. Fields visible but not in `publicEditableFields` have `ui:disabled: true` in `uiSchema`. Use `fieldOrder` to render fields in the correct sequence, and `evaluateConditions` from the types package to handle conditional field visibility. ```typescript import { contact, evaluateConditions } from '@proveanything/smartlinks' const schema = await contact.publicGetSchema(collectionId) for (const fieldId of schema.fieldOrder) { const property = schema.schema.properties[fieldId] const ui = schema.uiSchema[fieldId] || {} const visible = evaluateConditions(property.conditions, property.showWhen, formValues) const disabled = ui['ui:disabled'] === true if (visible) renderField({ fieldId, property, ui, disabled }) } ```
14719
14947
 
14720
- **findDuplicates**(collectionId: string,
14948
+ **findDuplicates**(collectionId: string,
14721
14949
  params?: { limit?: number; offset?: number }) → `Promise<ContactDuplicatesResponse>`
14722
14950
  Admin: pairs of contacts that look like one person. GET /admin/collection/:collectionId/contacts/duplicates The pattern it finds: someone the collection knew by email first (an import, a list, a form) who later signed in. Their sign-in got a second contact, which could not take the email the first one already held — so one contact has the email and no sign-in, the other the sign-in (and everything they did) and no email. The match is made on the server, on verified addresses only. Checks a window of contacts per call; while `more` is true, call again with `offset` moved on by `scanned`. ```typescript const { pairs } = await contact.findDuplicates(collectionId) for (const pair of pairs) { await contact.merge(collectionId, pair.keep.contactId, pair.merge.contactId) } ```
14723
14951
 
14724
- **merge**(collectionId: string,
14725
- keepContactId: string,
14952
+ **merge**(collectionId: string,
14953
+ keepContactId: string,
14726
14954
  fromContactId: string) → `Promise<ContactMergeResponse>`
14727
14955
  Admin: fold contact `fromContactId` INTO contact `keepContactId`. POST /admin/collection/:collectionId/contacts/:keepContactId/merge The kept contact gains the other's sign-in, emails and phones, and anything it had no value for; its own values win. Everything recorded against the other contact moves to the kept one. Consent is never loosened: an opt-out on either contact stays an opt-out. The other contact is soft-deleted and marked with `customFields.mergedInto`. Refused (HTTP 409, `error` = a `ContactMergeErrorCode`) when the two have different sign-ins (`LOGIN_CONFLICT`) or are both members of the same loyalty scheme (`LOYALTY_CONFLICT`).
14728
14956
 
14729
- **linkLogin**(collectionId: string,
14957
+ **linkLogin**(collectionId: string,
14730
14958
  userId: string) → `Promise<ContactLinkLoginResponse>`
14731
14959
  Admin: the contact that carries a sign-in, attaching the sign-in first to the contact that already holds its verified email or phone. POST /admin/collection/:collectionId/contacts/link-login For a service about to create a contact for a `userId`: call this first and only create when it throws 404 (`NOTHING_TO_LINK`), so a person the collection already knows by email stays one contact. The address is read from the sign-in itself and must be verified; nothing the caller says about an email is used. Never creates a contact. ```typescript let contactId: string try { contactId = (await contact.linkLogin(collectionId, userId)).contactId } catch (err) { if (err.statusCode !== 404) throw err contactId = (await contact.create(collectionId, { userId, source: 'my-service' })).contactId } ```
14732
14960
 
14733
- **getUser**(collectionId: string,
14961
+ **getUser**(collectionId: string,
14734
14962
  userId: string,) → `Promise<UserSearchResponse>`
14735
14963
  Admin: the contact that carries a sign-in, attaching the sign-in first to the contact that already holds its verified email or phone. POST /admin/collection/:collectionId/contacts/link-login For a service about to create a contact for a `userId`: call this first and only create when it throws 404 (`NOTHING_TO_LINK`), so a person the collection already knows by email stays one contact. The address is read from the sign-in itself and must be verified; nothing the caller says about an email is used. Never creates a contact. ```typescript let contactId: string try { contactId = (await contact.linkLogin(collectionId, userId)).contactId } catch (err) { if (err.statusCode !== 404) throw err contactId = (await contact.create(collectionId, { userId, source: 'my-service' })).contactId } ```
14736
14964
 
14737
14965
  ### containers
14738
14966
 
14739
- **create**(collectionId: string,
14967
+ **create**(collectionId: string,
14740
14968
  data: CreateContainerInput) → `Promise<Container>`
14741
14969
  Create a new container (admin). ```typescript const cask = await containers.create('coll_123', { containerType: 'cask', ref: 'CASK-0042', name: 'Cask 42 — Single Malt', metadata: { distilleryYear: 2019, capacity: 200 }, }) ```
14742
14970
 
14743
- **list**(collectionId: string,
14971
+ **list**(collectionId: string,
14744
14972
  params?: ListContainersParams) → `Promise<ListContainersResponse>`
14745
14973
  List containers (admin). Supports filtering by type, status, ref, parent, and top-level flag. ```typescript // All active pallets const { containers: pallets } = await containers.list('coll_123', { containerType: 'pallet', status: 'active', limit: 50, }) // Top-level containers only const { containers: roots } = await containers.list('coll_123', { topLevel: true }) ```
14746
14974
 
14747
- **findForItem**(collectionId: string,
14975
+ **findForItem**(collectionId: string,
14748
14976
  params: FindContainersForItemParams) → `Promise<FindContainersForItemResponse>`
14749
14977
  Reverse lookup — find all containers currently holding a specific item (admin). ```typescript const { containers: holding } = await containers.findForItem('coll_123', { itemType: 'proof', itemId: 'unit-0007', productId: 'drill', }) ```
14750
14978
 
14751
- **get**(collectionId: string,
14752
- containerId: string,
14979
+ **get**(collectionId: string,
14980
+ containerId: string,
14753
14981
  params?: GetContainerParams) → `Promise<Container>`
14754
14982
  Get a single container by ID (admin). Pass `?tree=true` to recursively embed children, and/or `?includeContents=true` to embed the current item list. ```typescript // Flat const cask = await containers.get('coll_123', 'cask-uuid') // Full tree with contents const tree = await containers.get('coll_123', 'warehouse-uuid', { tree: true, treeDepth: 3, includeContents: true, }) ```
14755
14983
 
14756
- **update**(collectionId: string,
14757
- containerId: string,
14984
+ **update**(collectionId: string,
14985
+ containerId: string,
14758
14986
  data: UpdateContainerInput) → `Promise<Container>`
14759
14987
  Partially update a container (admin). Only fields present in the request body are modified. Pass `parentContainerId: null` to promote a container to top-level. ```typescript const updated = await containers.update('coll_123', 'cask-uuid', { status: 'archived', metadata: { bottledAt: '2025-04-01' }, }) ```
14760
14988
 
14761
- **remove**(collectionId: string,
14989
+ **remove**(collectionId: string,
14762
14990
  containerId: string) → `Promise<`
14763
14991
  Soft-delete a container (admin). Sets `deletedAt`; the record and its full item history remain queryable by admins. Public API responses automatically exclude deleted containers.
14764
14992
 
14765
- **listItems**(collectionId: string,
14766
- containerId: string,
14993
+ **listItems**(collectionId: string,
14994
+ containerId: string,
14767
14995
  params?: ListContainerItemsParams) → `Promise<ContainerItemsResponse>`
14768
14996
  List items currently (or historically) inside a container (admin). Pass `history: true` to include removed items and see the full membership log. ```typescript // Current contents const { items } = await containers.listItems('coll_123', 'cask-uuid') // Full history including removed items const { items: history } = await containers.listItems('coll_123', 'cask-uuid', { history: true }) ```
14769
14997
 
14770
- **addItems**(collectionId: string,
14771
- containerId: string,
14998
+ **addItems**(collectionId: string,
14999
+ containerId: string,
14772
15000
  data: AddContainerItemsInput) → `Promise<AddContainerItemsResponse>`
14773
15001
  Add one or more items to a container (admin). Each item requires `itemType` and `itemId`. Pass `productId` / `proofId` for denormalisation convenience. ```typescript const { items } = await containers.addItems('coll_123', 'pallet-uuid', { items: [ { itemType: 'tag', itemId: 'NFC-00AABBCC' }, { itemType: 'proof', itemId: 'proof-uuid', productId: 'product-id' }, ], }) ```
14774
15002
 
14775
- **removeItems**(collectionId: string,
14776
- containerId: string,
15003
+ **removeItems**(collectionId: string,
15004
+ containerId: string,
14777
15005
  data: RemoveContainerItemsInput) → `Promise<RemoveContainerItemsResponse>`
14778
15006
  Soft-remove items from a container (admin). Sets `removedAt` on the specified `ContainerItem` records. The records are retained in the history log and can be queried with `history: true`. ```typescript const result = await containers.removeItems('coll_123', 'pallet-uuid', { ids: ['container-item-uuid-1', 'container-item-uuid-2'], }) console.log(`Removed ${result.removedCount} items`) ```
14779
15007
 
14780
- **publicList**(collectionId: string,
15008
+ **publicList**(collectionId: string,
14781
15009
  params?: ListContainersParams) → `Promise<PublicListContainersResponse>`
14782
15010
  List containers (public). Soft-deleted containers and containers with `metadata.publicListing === false` are excluded from results.
14783
15011
 
14784
- **publicGet**(collectionId: string,
14785
- containerId: string,
15012
+ **publicGet**(collectionId: string,
15013
+ containerId: string,
14786
15014
  params?: GetContainerParams) → `Promise<Container>`
14787
15015
  Get a single container (public). Soft-deleted containers return a 404. Same `?tree` and `?includeContents` options as the admin version.
14788
15016
 
14789
- **publicListItems**(collectionId: string,
14790
- containerId: string,
15017
+ **publicListItems**(collectionId: string,
15018
+ containerId: string,
14791
15019
  params?: Pick<ListContainerItemsParams, 'limit' | 'offset'>) → `Promise<ContainerItemsResponse>`
14792
15020
  List current contents of a container (public). Returns only items where `removedAt` is null. No `?history` option on the public side.
14793
15021
 
@@ -15010,8 +15238,8 @@ Update whitelisted fields. PUT /integrations/flows/:id
15010
15238
  **deleteFlow**(collectionId: string, id: string) → `Promise<`
15011
15239
  Soft-delete a flow. DELETE /integrations/flows/:id
15012
15240
 
15013
- **runFlow**(collectionId: string,
15014
- id: string,
15241
+ **runFlow**(collectionId: string,
15242
+ id: string,
15015
15243
  options: RunFlowInput & { async?: boolean } = {}) → `Promise<RunFlowResult>`
15016
15244
  Run a flow now. POST /integrations/flows/:id/run - inline (default): resolves and returns the run summary. - options.async: enqueue on the worker, returns { enqueued: true }. Pass options.entityId to run for a single source entity.
15017
15245
 
@@ -15039,8 +15267,8 @@ Is enhanced logging active for a connection? GET /integrations/logging/:connecti
15039
15267
  **setLogging**(collectionId: string, connectionId: string, input: SetLoggingInput = {}) → `Promise<`
15040
15268
  Enable enhanced logging. POST /integrations/logging/:connectionId (omit ttlMinutes = until cancelled)
15041
15269
 
15042
- **listFailed**(collectionId: string,
15043
- flowId: string,
15270
+ **listFailed**(collectionId: string,
15271
+ flowId: string,
15044
15272
  query: { status?: 'failed' | 'dead'; limit?: number; cursor?: string } = {}) → `Promise<FailedRecordList>`
15045
15273
  A flow's failed / dead records. GET /integrations/flows/:id/failed
15046
15274
 
@@ -15065,30 +15293,30 @@ Cancel enhanced logging now. DELETE /integrations/logging/:connectionId
15065
15293
  **listConnectors**(collectionId: string) → `Promise<`
15066
15294
  The collection's installed connector apps. GET /integrations/connectors
15067
15295
 
15068
- **saveConnectorInstallation**(collectionId: string,
15069
- appId: string,
15296
+ **saveConnectorInstallation**(collectionId: string,
15297
+ appId: string,
15070
15298
  input: SaveConnectorInstallationInput) → `Promise<`
15071
15299
  Save a connector's non-secret Connect-form values and/or settings. PUT /integrations/connectors/:appId/installation
15072
15300
 
15073
- **runConnectorStep**(collectionId: string,
15074
- appId: string,
15075
- step: ConnectorConsoleStep,
15301
+ **runConnectorStep**(collectionId: string,
15302
+ appId: string,
15303
+ step: ConnectorConsoleStep,
15076
15304
  input: Record<string, unknown> & { flowId?: string } = {}) → `Promise<T>`
15077
15305
  Run a connector step from the console: `testConnection` → ConnectorTestResult, `describeTarget` → ConnectorTargetSchema, `sample` → ConnectorRecords, and dry runs of `shape` ({ records }) → ConnectorShapeResult and `serialize` ({ documents }) → ConnectorSerializeResult. The server adds the installation; pass `flowId` to layer that flow's settings. POST /integrations/connectors/:appId/steps/:step
15078
15306
 
15079
- **runConnectorAction**(collectionId: string,
15080
- appId: string,
15081
- action: string,
15307
+ **runConnectorAction**(collectionId: string,
15308
+ appId: string,
15309
+ action: string,
15082
15310
  input: Record<string, unknown> = {}) → `Promise<T>`
15083
15311
  Invoke a connector ACTION from the console (any visibility): redeem, enrol, adjust points, issue a coupon… The connector's function runs with its own credentials and is told who asked. POST /integrations/connectors/:appId/actions/:action { input }
15084
15312
 
15085
- **listConnectorActions**(collectionId: string,
15313
+ **listConnectorActions**(collectionId: string,
15086
15314
  appId: string) → `Promise<`
15087
15315
  PUBLIC (the Hub, a site): the connector actions the caller may invoke — those declared `public`, plus `member` ones when signed in. GET /public/collection/:collectionId/connectors/:appId/actions
15088
15316
 
15089
- **callConnectorAction**(collectionId: string,
15090
- appId: string,
15091
- action: string,
15317
+ **callConnectorAction**(collectionId: string,
15318
+ appId: string,
15319
+ action: string,
15092
15320
  input: Record<string, unknown> = {}) → `Promise<T>`
15093
15321
  PUBLIC (the Hub, a site): invoke a connector action — e.g. redeem a reward for the signed-in member. 401 SIGN_IN_REQUIRED for a `member` action without a session; 403 for an admin-only one; 400 with `missing[]` when a required input is absent. POST /public/collection/:collectionId/connectors/:appId/actions/:action { input }
15094
15322
 
@@ -15322,82 +15550,82 @@ Paginated member product summaries.
15322
15550
 
15323
15551
  Loyalty programmes built on top of collections. Configure schemes and earning rules; contacts earn points automatically via interaction events. See the [Loyalty guide](loyalty.md) for the full walkthrough.
15324
15552
 
15325
- **list**(collectionId: string,
15553
+ **list**(collectionId: string,
15326
15554
  params: { includeDeleted?: boolean } = {}) → `Promise<LoyaltyScheme[]>`
15327
15555
 
15328
- **get**(collectionId: string,
15556
+ **get**(collectionId: string,
15329
15557
  schemeId: string) → `Promise<LoyaltyScheme>`
15330
15558
 
15331
- **create**(collectionId: string,
15559
+ **create**(collectionId: string,
15332
15560
  body: CreateLoyaltySchemeBody) → `Promise<LoyaltyScheme>`
15333
15561
 
15334
- **update**(collectionId: string,
15335
- schemeId: string,
15562
+ **update**(collectionId: string,
15563
+ schemeId: string,
15336
15564
  body: UpdateLoyaltySchemeBody) → `Promise<LoyaltyScheme>`
15337
15565
 
15338
- **remove**(collectionId: string,
15566
+ **remove**(collectionId: string,
15339
15567
  schemeId: string) → `Promise<LoyaltyScheme>`
15340
15568
 
15341
- **listEarningRules**(collectionId: string,
15569
+ **listEarningRules**(collectionId: string,
15342
15570
  schemeId: string) → `Promise<LoyaltyEarningRule[]>`
15343
15571
 
15344
- **getEarningRule**(collectionId: string,
15345
- schemeId: string,
15572
+ **getEarningRule**(collectionId: string,
15573
+ schemeId: string,
15346
15574
  ruleId: string) → `Promise<LoyaltyEarningRule>`
15347
15575
 
15348
- **createEarningRule**(collectionId: string,
15349
- schemeId: string,
15576
+ **createEarningRule**(collectionId: string,
15577
+ schemeId: string,
15350
15578
  body: CreateLoyaltyEarningRuleBody) → `Promise<LoyaltyEarningRule>`
15351
15579
 
15352
- **updateEarningRule**(collectionId: string,
15353
- schemeId: string,
15354
- ruleId: string,
15580
+ **updateEarningRule**(collectionId: string,
15581
+ schemeId: string,
15582
+ ruleId: string,
15355
15583
  body: UpdateLoyaltyEarningRuleBody) → `Promise<LoyaltyEarningRule>`
15356
15584
 
15357
- **removeEarningRule**(collectionId: string,
15358
- schemeId: string,
15585
+ **removeEarningRule**(collectionId: string,
15586
+ schemeId: string,
15359
15587
  ruleId: string) → `Promise<LoyaltyEarningRule>`
15360
15588
 
15361
- **listMembers**(collectionId: string,
15362
- schemeId: string,
15589
+ **listMembers**(collectionId: string,
15590
+ schemeId: string,
15363
15591
  params: LoyaltyPaginationParams = {}) → `Promise<LoyaltyPaginatedResult<LoyaltyMember>>`
15364
15592
 
15365
- **getMember**(collectionId: string,
15366
- schemeId: string,
15593
+ **getMember**(collectionId: string,
15594
+ schemeId: string,
15367
15595
  contactId: string) → `Promise<LoyaltyMember>`
15368
15596
 
15369
- **recordTransaction**(collectionId: string,
15370
- schemeId: string,
15371
- contactId: string,
15597
+ **recordTransaction**(collectionId: string,
15598
+ schemeId: string,
15599
+ contactId: string,
15372
15600
  body: RecordLoyaltyTransactionBody) → `Promise<LoyaltyTransactionResult>`
15373
15601
  Manually award or deduct points for a contact. - `points` must be a non-zero integer - Positive = award, negative = deduct - Deducting below zero returns HTTP 422 `INSUFFICIENT_BALANCE` - Supply `idempotencyKey` to safely retry without double-crediting Points earned via interaction events are awarded automatically by the server — this endpoint is for manual adjustments and admin overrides.
15374
15602
 
15375
- **getMemberHistory**(collectionId: string,
15376
- schemeId: string,
15377
- contactId: string,
15603
+ **getMemberHistory**(collectionId: string,
15604
+ schemeId: string,
15605
+ contactId: string,
15378
15606
  params: LoyaltyPaginationParams = {}) → `Promise<LoyaltyPaginatedResult<LoyaltyTransaction>>`
15379
15607
  Manually award or deduct points for a contact. - `points` must be a non-zero integer - Positive = award, negative = deduct - Deducting below zero returns HTTP 422 `INSUFFICIENT_BALANCE` - Supply `idempotencyKey` to safely retry without double-crediting Points earned via interaction events are awarded automatically by the server — this endpoint is for manual adjustments and admin overrides.
15380
15608
 
15381
15609
  **publicList**(collectionId: string) → `Promise<LoyaltyScheme[]>`
15382
15610
  List active schemes for a collection. No authentication required.
15383
15611
 
15384
- **publicGet**(collectionId: string,
15612
+ **publicGet**(collectionId: string,
15385
15613
  schemeId: string) → `Promise<LoyaltyScheme>`
15386
15614
  Get a single active scheme. No authentication required.
15387
15615
 
15388
- **publicListEarningRules**(collectionId: string,
15616
+ **publicListEarningRules**(collectionId: string,
15389
15617
  schemeId: string) → `Promise<LoyaltyEarningRule[]>`
15390
15618
  List active earning rules for a scheme — useful for showing "how to earn" in a loyalty UI. No authentication required.
15391
15619
 
15392
15620
  **publicGetMe**(collectionId: string) → `Promise<LoyaltySchemeWithMembership[]>`
15393
15621
  Get all active schemes with the caller's membership embedded in each. This is the primary entry point for a loyalty widget — one call gives you everything needed to render a user's loyalty status across all programs in a collection. - Authenticated: `member` is populated with balance + lifetimePoints (or null if not yet enrolled in that scheme) - Unauthenticated: `member` is null on all schemes
15394
15622
 
15395
- **publicGetMine**(collectionId: string,
15623
+ **publicGetMine**(collectionId: string,
15396
15624
  schemeId: string) → `Promise<LoyaltyMember>`
15397
15625
  Get the authenticated caller's membership (balance + lifetimePoints) on a specific scheme. Requires authentication.
15398
15626
 
15399
- **publicGetMineHistory**(collectionId: string,
15400
- schemeId: string,
15627
+ **publicGetMineHistory**(collectionId: string,
15628
+ schemeId: string,
15401
15629
  params: LoyaltyPaginationParams = {}) → `Promise<LoyaltyPaginatedResult<LoyaltyTransaction>>`
15402
15630
  Get the authenticated caller's transaction history on a specific scheme. Ordered newest first. Requires authentication.
15403
15631
 
@@ -15435,98 +15663,98 @@ What the server offers, by group: `{ workOrders: [...], stock: [...], boms: [...
15435
15663
 
15436
15664
  ### order
15437
15665
 
15438
- **create**(collectionId: string,
15666
+ **create**(collectionId: string,
15439
15667
  data: CreateOrderRequest) → `Promise<CreateOrderResponse>`
15440
15668
  Create a new order with items. ```typescript const order = await order.create('coll_123', { orderRef: 'ORD-12345', customerId: 'CUST-789', items: [ { itemType: 'tag', itemId: 'TAG001' }, { itemType: 'tag', itemId: 'TAG002' }, { itemType: 'serial', itemId: 'SN12345' } ], status: 'pending', metadata: { shipmentId: 'SHIP-789', destination: 'Warehouse B' } }) ```
15441
15669
 
15442
- **get**(collectionId: string,
15443
- orderId: string,
15670
+ **get**(collectionId: string,
15671
+ orderId: string,
15444
15672
  params?: GetOrderParams) → `Promise<GetOrderResponse>`
15445
15673
  Get a single order by ID. ```typescript // Get order without items (faster) const order = await order.get('coll_123', 'order_abc123') console.log(`Order has ${order.itemCount} items`) // Get order with items const orderWithItems = await order.get('coll_123', 'order_abc123', { includeItems: true }) console.log(orderWithItems.items) // Items array available ```
15446
15674
 
15447
- **update**(collectionId: string,
15448
- orderId: string,
15675
+ **update**(collectionId: string,
15676
+ orderId: string,
15449
15677
  data: UpdateOrderRequest) → `Promise<UpdateOrderResponse>`
15450
15678
  Update order status or metadata. Items are managed separately via addItems/removeItems. ```typescript const updated = await order.update('coll_123', 'order_abc123', { status: 'shipped', metadata: { trackingNumber: '1Z999AA10123456784', shippedAt: '2026-02-02T14:30:00Z' } }) ```
15451
15679
 
15452
- **remove**(collectionId: string,
15680
+ **remove**(collectionId: string,
15453
15681
  orderId: string) → `Promise<DeleteOrderResponse>`
15454
15682
  Delete an order and all its items (cascade delete). ```typescript await order.remove('coll_123', 'order_abc123') ```
15455
15683
 
15456
- **list**(collectionId: string,
15684
+ **list**(collectionId: string,
15457
15685
  params?: ListOrdersRequest) → `Promise<ListOrdersResponse>`
15458
15686
  List orders for a collection with optional filters and pagination. Orders are returned in descending order by createdAt (newest first). ```typescript // List all orders (without items for better performance) const all = await order.list('coll_123') // List with filters const pending = await order.list('coll_123', { status: 'pending', limit: 50, offset: 0 }) // Filter by customer with items const customerOrders = await order.list('coll_123', { customerId: 'CUST-789', includeItems: true }) ```
15459
15687
 
15460
- **getItems**(collectionId: string,
15461
- orderId: string,
15688
+ **getItems**(collectionId: string,
15689
+ orderId: string,
15462
15690
  params?: GetOrderItemsParams) → `Promise<GetOrderItemsResponse>`
15463
15691
  Get items from an order with pagination support. Use this for orders with many items instead of includeItems. ```typescript // Get first page of items const page1 = await order.getItems('coll_123', 'order_abc123', { limit: 100, offset: 0 }) // Get next page const page2 = await order.getItems('coll_123', 'order_abc123', { limit: 100, offset: 100 }) ```
15464
15692
 
15465
- **addItems**(collectionId: string,
15466
- orderId: string,
15693
+ **addItems**(collectionId: string,
15694
+ orderId: string,
15467
15695
  data: AddItemsRequest) → `Promise<AddItemsResponse>`
15468
15696
  Add additional items to an existing order. ```typescript const updated = await order.addItems('coll_123', 'order_abc123', { items: [ { itemType: 'tag', itemId: 'TAG003' }, { itemType: 'proof', itemId: 'proof_xyz' } ] }) console.log(`Order now has ${updated.itemCount} items`) ```
15469
15697
 
15470
15698
  **lineDone**(collectionId: string, orderId: string, itemId: string, by: number) → `Promise<OrderItem>`
15471
15699
  Add to (or take from) how much of a line has been shipped or received. Atomic, so two receipts at once both count; it can't go below zero. ```typescript // 20 more caps arrived against a purchase order line await order.lineDone('coll_123', orderId, lineId, 20) ```
15472
15700
 
15473
- **removeItems**(collectionId: string,
15474
- orderId: string,
15701
+ **removeItems**(collectionId: string,
15702
+ orderId: string,
15475
15703
  data: RemoveItemsRequest) → `Promise<RemoveItemsResponse>`
15476
15704
  Add to (or take from) how much of a line has been shipped or received. Atomic, so two receipts at once both count; it can't go below zero. ```typescript // 20 more caps arrived against a purchase order line await order.lineDone('coll_123', orderId, lineId, 20) ```
15477
15705
 
15478
- **lookup**(collectionId: string,
15706
+ **lookup**(collectionId: string,
15479
15707
  data: LookupOrdersRequest) → `Promise<LookupOrdersResponse>`
15480
15708
  Find all orders containing specific items (tags, proofs, or serial numbers). Use case: Scan a tag and immediately see if it's part of any order. ```typescript // Scan a tag and find associated orders const result = await order.lookup('coll_123', { items: [ { itemType: 'tag', itemId: 'TAG001' } ] }) if (result.orders.length > 0) { console.log(`Tag is part of ${result.orders.length} order(s)`) result.orders.forEach(ord => { console.log(`Order ${ord.orderRef}: ${ord.status}`) }) } // Batch lookup multiple items const batchResult = await order.lookup('coll_123', { items: [ { itemType: 'tag', itemId: 'TAG001' }, { itemType: 'serial', itemId: 'SN12345' }, { itemType: 'proof', itemId: 'proof_xyz' } ] }) ```
15481
15709
 
15482
- **query**(collectionId: string,
15710
+ **query**(collectionId: string,
15483
15711
  data: QueryOrdersRequest) → `Promise<QueryOrdersResponse>`
15484
15712
  Advanced query for orders with order-level and item-level filtering. More powerful than the basic list() function. ```typescript // Find pending orders created in January 2026 const result = await order.query('coll_123', { query: { status: 'pending', createdAfter: '2026-01-01T00:00:00Z', createdBefore: '2026-02-01T00:00:00Z', sortBy: 'createdAt', sortOrder: 'desc' }, limit: 50 }) // Find orders with specific metadata and item count const highPriority = await order.query('coll_123', { query: { metadata: { priority: 'high' }, minItemCount: 10, maxItemCount: 100 }, includeItems: true }) // Find orders containing a specific product batch const batchOrders = await order.query('coll_123', { query: { productId: 'prod_789', batchId: 'BATCH-2024-001' }, includeItems: true }) // Find an order containing one of several specific items const matched = await order.query('coll_123', { query: { items: [ { itemType: 'tag', itemId: 'TAG001' }, { itemType: 'serial', itemId: 'SN12345' } ] }, includeItems: true }) ```
15485
15713
 
15486
- **reports**(collectionId: string,
15714
+ **reports**(collectionId: string,
15487
15715
  params?: ReportsParams) → `Promise<ReportsResponse>`
15488
15716
  Get reports and aggregations for orders. Provides analytics grouped by status, customer, product, date, etc. ```typescript // Get order counts by status const statusReport = await order.reports('coll_123', { groupByStatus: true }) console.log(statusReport.ordersByStatus) // { pending: 45, shipped: 123, completed: 789 } // Get comprehensive analytics const fullReport = await order.reports('coll_123', { groupByStatus: true, groupByProduct: true, includeItemStats: true, createdAfter: '2026-01-01T00:00:00Z' }) console.log(fullReport.itemStats?.avgItemsPerOrder) // Get top 10 customers by order count const topCustomers = await order.reports('coll_123', { groupByCustomer: true, topN: 10 }) ```
15489
15717
 
15490
- **findByProduct**(collectionId: string,
15491
- productId: string,
15718
+ **findByProduct**(collectionId: string,
15719
+ productId: string,
15492
15720
  params?: LookupByProductParams) → `Promise<LookupByProductResponse>`
15493
15721
  Find all orders containing items with a specific product ID. Uses the automatic productSummary tracking in order metadata. ```typescript // Find all orders with a specific product const result = await order.findByProduct('coll_123', 'product_abc123', { limit: 50, includeItems: false }) result.orders.forEach(ord => { const count = ord.metadata.productSummary?.['product_abc123'] ?? 0 console.log(`Order ${ord.orderRef} has ${count} items of this product`) }) ```
15494
15722
 
15495
- **getAnalytics**(collectionId: string,
15723
+ **getAnalytics**(collectionId: string,
15496
15724
  orderId: string) → `Promise<OrderAnalyticsResponse>`
15497
15725
  Get comprehensive scan analytics for all tags in an order. Returns scan counts, timestamps, locations, devices, and per-tag summaries. ```typescript const analytics = await order.getAnalytics('coll_123', 'order_abc123') if (analytics.analytics) { console.log(`Total scans: ${analytics.analytics.totalScans}`) console.log(`Admin scans: ${analytics.analytics.adminScans}`) console.log(`Created at: ${analytics.analytics.estimatedCreatedAt}`) console.log(`Unique locations: ${analytics.analytics.uniqueLocations}`) analytics.analytics.tagSummaries.forEach(tag => { console.log(`Tag ${tag.tagId}: ${tag.totalScans} scans`) }) } ```
15498
15726
 
15499
- **getTimeline**(collectionId: string,
15500
- orderId: string,
15727
+ **getTimeline**(collectionId: string,
15728
+ orderId: string,
15501
15729
  params?: TimelineRequest) → `Promise<TimelineResponse>`
15502
15730
  Get chronological timeline of all scan events for an order's tags. Supports filtering by date range and admin/customer scans. ```typescript // Get all scan events const timeline = await order.getTimeline('coll_123', 'order_abc123') timeline.timeline.forEach(event => { console.log(`${event.timestamp}: ${event.eventType} by ${event.isAdmin ? 'admin' : 'customer'}`) }) // Get admin scans only from last week const adminScans = await order.getTimeline('coll_123', 'order_abc123', { isAdmin: true, from: '2026-02-01T00:00:00Z', limit: 500 }) ```
15503
15731
 
15504
- **getLocationHistory**(collectionId: string,
15505
- orderId: string,
15732
+ **getLocationHistory**(collectionId: string,
15733
+ orderId: string,
15506
15734
  params?: LocationRequest) → `Promise<LocationResponse>`
15507
15735
  Get location-based scan history for an order's tags. Shows where the order's tags have been scanned. ```typescript const locations = await order.getLocationHistory('coll_123', 'order_abc123', { limit: 100 }) console.log(`Order scanned in ${locations.count} locations`) locations.locations.forEach(scan => { console.log(`${scan.location} at ${scan.timestamp}`) }) ```
15508
15736
 
15509
- **getBulkAnalytics**(collectionId: string,
15737
+ **getBulkAnalytics**(collectionId: string,
15510
15738
  data: BulkAnalyticsRequest) → `Promise<BulkAnalyticsResponse>`
15511
15739
  Get analytics summary for multiple orders at once. Efficient way to retrieve scan data for many orders. ```typescript const bulk = await order.getBulkAnalytics('coll_123', { orderIds: ['order_1', 'order_2', 'order_3'], from: '2026-01-01T00:00:00Z' }) bulk.results.forEach(result => { if (result.analytics) { console.log(`${result.orderRef}: ${result.analytics.totalScans} scans`) } }) ```
15512
15740
 
15513
- **getCollectionSummary**(collectionId: string,
15741
+ **getCollectionSummary**(collectionId: string,
15514
15742
  params?: SummaryRequest) → `Promise<CollectionSummaryResponse>`
15515
15743
  Get collection-wide analytics summary across all orders. Returns daily scan counts and admin activity overview. ```typescript // Get all-time collection summary const summary = await order.getCollectionSummary('coll_123') console.log(`Admin activity count: ${summary.adminActivity.count}`) console.log('Scans by day:') summary.scansByDay.forEach(day => { console.log(` ${day.date}: ${day.scanCount} scans`) }) // Get summary for last 30 days const recentSummary = await order.getCollectionSummary('coll_123', { from: '2026-01-08T00:00:00Z', to: '2026-02-08T00:00:00Z' }) ```
15516
15744
 
15517
- **findOrdersByProduct**(collectionId: string,
15518
- productId: string,
15745
+ **findOrdersByProduct**(collectionId: string,
15746
+ productId: string,
15519
15747
  params?: FindOrdersByAttributeParams) → `Promise<FindOrdersByAttributeResponse>`
15520
15748
  Find all orders containing items from a specific product. Uses indexed queries for fast lookups across order items. ```typescript // Find all orders containing a product const { orders, limit, offset } = await order.findOrdersByProduct('coll_123', 'prod_789', { limit: 100 }) console.log(`Product appears in ${orders.length} orders`) ```
15521
15749
 
15522
- **findItemsByProduct**(collectionId: string,
15523
- productId: string,
15750
+ **findItemsByProduct**(collectionId: string,
15751
+ productId: string,
15524
15752
  params?: FindItemsByAttributeParams) → `Promise<FindItemsByAttributeResponse>`
15525
15753
  Get individual order items for a specific product. Returns all matching items with optional order summary. ```typescript // Get all items for a product const { items } = await order.findItemsByProduct('coll_123', 'prod_789', { includeOrder: true }) console.log(`Product delivered in ${items.length} order items`) ```
15526
15754
 
15527
- **getOrderIdsByAttribute**(collectionId: string,
15528
- attribute: 'productId',
15529
- value: string,
15755
+ **getOrderIdsByAttribute**(collectionId: string,
15756
+ attribute: 'productId',
15757
+ value: string,
15530
15758
  params?: GetOrderIdsParams) → `Promise<GetOrderIdsResponse>`
15531
15759
  Get unique order IDs containing items for a specific product. Lightweight query that only returns order IDs, not full order objects. ```typescript // Get order IDs for a product const productOrders = await order.getOrderIdsByAttribute( 'coll_123', 'productId', 'prod_789', { limit: 500 } ) ```
15532
15760
 
@@ -15560,7 +15788,7 @@ Move items (by membership), chips without an item (by membership) or containers
15560
15788
 
15561
15789
  ### podcast
15562
15790
 
15563
- **generate**(collectionId: string,
15791
+ **generate**(collectionId: string,
15564
15792
  request: GeneratePodcastRequest) → `Promise<GeneratePodcastResponse>`
15565
15793
  Generate a NotebookLM-style conversational podcast from product documents
15566
15794
 
@@ -15596,6 +15824,7 @@ Delete a product for a collection (admin only).
15596
15824
 
15597
15825
  **publicFind**(collectionId: string,
15598
15826
  params?: ProductPublicFindParams) → `Promise<ProductResponse[]>`
15827
+ answers 404. Use `products.get(...)` when the product id is known, or `products.query(...)` to search.
15599
15828
 
15600
15829
  **clone**(collectionId: string,
15601
15830
  productId: string,
@@ -15638,209 +15867,209 @@ Look up a serial number by code for a product (admin only).
15638
15867
 
15639
15868
  ### products
15640
15869
 
15641
- **get**(collectionId: string,
15642
- productId: string,
15870
+ **get**(collectionId: string,
15871
+ productId: string,
15643
15872
  admin?: boolean) → `Promise<ProductResponse>`
15644
15873
 
15645
- **list**(collectionId: string,
15874
+ **list**(collectionId: string,
15646
15875
  admin?: boolean) → `Promise<ProductResponse[]>`
15647
15876
 
15648
- **create**(collectionId: string,
15877
+ **create**(collectionId: string,
15649
15878
  data: ProductCreateRequest) → `Promise<ProductResponse>`
15650
15879
 
15651
- **update**(collectionId: string,
15652
- productId: string,
15880
+ **update**(collectionId: string,
15881
+ productId: string,
15653
15882
  data: ProductUpdateRequest) → `Promise<ProductResponse>`
15654
15883
 
15655
- **remove**(collectionId: string,
15884
+ **remove**(collectionId: string,
15656
15885
  productId: string) → `Promise<void>`
15657
15886
 
15658
- **query**(collectionId: string,
15659
- body: ProductQueryRequest,
15887
+ **query**(collectionId: string,
15888
+ body: ProductQueryRequest,
15660
15889
  admin?: boolean) → `Promise<ProductQueryResponse>`
15661
15890
  Query products in a collection with filtering, sorting, and pagination. authenticated admin context). Defaults to `false`, which targets the `/public` endpoint — consistent with `get`, `list`, and `listAssets`. ```typescript // Public query (default) await products.query(collectionId, { query: { search: 'cabernet' } }) // Admin query (authenticated) await products.query(collectionId, { query: { search: 'cabernet' } }, true) ```
15662
15891
 
15663
- **standardQuery**(collectionId: string,
15892
+ **standardQuery**(collectionId: string,
15664
15893
  body: StandardQuery = {}) → `Promise<QueryResult>`
15665
15894
  The standard query on products (admin only): the one query shape every resource is moving to, with counts, totals and filtering by facet. It sits beside `products.query`, whose own body is unchanged. POST /admin/collection/:collectionId/products/standard/query Fields: id, name, description, sku, gtin, schemaType, status, sortOrder, createdAt, updatedAt, facets. Facets are filtered by key: the facet by its key or name, the value by its key or name. ```typescript await products.standardQuery(collectionId, { where: { facets: { brand: 'Breville', category: { in: ['Toasters', 'Kettles'] } }, status: 'active' }, select: ['id', 'name', 'sku'], count: true, }) ```
15666
15895
 
15667
15896
  **standardQueryFields**(collectionId: string) → `Promise<QueryDescription>`
15668
15897
  What a products standard query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/products/standard/query
15669
15898
 
15670
- **clone**(collectionId: string,
15671
- productId: string,
15899
+ **clone**(collectionId: string,
15900
+ productId: string,
15672
15901
  body: Record<string, JsonValue> = {}) → `Promise<ProductResponse>`
15673
15902
  What a products standard query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/products/standard/query
15674
15903
 
15675
- **listAssets**(collectionId: string,
15676
- productId: string,
15904
+ **listAssets**(collectionId: string,
15905
+ productId: string,
15677
15906
  admin?: boolean) → `Promise<unknown>`
15678
15907
  What a products standard query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/products/standard/query
15679
15908
 
15680
- **createClaimWindow**(collectionId: string,
15681
- productId: string,
15909
+ **createClaimWindow**(collectionId: string,
15910
+ productId: string,
15682
15911
  body: Record<string, JsonValue>) → `Promise<unknown>`
15683
15912
  What a products standard query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/products/standard/query
15684
15913
 
15685
- **updateClaimWindow**(collectionId: string,
15686
- productId: string,
15687
- claimId: string,
15914
+ **updateClaimWindow**(collectionId: string,
15915
+ productId: string,
15916
+ claimId: string,
15688
15917
  body: Record<string, JsonValue>) → `Promise<unknown>`
15689
15918
  What a products standard query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/products/standard/query
15690
15919
 
15691
- **refresh**(collectionId: string,
15920
+ **refresh**(collectionId: string,
15692
15921
  productId: string) → `Promise<ProductResponse>`
15693
15922
  What a products standard query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/products/standard/query
15694
15923
 
15695
- **getSN**(collectionId: string,
15696
- productId: string,
15697
- startIndex: number = 0,
15924
+ **getSN**(collectionId: string,
15925
+ productId: string,
15926
+ startIndex: number = 0,
15698
15927
  count: number = 10) → `Promise<unknown>`
15699
15928
  What a products standard query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/products/standard/query
15700
15929
 
15701
- **lookupSN**(collectionId: string,
15702
- productId: string,
15930
+ **lookupSN**(collectionId: string,
15931
+ productId: string,
15703
15932
  codeId: string) → `Promise<unknown>`
15704
15933
  What a products standard query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/products/standard/query
15705
15934
 
15706
- **publicLookupClaim**(collectionId: string,
15707
- productId: string,
15935
+ **publicLookupClaim**(collectionId: string,
15936
+ productId: string,
15708
15937
  claimId: string) → `Promise<unknown>`
15709
15938
  What a products standard query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/products/standard/query
15710
15939
 
15711
- **publicCreateClaim**(collectionId: string,
15712
- productId: string,
15940
+ **publicCreateClaim**(collectionId: string,
15941
+ productId: string,
15713
15942
  body: ProductClaimCreateRequestBody) → `Promise<unknown>`
15714
15943
  What a products standard query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/products/standard/query
15715
15944
 
15716
15945
  ### proof
15717
15946
 
15718
- **query**(collectionId: string,
15947
+ **query**(collectionId: string,
15719
15948
  body: StandardQuery = {}) → `Promise<QueryResult>`
15720
15949
  The standard query on proofs (admin only): filter, sort, page, count and total a collection's proofs in one call, and follow a proof to its `product` and its `owner` (the owner's contact). POST /admin/collection/:collectionId/proof/query Fields: id, productId, userId (the owner's login id), batchId, variantId, lotId, status, claimable, createdAt, updatedAt. A proof's own values are not returned by this call. ```typescript // How many people own each product await proof.query(collectionId, { where: { userId: { isNull: false } }, groupBy: ['productId'], aggregates: { owners: { countDistinct: 'userId' } }, }) // The most recent owner of a product, with their name await proof.query(collectionId, { where: { productId: 'toaster', userId: { isNull: false } }, orderBy: [{ createdAt: 'desc' }], limit: 1, expand: { owner: ['firstName', 'lastName', 'email'] }, }) ```
15721
15950
 
15722
15951
  **queryFields**(collectionId: string) → `Promise<QueryDescription>`
15723
15952
  What a proofs query can use: its fields, what each can filter, sort, group or total, and its links. GET /admin/collection/:collectionId/proof/query
15724
15953
 
15725
- **get**(collectionId: string,
15726
- productId: string,
15727
- proofId: string,
15728
- admin?: boolean,
15954
+ **get**(collectionId: string,
15955
+ productId: string,
15956
+ proofId: string,
15957
+ admin?: boolean,
15729
15958
  include?: string[]) → `Promise<ProofResponse>`
15730
15959
  Retrieves a single Proof by Collection ID, Product ID, and Proof ID. Both public and admin endpoints now include productId in the path.
15731
15960
 
15732
- **list**(collectionId: string,
15961
+ **list**(collectionId: string,
15733
15962
  include?: string[]) → `Promise<ProofResponse[]>`
15734
15963
  List all Proofs for a Collection.
15735
15964
 
15736
- **create**(collectionId: string,
15737
- productId: string,
15965
+ **create**(collectionId: string,
15966
+ productId: string,
15738
15967
  request: ProofCreateRequest) → `Promise<ProofResponse>`
15739
15968
  Create a proof for a product (admin only). POST /admin/collection/:collectionId/product/:productId/proof Pass the proof's content in a `proof` block, keyed by zone (see {@link ProofWrite}): ```ts proof.create(collectionId, productId, { proof: { values: { colour: 'red' }, // public + owner readable, owner + admin writable data: { serialNo: 1001 }, // public + owner readable, ADMIN-only writable admin: { costPrice: 4.20 }, // admin-only }, claimable: true, }) ``` Note: a top-level `data`/`admin` on the request body is legacy — top-level `data` gets folded into the values bag, so use `proof.data` for `proof.data`.
15740
15969
 
15741
- **update**(collectionId: string,
15742
- productId: string,
15743
- proofId: string,
15970
+ **update**(collectionId: string,
15971
+ productId: string,
15972
+ proofId: string,
15744
15973
  values: ProofUpdateRequest) → `Promise<ProofResponse>`
15745
15974
  Update a proof for a product (admin only). PUT /admin/collection/:collectionId/product/:productId/proof/:proofId Pass the fields to change **at the root**, keyed by zone (see {@link ProofWrite}): ```ts proof.update(collectionId, productId, proofId, { data: { serialNo: 1002 }, // → proof.data (admin-only writable) values: { colour: 'blue' }, // → proof.values }) ``` Object zones deep-merge, so you can change one field without wiping the rest.
15746
15975
 
15747
- **updateValues**(collectionId: string,
15748
- productId: string,
15749
- proofId: string,
15976
+ **updateValues**(collectionId: string,
15977
+ productId: string,
15978
+ proofId: string,
15750
15979
  values: ProofValuesUpdateRequest) → `Promise<ProofResponse>`
15751
15980
  Owner self-service update of a proof's owner-writable data. PUT /public/collection/:collectionId/product/:productId/proof/:proofId/values The public counterpart to admin `update` — the current OWNER (or a collection admin) editing their own proof, no admin credentials required. Only owner-writable zones are honoured (see {@link ProofValuesUpdateRequest}): ```ts proof.updateValues(collectionId, productId, proofId, { colour: 'blue', // → proof.values.colour (public) owner: { warranty: '2y' }, // → proof.values.owner (owner-scoped) personal: { nickname: 'Bo' }, // → proof.values.personal[callerUid] (private, own slot only) }) ``` `personal` always targets the caller's OWN slot — you cannot write another user's personal data, even as an admin. Object zones deep-merge (owner/personal merge field-by-field), so you can change one field without wiping the rest. Business-only zones (`data`/`admin`/`private`) are not writable here — use the admin `update` for those.
15752
15981
 
15753
- **claim**(collectionId: string,
15754
- productId: string,
15755
- proofId: string,
15982
+ **claim**(collectionId: string,
15983
+ productId: string,
15984
+ proofId: string,
15756
15985
  values: ProofClaimRequest) → `Promise<ProofResponse>`
15757
15986
  Claim a proof for a product using a proof ID (serial number, NFC tag, etc.). PUT /public/collection/:collectionId/product/:productId/proof/:proofId/claim
15758
15987
 
15759
- **claimProduct**(collectionId: string,
15760
- productId: string,
15988
+ **claimProduct**(collectionId: string,
15989
+ productId: string,
15761
15990
  values?: ProofClaimRequest) → `Promise<ProofResponse>`
15762
15991
  Claim a product without providing a proof ID. System auto-generates a unique serial number on-demand. Requires allowAutoGenerateClaims to be enabled on the collection or product. PUT /public/collection/:collectionId/product/:productId/proof/claim ```typescript const proof = await proof.claimProduct( 'beauty-brand', 'moisturizer-pro', { purchaseDate: '2026-02-17', store: 'Target' } ); console.log('Auto-generated ID:', proof.id); ```
15763
15992
 
15764
- **remove**(collectionId: string,
15765
- productId: string,
15993
+ **remove**(collectionId: string,
15994
+ productId: string,
15766
15995
  proofId: string) → `Promise<void>`
15767
15996
  Delete a proof for a product (admin only). DELETE /admin/collection/:collectionId/product/:productId/proof/:proofId
15768
15997
 
15769
- **getByUser**(collectionId: string,
15998
+ **getByUser**(collectionId: string,
15770
15999
  userId: string) → `Promise<ProofResponse[]>`
15771
16000
  Get proofs for a user in a collection (admin only). GET /admin/collection/:collectionId/proof/findByUser/:userId
15772
16001
 
15773
- **getByProduct**(collectionId: string,
16002
+ **getByProduct**(collectionId: string,
15774
16003
  productId: string) → `Promise<ProofResponse[]>`
15775
16004
  Get proofs for a product (admin only). GET /admin/collection/:collectionId/product/:productId/proof
15776
16005
 
15777
- **findByProduct**(collectionId: string,
15778
- productId: string,
16006
+ **findByProduct**(collectionId: string,
16007
+ productId: string,
15779
16008
  query: any) → `Promise<ProofResponse[]>`
15780
16009
  Find proofs for a product (admin only). POST /admin/collection/:collectionId/product/:productId/proof/find
15781
16010
 
15782
- **getByBatch**(collectionId: string,
15783
- productId: string,
16011
+ **getByBatch**(collectionId: string,
16012
+ productId: string,
15784
16013
  batchId: string) → `Promise<ProofResponse[]>`
15785
16014
  Get proofs for a batch (admin only). GET /admin/collection/:collectionId/product/:productId/batch/:batchId/proof
15786
16015
 
15787
- **migrate**(collectionId: string,
15788
- productId: string,
15789
- proofId: string,
15790
- /** The destination product ID */
16016
+ **migrate**(collectionId: string,
16017
+ productId: string,
16018
+ proofId: string,
16019
+ /** The destination product ID */
15791
16020
  data: { targetProductId: string }) → `Promise<ProofResponse>`
15792
16021
  Migrate a proof to a different product within the same collection (admin only). Because the Firestore ledger document ID is `{productId}-{proofId}`, a proof cannot simply be re-assigned to another product by updating a field — the document must be re-keyed. This endpoint handles that atomically: 1. Reads the source ledger document (`{sourceProductId}-{proofId}`). 2. Writes a new document (`{targetProductId}-{proofId}`) with `productId` and `proofGroup` updated. The short `proofId` (nanoid) is unchanged. 3. Writes a migration history entry to the new document's `history` subcollection (snapshot of the original proof + migration metadata). 4. Copies all subcollections — `assets`, `attestations`, `history` — from the old document to the new one. 5. Deletes the old subcollections and then the old document. Repeated migrations are safe — each one appends a history record; no migration metadata is stored on the proof document itself. ```typescript const migrated = await proof.migrate('coll_123', 'prod_old', 'proof_abc', { targetProductId: 'prod_new', }) console.log(migrated.productId) // 'prod_new' ```
15793
16022
 
15794
- **createGrant**(collectionId: string,
15795
- productId: string,
15796
- proofId: string,
16023
+ **createGrant**(collectionId: string,
16024
+ productId: string,
16025
+ proofId: string,
15797
16026
  options: CreateGrantOptions) → `Promise<ProofGrant>`
15798
16027
  Create a share grant on a proof (owner / collection admin only). The returned grant includes `token` — the opaque bearer secret, available ONLY on this response. Embed it in a share link and hand recipients {@link redeemGrant} / {@link setGrantToken}.
15799
16028
 
15800
- **listGrants**(collectionId: string,
15801
- productId: string,
16029
+ **listGrants**(collectionId: string,
16030
+ productId: string,
15802
16031
  proofId: string) → `Promise<ProofGrant[]>`
15803
16032
  List the active + past grants on a proof (owner / collection admin only). Tokens are never returned here.
15804
16033
 
15805
- **revokeGrant**(collectionId: string,
15806
- productId: string,
15807
- proofId: string,
16034
+ **revokeGrant**(collectionId: string,
16035
+ productId: string,
16036
+ proofId: string,
15808
16037
  grantId: string) → `Promise<void>`
15809
16038
  Revoke a grant by id (owner / collection admin only). Takes effect immediately.
15810
16039
 
15811
- **redeemGrant**(collectionId: string,
15812
- productId: string,
15813
- proofId: string,
15814
- token: string,
16040
+ **redeemGrant**(collectionId: string,
16041
+ productId: string,
16042
+ proofId: string,
16043
+ token: string,
15815
16044
  options?: RedeemGrantOptions) → `Promise<RedeemGrantResult>`
15816
16045
  Redeem a grant token (anonymous or signed-in). Records the redemption and returns the granted scope, or — for a `verify_owner` grant — an ownership assertion (never the account). After redeeming, call {@link setGrantToken} so subsequent data requests carry the token.
15817
16046
 
15818
- **transfer**(collectionId: string,
15819
- productId: string,
15820
- proofId: string,
16047
+ **transfer**(collectionId: string,
16048
+ productId: string,
16049
+ proofId: string,
15821
16050
  options: TransferProofOptions) → `Promise<TransferProofResult>`
15822
16051
  Start a push transfer of a proof (current owner / collection admin only). Directed — hand it to a named recipient who then calls {@link acceptTransfer}: ```ts await proof.transfer(collectionId, productId, proofId, { toEmail: 'buyer@example.com' }) ``` Open release — make the proof claimable by anyone: ```ts await proof.transfer(collectionId, productId, proofId, { release: true }) ``` Send comms by naming templates per role (server decides who receives each): ```ts await proof.transfer(collectionId, productId, proofId, { toEmail: 'buyer@example.com', comms: { recipient: { templateId: 'transfer-incoming', props: { note: 'Enjoy!' } }, sender: { templateId: 'transfer-sent' }, }, }) ``` Direct to an SMS recipient by phone (E.164) and notify them by text: ```ts await proof.transfer(collectionId, productId, proofId, { toPhone: '+14155551234', comms: { recipient: { templateId: 'transfer-incoming', channel: 'sms' } }, }) ```
15823
16052
 
15824
- **acceptTransfer**(collectionId: string,
15825
- productId: string,
15826
- proofId: string,
16053
+ **acceptTransfer**(collectionId: string,
16054
+ productId: string,
16055
+ proofId: string,
15827
16056
  options: AcceptTransferOptions = {}) → `Promise<`
15828
16057
  Accept a directed transfer (the named recipient only). Completes the ownership move — the proof's `userId` becomes the caller and the previous owner's private data and share grants are cleared/voided.
15829
16058
 
15830
- **cancelTransfer**(collectionId: string,
15831
- productId: string,
15832
- proofId: string,
16059
+ **cancelTransfer**(collectionId: string,
16060
+ productId: string,
16061
+ proofId: string,
15833
16062
  options: CancelTransferOptions = {}) → `Promise<`
15834
16063
  Cancel a pending push transfer (current owner / collection admin only).
15835
16064
 
15836
- **getTransfer**(collectionId: string,
15837
- productId: string,
16065
+ **getTransfer**(collectionId: string,
16066
+ productId: string,
15838
16067
  proofId: string) → `Promise<`
15839
16068
  Get the active transfer/status for a proof (owner, collection admin, or the named recipient). Returns `{ transfer: null }` when nothing is in flight.
15840
16069
 
15841
16070
  ### publicClient
15842
16071
 
15843
- **agentRun**(collectionId: string,
16072
+ **agentRun**(collectionId: string,
15844
16073
  body: PublicAgentRunRequest) → `Promise<AgentRunResult>`
15845
16074
  Public agent loop — run the orchestration-neutral tool loop on the consumer surface. Exposes an app's PUBLIC server functions (`agent.tool:true`, `visibility:'public'`) to a consumer assistant; built-in tools are opt-in by explicit `server_tools[]` allowlist only. The caller runs as the signed-in consumer ('owner', send the authKit bearer) or anonymous ('public'). POST /public/collection/:collectionId/ai/agent/run
15846
16075
 
@@ -15855,19 +16084,19 @@ Check rate limit status
15855
16084
 
15856
16085
  ### publicClient.sessions
15857
16086
 
15858
- **create**(collectionId: string,
16087
+ **create**(collectionId: string,
15859
16088
  body: AiSessionCreate & { scope?: 'owner' | 'public' } = {}) → `Promise<AiSession>`
15860
16089
 
15861
- **list**(collectionId: string,
16090
+ **list**(collectionId: string,
15862
16091
  params?: { appId?: string; limit?: number }) → `Promise<`
15863
16092
  List the signed-in consumer's own ('owner') sessions — requires an authKit bearer.
15864
16093
 
15865
16094
  **get**(collectionId: string, id: string) → `Promise<AiSession>`
15866
16095
  List the signed-in consumer's own ('owner') sessions — requires an authKit bearer.
15867
16096
 
15868
- **append**(collectionId: string,
15869
- id: string,
15870
- items: ResponseInputItem[],
16097
+ **append**(collectionId: string,
16098
+ id: string,
16099
+ items: ResponseInputItem[],
15871
16100
  opts?: { usage?: Record<string, any> }) → `Promise<AiSession>`
15872
16101
  List the signed-in consumer's own ('owner') sessions — requires an authKit bearer.
15873
16102
 
@@ -15974,9 +16203,9 @@ List sessions, most-recently-active first (optionally filtered by app).
15974
16203
  **get**(collectionId: string, id: string) → `Promise<AiSession>`
15975
16204
  Get one session, including its full transcript.
15976
16205
 
15977
- **append**(collectionId: string,
15978
- id: string,
15979
- items: ResponseInputItem[],
16206
+ **append**(collectionId: string,
16207
+ id: string,
16208
+ items: ResponseInputItem[],
15980
16209
  opts?: { usage?: Record<string, any> }) → `Promise<AiSession>`
15981
16210
  Append Responses items (input/output/tool) to a session — the manual-persistence path.
15982
16211
 
@@ -16055,6 +16284,80 @@ List the skills apps can invoke (name, description, input/output schema).
16055
16284
  **run**(collectionId: string, name: string, input: Record<string, any> = {}) → `Promise<T>`
16056
16285
  Invoke a skill by name with structured input — the app-facing verb; no prompt-shaping. POST /admin/collection/:collectionId/ai/skills/:name/run
16057
16286
 
16287
+ ### subscriptions
16288
+
16289
+ **plans**(collectionId: string) → `Promise<PublicPlan[]>`
16290
+ Plans open to new members, each with its prices (monthly, yearly, one-off).
16291
+
16292
+ **start**(collectionId: string, input: SubscriptionStartInput) → `Promise<SubscriptionStartResult>`
16293
+ Join a plan: Stripe's checkout page for the chosen price. Send them to `checkoutUrl`. Signed in only (a membership belongs to an account). The membership exists once Stripe confirms the payment. ```typescript const plans = await subscriptions.plans(collectionId) const yearly = plans[0].prices.find((p) => p.interval === 'year') const { checkoutUrl } = await subscriptions.start(collectionId, { priceId: yearly.id, successUrl: `${location.origin}/welcome`, cancelUrl: `${location.origin}/join`, }) location.href = checkoutUrl ```
16294
+
16295
+ **mine**(collectionId: string) → `Promise<MySubscription[]>`
16296
+ The signed-in member's memberships, newest first (ended ones too: check `live`).
16297
+
16298
+ **cancel**(collectionId: string, subscriptionId: string) → `Promise<MySubscription>`
16299
+ Cancel: it ends at the end of the paid period, and access stays until then. A one-off plan or a staff grant ends now. Undo with `resume` before the period ends.
16300
+
16301
+ **resume**(collectionId: string, subscriptionId: string) → `Promise<MySubscription>`
16302
+ Undo a cancel before the period ends. @throws `NOT_CANCELLING`
16303
+
16304
+ **change**(collectionId: string, subscriptionId: string, priceId: string) → `Promise<MySubscription>`
16305
+ Move to another plan's price. Up (a higher-ranked or dearer plan): at once, charging the difference. Down: from the next renewal (`pendingPriceId` until then). @throws `CANNOT_CHANGE`, `NOT_FOUND`
16306
+
16307
+ **billingLink**(collectionId: string, subscriptionId: string, returnUrl: string) → `Promise<`
16308
+ Stripe's page for the member's card, invoices and cancelling. Send them to `url`. @throws `NO_BILLING`
16309
+
16310
+ **describePrice**(p: { amount: number; currency: string; interval: 'month' | 'year' | null; intervalCount?: number }, locale?: string) → `string`
16311
+ Format a plan price for people: "£15 a month", "£150 a year", "£40 every 3 months", "£99 once".
16312
+
16313
+ ### subscriptions.admin
16314
+
16315
+ **listPlans**(collectionId: string, params?: { active?: boolean; limit?: number; offset?: number }) → `Promise<SubscriptionPage<PlanWithPrices>>`
16316
+
16317
+ **getPlan**(collectionId: string, planId: string) → `Promise<PlanWithPrices>`
16318
+ A plan with its prices and how many live members it has.
16319
+
16320
+ **createPlan**(collectionId: string, input: PlanInput) → `Promise<Plan>`
16321
+
16322
+ **updatePlan**(collectionId: string, planId: string, changes: PlanUpdate) → `Promise<Plan>`
16323
+ Change a plan. Its term can't change once it has prices. Changed grants reach members when their membership next changes, or at once with `reapply`. @throws `PLAN_HAS_PRICES`
16324
+
16325
+ **removePlan**(collectionId: string, planId: string) → `Promise<`
16326
+ Only a plan nobody has held; otherwise close it to new members (`active: false`). @throws `PLAN_HAS_MEMBERS`
16327
+
16328
+ **setPrice**(collectionId: string, planId: string, input: PlanPriceInput) → `Promise<PlanPrice>`
16329
+ Set a plan's price for a currency and billing period (one each): replaces it if there is one.
16330
+
16331
+ **updatePrice**(collectionId: string, priceId: string, changes: Partial<PlanPriceInput>) → `Promise<PlanPrice>`
16332
+ Set a plan's price for a currency and billing period (one each): replaces it if there is one.
16333
+
16334
+ **removePrice**(collectionId: string, priceId: string) → `Promise<`
16335
+ A price nobody pays. One that members pay is kept: close it with `active: false`. @throws `PRICE_IN_USE`
16336
+
16337
+ **list**(collectionId: string, params?: SubscriptionListParams) → `Promise<SubscriptionPage<Membership>>`
16338
+ Memberships, newest first, with each one's plan.
16339
+
16340
+ **get**(collectionId: string, subscriptionId: string) → `Promise<Membership>`
16341
+ Memberships, newest first, with each one's plan.
16342
+
16343
+ **grant**(collectionId: string, input: SubscriptionGrantInput) → `Promise<Membership>`
16344
+ Give someone a plan without payment (free, honorary, paid in cash). Its grants apply at once.
16345
+
16346
+ **cancel**(collectionId: string, subscriptionId: string, opts: { atPeriodEnd?: boolean } = {}) → `Promise<Membership>`
16347
+ Cancel at the end of the paid period (default), or now with `atPeriodEnd: false`.
16348
+
16349
+ **resume**(collectionId: string, subscriptionId: string) → `Promise<Membership>`
16350
+ Cancel at the end of the paid period (default), or now with `atPeriodEnd: false`.
16351
+
16352
+ **change**(collectionId: string, subscriptionId: string, priceId: string) → `Promise<Membership>`
16353
+ Cancel at the end of the paid period (default), or now with `atPeriodEnd: false`.
16354
+
16355
+ **end**(collectionId: string, subscriptionId: string) → `Promise<Membership>`
16356
+ End now. A paid one is stopped in Stripe at once (no refund is made here).
16357
+
16358
+ **reapply**(collectionId: string, subscriptionId: string) → `Promise<`
16359
+ Re-apply what the plan grants now (after the plan's grants were changed).
16360
+
16058
16361
  ### tagCodes
16059
16362
 
16060
16363
  **lookup**(collectionId: string, tag: TagCodeRef) → `Promise<TagCodeState>`
@@ -16156,17 +16459,17 @@ Reverse lookup by ref via POST (public). `POST /public/collection/:collectionId/
16156
16459
 
16157
16460
  ### tools
16158
16461
 
16159
- **run**(collectionId: string,
16160
- name: K,
16161
- args: AiToolArgsMap[K],) → `Promise<ToolRunResult>
16162
- export async function run<T = any>(
16163
- collectionId: string,
16164
- name: string,
16165
- args?: Record<string, any>,
16166
- ): Promise<ToolRunResult<T>>
16167
- export async function run(
16168
- collectionId: string,
16169
- name: string,
16462
+ **run**(collectionId: string,
16463
+ name: K,
16464
+ args: AiToolArgsMap[K],) → `Promise<ToolRunResult>
16465
+ export async function run<T = any>(
16466
+ collectionId: string,
16467
+ name: string,
16468
+ args?: Record<string, any>,
16469
+ ): Promise<ToolRunResult<T>>
16470
+ export async function run(
16471
+ collectionId: string,
16472
+ name: string,
16170
16473
  args: Record<string, any> =`
16171
16474
  Invoke ONE built-in server tool directly — no model in the loop. This is the "direct code" caller of the orchestration-neutral tool registry: the SAME tools the agent loop and the Responses `server_tools` path run, but called as a plain, typed, deterministic API. A front end can use it two ways: (1) call a tool straight as an API (e.g. `pdf.render` / `pdf.extract` behind a PDF UX), or (2) drive its OWN agent loop and execute each model tool-call here. Capability-gated server-side to the caller's grants (same blast-radius rules as the agent loop). POST /admin/collection/:collectionId/ai/tools/:name/run
16172
16475
 
@@ -16230,7 +16533,7 @@ Admin: replace the site's translation rules. They apply to new translations from
16230
16533
 
16231
16534
  ### tts
16232
16535
 
16233
- **generate**(collectionId: string,
16536
+ **generate**(collectionId: string,
16234
16537
  request: TTSRequest) → `Promise<Blob>`
16235
16538
  Generate text-to-speech audio
16236
16539