@proveanything/smartlinks 3.0.0-alpha.2 → 3.0.0-alpha.3

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 (151) hide show
  1. package/README.md +741 -741
  2. package/dist/README.md +573 -573
  3. package/dist/adminCardsView.js +55 -55
  4. package/dist/api/bookings.d.ts +49 -2
  5. package/dist/api/bookings.js +59 -2
  6. package/dist/api/index.d.ts +1 -0
  7. package/dist/api/index.js +1 -0
  8. package/dist/api/payments.d.ts +60 -0
  9. package/dist/api/payments.js +94 -0
  10. package/dist/api/realtime.d.ts +3 -0
  11. package/dist/api/realtime.js +10 -2
  12. package/dist/baseline.css +194 -194
  13. package/dist/dataChanged.d.ts +74 -0
  14. package/dist/dataChanged.js +162 -0
  15. package/dist/docs/API_SUMMARY.md +1086 -858
  16. package/dist/docs/admin-cards.md +189 -189
  17. package/dist/docs/agent-tools.md +156 -156
  18. package/dist/docs/ai-tools-and-skills.md +180 -180
  19. package/dist/docs/ai.md +1721 -1721
  20. package/dist/docs/api-versions.md +85 -85
  21. package/dist/docs/app-data-storage.md +277 -277
  22. package/dist/docs/app-docs.md +73 -73
  23. package/dist/docs/app-manifest.md +852 -852
  24. package/dist/docs/app-records-pattern.md +388 -388
  25. package/dist/docs/appConfig.md +550 -550
  26. package/dist/docs/assistant-apps.md +172 -172
  27. package/dist/docs/assistant-context.md +119 -119
  28. package/dist/docs/bookings.md +105 -8
  29. package/dist/docs/caching.md +32 -3
  30. package/dist/docs/comms.md +689 -689
  31. package/dist/docs/connectors.md +340 -340
  32. package/dist/docs/css-baseline.md +133 -133
  33. package/dist/docs/customer-guide.md +70 -70
  34. package/dist/docs/data-changed.md +91 -0
  35. package/dist/docs/deploying-apps.md +340 -340
  36. package/dist/docs/dpp.md +115 -115
  37. package/dist/docs/entitlements.md +90 -90
  38. package/dist/docs/files.md +69 -69
  39. package/dist/docs/host-dependency-contract.md +252 -252
  40. package/dist/docs/iframe-responder.md +11 -0
  41. package/dist/docs/integrations.md +322 -322
  42. package/dist/docs/interactions.md +544 -544
  43. package/dist/docs/item-context.md +181 -181
  44. package/dist/docs/knowledge.md +105 -105
  45. package/dist/docs/lists.md +157 -157
  46. package/dist/docs/lots.md +112 -112
  47. package/dist/docs/loyalty.md +348 -348
  48. package/dist/docs/members.md +183 -183
  49. package/dist/docs/memberships.md +150 -150
  50. package/dist/docs/mobile-admin-container.md +693 -693
  51. package/dist/docs/operations.md +281 -281
  52. package/dist/docs/overview.md +487 -485
  53. package/dist/docs/payments.md +94 -0
  54. package/dist/docs/proof-comms-triggers.md +142 -142
  55. package/dist/docs/proof-ownership-transfer.md +155 -155
  56. package/dist/docs/proof-product-data-scoping.md +462 -462
  57. package/dist/docs/proof-share-grants.md +305 -305
  58. package/dist/docs/realtime.md +149 -139
  59. package/dist/docs/records-admin-pattern.md +304 -304
  60. package/dist/docs/service-accounts.md +64 -64
  61. package/dist/docs/standard-query.md +196 -187
  62. package/dist/docs/tag-codes.md +97 -97
  63. package/dist/docs/tag-ranges.md +106 -106
  64. package/dist/docs/theme-tokens.md +252 -252
  65. package/dist/docs/upgrading-to-3.md +550 -532
  66. package/dist/docs/wallet-passes.md +107 -107
  67. package/dist/docs/websites.md +123 -123
  68. package/dist/http.d.ts +6 -3
  69. package/dist/http.js +48 -19
  70. package/dist/iframeResponder.d.ts +7 -0
  71. package/dist/iframeResponder.js +10 -0
  72. package/dist/index.d.ts +2 -0
  73. package/dist/index.js +2 -0
  74. package/dist/openapi.yaml +426 -3
  75. package/dist/testing/bookingsMemory.d.ts +29 -1
  76. package/dist/testing/bookingsMemory.js +89 -1
  77. package/dist/testing/index.js +4 -1
  78. package/dist/theme-boot.js +82 -82
  79. package/dist/theme.css +75 -75
  80. package/dist/types/appManifest.d.ts +26 -4
  81. package/dist/types/bookings.d.ts +99 -1
  82. package/dist/types/index.d.ts +1 -0
  83. package/dist/types/index.js +1 -0
  84. package/dist/types/payments.d.ts +101 -0
  85. package/dist/types/payments.js +5 -0
  86. package/dist/types/realtime.d.ts +5 -1
  87. package/dist/version.d.ts +1 -1
  88. package/dist/version.js +1 -1
  89. package/docs/API_SUMMARY.md +1086 -858
  90. package/docs/admin-cards.md +189 -189
  91. package/docs/agent-tools.md +156 -156
  92. package/docs/ai-tools-and-skills.md +180 -180
  93. package/docs/ai.md +1721 -1721
  94. package/docs/api-versions.md +85 -85
  95. package/docs/app-data-storage.md +277 -277
  96. package/docs/app-docs.md +73 -73
  97. package/docs/app-manifest.md +852 -852
  98. package/docs/app-records-pattern.md +388 -388
  99. package/docs/appConfig.md +550 -550
  100. package/docs/assistant-apps.md +172 -172
  101. package/docs/assistant-context.md +119 -119
  102. package/docs/bookings.md +105 -8
  103. package/docs/caching.md +32 -3
  104. package/docs/comms.md +689 -689
  105. package/docs/connectors.md +340 -340
  106. package/docs/css-baseline.md +133 -133
  107. package/docs/customer-guide.md +70 -70
  108. package/docs/data-changed.md +91 -0
  109. package/docs/deploying-apps.md +340 -340
  110. package/docs/dpp.md +115 -115
  111. package/docs/entitlements.md +90 -90
  112. package/docs/files.md +69 -69
  113. package/docs/host-dependency-contract.md +252 -252
  114. package/docs/iframe-responder.md +11 -0
  115. package/docs/integrations.md +322 -322
  116. package/docs/interactions.md +544 -544
  117. package/docs/item-context.md +181 -181
  118. package/docs/knowledge.md +105 -105
  119. package/docs/lists.md +157 -157
  120. package/docs/lots.md +112 -112
  121. package/docs/loyalty.md +348 -348
  122. package/docs/members.md +183 -183
  123. package/docs/memberships.md +150 -150
  124. package/docs/mobile-admin-container.md +693 -693
  125. package/docs/operations.md +281 -281
  126. package/docs/overview.md +487 -485
  127. package/docs/payments.md +94 -0
  128. package/docs/proof-comms-triggers.md +142 -142
  129. package/docs/proof-ownership-transfer.md +155 -155
  130. package/docs/proof-product-data-scoping.md +462 -462
  131. package/docs/proof-share-grants.md +305 -305
  132. package/docs/realtime.md +149 -139
  133. package/docs/service-accounts.md +64 -64
  134. package/docs/standard-query.md +196 -187
  135. package/docs/tag-codes.md +97 -97
  136. package/docs/tag-ranges.md +106 -106
  137. package/docs/theme-lookbook.v1.json +120 -120
  138. package/docs/theme-tokens.md +252 -252
  139. package/docs/upgrading-to-3.md +550 -532
  140. package/docs/wallet-passes.md +107 -107
  141. package/docs/websites.md +123 -123
  142. package/openapi.yaml +426 -3
  143. package/package.json +91 -91
  144. package/scripts/headless-check.mjs +87 -87
  145. package/scripts/lib/bare-imports.mjs +57 -57
  146. package/scripts/lib/keyed-app-data.mjs +21 -21
  147. package/scripts/lib/upgrade.mjs +708 -668
  148. package/scripts/publish.mjs +272 -272
  149. package/scripts/register-release.mjs +91 -91
  150. package/scripts/upgrade.mjs +79 -79
  151. package/upgrade/3.json +2 -2
@@ -1,6 +1,6 @@
1
1
  # Smartlinks API Summary
2
2
 
3
- Version: 3.0.0-alpha.2 | Generated: 2026-11-25T11:02:24.959Z
3
+ Version: 3.0.0-alpha.3 | Generated: 2026-12-04T21:06:10.095Z
4
4
 
5
5
  This is a concise summary of all available API functions and types.
6
6
 
@@ -163,6 +163,7 @@ The Smartlinks SDK is organized into the following namespaces:
163
163
  - **operations** - Functions for operations operations
164
164
  - **order** - Functions for order operations
165
165
  - **partner** - Functions for partner operations
166
+ - **payments** - Functions for payments operations
166
167
  - **places** - Functions for places operations
167
168
  - **products** - Functions for products operations
168
169
  - **realtime** - Functions for realtime operations
@@ -209,17 +210,17 @@ The release channel explicitly set for this app build (initializeApi({ appChanne
209
210
  **setAppChannel**(channel: string | undefined) → `void`
210
211
  Set (or clear) the release channel SL.functions calls target.
211
212
 
212
- **initializeApi**(options: {
213
- baseURL: string
214
- apiKey?: string
215
- bearerToken?: string
216
- proxyMode?: boolean
217
- ngrokSkipBrowserWarning?: boolean
218
- extraHeaders?: Record<string, string>
219
- /**
220
- * Declares the host platform. Set to `'native'` on native/Capacitor hosts to opt into
221
- * AuthKit refresh tokens — the SDK then sends `X-Client-Platform: native` on every
222
- * request, so login endpoints return `refreshToken`/`refreshTokenExpiresAt` and a
213
+ **initializeApi**(options: {
214
+ baseURL: string
215
+ apiKey?: string
216
+ bearerToken?: string
217
+ proxyMode?: boolean
218
+ ngrokSkipBrowserWarning?: boolean
219
+ extraHeaders?: Record<string, string>
220
+ /**
221
+ * Declares the host platform. Set to `'native'` on native/Capacitor hosts to opt into
222
+ * AuthKit refresh tokens — the SDK then sends `X-Client-Platform: native` on every
223
+ * request, so login endpoints return `refreshToken`/`refreshTokenExpiresAt` and a
223
224
  * short-lived access token. Omit (or `'web'`) → `void`
224
225
  Call this once (e.g. at app startup) to configure baseURL/auth.
225
226
 
@@ -250,56 +251,56 @@ Returns true if initializeApi() has been called at least once. Useful for guards
250
251
  **hasAuthCredentials**() → `boolean`
251
252
  Returns true if the SDK currently has any auth credential set (bearer token or API key). Use this as a cheap pre-flight check before calling endpoints that require authentication, to avoid issuing a network request that you already know will return a 401. ```ts if (hasAuthCredentials()) { const account = await auth.getAccount() } ```
252
253
 
253
- **configureSdkCache**(options: {
254
- enabled?: boolean
255
- ttlMs?: number
256
- maxEntries?: number
257
- persistence?: 'none' | 'indexeddb'
258
- persistenceTtlMs?: number
259
- serveStaleOnOffline?: boolean
260
- clearOnPageLoad?: boolean
254
+ **configureSdkCache**(options: {
255
+ enabled?: boolean
256
+ ttlMs?: number
257
+ maxEntries?: number
258
+ persistence?: 'none' | 'indexeddb'
259
+ persistenceTtlMs?: number
260
+ serveStaleOnOffline?: boolean
261
+ clearOnPageLoad?: boolean
261
262
  }) → `void`
262
- Configure the SDK's built-in in-memory GET cache. The cache is transparent — it sits inside the HTTP layer and requires no changes to your existing API calls. All GET requests benefit automatically. Per-resource rules (collections/products → 1 h, proofs → 30 s, etc.) override this value. in-memory only (`'none'`, default). Ignored in Node.js. fallback, from the original fetch time (default: 7 days). `SmartlinksOfflineError` with stale data instead of propagating the network error. caches on page load/refresh. IndexedDB persists for offline. ```ts // Enable IndexedDB persistence for offline support configureSdkCache({ persistence: 'indexeddb' }) // Disable cache entirely in test environments configureSdkCache({ enabled: false }) // Keep caches across page refreshes (not recommended for production) configureSdkCache({ clearOnPageLoad: false }) ```
263
+ Configure the SDK's built-in in-memory GET cache. The cache is transparent — it sits inside the HTTP layer and requires no changes to your existing API calls. Public GET requests benefit automatically. Admin GETs (`/admin/...`) are never kept, whatever is set here: see docs/caching.md. Per-resource rules (collections/products → 1 h, proofs → 30 s, etc.) override this value. in-memory only (`'none'`, default). Ignored in Node.js. fallback, from the original fetch time (default: 7 days). `SmartlinksOfflineError` with stale data instead of propagating the network error. caches on page load/refresh. IndexedDB persists for offline. ```ts // Enable IndexedDB persistence for offline support configureSdkCache({ persistence: 'indexeddb' }) // Disable cache entirely in test environments configureSdkCache({ enabled: false }) // Keep caches across page refreshes (not recommended for production) configureSdkCache({ clearOnPageLoad: false }) ```
263
264
 
264
265
  **invalidateCache**(urlPattern?: string, options?: InvalidateCacheOptions) → `void`
265
266
  Manually invalidate entries in the SDK's GET cache. Note: the GET cache is **in-memory, per page load** (with an optional L2 IndexedDB layer when persistence is enabled) — it does not persist across reloads unless you opt into persistence, so it rarely needs disabling "for correctness". *contains* this string is removed). With `{ exact: true }`, matches the path precisely. Omit to wipe the entire cache. ```ts invalidateCache() // clear everything invalidateCache('/collection/abc123') // that collection AND everything under it invalidateCache('/collection/abc123', { exact: true }) // ONLY that collection entry invalidateCache('/products/') // all canonical plural product responses ```
266
267
 
267
- **proxyUploadFormData**(path: string,
268
- formData: FormData,
268
+ **proxyUploadFormData**(path: string,
269
+ formData: FormData,
269
270
  onProgress?: (percent: number) → `void`
270
271
  Upload a FormData payload via proxy with progress events using chunked postMessage. Parent is expected to implement the counterpart protocol.
271
272
 
272
273
  **request**(path: string) → `Promise<T>`
273
- Internal helper that performs a GET request to `${baseURL}${path}`, injecting headers for apiKey or bearerToken if present. Cache pipeline (when caching is not skipped): L1 hit → return from memory (no I/O) L2 hit → return from IndexedDB, promote to L1 (no network) Miss → fetch from network, store in L1 + L2 Offline → serve stale L2 entry via SmartlinksOfflineError (if persistence enabled) Concurrent identical GETs share one in-flight promise (deduplication). Node-safe: IndexedDB calls are no-ops when IDB is unavailable.
274
+ Internal helper that performs a GET request to `${baseURL}${path}`, injecting headers for apiKey or bearerToken if present. Cache pipeline (when caching is not skipped): L1 hit → return from memory (no I/O) L2 hit → return from IndexedDB, promote to L1 (no network) Miss → fetch from network, store in L1 + L2 Offline → serve stale L2 entry via SmartlinksOfflineError (if persistence enabled) Admin paths (`/admin/...`) are never kept (see isAdminPath): every call goes to the network. Concurrent identical GETs share one in-flight promise (deduplication), admin ones included. Node-safe: IndexedDB calls are no-ops when IDB is unavailable.
274
275
 
275
- **post**(path: string,
276
- body: any,
276
+ **post**(path: string,
277
+ body: any,
277
278
  extraHeaders?: Record<string, string>) → `Promise<T>`
278
279
  Internal helper that performs a POST request to `${baseURL}${path}`, injecting headers for apiKey or bearerToken if present. If body is FormData, Content-Type is not set. Returns the parsed JSON as T, or throws an Error.
279
280
 
280
- **put**(path: string,
281
- body: any,
281
+ **put**(path: string,
282
+ body: any,
282
283
  extraHeaders?: Record<string, string>) → `Promise<T>`
283
284
  Internal helper that performs a PUT request to `${baseURL}${path}`, injecting headers for apiKey or bearerToken if present. If body is FormData, Content-Type is not set. Returns the parsed JSON as T, or throws an Error.
284
285
 
285
- **patch**(path: string,
286
- body: any,
286
+ **patch**(path: string,
287
+ body: any,
287
288
  extraHeaders?: Record<string, string>) → `Promise<T>`
288
289
  Internal helper that performs a PATCH request to `${baseURL}${path}`, injecting headers for apiKey or bearerToken if present. If body is FormData, Content-Type is not set. Returns the parsed JSON as T, or throws an Error.
289
290
 
290
- **requestWithOptions**(path: string,
291
+ **requestWithOptions**(path: string,
291
292
  options: RequestInit) → `Promise<T>`
292
293
  Internal helper that performs a request to `${baseURL}${path}` with custom options, injecting headers for apiKey or bearerToken if present. Returns the parsed JSON as T, or throws an Error.
293
294
 
294
- **requestStream**(path: string,
295
- options?: {
296
- method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'
297
- body?: any
298
- headers?: Record<string, string>
295
+ **requestStream**(path: string,
296
+ options?: {
297
+ method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'
298
+ body?: any
299
+ headers?: Record<string, string>
299
300
  }) → `Promise<AsyncIterable<T>>`
300
301
  Internal helper that performs a streaming request using the shared auth and proxy transport. The response is expected to be `text/event-stream` with JSON payloads in `data:` frames.
301
302
 
302
- **del**(path: string,
303
+ **del**(path: string,
303
304
  extraHeaders?: Record<string, string>) → `Promise<T>`
304
305
  Internal helper that performs a DELETE request to `${baseURL}${path}`, injecting headers for apiKey or bearerToken if present. Returns the parsed JSON as T, or throws an Error.
305
306
 
@@ -2760,8 +2761,10 @@ interface ServerFunctionBookings {
2760
2761
  query(params?: BookingListQueryParams): Promise<PaginatedResponse<Booking>>;
2761
2762
  mine(params?: BookingListQueryParams): Promise<PaginatedResponse<Booking>>;
2762
2763
  update(bookingId: string, fields: UpdateBookingInput): Promise<Booking>;
2763
- confirm(bookingId: string): Promise<Booking>;
2764
- cancel(bookingId: string, opts?: { reason?: string }): Promise<Booking>;
2764
+ confirm(bookingId: string, opts?: { payment?: 'waive' }): Promise<Booking>;
2765
+ cancel(bookingId: string, opts?: { reason?: string; refund?: 'full' | 'none' | number }): Promise<Booking>;
2766
+ checkout(input: BookingCheckoutInput): Promise<Omit<BookingCheckoutResult, 'editToken'> & { replayed?: boolean }>;
2767
+ refund(bookingId: string, opts?: { amount?: number; reason?: string }): Promise<{ booking: Booking; refunded: number; pending: boolean }>;
2765
2768
  move(bookingId: string, input: MoveBookingInput): Promise<Booking>;
2766
2769
  extendHold(bookingId: string, holdMinutes: number): Promise<Booking>;
2767
2770
  complete(bookingId: string): Promise<Booking>;
@@ -5435,6 +5438,7 @@ interface Booking {
5435
5438
  admin?: Record<string, any>
5436
5439
  allocations: BookingAllocation[]
5437
5440
  editToken?: string
5441
+ payment?: BookingPayment
5438
5442
  }
5439
5443
  ```
5440
5444
 
@@ -5709,6 +5713,87 @@ interface StandardSchedule {
5709
5713
  }
5710
5714
  ```
5711
5715
 
5716
+ **BookingPaymentLine** (interface)
5717
+ ```typescript
5718
+ interface BookingPaymentLine {
5719
+ priceId: string
5720
+ label: string
5721
+ unitAmount: number
5722
+ quantity: number
5723
+ }
5724
+ ```
5725
+
5726
+ **BookingPayment** (interface)
5727
+ ```typescript
5728
+ interface BookingPayment {
5729
+ status: 'awaiting' | 'paid' | 'partially_refunded' | 'refunded' | 'waived'
5730
+ total: number
5731
+ currency: string
5732
+ refunded: number
5733
+ lines: BookingPaymentLine[]
5734
+ paidAt?: string
5735
+ payBy?: string
5736
+ requested?: boolean
5737
+ link?: string
5738
+ }
5739
+ ```
5740
+
5741
+ **BookingPrice** (interface)
5742
+ ```typescript
5743
+ interface BookingPrice {
5744
+ id: string
5745
+ label: string
5746
+ amount: number
5747
+ durationMinutes?: number
5748
+ resourceIds?: string[]
5749
+ }
5750
+ ```
5751
+
5752
+ **BookingPaymentsConfig** (interface)
5753
+ ```typescript
5754
+ interface BookingPaymentsConfig {
5755
+ required?: boolean
5756
+ currency?: string
5757
+ prices?: BookingPrice[]
5758
+ sessionMinutes?: number
5759
+ ownerCancelRefund?: 'full' | 'none'
5760
+ payWithinHours?: number
5761
+ successUrl?: string
5762
+ cancelUrl?: string
5763
+ allowedHosts?: string[]
5764
+ }
5765
+ ```
5766
+
5767
+ **BookingPriceLine** (interface)
5768
+ ```typescript
5769
+ interface BookingPriceLine {
5770
+ priceId: string
5771
+ quantity?: number
5772
+ }
5773
+ ```
5774
+
5775
+ **BookingCheckoutResult** (interface)
5776
+ ```typescript
5777
+ interface BookingCheckoutResult {
5778
+ booking: Booking
5779
+ editToken?: string
5780
+ checkoutUrl: string | null
5781
+ expiresAt: string | null
5782
+ total: number
5783
+ currency: string | null
5784
+ request?: boolean
5785
+ }
5786
+ ```
5787
+
5788
+ **BookingPayLinkResult** (interface)
5789
+ ```typescript
5790
+ interface BookingPayLinkResult {
5791
+ checkoutUrl?: string
5792
+ done?: 'paid' | 'closed'
5793
+ url?: string | null
5794
+ }
5795
+ ```
5796
+
5712
5797
  **BookingStatus** = ``
5713
5798
 
5714
5799
  **BookingVisibility** = `'public' | 'owner' | 'admin'`
@@ -5732,6 +5817,8 @@ type BookingResourceRef = { type: string; id: string }
5732
5817
 
5733
5818
  **ScheduleDay** = `'mon' | 'tue' | 'wed' | 'thu' | 'fri' | 'sat' | 'sun'`
5734
5819
 
5820
+ **BookingRefundResult** = `Booking & { refunded: number`
5821
+
5735
5822
  ### broadcasts
5736
5823
 
5737
5824
  **BroadcastRecord** (interface)
@@ -6833,427 +6920,427 @@ interface TransactionalSendError {
6833
6920
 
6834
6921
  **EmailAttachmentSpec** = ``
6835
6922
 
6836
- **TransactionalSendResult** = `// src/types/comms.ts
6837
- // Communication and notification types for the Smartlinks API
6838
- import type { IdField } from './common'
6839
- import type { BroadcastChannel } from './broadcasts'
6840
- import type { ListResult, ListOptions } from './list'
6841
-
6842
- /**
6843
- * Target subject for notifications (product, collection, etc.)
6844
- */
6845
- export interface NotificationSubjectTarget {
6846
- /** Type of target entity */
6847
- type: 'product' | 'collection' | 'user' | 'batch' | 'proof'
6848
- /** ID of the target entity */
6849
- id: string
6850
- }
6851
-
6852
-
6853
- // Analytics & logging (communication events)
6854
-
6855
- export interface CommunicationEvent {
6856
- orgId: string
6857
- broadcastId?: string
6858
- journeyId?: string
6859
- userId?: string
6860
- contactId?: string
6861
- channel?: string
6862
- timestamp: string
6863
- eventType: string
6864
- outcome?: string | null
6865
- templateId?: string | null
6866
- [k: string]: any
6867
- }
6868
-
6869
- /** `comms.queryByUser` options: who, the time window (`from` / `to`), plus `limit` and `cursor`. */
6870
- export interface CommsQueryByUser extends ListOptions {
6871
- userId?: string
6872
- contactId?: string
6873
- from?: string
6874
- to?: string
6875
- }
6876
-
6877
- export type RecipientId = string
6878
- export interface RecipientWithOutcome { id: string; outcome: string }
6879
-
6880
- /** `comms.queryRecipientIds` options: the source, the time window (`from` / `to`), plus `limit` and `cursor`. */
6881
- export interface CommsRecipientIdsQuery extends ListOptions {
6882
- broadcastId?: string
6883
- journeyId?: string
6884
- idField?: IdField
6885
- from?: string
6886
- to?: string
6887
- }
6888
-
6889
- /** Who a broadcast or journey reached that did NOT then do an interaction. */
6890
- export interface CommsRecipientsWithoutInteractionQuery {
6891
- broadcastId?: string
6892
- journeyId?: string
6893
- /** The interaction to look for (its id). */
6894
- interactionId?: string
6895
- appId?: string
6896
- idField?: IdField
6897
- from?: string
6898
- to?: string
6899
- limit?: number
6900
- /** A `nextCursor` from the previous page. */
6901
- cursor?: string
6902
- }
6903
-
6904
- /** Who a broadcast or journey reached that then did an interaction. */
6905
- export interface CommsRecipientsWithInteractionQuery {
6906
- broadcastId?: string
6907
- journeyId?: string
6908
- /** The interaction to look for (its id). */
6909
- interactionId?: string
6910
- appId?: string
6911
- outcome?: string
6912
- idField?: IdField
6913
- includeOutcome?: boolean
6914
- from?: string
6915
- to?: string
6916
- limit?: number
6917
- /** A `nextCursor` from the previous page. */
6918
- cursor?: string
6919
- }
6920
-
6921
- export interface LogCommunicationEventBody {
6922
- broadcastId?: string
6923
- journeyId?: string
6924
- userId?: string
6925
- contactId?: string
6926
- channel?: string
6927
- eventType: string
6928
- outcome?: string
6929
- templateId?: string
6930
- timestamp?: string
6931
- [k: string]: any
6932
- }
6933
-
6934
- export interface LogBulkCommunicationEventsBody {
6935
- params: { broadcastId?: string; journeyId?: string; [k: string]: any }
6936
- ids: string[]
6937
- idField?: IdField
6938
- }
6939
-
6940
- export interface AppendResult { success: true }
6941
- export interface AppendBulkResult { success: true; count: number }
6942
-
6943
- // Common recipient type used by segments and broadcasts
6944
- export type Recipient = import('./contact').Contact
6945
-
6946
- // Shared page response shape for recipient listings
6947
- export interface RecipientsPage {
6948
- items: Recipient[]
6949
- total: number
6950
- limit: number
6951
- offset: number
6952
- note?: string
6953
- }
6954
-
6955
- // Web Push (public client registration)
6956
-
6957
- export interface PushSubscriptionJSON {
6958
- endpoint: string
6959
- keys?: {
6960
- p256dh?: string
6961
- auth?: string
6962
- }
6963
- }
6964
-
6965
- export interface PushVapidResponse { publicKey: string }
6966
- export interface PushSubscribeResponse { ok: true; id: string }
6967
-
6968
- // Public: register a push contact method
6969
- export interface RegisterPushMethodRequest {
6970
- /** Optional: defaults to the signed-in user's own contact. Only collection admins may name another contact. */
6971
- contactId?: string
6972
- endpoint: string
6973
- keys: { p256dh: string; auth: string }
6974
- meta?: Record<string, any>
6975
- }
6976
-
6977
- // Admin Comms Settings
6978
-
6979
- export interface CommsSettings {
6980
- unsub?: {
6981
- requireToken?: boolean
6982
- /** Secret for token generation; omitted unless includeSecret=true */
6983
- secret?: string
6984
- /** Convenience flag indicating a secret is set (masked responses) */
6985
- hasSecret?: boolean
6986
- }
6987
- /** Map of topic keys to topic config */
6988
- topics?: Record<string, TopicConfig>
6989
- [k: string]: any
6990
- }
6991
-
6992
- export interface TopicConfig {
6993
- label?: string
6994
- description?: string
6995
- /** Optional UI-only grouping labels */
6996
- labels?: string[]
6997
- /** Classification for UI and default policy guidance */
6998
- classification?: 'transactional' | 'marketing'
6999
- defaults?: {
7000
- channels?: Partial<Record<BroadcastChannel, boolean>>
7001
- topics?: Record<string, boolean | undefined>
7002
- /** Default consent policy when explicit preferences are absent */
7003
- policy?: 'opt-in' | 'opt-out'
7004
- /** Per-channel default policy (overrides policy when present) */
7005
- byChannel?: Partial<Record<BroadcastChannel, 'opt-in' | 'opt-out'>>
7006
- }
7007
- rules?: {
7008
- allowChannels?: BroadcastChannel[]
7009
- allowUnsubscribe?: boolean
7010
- required?: boolean
7011
- }
7012
- [k: string]: any
7013
- }
7014
-
7015
- export interface CommsSettingsGetResponse {
7016
- ok: true
7017
- settings: CommsSettings
7018
- }
7019
-
7020
- export type CommsSettingsPatchBody = Partial<CommsSettings>
7021
-
7022
- // Public types listing (array form for public API)
7023
- export interface CommsPublicTopicsResponse { ok: true; topics: Record<string, TopicConfig> }
7024
-
7025
- export interface UnsubscribeQuery {
7026
- /** Optional: defaults to the signed-in user's own contact. Only collection admins may name another contact. */
7027
- contactId?: string
7028
- topic?: string
7029
- channel?: BroadcastChannel
7030
- token?: string
7031
- }
7032
-
7033
- export interface UnsubscribeResponse { ok: true; applied?: { channels?: Record<string, boolean>; topics?: Record<string, boolean> } }
7034
-
7035
- // Public sign-up (double opt-in)
7036
- export interface CommsSignupRequest {
7037
- email: string
7038
- /**
7039
- * Required: YOUR app's confirmation email — a template in this collection (SL.template) whose body
7040
- * uses `{{ action_url }}` for the confirm link (`{{ topics }}` lists what they signed up for). The
7041
- * platform sends no default sign-up email.
7042
- */
7043
- templateId: string
7044
- /** Topic ids from the collection's comm settings (e.g. ["newsletter"]). */
7045
- topics?: string[]
7046
- firstName?: string
7047
- /**
7048
- * The form's other answers — firstName/lastName/displayName/company/locale/timezone and
7049
- * `customFields`. Applied to the contact when the address is confirmed, and only where the contact
7050
- * has no value yet (never overwritten). Small: ~2 KB.
7051
- */
7052
- fields?: { firstName?: string; lastName?: string; displayName?: string; company?: string; locale?: string; timezone?: string; customFields?: Record<string, string | number | boolean> }
7053
- /** Your app id, recorded with the sent email. */
7054
- appId?: string
7055
- }
7056
- export interface CommsSignupResponse { ok: true; pending: true }
7057
-
7058
- // Public consent/preferences/subscribe
7059
- export type ConsentChannels = Partial<Record<BroadcastChannel, boolean>>
7060
- type SubjectType = import('./contact').SubjectType
7061
-
7062
- export interface CommsConsentUpsertRequest {
7063
- /** Optional: defaults to the signed-in user's own contact. Only collection admins may name another contact. */
7064
- contactId?: string
7065
- channels?: ConsentChannels
7066
- topics?: Record<string, boolean>
7067
- topicsByChannel?: Partial<Record<BroadcastChannel, Record<string, boolean>>>
7068
- }
7069
-
7070
- export interface CommsPreferencesUpsertRequest {
7071
- /** Optional: defaults to the signed-in user's own contact. Only collection admins may name another contact. */
7072
- contactId?: string
7073
- subject?: { type: SubjectType; id: string; productId?: string }
7074
- channels?: ConsentChannels
7075
- topics?: Record<string, boolean>
7076
- topicsByChannel?: Partial<Record<BroadcastChannel, Record<string, boolean>>>
7077
- }
7078
-
7079
- export interface CommsSubscribeRequest {
7080
- /** Optional: defaults to the signed-in user's own contact. Only collection admins may name another contact. */
7081
- contactId?: string
7082
- subject: { type: SubjectType; id: string; productId?: string }
7083
- subscribe: boolean
7084
- source?: string
7085
- }
7086
- export interface CommsSubscribeResponse { ok: true; subscriptionId: string }
7087
-
7088
- export interface CommsSubscriptionCheckQuery {
7089
- /** Optional: defaults to the signed-in user's own contact. Only collection admins may name another contact. */
7090
- contactId?: string
7091
- subjectType: SubjectType
7092
- subjectId: string
7093
- productId?: string
7094
- }
7095
- export interface CommsSubscriptionCheckResponse { ok: true; subscribed: boolean }
7096
-
7097
- export interface CommsListMethodsQuery {
7098
- /** Optional: defaults to the signed-in user's own contact. Only collection admins may name another contact. */
7099
- contactId?: string
7100
- type?: BroadcastChannel
7101
- }
7102
- /** What `comms.listMethods` returns: the contact's registered methods in `items` (all of them; `nextCursor` is always null). */
7103
- export type CommsListMethodsResponse = ListResult<import('./contact').CommMethod>
7104
-
7105
- export interface RegisterEmailMethodRequest { contactId?: string; email?: string; userId?: string }
7106
- export interface RegisterSmsMethodRequest { contactId?: string; phone?: string; userId?: string }
7107
- export interface RegisterMethodResponse { ok: true; contactId: string }
7108
-
7109
- export interface SubscriptionsResolveRequest {
7110
- subject: { type: SubjectType; id: string; productId?: string }
7111
- hints: { userId?: string; pushEndpoint?: string; email?: string }
7112
- }
7113
- export interface SubscriptionsResolveResponse {
7114
- ok: true
7115
- subject: { type: SubjectType; id: string; productId?: string }
7116
- contacts: Array<{
7117
- contactId: string
7118
- subscribed: boolean
7119
- channels?: Partial<Record<BroadcastChannel, boolean>>
7120
- }>
7121
- anySubscribed: boolean
7122
- anyMethods: boolean
7123
- }
7124
-
7125
- // Transactional send (single-contact, single-message)
7126
-
7127
- /**
7128
- * Send a single message to one contact using a template.
7129
- * No broadcast record is created; the send is logged directly to the
7130
- * contact's communication history with sourceType: 'transactional'.
7131
- *
7132
- * POST /admin/collection/:collectionId/comm/send
7133
- */
7134
- export interface TransactionalSendRequest {
7135
- /** CRM contact UUID */
7136
- contactId: string
7137
- /** A saved template's id. Give this or `message`. */
7138
- templateId?: string
7139
- /**
7140
- * A typed message instead of a template: plain text, Liquid allowed (`{{ contact.firstName }}`).
7141
- * `sms` is the shorter text for SMS and WhatsApp (defaults to `body`).
7142
- */
7143
- message?: TypedMessage
7144
- /**
7145
- * Channel to send on. Defaults to 'preferred', which auto-selects the
7146
- * contact's best available channel respecting consent, suppression, and
7147
- * template availability.
7148
- */
7149
- channel?: 'email' | 'sms' | 'whatsapp' | 'push' | 'wallet' | 'preferred'
7150
- /** Extra Liquid variables merged into the top-level render context */
7151
- props?: Record<string, unknown>
7152
- /** Context objects to hydrate into the Liquid template */
7153
- include?: {
7154
- /** Hydrate {{ collection }}. Default: true */
7155
- collection?: boolean
7156
- /** Hydrate {{ product }} from this product ID */
7157
- productId?: string
7158
- /** Hydrate {{ proof }} (requires productId) */
7159
- proofId?: string
7160
- /** Hydrate {{ user }} from contact.userId */
7161
- user?: boolean
7162
- /** Hydrate {{ appCase }} from this case UUID */
7163
- appCase?: string
7164
- /** Hydrate {{ appThread }} from this thread UUID */
7165
- appThread?: string
7166
- /** Hydrate {{ appRecord }} from this record UUID */
7167
- appRecord?: string
7168
- }
7169
- /** Arbitrary label stored on the comms-events row (e.g. 'warranty-step-2') */
7170
- ref?: string
7171
- /** App context stored on the comms-events row */
7172
- appId?: string
7173
- /**
7174
- * What the message is about: the record it was sent for and the admin screen that shows it, so it is a
7175
- * link in Messages, on the contact's Activity, and on the conversation a reply opens. `appId` defaults
7176
- * to the sending app.
7177
- */
7178
- about?: MessageAbout
7179
- /**
7180
- * `'service'` (a confirmation, a reminder, an update): an asked-for channel the person turned off, or a
7181
- * suppressed email, is refused (`transactional.opted_out`). Marketing goes out as a campaign.
7182
- */
7183
- category?: 'service'
7184
- /**
7185
- * Files to attach (email only; at most 5, 10 MB in all). What can't be made is left out and listed in
7186
- * `attachmentsLeftOut` — the email still goes.
7187
- */
7188
- attach?: EmailAttachmentSpec[]
7189
- }
7190
-
7191
- /**
7192
- * One file for an email:
7193
- * - `'calendar'` — the booking's `.ics` calendar invite (needs `include.booking` and `appId`)
7194
- * - `{ asset }` — a file uploaded to this collection's assets
7195
- * - `{ function }` — the app's (`appId`) own server function makes it (see server-functions.md, "Making an email attachment")
7196
- * - `{ filename, contentType, content }` — a file you made, base64 (PDF, Office documents, images, text, CSV, calendar)
7197
- * - `{ filename, file }` — a private file you made (e.g. `pdf.create` with `return: 'signedUrl'`)
7198
- */
7199
- export type EmailAttachmentSpec =
7200
- | 'calendar'
7201
- | { asset: string }
7202
- | { function: string }
7203
- | { filename: string; contentType: string; content: string }
7204
- | { filename: string; contentType?: string; file: string }
7205
-
7206
- export interface TransactionalSendResponse {
7207
- ok: true
7208
- /** The channel the message was actually sent on */
7209
- channel: 'email' | 'sms' | 'whatsapp' | 'push' | 'wallet'
7210
- /** Provider message ID (email/SMS/WhatsApp); absent for push/wallet */
7211
- messageId?: string
7212
- /** Attachments that couldn't be made, and why (the email went without them) */
7213
- attachmentsLeftOut?: string[]
7214
- }
7215
-
7216
- /** A message written there and then rather than a saved template. */
7217
- export interface TypedMessage {
7218
- subject?: string
7219
- body: string
7220
- /** The shorter text for SMS and WhatsApp (defaults to `body`). */
7221
- sms?: string
7222
- }
7223
-
7224
- /**
7225
- * What a message is about (docs/comms.md, "What a message is about"). Ids only, never content.
7226
- * `view` and `params` name one of the app's admin views (manifest `adminViews`, docs/admin-views.md).
7227
- */
7228
- export interface MessageAbout {
7229
- appId?: string
7230
- /** What kind of record: `'booking'`, `'entry'`, `'case'`. */
7231
- type: string
7232
- id: string
7233
- view?: string
7234
- params?: Record<string, string>
7235
- /** A short label to show without looking the record up: `'Sat 3pm, table for 4'`. */
7236
- label?: string
7237
- }
7238
-
7239
- export interface TransactionalSendError {
7240
- ok: false
7241
- /**
7242
- * Error code. Known values:
7243
- * - `transactional.contact_not_found`
7244
- * - `transactional.template_not_found`
7245
- * - `transactional.no_channel_available`
7246
- * - `transactional.email_missing`
7247
- * - `transactional.phone_missing`
7248
- * - `transactional.whatsapp_missing`
7249
- * - `transactional.no_push_methods`
7250
- * - `transactional.no_wallet_passes` (`channel: 'wallet'`: the person has no wallet passes from this app)
7251
- * - `transactional.opted_out` (category `'service'`: the person turned that channel off, or the email is suppressed)
7252
- * - `transactional.template_or_message` / `transactional.message_invalid` / `transactional.about_invalid`
7253
- */
7254
- error: string
7255
- }
7256
-
6923
+ **TransactionalSendResult** = `// src/types/comms.ts
6924
+ // Communication and notification types for the Smartlinks API
6925
+ import type { IdField } from './common'
6926
+ import type { BroadcastChannel } from './broadcasts'
6927
+ import type { ListResult, ListOptions } from './list'
6928
+
6929
+ /**
6930
+ * Target subject for notifications (product, collection, etc.)
6931
+ */
6932
+ export interface NotificationSubjectTarget {
6933
+ /** Type of target entity */
6934
+ type: 'product' | 'collection' | 'user' | 'batch' | 'proof'
6935
+ /** ID of the target entity */
6936
+ id: string
6937
+ }
6938
+
6939
+
6940
+ // Analytics & logging (communication events)
6941
+
6942
+ export interface CommunicationEvent {
6943
+ orgId: string
6944
+ broadcastId?: string
6945
+ journeyId?: string
6946
+ userId?: string
6947
+ contactId?: string
6948
+ channel?: string
6949
+ timestamp: string
6950
+ eventType: string
6951
+ outcome?: string | null
6952
+ templateId?: string | null
6953
+ [k: string]: any
6954
+ }
6955
+
6956
+ /** `comms.queryByUser` options: who, the time window (`from` / `to`), plus `limit` and `cursor`. */
6957
+ export interface CommsQueryByUser extends ListOptions {
6958
+ userId?: string
6959
+ contactId?: string
6960
+ from?: string
6961
+ to?: string
6962
+ }
6963
+
6964
+ export type RecipientId = string
6965
+ export interface RecipientWithOutcome { id: string; outcome: string }
6966
+
6967
+ /** `comms.queryRecipientIds` options: the source, the time window (`from` / `to`), plus `limit` and `cursor`. */
6968
+ export interface CommsRecipientIdsQuery extends ListOptions {
6969
+ broadcastId?: string
6970
+ journeyId?: string
6971
+ idField?: IdField
6972
+ from?: string
6973
+ to?: string
6974
+ }
6975
+
6976
+ /** Who a broadcast or journey reached that did NOT then do an interaction. */
6977
+ export interface CommsRecipientsWithoutInteractionQuery {
6978
+ broadcastId?: string
6979
+ journeyId?: string
6980
+ /** The interaction to look for (its id). */
6981
+ interactionId?: string
6982
+ appId?: string
6983
+ idField?: IdField
6984
+ from?: string
6985
+ to?: string
6986
+ limit?: number
6987
+ /** A `nextCursor` from the previous page. */
6988
+ cursor?: string
6989
+ }
6990
+
6991
+ /** Who a broadcast or journey reached that then did an interaction. */
6992
+ export interface CommsRecipientsWithInteractionQuery {
6993
+ broadcastId?: string
6994
+ journeyId?: string
6995
+ /** The interaction to look for (its id). */
6996
+ interactionId?: string
6997
+ appId?: string
6998
+ outcome?: string
6999
+ idField?: IdField
7000
+ includeOutcome?: boolean
7001
+ from?: string
7002
+ to?: string
7003
+ limit?: number
7004
+ /** A `nextCursor` from the previous page. */
7005
+ cursor?: string
7006
+ }
7007
+
7008
+ export interface LogCommunicationEventBody {
7009
+ broadcastId?: string
7010
+ journeyId?: string
7011
+ userId?: string
7012
+ contactId?: string
7013
+ channel?: string
7014
+ eventType: string
7015
+ outcome?: string
7016
+ templateId?: string
7017
+ timestamp?: string
7018
+ [k: string]: any
7019
+ }
7020
+
7021
+ export interface LogBulkCommunicationEventsBody {
7022
+ params: { broadcastId?: string; journeyId?: string; [k: string]: any }
7023
+ ids: string[]
7024
+ idField?: IdField
7025
+ }
7026
+
7027
+ export interface AppendResult { success: true }
7028
+ export interface AppendBulkResult { success: true; count: number }
7029
+
7030
+ // Common recipient type used by segments and broadcasts
7031
+ export type Recipient = import('./contact').Contact
7032
+
7033
+ // Shared page response shape for recipient listings
7034
+ export interface RecipientsPage {
7035
+ items: Recipient[]
7036
+ total: number
7037
+ limit: number
7038
+ offset: number
7039
+ note?: string
7040
+ }
7041
+
7042
+ // Web Push (public client registration)
7043
+
7044
+ export interface PushSubscriptionJSON {
7045
+ endpoint: string
7046
+ keys?: {
7047
+ p256dh?: string
7048
+ auth?: string
7049
+ }
7050
+ }
7051
+
7052
+ export interface PushVapidResponse { publicKey: string }
7053
+ export interface PushSubscribeResponse { ok: true; id: string }
7054
+
7055
+ // Public: register a push contact method
7056
+ export interface RegisterPushMethodRequest {
7057
+ /** Optional: defaults to the signed-in user's own contact. Only collection admins may name another contact. */
7058
+ contactId?: string
7059
+ endpoint: string
7060
+ keys: { p256dh: string; auth: string }
7061
+ meta?: Record<string, any>
7062
+ }
7063
+
7064
+ // Admin Comms Settings
7065
+
7066
+ export interface CommsSettings {
7067
+ unsub?: {
7068
+ requireToken?: boolean
7069
+ /** Secret for token generation; omitted unless includeSecret=true */
7070
+ secret?: string
7071
+ /** Convenience flag indicating a secret is set (masked responses) */
7072
+ hasSecret?: boolean
7073
+ }
7074
+ /** Map of topic keys to topic config */
7075
+ topics?: Record<string, TopicConfig>
7076
+ [k: string]: any
7077
+ }
7078
+
7079
+ export interface TopicConfig {
7080
+ label?: string
7081
+ description?: string
7082
+ /** Optional UI-only grouping labels */
7083
+ labels?: string[]
7084
+ /** Classification for UI and default policy guidance */
7085
+ classification?: 'transactional' | 'marketing'
7086
+ defaults?: {
7087
+ channels?: Partial<Record<BroadcastChannel, boolean>>
7088
+ topics?: Record<string, boolean | undefined>
7089
+ /** Default consent policy when explicit preferences are absent */
7090
+ policy?: 'opt-in' | 'opt-out'
7091
+ /** Per-channel default policy (overrides policy when present) */
7092
+ byChannel?: Partial<Record<BroadcastChannel, 'opt-in' | 'opt-out'>>
7093
+ }
7094
+ rules?: {
7095
+ allowChannels?: BroadcastChannel[]
7096
+ allowUnsubscribe?: boolean
7097
+ required?: boolean
7098
+ }
7099
+ [k: string]: any
7100
+ }
7101
+
7102
+ export interface CommsSettingsGetResponse {
7103
+ ok: true
7104
+ settings: CommsSettings
7105
+ }
7106
+
7107
+ export type CommsSettingsPatchBody = Partial<CommsSettings>
7108
+
7109
+ // Public types listing (array form for public API)
7110
+ export interface CommsPublicTopicsResponse { ok: true; topics: Record<string, TopicConfig> }
7111
+
7112
+ export interface UnsubscribeQuery {
7113
+ /** Optional: defaults to the signed-in user's own contact. Only collection admins may name another contact. */
7114
+ contactId?: string
7115
+ topic?: string
7116
+ channel?: BroadcastChannel
7117
+ token?: string
7118
+ }
7119
+
7120
+ export interface UnsubscribeResponse { ok: true; applied?: { channels?: Record<string, boolean>; topics?: Record<string, boolean> } }
7121
+
7122
+ // Public sign-up (double opt-in)
7123
+ export interface CommsSignupRequest {
7124
+ email: string
7125
+ /**
7126
+ * Required: YOUR app's confirmation email — a template in this collection (SL.template) whose body
7127
+ * uses `{{ action_url }}` for the confirm link (`{{ topics }}` lists what they signed up for). The
7128
+ * platform sends no default sign-up email.
7129
+ */
7130
+ templateId: string
7131
+ /** Topic ids from the collection's comm settings (e.g. ["newsletter"]). */
7132
+ topics?: string[]
7133
+ firstName?: string
7134
+ /**
7135
+ * The form's other answers — firstName/lastName/displayName/company/locale/timezone and
7136
+ * `customFields`. Applied to the contact when the address is confirmed, and only where the contact
7137
+ * has no value yet (never overwritten). Small: ~2 KB.
7138
+ */
7139
+ fields?: { firstName?: string; lastName?: string; displayName?: string; company?: string; locale?: string; timezone?: string; customFields?: Record<string, string | number | boolean> }
7140
+ /** Your app id, recorded with the sent email. */
7141
+ appId?: string
7142
+ }
7143
+ export interface CommsSignupResponse { ok: true; pending: true }
7144
+
7145
+ // Public consent/preferences/subscribe
7146
+ export type ConsentChannels = Partial<Record<BroadcastChannel, boolean>>
7147
+ type SubjectType = import('./contact').SubjectType
7148
+
7149
+ export interface CommsConsentUpsertRequest {
7150
+ /** Optional: defaults to the signed-in user's own contact. Only collection admins may name another contact. */
7151
+ contactId?: string
7152
+ channels?: ConsentChannels
7153
+ topics?: Record<string, boolean>
7154
+ topicsByChannel?: Partial<Record<BroadcastChannel, Record<string, boolean>>>
7155
+ }
7156
+
7157
+ export interface CommsPreferencesUpsertRequest {
7158
+ /** Optional: defaults to the signed-in user's own contact. Only collection admins may name another contact. */
7159
+ contactId?: string
7160
+ subject?: { type: SubjectType; id: string; productId?: string }
7161
+ channels?: ConsentChannels
7162
+ topics?: Record<string, boolean>
7163
+ topicsByChannel?: Partial<Record<BroadcastChannel, Record<string, boolean>>>
7164
+ }
7165
+
7166
+ export interface CommsSubscribeRequest {
7167
+ /** Optional: defaults to the signed-in user's own contact. Only collection admins may name another contact. */
7168
+ contactId?: string
7169
+ subject: { type: SubjectType; id: string; productId?: string }
7170
+ subscribe: boolean
7171
+ source?: string
7172
+ }
7173
+ export interface CommsSubscribeResponse { ok: true; subscriptionId: string }
7174
+
7175
+ export interface CommsSubscriptionCheckQuery {
7176
+ /** Optional: defaults to the signed-in user's own contact. Only collection admins may name another contact. */
7177
+ contactId?: string
7178
+ subjectType: SubjectType
7179
+ subjectId: string
7180
+ productId?: string
7181
+ }
7182
+ export interface CommsSubscriptionCheckResponse { ok: true; subscribed: boolean }
7183
+
7184
+ export interface CommsListMethodsQuery {
7185
+ /** Optional: defaults to the signed-in user's own contact. Only collection admins may name another contact. */
7186
+ contactId?: string
7187
+ type?: BroadcastChannel
7188
+ }
7189
+ /** What `comms.listMethods` returns: the contact's registered methods in `items` (all of them; `nextCursor` is always null). */
7190
+ export type CommsListMethodsResponse = ListResult<import('./contact').CommMethod>
7191
+
7192
+ export interface RegisterEmailMethodRequest { contactId?: string; email?: string; userId?: string }
7193
+ export interface RegisterSmsMethodRequest { contactId?: string; phone?: string; userId?: string }
7194
+ export interface RegisterMethodResponse { ok: true; contactId: string }
7195
+
7196
+ export interface SubscriptionsResolveRequest {
7197
+ subject: { type: SubjectType; id: string; productId?: string }
7198
+ hints: { userId?: string; pushEndpoint?: string; email?: string }
7199
+ }
7200
+ export interface SubscriptionsResolveResponse {
7201
+ ok: true
7202
+ subject: { type: SubjectType; id: string; productId?: string }
7203
+ contacts: Array<{
7204
+ contactId: string
7205
+ subscribed: boolean
7206
+ channels?: Partial<Record<BroadcastChannel, boolean>>
7207
+ }>
7208
+ anySubscribed: boolean
7209
+ anyMethods: boolean
7210
+ }
7211
+
7212
+ // Transactional send (single-contact, single-message)
7213
+
7214
+ /**
7215
+ * Send a single message to one contact using a template.
7216
+ * No broadcast record is created; the send is logged directly to the
7217
+ * contact's communication history with sourceType: 'transactional'.
7218
+ *
7219
+ * POST /admin/collection/:collectionId/comm/send
7220
+ */
7221
+ export interface TransactionalSendRequest {
7222
+ /** CRM contact UUID */
7223
+ contactId: string
7224
+ /** A saved template's id. Give this or `message`. */
7225
+ templateId?: string
7226
+ /**
7227
+ * A typed message instead of a template: plain text, Liquid allowed (`{{ contact.firstName }}`).
7228
+ * `sms` is the shorter text for SMS and WhatsApp (defaults to `body`).
7229
+ */
7230
+ message?: TypedMessage
7231
+ /**
7232
+ * Channel to send on. Defaults to 'preferred', which auto-selects the
7233
+ * contact's best available channel respecting consent, suppression, and
7234
+ * template availability.
7235
+ */
7236
+ channel?: 'email' | 'sms' | 'whatsapp' | 'push' | 'wallet' | 'preferred'
7237
+ /** Extra Liquid variables merged into the top-level render context */
7238
+ props?: Record<string, unknown>
7239
+ /** Context objects to hydrate into the Liquid template */
7240
+ include?: {
7241
+ /** Hydrate {{ collection }}. Default: true */
7242
+ collection?: boolean
7243
+ /** Hydrate {{ product }} from this product ID */
7244
+ productId?: string
7245
+ /** Hydrate {{ proof }} (requires productId) */
7246
+ proofId?: string
7247
+ /** Hydrate {{ user }} from contact.userId */
7248
+ user?: boolean
7249
+ /** Hydrate {{ appCase }} from this case UUID */
7250
+ appCase?: string
7251
+ /** Hydrate {{ appThread }} from this thread UUID */
7252
+ appThread?: string
7253
+ /** Hydrate {{ appRecord }} from this record UUID */
7254
+ appRecord?: string
7255
+ }
7256
+ /** Arbitrary label stored on the comms-events row (e.g. 'warranty-step-2') */
7257
+ ref?: string
7258
+ /** App context stored on the comms-events row */
7259
+ appId?: string
7260
+ /**
7261
+ * What the message is about: the record it was sent for and the admin screen that shows it, so it is a
7262
+ * link in Messages, on the contact's Activity, and on the conversation a reply opens. `appId` defaults
7263
+ * to the sending app.
7264
+ */
7265
+ about?: MessageAbout
7266
+ /**
7267
+ * `'service'` (a confirmation, a reminder, an update): an asked-for channel the person turned off, or a
7268
+ * suppressed email, is refused (`transactional.opted_out`). Marketing goes out as a campaign.
7269
+ */
7270
+ category?: 'service'
7271
+ /**
7272
+ * Files to attach (email only; at most 5, 10 MB in all). What can't be made is left out and listed in
7273
+ * `attachmentsLeftOut` — the email still goes.
7274
+ */
7275
+ attach?: EmailAttachmentSpec[]
7276
+ }
7277
+
7278
+ /**
7279
+ * One file for an email:
7280
+ * - `'calendar'` — the booking's `.ics` calendar invite (needs `include.booking` and `appId`)
7281
+ * - `{ asset }` — a file uploaded to this collection's assets
7282
+ * - `{ function }` — the app's (`appId`) own server function makes it (see server-functions.md, "Making an email attachment")
7283
+ * - `{ filename, contentType, content }` — a file you made, base64 (PDF, Office documents, images, text, CSV, calendar)
7284
+ * - `{ filename, file }` — a private file you made (e.g. `pdf.create` with `return: 'signedUrl'`)
7285
+ */
7286
+ export type EmailAttachmentSpec =
7287
+ | 'calendar'
7288
+ | { asset: string }
7289
+ | { function: string }
7290
+ | { filename: string; contentType: string; content: string }
7291
+ | { filename: string; contentType?: string; file: string }
7292
+
7293
+ export interface TransactionalSendResponse {
7294
+ ok: true
7295
+ /** The channel the message was actually sent on */
7296
+ channel: 'email' | 'sms' | 'whatsapp' | 'push' | 'wallet'
7297
+ /** Provider message ID (email/SMS/WhatsApp); absent for push/wallet */
7298
+ messageId?: string
7299
+ /** Attachments that couldn't be made, and why (the email went without them) */
7300
+ attachmentsLeftOut?: string[]
7301
+ }
7302
+
7303
+ /** A message written there and then rather than a saved template. */
7304
+ export interface TypedMessage {
7305
+ subject?: string
7306
+ body: string
7307
+ /** The shorter text for SMS and WhatsApp (defaults to `body`). */
7308
+ sms?: string
7309
+ }
7310
+
7311
+ /**
7312
+ * What a message is about (docs/comms.md, "What a message is about"). Ids only, never content.
7313
+ * `view` and `params` name one of the app's admin views (manifest `adminViews`, docs/admin-views.md).
7314
+ */
7315
+ export interface MessageAbout {
7316
+ appId?: string
7317
+ /** What kind of record: `'booking'`, `'entry'`, `'case'`. */
7318
+ type: string
7319
+ id: string
7320
+ view?: string
7321
+ params?: Record<string, string>
7322
+ /** A short label to show without looking the record up: `'Sat 3pm, table for 4'`. */
7323
+ label?: string
7324
+ }
7325
+
7326
+ export interface TransactionalSendError {
7327
+ ok: false
7328
+ /**
7329
+ * Error code. Known values:
7330
+ * - `transactional.contact_not_found`
7331
+ * - `transactional.template_not_found`
7332
+ * - `transactional.no_channel_available`
7333
+ * - `transactional.email_missing`
7334
+ * - `transactional.phone_missing`
7335
+ * - `transactional.whatsapp_missing`
7336
+ * - `transactional.no_push_methods`
7337
+ * - `transactional.no_wallet_passes` (`channel: 'wallet'`: the person has no wallet passes from this app)
7338
+ * - `transactional.opted_out` (category `'service'`: the person turned that channel off, or the email is suppressed)
7339
+ * - `transactional.template_or_message` / `transactional.message_invalid` / `transactional.about_invalid`
7340
+ */
7341
+ error: string
7342
+ }
7343
+
7257
7344
  export type TransactionalSendResult =`
7258
7345
 
7259
7346
  ### config
@@ -10694,6 +10781,110 @@ interface CollectionSummaryResponse {
10694
10781
 
10695
10782
  **OrderDirection** = `'sales' | 'purchase'`
10696
10783
 
10784
+ ### payments
10785
+
10786
+ **PaymentsPublicConfig** (interface)
10787
+ ```typescript
10788
+ interface PaymentsPublicConfig {
10789
+ ready: boolean
10790
+ publishableKey: string | null
10791
+ accountId: string | null
10792
+ }
10793
+ ```
10794
+
10795
+ **PaymentIntentInput** (interface)
10796
+ ```typescript
10797
+ interface PaymentIntentInput {
10798
+ appId: string
10799
+ amount: number
10800
+ currency: string
10801
+ email?: string
10802
+ description?: string
10803
+ reference?: string
10804
+ metadata?: Record<string, string | number | boolean>
10805
+ cardOnly?: boolean
10806
+ idempotencyKey?: string
10807
+ }
10808
+ ```
10809
+
10810
+ **PaymentIntentResult** (interface)
10811
+ ```typescript
10812
+ interface PaymentIntentResult {
10813
+ paymentIntentId: string
10814
+ clientSecret: string
10815
+ publishableKey: string
10816
+ accountId: string
10817
+ amount: number
10818
+ currency: string
10819
+ fee: number
10820
+ }
10821
+ ```
10822
+
10823
+ **PaymentsStatus** (interface)
10824
+ ```typescript
10825
+ interface PaymentsStatus {
10826
+ connected: boolean
10827
+ accountId?: string
10828
+ chargesEnabled?: boolean | null
10829
+ detailsSubmitted?: boolean | null
10830
+ payoutsEnabled?: boolean | null
10831
+ platformReady: boolean
10832
+ publishableKeySet: boolean
10833
+ fees: Array<{ appId: string; bps: number; percent: number }>
10834
+ }
10835
+ ```
10836
+
10837
+ **PaymentsConnectInput** (interface)
10838
+ ```typescript
10839
+ interface PaymentsConnectInput {
10840
+ returnUrl: string
10841
+ refreshUrl: string
10842
+ country?: string
10843
+ }
10844
+ ```
10845
+
10846
+ **PaymentRecord** (interface)
10847
+ ```typescript
10848
+ interface PaymentRecord {
10849
+ id: string
10850
+ amount: number
10851
+ amountReceived: number
10852
+ currency: string
10853
+ status: string
10854
+ created: string
10855
+ email: string | null
10856
+ metadata: Record<string, string>
10857
+ }
10858
+ ```
10859
+
10860
+ **PaymentListParams** (interface)
10861
+ ```typescript
10862
+ interface PaymentListParams {
10863
+ appId?: string
10864
+ since?: string
10865
+ limit?: number
10866
+ after?: string
10867
+ }
10868
+ ```
10869
+
10870
+ **PaymentList** (interface)
10871
+ ```typescript
10872
+ interface PaymentList {
10873
+ data: PaymentRecord[]
10874
+ hasMore: boolean
10875
+ next: string | null
10876
+ }
10877
+ ```
10878
+
10879
+ **PaymentDomainResult** (interface)
10880
+ ```typescript
10881
+ interface PaymentDomainResult {
10882
+ domain: string
10883
+ applePay: string
10884
+ googlePay: string
10885
+ }
10886
+ ```
10887
+
10697
10888
  ### product
10698
10889
 
10699
10890
  **ProductKey** (interface)
@@ -12512,36 +12703,36 @@ interface GuideStartOptions {
12512
12703
 
12513
12704
  **AppConfigOptions** (type)
12514
12705
  ```typescript
12515
- type AppConfigOptions = {
12516
- /** The app ID */
12517
- appId: string
12518
-
12519
- /** Collection ID (required for most operations) */
12520
- collectionId?: string
12521
- /** Product ID (optional - for product-scoped config) */
12522
- productId?: string
12523
- /** Variant ID (optional - for variant-scoped config) */
12524
- variantId?: string
12525
- /** Batch ID (optional - for batch-scoped config) */
12526
- batchId?: string
12527
-
12528
- /** Item ID - required for getDataItem/deleteDataItem */
12529
- itemId?: string
12530
-
12531
- /**
12532
- * Use admin endpoints instead of public.
12533
- * This selects which endpoint is called; it does not by itself make root-level config fields private.
12534
- */
12535
- admin?: boolean
12536
-
12537
- /**
12538
- * Configuration object for setConfig.
12539
- * For admin-only values in app config, store them under a top-level `admin` object.
12540
- * Public reads return the root config but omit `config.admin`.
12541
- */
12542
- config?: any
12543
- /** Data object for setDataItem. Best for small keyed scoped documents rather than richer app domain objects. */
12544
- data?: any
12706
+ type AppConfigOptions = {
12707
+ /** The app ID */
12708
+ appId: string
12709
+
12710
+ /** Collection ID (required for most operations) */
12711
+ collectionId?: string
12712
+ /** Product ID (optional - for product-scoped config) */
12713
+ productId?: string
12714
+ /** Variant ID (optional - for variant-scoped config) */
12715
+ variantId?: string
12716
+ /** Batch ID (optional - for batch-scoped config) */
12717
+ batchId?: string
12718
+
12719
+ /** Item ID - required for getDataItem/deleteDataItem */
12720
+ itemId?: string
12721
+
12722
+ /**
12723
+ * Use admin endpoints instead of public.
12724
+ * This selects which endpoint is called; it does not by itself make root-level config fields private.
12725
+ */
12726
+ admin?: boolean
12727
+
12728
+ /**
12729
+ * Configuration object for setConfig.
12730
+ * For admin-only values in app config, store them under a top-level `admin` object.
12731
+ * Public reads return the root config but omit `config.admin`.
12732
+ */
12733
+ config?: any
12734
+ /** Data object for setDataItem. Best for small keyed scoped documents rather than richer app domain objects. */
12735
+ data?: any
12545
12736
  }
12546
12737
  ```
12547
12738
 
@@ -12979,70 +13170,70 @@ Fire-and-forget tag analytics event. Uses `navigator.sendBeacon()` when availabl
12979
13170
 
12980
13171
  Workflow-oriented app objects for issues, requests, claims, and tasks that move through statuses and often need assignment or history.
12981
13172
 
12982
- **create**(collectionId: string,
12983
- appId: string,
12984
- input: CreateCaseInput,
13173
+ **create**(collectionId: string,
13174
+ appId: string,
13175
+ input: CreateCaseInput,
12985
13176
  admin: boolean = false) → `Promise<AppCase>`
12986
13177
  Create a new case POST /cases
12987
13178
 
12988
- **list**(collectionId: string,
12989
- appId: string,
12990
- params?: CaseListQueryParams,
13179
+ **list**(collectionId: string,
13180
+ appId: string,
13181
+ params?: CaseListQueryParams,
12991
13182
  admin: boolean = false) → `Promise<ListResult<AppCase>>`
12992
13183
  List cases with optional query parameters GET /cases Returns `{ items, nextCursor, count }`: the cases are in `items`, `count` is how many match in all, and `nextCursor` is `null` on the last page. Page with `limit` and `cursor`. Sort with `orderBy`. A date field (`createdAt`, `updatedAt`, `closedAt`) takes a range: `{ gte, lte }`. `includeDeleted`, `contactId` and `assignedTo` are for admin calls (`admin = true`) only: the public list refuses a parameter it does not read. ```typescript let page = await app.cases.list(collectionId, appId, { status: 'open', limit: 50 }) console.log(page.items, page.count) while (page.nextCursor) { page = await app.cases.list(collectionId, appId, { status: 'open', limit: 50, cursor: page.nextCursor }) } // This month's cases, most urgent first await app.cases.list(collectionId, appId, { createdAt: { gte: '2026-11-01T00:00:00Z', lte: '2026-11-30T23:59:59Z' }, orderBy: [{ priority: 'desc' }, { createdAt: 'asc' }], }) ```
12993
13184
 
12994
- **get**(collectionId: string,
12995
- appId: string,
12996
- caseId: string,
13185
+ **get**(collectionId: string,
13186
+ appId: string,
13187
+ caseId: string,
12997
13188
  admin: boolean = false) → `Promise<AppCase>`
12998
13189
  Get a single case by ID GET /cases/:caseId
12999
13190
 
13000
- **update**(collectionId: string,
13001
- appId: string,
13002
- caseId: string,
13003
- input: UpdateCaseInput,
13191
+ **update**(collectionId: string,
13192
+ appId: string,
13193
+ caseId: string,
13194
+ input: UpdateCaseInput,
13004
13195
  admin: boolean = false) → `Promise<AppCase>`
13005
13196
  Update a case PATCH /cases/:caseId Admin can update any field, public (owner) can only update data and owner zones
13006
13197
 
13007
- **remove**(collectionId: string,
13008
- appId: string,
13009
- caseId: string,
13198
+ **remove**(collectionId: string,
13199
+ appId: string,
13200
+ caseId: string,
13010
13201
  admin: boolean = false) → `Promise<`
13011
13202
  Soft delete a case DELETE /cases/:caseId
13012
13203
 
13013
- **aggregate**(collectionId: string,
13014
- appId: string,
13015
- request: AggregateRequest,
13204
+ **aggregate**(collectionId: string,
13205
+ appId: string,
13206
+ request: AggregateRequest,
13016
13207
  admin: boolean = false) → `Promise<AggregateResponse>`
13017
13208
  Get aggregate statistics for cases POST /cases/aggregate
13018
13209
 
13019
- **summary**(collectionId: string,
13020
- appId: string,
13210
+ **summary**(collectionId: string,
13211
+ appId: string,
13021
13212
  request?: CaseSummaryRequest) → `Promise<CaseSummaryResponse>`
13022
13213
  Get case summary (admin only) POST /cases/summary
13023
13214
 
13024
- **appendHistory**(collectionId: string,
13025
- appId: string,
13026
- caseId: string,
13215
+ **appendHistory**(collectionId: string,
13216
+ appId: string,
13217
+ caseId: string,
13027
13218
  input: AppendHistoryInput) → `Promise<AppCase>`
13028
13219
  Append an entry to case history (admin only) POST /cases/:caseId/history
13029
13220
 
13030
- **related**(collectionId: string,
13031
- appId: string,
13221
+ **related**(collectionId: string,
13222
+ appId: string,
13032
13223
  caseId: string) → `Promise<RelatedResponse>`
13033
13224
  Get related threads and records for a case (admin only) GET /cases/:caseId/related
13034
13225
 
13035
13226
  ### app.options
13036
13227
 
13037
- **get**(collectionId: string,
13038
- appId: string,
13039
- source: string,
13228
+ **get**(collectionId: string,
13229
+ appId: string,
13230
+ source: string,
13040
13231
  opts: ListOptions & { q?: string; version?: string; admin?: boolean } = {},) → `Promise<import('../types/appOptions').AppOptionsList>`
13041
13232
  `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. Returns `{ items, nextCursor, count?, version, mode }`: the entries are in `items`, already sorted, 50 at a time unless you give a `limit` (at most 1000). Pass `nextCursor` back as `cursor` for the next page; `null` means that was the last one. `q` searches the entries. ```typescript const res = await app.options.get(collectionId, appId, 'type:machine', { admin: true, limit: 200 }) if (!res.unchanged) { options = res.items; version = res.version } // A type too large to send whole: search it const found = await app.options.get(collectionId, appId, 'type:machine', { q: 'mix', limit: 20 }) ```
13042
13233
 
13043
- **saveList**(collectionId: string,
13044
- appId: string,
13045
- listId: string,
13234
+ **saveList**(collectionId: string,
13235
+ appId: string,
13236
+ listId: string,
13046
13237
  values: import('../types/appOptions') → `void`
13047
13238
  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.
13048
13239
 
@@ -13050,92 +13241,92 @@ Save a value list's values, in order (admins). Codes never change and are never
13050
13241
 
13051
13242
  General-purpose structured app objects. Use these when a simple scoped data item grows into something queryable, lifecycle-aware, or access-controlled.
13052
13243
 
13053
- **create**(collectionId: string,
13054
- appId: string,
13055
- input: CreateRecordInput,
13244
+ **create**(collectionId: string,
13245
+ appId: string,
13246
+ input: CreateRecordInput,
13056
13247
  admin: boolean = false) → `Promise<CreateRecordResponse>`
13057
13248
  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.
13058
13249
 
13059
- **query**(collectionId: string,
13060
- appId: string,
13250
+ **query**(collectionId: string,
13251
+ appId: string,
13061
13252
  body: StandardQuery = {}) → `Promise<QueryResult>`
13062
13253
  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' } }, }) ```
13063
13254
 
13064
13255
  **queryFields**(collectionId: string, appId: string) → `Promise<QueryDescription>`
13065
13256
  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
13066
13257
 
13067
- **list**(collectionId: string,
13068
- appId: string,
13069
- params?: RecordListQueryParams,
13258
+ **list**(collectionId: string,
13259
+ appId: string,
13260
+ params?: RecordListQueryParams,
13070
13261
  admin: boolean = false) → `Promise<ListResult<AppRecord>>`
13071
13262
  List records with optional query parameters GET /records Returns `{ items, nextCursor, count }`: the records are in `items`, `count` is how many match in all, and `nextCursor` is `null` on the last page. Page with `limit` and `cursor`. Search with `q`, sort with `orderBy`. A date field (`createdAt`, `updatedAt`, `startsAt`, `expiresAt`) takes a range: `{ gte, lte }`. Public/owner callers only receive records with `status: "active"`. Admin callers can query all statuses (for example `draft`/`archived`). `qFields`, `dataFilter`, `contactId` and `includeDeleted` are for admin calls (`admin = true`) only: the public list refuses a parameter it does not read. ```typescript let page = await app.records.list(collectionId, appId, { recordType: 'tip', limit: 100 }) console.log(page.items, page.count) while (page.nextCursor) { page = await app.records.list(collectionId, appId, { recordType: 'tip', limit: 100, cursor: page.nextCursor }) } // Tips about watering, changed this month, newest change first await app.records.list(collectionId, appId, { recordType: 'tip', q: 'watering', updatedAt: { gte: '2026-11-01T00:00:00Z' }, orderBy: [{ updatedAt: 'desc' }], }) ```
13072
13263
 
13073
- **get**(collectionId: string,
13074
- appId: string,
13075
- recordId: string,
13264
+ **get**(collectionId: string,
13265
+ appId: string,
13266
+ recordId: string,
13076
13267
  admin: boolean = false) → `Promise<AppRecord>`
13077
13268
  Get a single record by ID GET /records/:recordId
13078
13269
 
13079
- **update**(collectionId: string,
13080
- appId: string,
13081
- recordId: string,
13082
- input: UpdateRecordInput,
13270
+ **update**(collectionId: string,
13271
+ appId: string,
13272
+ recordId: string,
13273
+ input: UpdateRecordInput,
13083
13274
  admin: boolean = false) → `Promise<AppRecord>`
13084
13275
  Update a record PATCH /records/:recordId Admin can update any field, public (owner) can only update data and owner
13085
13276
 
13086
- **updateWithToken**(collectionId: string,
13087
- appId: string,
13088
- recordId: string,
13089
- data: Record<string, unknown>,
13277
+ **updateWithToken**(collectionId: string,
13278
+ appId: string,
13279
+ recordId: string,
13280
+ data: Record<string, unknown>,
13090
13281
  editToken: string) → `Promise<AppRecord>`
13091
13282
  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 |
13092
13283
 
13093
- **remove**(collectionId: string,
13094
- appId: string,
13095
- recordId: string,
13284
+ **remove**(collectionId: string,
13285
+ appId: string,
13286
+ recordId: string,
13096
13287
  admin: boolean = false) → `Promise<`
13097
13288
  Soft delete a record DELETE /records/:recordId
13098
13289
 
13099
- **aggregate**(collectionId: string,
13100
- appId: string,
13101
- request: AggregateRequest,
13290
+ **aggregate**(collectionId: string,
13291
+ appId: string,
13292
+ request: AggregateRequest,
13102
13293
  admin: boolean = false) → `Promise<AggregateResponse>`
13103
13294
  Get aggregate statistics for records POST /records/aggregate
13104
13295
 
13105
- **restore**(collectionId: string,
13106
- appId: string,
13296
+ **restore**(collectionId: string,
13297
+ appId: string,
13107
13298
  recordId: string) → `Promise<AppRecord>`
13108
13299
  Restore a soft-deleted record. POST /records/:recordId/restore (admin only)
13109
13300
 
13110
- **upsert**(collectionId: string,
13111
- appId: string,
13301
+ **upsert**(collectionId: string,
13302
+ appId: string,
13112
13303
  input: UpsertRecordInput) → `Promise<UpsertRecordResponse>`
13113
13304
  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)
13114
13305
 
13115
- **match**(collectionId: string,
13116
- appId: string,
13117
- input: MatchRecordsInput,
13306
+ **match**(collectionId: string,
13307
+ appId: string,
13308
+ input: MatchRecordsInput,
13118
13309
  admin: boolean = false) → `Promise<MatchResult>`
13119
13310
  Match records against a runtime target scope. Returns `{ items, nextCursor, count, strategy }`: `items` are the records whose scope is satisfied by the target, most specific first, and `count` is how many matched. Without a `limit` it answers up to 100. Give a `limit` (in `input`) to page: when there are more, pass `nextCursor` back as `cursor`. POST /records/match ```ts const { items } = await app.records.match(collectionId, appId, { target: { productId: 'prod_abc', facets: { tier: ['gold'] } }, strategy: 'best', recordType: 'nutrition', }, true); const best = items[0] // the single highest-specificity nutrition record // 50 at a time const target = { productId: 'prod_abc' } let page = await app.records.match(collectionId, appId, { target, limit: 50 }) while (page.nextCursor) { page = await app.records.match(collectionId, appId, { target, limit: 50, cursor: page.nextCursor }) } ```
13120
13311
 
13121
- **bulkUpsert**(collectionId: string,
13122
- appId: string,
13312
+ **bulkUpsert**(collectionId: string,
13313
+ appId: string,
13123
13314
  records: BulkUpsertItem[]) → `Promise<BulkUpsertResult>`
13124
13315
  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)
13125
13316
 
13126
- **bulkDelete**(collectionId: string,
13127
- appId: string,
13317
+ **bulkDelete**(collectionId: string,
13318
+ appId: string,
13128
13319
  input: BulkDeleteInput) → `Promise<BulkDeleteResult>`
13129
13320
  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' }, }); ```
13130
13321
 
13131
- **resolveAll**(collectionId: string,
13132
- appId: string,
13133
- input: ResolveAllParams,
13322
+ **resolveAll**(collectionId: string,
13323
+ appId: string,
13324
+ input: ResolveAllParams,
13134
13325
  admin: boolean = false) → `Promise<ResolveAllResult>`
13135
13326
  Resolve every applicable record for a product context in one call. Returns `{ items, nextCursor, count, context, truncated }`: `items` are the records across all tiers (proof, batch, variant, product, rule, facet, collection), deduplicated and sorted by specificity descending, each as `{ record, matchedAt, specificity }`. Without a `limit` it answers up to 500. Give a `limit` (in `input`) to page: when there are more, pass `nextCursor` back as `cursor`. POST /records/resolve-all ```ts const { items } = await app.records.resolveAll(collectionId, appId, { context: { productId: 'prod_abc' }, recordType: 'nutrition', }) for (const { record, matchedAt } of items) console.log(matchedAt, record.data) // 100 at a time const context = { productId: 'prod_abc' } let page = await app.records.resolveAll(collectionId, appId, { context, limit: 100 }) while (page.nextCursor) { page = await app.records.resolveAll(collectionId, appId, { context, limit: 100, cursor: page.nextCursor }) } ```
13136
13327
 
13137
- **previewRule**(collectionId: string,
13138
- appId: string,
13328
+ **previewRule**(collectionId: string,
13329
+ appId: string,
13139
13330
  input: PreviewRuleParams) → `Promise<PreviewRuleResult>`
13140
13331
  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
13141
13332
 
@@ -13143,54 +13334,54 @@ Preview which products in the collection match a given facetRule. Admin only. Us
13143
13334
 
13144
13335
  Conversation-oriented app objects for comments, discussions, Q&A, and reply-driven experiences.
13145
13336
 
13146
- **create**(collectionId: string,
13147
- appId: string,
13148
- input: CreateThreadInput,
13337
+ **create**(collectionId: string,
13338
+ appId: string,
13339
+ input: CreateThreadInput,
13149
13340
  admin: boolean = false) → `Promise<AppThread>`
13150
13341
  Create a new thread POST /threads
13151
13342
 
13152
- **list**(collectionId: string,
13153
- appId: string,
13154
- params?: ThreadListQueryParams,
13343
+ **list**(collectionId: string,
13344
+ appId: string,
13345
+ params?: ThreadListQueryParams,
13155
13346
  admin: boolean = false) → `Promise<ListResult<AppThread>>`
13156
13347
  List threads with optional query parameters GET /threads Returns `{ items, nextCursor, count }`: the threads are in `items`, `count` is how many match in all, and `nextCursor` is `null` on the last page. Page with `limit` and `cursor`. Sort with `orderBy`. A date field (`createdAt`, `updatedAt`) takes a range: `{ gte, lte }`. `includeDeleted` and `contactId` are for admin calls (`admin = true`) only: the public list refuses a parameter it does not read. ```typescript let page = await app.threads.list(collectionId, appId, { parentType: 'case', parentId: caseId, limit: 50 }) console.log(page.items, page.count) while (page.nextCursor) { page = await app.threads.list(collectionId, appId, { parentType: 'case', parentId: caseId, limit: 50, cursor: page.nextCursor }) } // The threads with the newest replies, started this month await app.threads.list(collectionId, appId, { createdAt: { gte: '2026-11-01T00:00:00Z' }, orderBy: [{ lastReplyAt: 'desc' }], }) ```
13157
13348
 
13158
- **get**(collectionId: string,
13159
- appId: string,
13160
- threadId: string,
13349
+ **get**(collectionId: string,
13350
+ appId: string,
13351
+ threadId: string,
13161
13352
  admin: boolean = false) → `Promise<AppThread>`
13162
13353
  Get a single thread by ID GET /threads/:threadId
13163
13354
 
13164
- **update**(collectionId: string,
13165
- appId: string,
13166
- threadId: string,
13167
- input: UpdateThreadInput,
13355
+ **update**(collectionId: string,
13356
+ appId: string,
13357
+ threadId: string,
13358
+ input: UpdateThreadInput,
13168
13359
  admin: boolean = false) → `Promise<AppThread>`
13169
13360
  Update a thread PATCH /threads/:threadId Admin can update any field, public (owner) can only update body, tags, data, owner
13170
13361
 
13171
- **remove**(collectionId: string,
13172
- appId: string,
13173
- threadId: string,
13362
+ **remove**(collectionId: string,
13363
+ appId: string,
13364
+ threadId: string,
13174
13365
  admin: boolean = false) → `Promise<`
13175
13366
  Soft delete a thread DELETE /threads/:threadId
13176
13367
 
13177
- **reply**(collectionId: string,
13178
- appId: string,
13179
- threadId: string,
13180
- input: ReplyInput,
13368
+ **reply**(collectionId: string,
13369
+ appId: string,
13370
+ threadId: string,
13371
+ input: ReplyInput,
13181
13372
  admin: boolean = false) → `Promise<AppThread>`
13182
13373
  Add a reply to a thread POST /threads/:threadId/reply Atomically appends to replies array, increments replyCount, updates lastReplyAt
13183
13374
 
13184
- **deleteReply**(collectionId: string,
13185
- appId: string,
13186
- threadId: string,
13187
- replyId: string,
13375
+ **deleteReply**(collectionId: string,
13376
+ appId: string,
13377
+ threadId: string,
13378
+ replyId: string,
13188
13379
  admin: boolean = false) → `Promise<AppThread>`
13189
13380
  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.
13190
13381
 
13191
- **aggregate**(collectionId: string,
13192
- appId: string,
13193
- request: AggregateRequest,
13382
+ **aggregate**(collectionId: string,
13383
+ appId: string,
13384
+ request: AggregateRequest,
13194
13385
  admin: boolean = false) → `Promise<AggregateResponse>`
13195
13386
  Get aggregate statistics for threads POST /threads/aggregate
13196
13387
 
@@ -13225,19 +13416,19 @@ Set/create a keyed data item within a scope. Requires admin authentication. Use
13225
13416
  **deleteDataItem**(opts: AppConfigOptions) → `Promise<void>`
13226
13417
  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' }); ```
13227
13418
 
13228
- **getWidgets**(collectionId: string,
13419
+ **getWidgets**(collectionId: string,
13229
13420
  options?: GetCollectionWidgetsOptions) → `Promise<CollectionWidgetsResponse>`
13230
13421
  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. and bundle files. It always comes back whole: there is no `limit` or `cursor`, and `nextCursor` is always `null`. ```typescript // Fetch all widget data for a collection const { items: apps } = await Api.AppConfiguration.getWidgets(collectionId); // apps: [{ 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 { items: fresh } = await Api.AppConfiguration.getWidgets(collectionId, { force: true }); ```
13231
13422
 
13232
13423
  **resolveFeature**(system: SystemBlock | undefined, flag: string) → `boolean`
13233
13424
  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'); ```
13234
13425
 
13235
- **getAppConfig**(collectionId: string,
13426
+ **getAppConfig**(collectionId: string,
13236
13427
  options?: { force?: boolean }) → `Promise<AppsConfigResponse>`
13237
13428
  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); ```
13238
13429
 
13239
- **isFeatureEnabled**(collectionId: string,
13240
- flag: string,
13430
+ **isFeatureEnabled**(collectionId: string,
13431
+ flag: string,
13241
13432
  options?: { force?: boolean }) → `Promise<boolean>`
13242
13433
  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(); } ```
13243
13434
 
@@ -13762,11 +13953,23 @@ Get one booking. Public: the signed-in booker, or a guest passing `{ editToken }
13762
13953
  **update**(collectionId: string, appId: string, bookingId: string, input: UpdateBookingInput, admin: boolean = true) → `Promise<Booking>`
13763
13954
  Update zones and descriptive fields (admin). PATCH /bookings/:bookingId
13764
13955
 
13765
- **confirm**(collectionId: string, appId: string, bookingId: string, admin: boolean = false, opts?: BookingAccessOptions) → `Promise<Booking>`
13766
- held / pending / waitlisted → confirmed (idempotent). A held booking whose hold has run out fails with HOLD_EXPIRED. Public: only the booker's own hold, when `ownerActions.bookings.confirm` allows. POST /bookings/:bookingId/confirm
13956
+ **confirm**(collectionId: string, appId: string, bookingId: string, admin: boolean = false, opts?: BookingAccessOptions & { payment?: 'waive' }) → `Promise<Booking>`
13957
+ held / pending / waitlisted → confirmed (idempotent). A held booking whose hold has run out fails with HOLD_EXPIRED. Public: only the booker's own hold, when `ownerActions.bookings.confirm` allows. Paid bookings: a booking waiting for its payment is confirmed by the payment (PAYMENT_REQUIRED otherwise). Admin confirming a REQUEST that has a price turns it into a hold with a pay link for the booker (`payment.link`, emailed through `booking.payment_requested`); `{ payment: 'waive' }` confirms without payment (paid in cash, a free place). POST /bookings/:bookingId/confirm
13958
+
13959
+ **cancel**(collectionId: string, appId: string, bookingId: string, admin: boolean = false, opts?: BookingAccessOptions & { reason?: string; refund?: 'full' | 'none' | number }) → `Promise<Booking>`
13960
+ Cancel and give the places back (idempotent). Public: per `ownerActions.bookings.cancel` and its cutoff. `reason` is admin-only (public cancels record 'owner'). Paid bookings are refunded: the booker's cancel follows the app's `bookingPayments.ownerCancelRefund` (full by default); staff choose with `refund`: 'full' (default) | 'none' | an amount in minor units. POST /bookings/:bookingId/cancel
13961
+
13962
+ **checkout**(collectionId: string, appId: string, input: BookingCheckoutInput) → `Promise<BookingCheckoutResult>`
13963
+ Book and pay. The same rules as `create` (public), then the app's `bookingPayments` decide: - pay now (the rules book as held / confirmed): the booking is held while the person pays on Stripe's page → go to `checkoutUrl`; Stripe's webhook confirms it. - a request (the rules book as pending): priced, nothing paid, `checkoutUrl: null`; staff approving it sends the booker a pay link. - free (no prices): booked the normal way, `checkoutUrl: null`. Name prices by id (`lines` for ticket types on a slot, `priceId` for an appointment's service); the server sets every amount. POST /bookings/checkout
13964
+
13965
+ **bySession**(collectionId: string, appId: string, sessionId: string) → `Promise<Booking &`
13966
+ The thank-you page: the booking a Checkout Session paid for (`session_id` in the success address). `confirming: true` while Stripe's webhook is still on its way: show "confirming your payment…" and read again in a moment. GET /bookings/by-session/:sessionId
13767
13967
 
13768
- **cancel**(collectionId: string, appId: string, bookingId: string, admin: boolean = false, opts?: BookingAccessOptions & { reason?: string }) → `Promise<Booking>`
13769
- Cancel and give the places back (idempotent). Public: per `ownerActions.bookings.cancel` and its cutoff. `reason` is admin-only (public cancels record 'owner'). POST /bookings/:bookingId/cancel
13968
+ **pay**(collectionId: string, appId: string, bookingId: string, token: string) → `Promise<BookingPayLinkResult>`
13969
+ An approved request's pay link, for an app with its own pay page (the link in the email goes straight to Stripe). `token` is the `t` of `payment.link`. → `{ checkoutUrl }`, or `{ done: 'paid' | 'closed', url }`. POST /bookings/:bookingId/pay
13970
+
13971
+ **refund**(collectionId: string, appId: string, bookingId: string, opts?: { amount?: number; reason?: string }) → `Promise<BookingRefundResult>`
13972
+ Refund a paid booking without cancelling it (admin): all that's left, or `amount` (minor units). A refund Stripe can't take now is retried by the platform (`refundPending: true`). POST /bookings/:bookingId/refund
13770
13973
 
13771
13974
  **move**(collectionId: string, appId: string, bookingId: string, input: MoveBookingInput, admin: boolean = false, opts?: BookingAccessOptions) → `Promise<Booking>`
13772
13975
  Move to a new slot / time, all-or-nothing (a failed move leaves the booking as it was). Public: per `ownerActions.bookings.move`; the create rules are re-checked for the new time. POST /bookings/:bookingId/move
@@ -13873,13 +14076,13 @@ The contacts a broadcast goes to (its segment), a page at a time. `count` is how
13873
14076
 
13874
14077
  ### chat.completions
13875
14078
 
13876
- **create**(collectionId: string,
14079
+ **create**(collectionId: string,
13877
14080
  request: ChatCompletionRequest) → `Promise<ChatCompletionResponse | AsyncIterable<ChatCompletionChunk>>`
13878
14081
  Create a chat completion (streaming or non-streaming)
13879
14082
 
13880
14083
  ### chat.responses
13881
14084
 
13882
- **create**(collectionId: string,
14085
+ **create**(collectionId: string,
13883
14086
  request: ResponsesRequest) → `Promise<ResponsesResult | AsyncIterable<ResponsesStreamEvent>>`
13884
14087
  Create a Responses API request (streaming or non-streaming)
13885
14088
 
@@ -14055,86 +14258,86 @@ Invite a user to a collection by email (admin only). Creates or links their acco
14055
14258
  **getPushVapidPublicKey**(collectionId: string) → `Promise<import("../types/comms").PushVapidResponse>`
14056
14259
  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.
14057
14260
 
14058
- **registerPush**(collectionId: string,
14261
+ **registerPush**(collectionId: string,
14059
14262
  body: import("../types/comms") → `void`
14060
14263
  Public: Register a Web Push subscription under unified comms. POST /public/collection/:collectionId/comm/push/register
14061
14264
 
14062
- **getSettings**(collectionId: string,
14265
+ **getSettings**(collectionId: string,
14063
14266
  opts: { includeSecret?: boolean } = {}) → `Promise<import("../types/comms").CommsSettingsGetResponse>`
14064
14267
  Admin: Get current comms settings for a collection. GET /admin/collection/:collectionId/comm.settings Optional query: includeSecret=true to include unsub.secret in response.
14065
14268
 
14066
- **patchSettings**(collectionId: string,
14269
+ **patchSettings**(collectionId: string,
14067
14270
  body: import("../types/comms") → `void`
14068
14271
  Admin: Patch comms settings for a collection. PATCH /admin/collection/:collectionId/comm.settings
14069
14272
 
14070
14273
  **getPublicTopics**(collectionId: string) → `Promise<import("../types/comms").CommsPublicTopicsResponse>`
14071
14274
  Public: Fetch configured topics for a collection. GET /public/collection/:collectionId/comm/topics
14072
14275
 
14073
- **unsubscribe**(collectionId: string,
14276
+ **unsubscribe**(collectionId: string,
14074
14277
  query: import("../types/comms") → `void`
14075
14278
  Public: Unsubscribe a contact from a category or channel. GET /public/collection/:collectionId/comm/unsubscribe
14076
14279
 
14077
- **signup**(collectionId: string,
14280
+ **signup**(collectionId: string,
14078
14281
  body: import("../types/comms") → `void`
14079
14282
  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
14080
14283
 
14081
- **upsertConsent**(collectionId: string,
14284
+ **upsertConsent**(collectionId: string,
14082
14285
  body: import("../types/comms") → `void`
14083
14286
  Public: Upsert default consent for a contact. POST /public/collection/:collectionId/comm/consent
14084
14287
 
14085
- **upsertPreferences**(collectionId: string,
14288
+ **upsertPreferences**(collectionId: string,
14086
14289
  body: import("../types/comms") → `void`
14087
14290
  Public: Upsert preferences for a specific subject (or default if subject omitted). POST /public/collection/:collectionId/comm/preferences
14088
14291
 
14089
- **subscribe**(collectionId: string,
14292
+ **subscribe**(collectionId: string,
14090
14293
  body: import("../types/comms") → `void`
14091
14294
  Public: Subscribe/unsubscribe contact to a subject. POST /public/collection/:collectionId/comm/subscribe
14092
14295
 
14093
- **checkSubscription**(collectionId: string,
14296
+ **checkSubscription**(collectionId: string,
14094
14297
  query: import("../types/comms") → `void`
14095
14298
  Public: Check subscription status for a subject. GET /public/collection/:collectionId/comm/subscription/check
14096
14299
 
14097
- **listMethods**(collectionId: string,
14300
+ **listMethods**(collectionId: string,
14098
14301
  query: import("../types/comms") → `void`
14099
14302
  Public: List registered contact methods. All of them come back in one answer: `nextCursor` is always null. GET /public/collection/:collectionId/comm/methods ```typescript const { items: methods } = await comms.listMethods(collectionId, { type: 'email' }) ```
14100
14303
 
14101
- **registerEmail**(collectionId: string,
14304
+ **registerEmail**(collectionId: string,
14102
14305
  body: import("../types/comms") → `void`
14103
14306
  Public: Register email method for a contact. POST /public/collection/:collectionId/comm/email/register
14104
14307
 
14105
- **registerSms**(collectionId: string,
14308
+ **registerSms**(collectionId: string,
14106
14309
  body: import("../types/comms") → `void`
14107
14310
  Public: Register SMS method for a contact. POST /public/collection/:collectionId/comm/sms/register
14108
14311
 
14109
- **resolveSubscriptions**(collectionId: string,
14312
+ **resolveSubscriptions**(collectionId: string,
14110
14313
  body: import("../types/comms") → `void`
14111
14314
  Public: Resolve contacts for a subject with identity hints. POST /public/collection/:collectionId/comm/subscriptions/resolve
14112
14315
 
14113
- **queryByUser**(collectionId: string,
14316
+ **queryByUser**(collectionId: string,
14114
14317
  body: CommsQueryByUser = {}) → `Promise<ListResult<CommunicationEvent>>`
14115
14318
  Analytics: Query communication events by user or contact, a page at a time (`limit` and `cursor` in the body). The time window is `from` / `to`. POST /admin/collection/:collectionId/comm/query/by-user ```typescript const query = { contactId, from: '2026-01-01T00:00:00Z', limit: 200 } let page = await comms.queryByUser(collectionId, query) page.items // CommunicationEvent[] while (page.nextCursor) page = await comms.queryByUser(collectionId, { ...query, cursor: page.nextCursor }) ```
14116
14319
 
14117
- **queryRecipientIds**(collectionId: string,
14320
+ **queryRecipientIds**(collectionId: string,
14118
14321
  body: CommsRecipientIdsQuery) → `Promise<ListResult<RecipientId>>`
14119
14322
  Analytics: Recipient IDs for a communication source, a page at a time (`limit` and `cursor` in the body). The time window is `from` / `to`. POST /admin/collection/:collectionId/comm/query/recipient-ids ```typescript const query = { broadcastId, idField: 'contactId' as const, limit: 500 } let page = await comms.queryRecipientIds(collectionId, query) page.items // the ids while (page.nextCursor) page = await comms.queryRecipientIds(collectionId, { ...query, cursor: page.nextCursor }) ```
14120
14323
 
14121
- **queryRecipientsWithoutInteraction**(collectionId: string,
14324
+ **queryRecipientsWithoutInteraction**(collectionId: string,
14122
14325
  body: CommsRecipientsWithoutInteractionQuery) → `Promise<ListResult<RecipientId>>`
14123
14326
  Analytics: the recipients of a broadcast or journey who did NOT then do an interaction. The ids come back in one answer (`nextCursor` is always null); `limit` is the most it returns. POST /admin/collection/:collectionId/comm/query/recipients/without-interaction ```typescript const { items: ids } = await comms.queryRecipientsWithoutInteraction(collectionId, { broadcastId, interactionId: 'survey-done' }) ```
14124
14327
 
14125
- **queryRecipientsWithInteraction**(collectionId: string,
14328
+ **queryRecipientsWithInteraction**(collectionId: string,
14126
14329
  body: CommsRecipientsWithInteractionQuery) → `Promise<ListResult<RecipientId | RecipientWithOutcome>>`
14127
14330
  Analytics: the recipients of a broadcast or journey who then did an interaction. With `includeOutcome: true` each item is `{ id, outcome }` instead of an id. One answer, no pages. POST /admin/collection/:collectionId/comm/query/recipients/with-interaction ```typescript const { items } = await comms.queryRecipientsWithInteraction(collectionId, { broadcastId, interactionId: 'survey-done', includeOutcome: true }) ```
14128
14331
 
14129
- **sendTransactional**(collectionId: string,
14332
+ **sendTransactional**(collectionId: string,
14130
14333
  body: TransactionalSendRequest) → `Promise<TransactionalSendResult>`
14131
14334
  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) } ```
14132
14335
 
14133
- **logCommunicationEvent**(collectionId: string,
14336
+ **logCommunicationEvent**(collectionId: string,
14134
14337
  body: LogCommunicationEventBody) → `Promise<AppendResult>`
14135
14338
  Logging: Append a single communication event. POST /admin/collection/:collectionId/comm/log
14136
14339
 
14137
- **logBulkCommunicationEvents**(collectionId: string,
14340
+ **logBulkCommunicationEvents**(collectionId: string,
14138
14341
  body: LogBulkCommunicationEventsBody | ({ sourceId: string; ids: string[]; idField?: 'userId'|'contactId'; [k: string]: any }) → `void`
14139
14342
  Logging: Append many communication events for a list of IDs. POST /admin/collection/:collectionId/comm/log/bulk
14140
14343
 
@@ -14165,7 +14368,7 @@ Returns all proof type definitions. Proof types are templates that specify which
14165
14368
 
14166
14369
  ### contact
14167
14370
 
14168
- **query**(collectionId: string,
14371
+ **query**(collectionId: string,
14169
14372
  body: StandardQuery = {}) → `Promise<QueryResult>`
14170
14373
  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 } } }) ```
14171
14374
 
@@ -14175,47 +14378,47 @@ What a contacts query can use: its fields and what each can filter, sort, group
14175
14378
  **create**(collectionId: string, data: ContactCreateRequest) → `Promise<ContactResponse>`
14176
14379
  What a contacts query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/contacts/query
14177
14380
 
14178
- **list**(collectionId: string,
14381
+ **list**(collectionId: string,
14179
14382
  params?: ListOptions & { includeDeleted?: boolean }) → `Promise<ListResult<ContactResponse>>`
14180
14383
  The collection's contacts, a page at a time (admin only). Pass `includeDeleted: true` to include deleted contacts. For filters, sorting and totals use `contact.query` or `contact.search`. GET /admin/collection/:collectionId/contacts ```typescript let page = await contact.list('coll_123', { limit: 50 }) page.items // Contact[] while (page.nextCursor) page = await contact.list('coll_123', { limit: 50, cursor: page.nextCursor }) ```
14181
14384
 
14182
- **search**({
14183
- collectionId,
14184
- tags,
14185
- tagsAll,
14186
- ...rest
14385
+ **search**({
14386
+ collectionId,
14387
+ tags,
14388
+ tagsAll,
14389
+ ...rest
14187
14390
  }: ContactSearchParams) → `Promise<ListResult<ContactResponse>>`
14188
14391
  Search the collection's contacts (admin only), a page at a time: free text (`q`, with `typeahead` for search-as-you-type), or filters on email, phone, id, tags, source and custom fields. Filter by when the contact was created with a range: `createdAt: { gte, lte }`. GET /admin/collection/:collectionId/contacts/search ```typescript let page = await contact.search({ collectionId, q: 'joh', typeahead: true, limit: 20 }) page.items // Contact[] if (page.nextCursor) page = await contact.search({ collectionId, q: 'joh', typeahead: true, limit: 20, cursor: page.nextCursor }) // Contacts created in November await contact.search({ collectionId, createdAt: { gte: '2026-11-01T00:00:00Z', lte: '2026-11-30T23:59:59Z' } }) ```
14189
14392
 
14190
- **get**(collectionId: string,
14191
- contactId: string,
14393
+ **get**(collectionId: string,
14394
+ contactId: string,
14192
14395
  params?: { includeDeleted?: boolean }) → `Promise<ContactResponse>`
14193
14396
  Search the collection's contacts (admin only), a page at a time: free text (`q`, with `typeahead` for search-as-you-type), or filters on email, phone, id, tags, source and custom fields. Filter by when the contact was created with a range: `createdAt: { gte, lte }`. GET /admin/collection/:collectionId/contacts/search ```typescript let page = await contact.search({ collectionId, q: 'joh', typeahead: true, limit: 20 }) page.items // Contact[] if (page.nextCursor) page = await contact.search({ collectionId, q: 'joh', typeahead: true, limit: 20, cursor: page.nextCursor }) // Contacts created in November await contact.search({ collectionId, createdAt: { gte: '2026-11-01T00:00:00Z', lte: '2026-11-30T23:59:59Z' } }) ```
14194
14397
 
14195
- **update**(collectionId: string,
14196
- contactId: string,
14398
+ **update**(collectionId: string,
14399
+ contactId: string,
14197
14400
  data: ContactUpdateRequest) → `Promise<ContactResponse>`
14198
14401
  Search the collection's contacts (admin only), a page at a time: free text (`q`, with `typeahead` for search-as-you-type), or filters on email, phone, id, tags, source and custom fields. Filter by when the contact was created with a range: `createdAt: { gte, lte }`. GET /admin/collection/:collectionId/contacts/search ```typescript let page = await contact.search({ collectionId, q: 'joh', typeahead: true, limit: 20 }) page.items // Contact[] if (page.nextCursor) page = await contact.search({ collectionId, q: 'joh', typeahead: true, limit: 20, cursor: page.nextCursor }) // Contacts created in November await contact.search({ collectionId, createdAt: { gte: '2026-11-01T00:00:00Z', lte: '2026-11-30T23:59:59Z' } }) ```
14199
14402
 
14200
14403
  **remove**(collectionId: string, contactId: string) → `Promise<void>`
14201
14404
  Search the collection's contacts (admin only), a page at a time: free text (`q`, with `typeahead` for search-as-you-type), or filters on email, phone, id, tags, source and custom fields. Filter by when the contact was created with a range: `createdAt: { gte, lte }`. GET /admin/collection/:collectionId/contacts/search ```typescript let page = await contact.search({ collectionId, q: 'joh', typeahead: true, limit: 20 }) page.items // Contact[] if (page.nextCursor) page = await contact.search({ collectionId, q: 'joh', typeahead: true, limit: 20, cursor: page.nextCursor }) // Contacts created in November await contact.search({ collectionId, createdAt: { gte: '2026-11-01T00:00:00Z', lte: '2026-11-30T23:59:59Z' } }) ```
14202
14405
 
14203
- **lookup**(collectionId: string,
14406
+ **lookup**(collectionId: string,
14204
14407
  params: { email?: string; phone?: string }) → `Promise<ContactResponse>`
14205
14408
  Search the collection's contacts (admin only), a page at a time: free text (`q`, with `typeahead` for search-as-you-type), or filters on email, phone, id, tags, source and custom fields. Filter by when the contact was created with a range: `createdAt: { gte, lte }`. GET /admin/collection/:collectionId/contacts/search ```typescript let page = await contact.search({ collectionId, q: 'joh', typeahead: true, limit: 20 }) page.items // Contact[] if (page.nextCursor) page = await contact.search({ collectionId, q: 'joh', typeahead: true, limit: 20, cursor: page.nextCursor }) // Contacts created in November await contact.search({ collectionId, createdAt: { gte: '2026-11-01T00:00:00Z', lte: '2026-11-30T23:59:59Z' } }) ```
14206
14409
 
14207
- **upsert**(collectionId: string,
14410
+ **upsert**(collectionId: string,
14208
14411
  data: ContactCreateRequest) → `Promise<ContactResponse>`
14209
14412
  Search the collection's contacts (admin only), a page at a time: free text (`q`, with `typeahead` for search-as-you-type), or filters on email, phone, id, tags, source and custom fields. Filter by when the contact was created with a range: `createdAt: { gte, lte }`. GET /admin/collection/:collectionId/contacts/search ```typescript let page = await contact.search({ collectionId, q: 'joh', typeahead: true, limit: 20 }) page.items // Contact[] if (page.nextCursor) page = await contact.search({ collectionId, q: 'joh', typeahead: true, limit: 20, cursor: page.nextCursor }) // Contacts created in November await contact.search({ collectionId, createdAt: { gte: '2026-11-01T00:00:00Z', lte: '2026-11-30T23:59:59Z' } }) ```
14210
14413
 
14211
- **publicUpsert**(collectionId: string,
14414
+ **publicUpsert**(collectionId: string,
14212
14415
  data: PublicContactUpsertRequest) → `Promise<PublicContactUpsertResponse>`
14213
14416
  Search the collection's contacts (admin only), a page at a time: free text (`q`, with `typeahead` for search-as-you-type), or filters on email, phone, id, tags, source and custom fields. Filter by when the contact was created with a range: `createdAt: { gte, lte }`. GET /admin/collection/:collectionId/contacts/search ```typescript let page = await contact.search({ collectionId, q: 'joh', typeahead: true, limit: 20 }) page.items // Contact[] if (page.nextCursor) page = await contact.search({ collectionId, q: 'joh', typeahead: true, limit: 20, cursor: page.nextCursor }) // Contacts created in November await contact.search({ collectionId, createdAt: { gte: '2026-11-01T00:00:00Z', lte: '2026-11-30T23:59:59Z' } }) ```
14214
14417
 
14215
14418
  **publicGetMine**(collectionId: string) → `Promise<PublicGetMyContactResponse>`
14216
14419
  Search the collection's contacts (admin only), a page at a time: free text (`q`, with `typeahead` for search-as-you-type), or filters on email, phone, id, tags, source and custom fields. Filter by when the contact was created with a range: `createdAt: { gte, lte }`. GET /admin/collection/:collectionId/contacts/search ```typescript let page = await contact.search({ collectionId, q: 'joh', typeahead: true, limit: 20 }) page.items // Contact[] if (page.nextCursor) page = await contact.search({ collectionId, q: 'joh', typeahead: true, limit: 20, cursor: page.nextCursor }) // Contacts created in November await contact.search({ collectionId, createdAt: { gte: '2026-11-01T00:00:00Z', lte: '2026-11-30T23:59:59Z' } }) ```
14217
14420
 
14218
- **publicUpdateMine**(collectionId: string,
14421
+ **publicUpdateMine**(collectionId: string,
14219
14422
  data: ContactPatch) → `Promise<PublicUpdateMyContactResponse>`
14220
14423
  Search the collection's contacts (admin only), a page at a time: free text (`q`, with `typeahead` for search-as-you-type), or filters on email, phone, id, tags, source and custom fields. Filter by when the contact was created with a range: `createdAt: { gte, lte }`. GET /admin/collection/:collectionId/contacts/search ```typescript let page = await contact.search({ collectionId, q: 'joh', typeahead: true, limit: 20 }) page.items // Contact[] if (page.nextCursor) page = await contact.search({ collectionId, q: 'joh', typeahead: true, limit: 20, cursor: page.nextCursor }) // Contacts created in November await contact.search({ collectionId, createdAt: { gte: '2026-11-01T00:00:00Z', lte: '2026-11-30T23:59:59Z' } }) ```
14221
14424
 
@@ -14225,77 +14428,77 @@ Public: Get the contact schema for a collection. GET /public/collection/:collect
14225
14428
  **erase**(collectionId: string, contactId: string, body?: any) → `Promise<ContactResponse>`
14226
14429
  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 }) } ```
14227
14430
 
14228
- **findDuplicates**(collectionId: string,
14431
+ **findDuplicates**(collectionId: string,
14229
14432
  params?: ListOptions) → `Promise<ContactDuplicatesResponse>`
14230
14433
  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 and returns the pairs found in it (`items`); `scanned` is how many contacts it checked. While `nextCursor` is not null, call again with it as `cursor` to check the next window. ```typescript const { items: pairs } = await contact.findDuplicates(collectionId) for (const pair of pairs) { await contact.merge(collectionId, pair.keep.contactId, pair.merge.contactId) } ```
14231
14434
 
14232
- **merge**(collectionId: string,
14233
- keepContactId: string,
14435
+ **merge**(collectionId: string,
14436
+ keepContactId: string,
14234
14437
  fromContactId: string) → `Promise<ContactMergeResponse>`
14235
14438
  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`).
14236
14439
 
14237
- **linkLogin**(collectionId: string,
14440
+ **linkLogin**(collectionId: string,
14238
14441
  userId: string) → `Promise<ContactLinkLoginResponse>`
14239
14442
  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 } ```
14240
14443
 
14241
- **getUser**(collectionId: string,
14444
+ **getUser**(collectionId: string,
14242
14445
  userId: string,) → `Promise<UserSearchResponse>`
14243
14446
  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 } ```
14244
14447
 
14245
14448
  ### containers
14246
14449
 
14247
- **create**(collectionId: string,
14450
+ **create**(collectionId: string,
14248
14451
  data: CreateContainerInput) → `Promise<Container>`
14249
14452
  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 }, }) ```
14250
14453
 
14251
- **list**(collectionId: string,
14454
+ **list**(collectionId: string,
14252
14455
  params?: ListContainersParams) → `Promise<ListResult<Container>>`
14253
14456
  List containers (admin), a page at a time. Supports filtering by type, status, ref, parent, and top-level flag. ```typescript // All active pallets let page = await containers.list('coll_123', { containerType: 'pallet', status: 'active', limit: 50, }) const pallets = page.items while (page.nextCursor) { page = await containers.list('coll_123', { containerType: 'pallet', status: 'active', limit: 50, cursor: page.nextCursor }) pallets.push(...page.items) } // Top-level containers only const { items: roots } = await containers.list('coll_123', { topLevel: true }) ```
14254
14457
 
14255
- **findForItem**(collectionId: string,
14458
+ **findForItem**(collectionId: string,
14256
14459
  params: FindContainersForItemParams) → `Promise<FindContainersForItemResponse>`
14257
14460
  Reverse lookup — find all containers currently holding a specific item (admin). containers, a page at a time. Pass `nextCursor` back as `cursor` for the next page. ```typescript const { containers: holding, nextCursor } = await containers.findForItem('coll_123', { itemType: 'proof', itemId: 'unit-0007', productId: 'drill', limit: 50, }) ```
14258
14461
 
14259
- **get**(collectionId: string,
14260
- containerId: string,
14462
+ **get**(collectionId: string,
14463
+ containerId: string,
14261
14464
  params?: GetContainerParams) → `Promise<Container>`
14262
14465
  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, }) ```
14263
14466
 
14264
- **update**(collectionId: string,
14265
- containerId: string,
14467
+ **update**(collectionId: string,
14468
+ containerId: string,
14266
14469
  data: UpdateContainerInput) → `Promise<Container>`
14267
14470
  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' }, }) ```
14268
14471
 
14269
- **remove**(collectionId: string,
14472
+ **remove**(collectionId: string,
14270
14473
  containerId: string) → `Promise<`
14271
14474
  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.
14272
14475
 
14273
- **listItems**(collectionId: string,
14274
- containerId: string,
14476
+ **listItems**(collectionId: string,
14477
+ containerId: string,
14275
14478
  params?: ListContainerItemsParams) → `Promise<ListResult<ContainerItem>>`
14276
14479
  List items currently (or historically) inside a container (admin). Pass `history: true` to include removed items and see the full membership log, a page at a time (`limit`, `cursor`). The current contents come back whole. ```typescript // Current contents const { items } = await containers.listItems('coll_123', 'cask-uuid') // Full history including removed items const { items: history, nextCursor } = await containers.listItems('coll_123', 'cask-uuid', { history: true, limit: 200 }) ```
14277
14480
 
14278
- **addItems**(collectionId: string,
14279
- containerId: string,
14481
+ **addItems**(collectionId: string,
14482
+ containerId: string,
14280
14483
  data: AddContainerItemsInput) → `Promise<AddContainerItemsResponse>`
14281
14484
  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' }, ], }) ```
14282
14485
 
14283
- **removeItems**(collectionId: string,
14284
- containerId: string,
14486
+ **removeItems**(collectionId: string,
14487
+ containerId: string,
14285
14488
  data: RemoveContainerItemsInput) → `Promise<RemoveContainerItemsResponse>`
14286
14489
  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`) ```
14287
14490
 
14288
- **publicList**(collectionId: string,
14491
+ **publicList**(collectionId: string,
14289
14492
  params?: PublicListContainersParams) → `Promise<ListResult<Container>>`
14290
14493
  List containers (public), a page at a time. Only active containers are listed; soft-deleted containers and containers with `metadata.publicListing === false` are excluded from results. ```typescript const { items, nextCursor } = await containers.publicList('coll_123', { containerType: 'cask', limit: 50 }) ```
14291
14494
 
14292
- **publicGet**(collectionId: string,
14293
- containerId: string,
14495
+ **publicGet**(collectionId: string,
14496
+ containerId: string,
14294
14497
  params?: GetContainerParams) → `Promise<Container>`
14295
14498
  Get a single container (public). Soft-deleted containers return a 404. Same `?tree` and `?includeContents` options as the admin version.
14296
14499
 
14297
- **publicListItems**(collectionId: string,
14298
- containerId: string,
14500
+ **publicListItems**(collectionId: string,
14501
+ containerId: string,
14299
14502
  options: ListOptions = {}) → `Promise<ListResult<ContainerItem>>`
14300
14503
  List current contents of a container (public), a page at a time. Returns only items where `removedAt` is null. No `?history` option on the public side. ```typescript let page = await containers.publicListItems('coll_123', 'cask-uuid', { limit: 50 }) while (page.nextCursor) { page = await containers.publicListItems('coll_123', 'cask-uuid', { limit: 50, cursor: page.nextCursor }) } ```
14301
14504
 
@@ -14605,8 +14808,8 @@ Update whitelisted fields. PUT /integrations/flows/:id
14605
14808
  **deleteFlow**(collectionId: string, id: string) → `Promise<`
14606
14809
  Soft-delete a flow. DELETE /integrations/flows/:id
14607
14810
 
14608
- **runFlow**(collectionId: string,
14609
- id: string,
14811
+ **runFlow**(collectionId: string,
14812
+ id: string,
14610
14813
  options: RunFlowInput & { async?: boolean } = {}) → `Promise<RunFlowResult>`
14611
14814
  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.
14612
14815
 
@@ -14634,8 +14837,8 @@ Is enhanced logging active for a connection? GET /integrations/logging/:connecti
14634
14837
  **setLogging**(collectionId: string, connectionId: string, input: SetLoggingInput = {}) → `Promise<`
14635
14838
  Enable enhanced logging. POST /integrations/logging/:connectionId (omit ttlMinutes = until cancelled)
14636
14839
 
14637
- **listFailed**(collectionId: string,
14638
- flowId: string,
14840
+ **listFailed**(collectionId: string,
14841
+ flowId: string,
14639
14842
  query: ListOptions & { status?: 'failed' | 'dead' } = {}) → `Promise<ListResult<FailedRecord> &`
14640
14843
  A flow's failed / dead records, a page at a time (`limit` and `cursor`), with the flow's `direction` beside the list. GET /integrations/flows/:id/failed ```typescript let page = await integrations.listFailed('coll_123', flowId, { status: 'dead', limit: 100 }) page.direction // 'inbound' | 'outbound' while (page.nextCursor) { page = await integrations.listFailed('coll_123', flowId, { status: 'dead', limit: 100, cursor: page.nextCursor }) } ```
14641
14844
 
@@ -14660,30 +14863,30 @@ Cancel enhanced logging now. DELETE /integrations/logging/:connectionId
14660
14863
  **listConnectors**(collectionId: string) → `Promise<ListResult<InstalledConnector>>`
14661
14864
  The collection's installed connector apps. A fixed set: always all of them in one answer, so it takes no `limit` or `cursor`. GET /integrations/connectors ```typescript const { items } = await integrations.listConnectors('coll_123') ```
14662
14865
 
14663
- **saveConnectorInstallation**(collectionId: string,
14664
- appId: string,
14866
+ **saveConnectorInstallation**(collectionId: string,
14867
+ appId: string,
14665
14868
  input: SaveConnectorInstallationInput) → `Promise<`
14666
14869
  Save a connector's non-secret Connect-form values and/or settings. PUT /integrations/connectors/:appId/installation
14667
14870
 
14668
- **runConnectorStep**(collectionId: string,
14669
- appId: string,
14670
- step: ConnectorConsoleStep,
14871
+ **runConnectorStep**(collectionId: string,
14872
+ appId: string,
14873
+ step: ConnectorConsoleStep,
14671
14874
  input: Record<string, unknown> & { flowId?: string } = {}) → `Promise<T>`
14672
14875
  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
14673
14876
 
14674
- **runConnectorAction**(collectionId: string,
14675
- appId: string,
14676
- action: string,
14877
+ **runConnectorAction**(collectionId: string,
14878
+ appId: string,
14879
+ action: string,
14677
14880
  input: Record<string, unknown> = {}) → `Promise<T>`
14678
14881
  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 }
14679
14882
 
14680
- **listConnectorActions**(collectionId: string,
14883
+ **listConnectorActions**(collectionId: string,
14681
14884
  appId: string) → `Promise<ListResult<`
14682
14885
  PUBLIC (the Hub, a site): the connector actions the caller may invoke — those declared `public`, plus `member` ones when signed in. A fixed set: always all of them in one answer, so it takes no `limit` or `cursor`. GET /public/collection/:collectionId/connectors/:appId/actions ```typescript const { items } = await integrations.listConnectorActions('coll_123', 'sessionm') const canRedeem = items.some((a) => a.name === 'redeem') ```
14683
14886
 
14684
- **callConnectorAction**(collectionId: string,
14685
- appId: string,
14686
- action: string,
14887
+ **callConnectorAction**(collectionId: string,
14888
+ appId: string,
14889
+ action: string,
14687
14890
  input: Record<string, unknown> = {}) → `Promise<T>`
14688
14891
  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 }
14689
14892
 
@@ -14762,19 +14965,19 @@ Public: list the collection's interaction types, optionally only one app's. GET
14762
14965
 
14763
14966
  ### jobs
14764
14967
 
14765
- **list**(collectionId: string,
14968
+ **list**(collectionId: string,
14766
14969
  query: ListJobsQuery = {}) → `Promise<ListResult<Job>>`
14767
14970
  List visible jobs for a collection, newest first. GET /admin/collection/:collectionId/jobs ```typescript let page = await jobs.list('coll_123', { state: 'errored', limit: 50 }) while (page.nextCursor) page = await jobs.list('coll_123', { state: 'errored', limit: 50, cursor: page.nextCursor }) ```
14768
14971
 
14769
- **get**(collectionId: string,
14972
+ **get**(collectionId: string,
14770
14973
  jobId: number) → `Promise<Job>`
14771
14974
  Get a single job GET /admin/collection/:collectionId/jobs/:jobId
14772
14975
 
14773
- **enqueue**(collectionId: string,
14976
+ **enqueue**(collectionId: string,
14774
14977
  params: EnqueueAsyncJobRequest) → `Promise<EnqueueAsyncJobResponse>`
14775
14978
  Start a background job for a collection. POST /admin/collection/:collectionId/async/jobs (202)
14776
14979
 
14777
- **status**(collectionId: string,
14980
+ **status**(collectionId: string,
14778
14981
  jobId: number) → `Promise<Job>`
14779
14982
  How a job you started is getting on (may answer 404 once it has finished and been cleared away). GET /admin/collection/:collectionId/async/jobs/:jobId
14780
14983
 
@@ -14856,11 +15059,11 @@ Push documents into a `documents` source; the same `ref` replaces its earlier ve
14856
15059
  **removeDocuments**(collectionId: string, sourceId: string, refs: string[]) → `Promise<`
14857
15060
  Remove pushed documents by `ref` (admin).
14858
15061
 
14859
- **search**(collectionId: string,
15062
+ **search**(collectionId: string,
14860
15063
  body: KnowledgeSearchRequest) → `Promise<ListResult<KnowledgeSearchResult> & Pick<KnowledgeSearchResponse, 'query' | 'mode'>>`
14861
15064
  Search every set, staff ones included (admin). `q` is what to look for. The matches come back as `items`, best first, with the `query` and the search `mode` beside them. `limit` says how many matches to return (default 8, at most 25); `cursor` is the previous page's `nextCursor`. ```typescript const { items, mode } = await knowledge.search('coll_123', { q: 'how do I descale', limit: 5 }) ```
14862
15065
 
14863
- **publicSearch**(collectionId: string,
15066
+ **publicSearch**(collectionId: string,
14864
15067
  body: KnowledgeSearchRequest) → `Promise<ListResult<KnowledgeSearchResult> & Pick<KnowledgeSearchResponse, 'query' | 'mode'>>`
14865
15068
  Search from a website, Portal or Hub: public sets, plus customer sets for a signed-in person. The options and the answer are the same as the admin `search`: `q` is what to look for, and the matches come back as `items`, best first, with the `query` and the search `mode` beside them. `limit` says how many matches to return (default 8, at most 25); `cursor` is the previous page's `nextCursor`. ```typescript const { items } = await knowledge.publicSearch('coll_123', { q: 'how do I descale', limit: 5 }) for (const r of items) console.log(r.title, r.heading, r.url, r.snippet) ```
14866
15069
 
@@ -14931,97 +15134,97 @@ A lot's member products (summaries) from a public context, a page at a time. ```
14931
15134
 
14932
15135
  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.
14933
15136
 
14934
- **list**(collectionId: string,
15137
+ **list**(collectionId: string,
14935
15138
  params: ListOptions & { includeDeleted?: boolean } = {}) → `Promise<ListResult<LoyaltyScheme>>`
14936
15139
  The collection's loyalty schemes (admin), a page at a time. Page with `limit` (50 unless you say) and `cursor`. Pass `includeDeleted: true` to include deleted schemes. ```typescript let page = await loyalty.list('coll_123', { limit: 50 }) while (page.nextCursor) page = await loyalty.list('coll_123', { limit: 50, cursor: page.nextCursor }) ```
14937
15140
 
14938
- **get**(collectionId: string,
15141
+ **get**(collectionId: string,
14939
15142
  schemeId: string) → `Promise<LoyaltyScheme>`
14940
15143
  The collection's loyalty schemes (admin), a page at a time. Page with `limit` (50 unless you say) and `cursor`. Pass `includeDeleted: true` to include deleted schemes. ```typescript let page = await loyalty.list('coll_123', { limit: 50 }) while (page.nextCursor) page = await loyalty.list('coll_123', { limit: 50, cursor: page.nextCursor }) ```
14941
15144
 
14942
- **create**(collectionId: string,
15145
+ **create**(collectionId: string,
14943
15146
  body: CreateLoyaltySchemeBody) → `Promise<LoyaltyScheme>`
14944
15147
  The collection's loyalty schemes (admin), a page at a time. Page with `limit` (50 unless you say) and `cursor`. Pass `includeDeleted: true` to include deleted schemes. ```typescript let page = await loyalty.list('coll_123', { limit: 50 }) while (page.nextCursor) page = await loyalty.list('coll_123', { limit: 50, cursor: page.nextCursor }) ```
14945
15148
 
14946
- **update**(collectionId: string,
14947
- schemeId: string,
15149
+ **update**(collectionId: string,
15150
+ schemeId: string,
14948
15151
  body: UpdateLoyaltySchemeBody) → `Promise<LoyaltyScheme>`
14949
15152
  The collection's loyalty schemes (admin), a page at a time. Page with `limit` (50 unless you say) and `cursor`. Pass `includeDeleted: true` to include deleted schemes. ```typescript let page = await loyalty.list('coll_123', { limit: 50 }) while (page.nextCursor) page = await loyalty.list('coll_123', { limit: 50, cursor: page.nextCursor }) ```
14950
15153
 
14951
- **remove**(collectionId: string,
15154
+ **remove**(collectionId: string,
14952
15155
  schemeId: string) → `Promise<LoyaltyScheme>`
14953
15156
  The collection's loyalty schemes (admin), a page at a time. Page with `limit` (50 unless you say) and `cursor`. Pass `includeDeleted: true` to include deleted schemes. ```typescript let page = await loyalty.list('coll_123', { limit: 50 }) while (page.nextCursor) page = await loyalty.list('coll_123', { limit: 50, cursor: page.nextCursor }) ```
14954
15157
 
14955
- **listEarningRules**(collectionId: string,
14956
- schemeId: string,
15158
+ **listEarningRules**(collectionId: string,
15159
+ schemeId: string,
14957
15160
  options: ListOptions = {}) → `Promise<ListResult<LoyaltyEarningRule>>`
14958
15161
  A scheme's earning rules (admin), a page at a time. Page with `limit` (50 unless you say) and `cursor`. ```typescript let page = await loyalty.listEarningRules('coll_123', schemeId, { limit: 50 }) while (page.nextCursor) page = await loyalty.listEarningRules('coll_123', schemeId, { limit: 50, cursor: page.nextCursor }) ```
14959
15162
 
14960
- **getEarningRule**(collectionId: string,
14961
- schemeId: string,
15163
+ **getEarningRule**(collectionId: string,
15164
+ schemeId: string,
14962
15165
  ruleId: string) → `Promise<LoyaltyEarningRule>`
14963
15166
  A scheme's earning rules (admin), a page at a time. Page with `limit` (50 unless you say) and `cursor`. ```typescript let page = await loyalty.listEarningRules('coll_123', schemeId, { limit: 50 }) while (page.nextCursor) page = await loyalty.listEarningRules('coll_123', schemeId, { limit: 50, cursor: page.nextCursor }) ```
14964
15167
 
14965
- **createEarningRule**(collectionId: string,
14966
- schemeId: string,
15168
+ **createEarningRule**(collectionId: string,
15169
+ schemeId: string,
14967
15170
  body: CreateLoyaltyEarningRuleBody) → `Promise<LoyaltyEarningRule>`
14968
15171
  A scheme's earning rules (admin), a page at a time. Page with `limit` (50 unless you say) and `cursor`. ```typescript let page = await loyalty.listEarningRules('coll_123', schemeId, { limit: 50 }) while (page.nextCursor) page = await loyalty.listEarningRules('coll_123', schemeId, { limit: 50, cursor: page.nextCursor }) ```
14969
15172
 
14970
- **updateEarningRule**(collectionId: string,
14971
- schemeId: string,
14972
- ruleId: string,
15173
+ **updateEarningRule**(collectionId: string,
15174
+ schemeId: string,
15175
+ ruleId: string,
14973
15176
  body: UpdateLoyaltyEarningRuleBody) → `Promise<LoyaltyEarningRule>`
14974
15177
  A scheme's earning rules (admin), a page at a time. Page with `limit` (50 unless you say) and `cursor`. ```typescript let page = await loyalty.listEarningRules('coll_123', schemeId, { limit: 50 }) while (page.nextCursor) page = await loyalty.listEarningRules('coll_123', schemeId, { limit: 50, cursor: page.nextCursor }) ```
14975
15178
 
14976
- **removeEarningRule**(collectionId: string,
14977
- schemeId: string,
15179
+ **removeEarningRule**(collectionId: string,
15180
+ schemeId: string,
14978
15181
  ruleId: string) → `Promise<LoyaltyEarningRule>`
14979
15182
  A scheme's earning rules (admin), a page at a time. Page with `limit` (50 unless you say) and `cursor`. ```typescript let page = await loyalty.listEarningRules('coll_123', schemeId, { limit: 50 }) while (page.nextCursor) page = await loyalty.listEarningRules('coll_123', schemeId, { limit: 50, cursor: page.nextCursor }) ```
14980
15183
 
14981
- **listMembers**(collectionId: string,
14982
- schemeId: string,
15184
+ **listMembers**(collectionId: string,
15185
+ schemeId: string,
14983
15186
  params: ListOptions = {}) → `Promise<ListResult<LoyaltyMember>>`
14984
15187
  A scheme's members (admin), a page at a time (default 50, at most 200). ```typescript let page = await loyalty.listMembers('coll_123', schemeId, { limit: 100 }) while (page.nextCursor) page = await loyalty.listMembers('coll_123', schemeId, { limit: 100, cursor: page.nextCursor }) ```
14985
15188
 
14986
- **getMember**(collectionId: string,
14987
- schemeId: string,
15189
+ **getMember**(collectionId: string,
15190
+ schemeId: string,
14988
15191
  contactId: string) → `Promise<LoyaltyMember>`
14989
15192
  A scheme's members (admin), a page at a time (default 50, at most 200). ```typescript let page = await loyalty.listMembers('coll_123', schemeId, { limit: 100 }) while (page.nextCursor) page = await loyalty.listMembers('coll_123', schemeId, { limit: 100, cursor: page.nextCursor }) ```
14990
15193
 
14991
- **recordTransaction**(collectionId: string,
14992
- schemeId: string,
14993
- contactId: string,
15194
+ **recordTransaction**(collectionId: string,
15195
+ schemeId: string,
15196
+ contactId: string,
14994
15197
  body: RecordLoyaltyTransactionBody) → `Promise<LoyaltyTransactionResult>`
14995
15198
  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.
14996
15199
 
14997
- **getMemberHistory**(collectionId: string,
14998
- schemeId: string,
14999
- contactId: string,
15200
+ **getMemberHistory**(collectionId: string,
15201
+ schemeId: string,
15202
+ contactId: string,
15000
15203
  params: ListOptions = {}) → `Promise<ListResult<LoyaltyTransaction>>`
15001
15204
  One member's points transactions (admin), newest first, a page at a time. ```typescript const { items, nextCursor } = await loyalty.getMemberHistory('coll_123', schemeId, contactId, { limit: 50 }) ```
15002
15205
 
15003
15206
  **publicList**(collectionId: string, options: ListOptions = {}) → `Promise<ListResult<LoyaltyScheme>>`
15004
15207
  List active schemes for a collection, a page at a time. No authentication required. Page with `limit` (50 unless you say) and `cursor`. ```typescript let page = await loyalty.publicList('coll_123', { limit: 50 }) while (page.nextCursor) page = await loyalty.publicList('coll_123', { limit: 50, cursor: page.nextCursor }) ```
15005
15208
 
15006
- **publicGet**(collectionId: string,
15209
+ **publicGet**(collectionId: string,
15007
15210
  schemeId: string) → `Promise<LoyaltyScheme>`
15008
15211
  Get a single active scheme. No authentication required.
15009
15212
 
15010
- **publicListEarningRules**(collectionId: string,
15011
- schemeId: string,
15213
+ **publicListEarningRules**(collectionId: string,
15214
+ schemeId: string,
15012
15215
  options: ListOptions = {}) → `Promise<ListResult<LoyaltyEarningRule>>`
15013
15216
  List active earning rules for a scheme — useful for showing "how to earn" in a loyalty UI. No authentication required. A page at a time: page with `limit` (50 unless you say) and `cursor`. ```typescript let page = await loyalty.publicListEarningRules('coll_123', schemeId, { limit: 50 }) while (page.nextCursor) page = await loyalty.publicListEarningRules('coll_123', schemeId, { limit: 50, cursor: page.nextCursor }) ```
15014
15217
 
15015
- **publicGetMe**(collectionId: string,
15218
+ **publicGetMe**(collectionId: string,
15016
15219
  options: ListOptions = {}) → `Promise<ListResult<LoyaltySchemeWithMembership>>`
15017
15220
  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 A page at a time: page with `limit` (50 unless you say) and `cursor`. ```typescript let page = await loyalty.publicGetMe('coll_123') for (const scheme of page.items) console.log(scheme.name, scheme.member?.balance ?? 0) while (page.nextCursor) page = await loyalty.publicGetMe('coll_123', { cursor: page.nextCursor }) ```
15018
15221
 
15019
- **publicGetMine**(collectionId: string,
15222
+ **publicGetMine**(collectionId: string,
15020
15223
  schemeId: string) → `Promise<LoyaltyMember>`
15021
15224
  Get the authenticated caller's membership (balance + lifetimePoints) on a specific scheme. Requires authentication.
15022
15225
 
15023
- **publicGetMineHistory**(collectionId: string,
15024
- schemeId: string,
15226
+ **publicGetMineHistory**(collectionId: string,
15227
+ schemeId: string,
15025
15228
  params: ListOptions = {}) → `Promise<ListResult<LoyaltyTransaction>>`
15026
15229
  Get the authenticated caller's transaction history on a specific scheme. Ordered newest first, a page at a time. Requires authentication. ```typescript let page = await loyalty.publicGetMineHistory('coll_123', schemeId, { limit: 20 }) while (page.nextCursor) page = await loyalty.publicGetMineHistory('coll_123', schemeId, { limit: 20, cursor: page.nextCursor }) ```
15027
15230
 
@@ -15059,73 +15262,73 @@ What the server offers, by group: `{ workOrders: [...], stock: [...], boms: [...
15059
15262
 
15060
15263
  ### order
15061
15264
 
15062
- **create**(collectionId: string,
15265
+ **create**(collectionId: string,
15063
15266
  data: CreateOrderRequest) → `Promise<CreateOrderResponse>`
15064
15267
  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' } }) ```
15065
15268
 
15066
- **get**(collectionId: string,
15067
- orderId: string,
15269
+ **get**(collectionId: string,
15270
+ orderId: string,
15068
15271
  params?: GetOrderParams) → `Promise<GetOrderResponse>`
15069
15272
  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 ```
15070
15273
 
15071
- **update**(collectionId: string,
15072
- orderId: string,
15274
+ **update**(collectionId: string,
15275
+ orderId: string,
15073
15276
  data: UpdateOrderRequest) → `Promise<UpdateOrderResponse>`
15074
15277
  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' } }) ```
15075
15278
 
15076
- **remove**(collectionId: string,
15279
+ **remove**(collectionId: string,
15077
15280
  orderId: string) → `Promise<DeleteOrderResponse>`
15078
15281
  Delete an order and all its items (cascade delete). ```typescript await order.remove('coll_123', 'order_abc123') ```
15079
15282
 
15080
- **list**(collectionId: string,
15283
+ **list**(collectionId: string,
15081
15284
  params?: ListOrdersRequest) → `Promise<ListResult<Order>>`
15082
15285
  List orders for a collection with optional filters, a page at a time (default 100). Orders are returned in descending order by createdAt (newest first). ```typescript // The first page of orders (without items for better performance) const { items } = await order.list('coll_123') // List with filters, page by page let page = await order.list('coll_123', { status: 'pending', limit: 50 }) while (page.nextCursor) { page = await order.list('coll_123', { status: 'pending', limit: 50, cursor: page.nextCursor }) } // Filter by customer with items const customerOrders = await order.list('coll_123', { customerId: 'CUST-789', expand: ['items'] }) // Purchase orders from one supplier const purchases = await order.list('coll_123', { direction: 'purchase', partyId: supplierId }) ```
15083
15286
 
15084
- **getItems**(collectionId: string,
15085
- orderId: string,
15287
+ **getItems**(collectionId: string,
15288
+ orderId: string,
15086
15289
  params?: GetOrderItemsParams) → `Promise<ListResult<OrderItem>>`
15087
15290
  Get items from an order with pagination support. Use this for orders with many items instead of `expand: ['items']`. ```typescript // Get first page of items const page1 = await order.getItems('coll_123', 'order_abc123', { limit: 100 }) // Get next page if (page1.nextCursor) { const page2 = await order.getItems('coll_123', 'order_abc123', { limit: 100, cursor: page1.nextCursor }) } ```
15088
15291
 
15089
- **addItems**(collectionId: string,
15090
- orderId: string,
15292
+ **addItems**(collectionId: string,
15293
+ orderId: string,
15091
15294
  data: AddItemsRequest) → `Promise<AddItemsResponse>`
15092
15295
  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`) ```
15093
15296
 
15094
15297
  **lineDone**(collectionId: string, orderId: string, itemId: string, by: number) → `Promise<OrderItem>`
15095
15298
  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) ```
15096
15299
 
15097
- **removeItems**(collectionId: string,
15098
- orderId: string,
15300
+ **removeItems**(collectionId: string,
15301
+ orderId: string,
15099
15302
  data: RemoveItemsRequest) → `Promise<RemoveItemsResponse>`
15100
15303
  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) ```
15101
15304
 
15102
- **query**(collectionId: string,
15305
+ **query**(collectionId: string,
15103
15306
  data: QueryOrdersRequest) → `Promise<ListResult<Order>>`
15104
15307
  Advanced query for orders with order-level and item-level filtering. More powerful than the basic list() function. `expand: ['items']`, and `limit` and `cursor` for paging. These all sit beside `query`, not inside it. ```typescript // Find pending orders created in January 2026, newest first const result = await order.query('coll_123', { query: { status: 'pending' }, createdAt: { gte: '2026-01-01T00:00:00Z', lte: '2026-02-01T00:00:00Z' }, orderBy: [{ createdAt: 'desc' }], limit: 50 }) console.log(result.items.length) // The next page: the same query with the cursor if (result.nextCursor) { const next = await order.query('coll_123', { query: { status: 'pending' }, createdAt: { gte: '2026-01-01T00:00:00Z', lte: '2026-02-01T00:00:00Z' }, orderBy: [{ createdAt: 'desc' }], limit: 50, cursor: result.nextCursor }) } // Find orders with specific metadata and item count, with their items const highPriority = await order.query('coll_123', { query: { metadata: { priority: 'high' }, minItemCount: 10, maxItemCount: 100 }, expand: ['items'] }) // Find orders containing a specific product batch const batchOrders = await order.query('coll_123', { query: { productId: 'prod_789', batchId: 'BATCH-2024-001' }, expand: ['items'] }) // 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' } ] }, expand: ['items'] }) ```
15105
15308
 
15106
- **reports**(collectionId: string,
15309
+ **reports**(collectionId: string,
15107
15310
  params?: ReportsParams) → `Promise<ReportsResponse>`
15108
15311
  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 }) ```
15109
15312
 
15110
- **getAnalytics**(collectionId: string,
15313
+ **getAnalytics**(collectionId: string,
15111
15314
  orderId: string) → `Promise<OrderAnalyticsResponse>`
15112
15315
  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`) }) } ```
15113
15316
 
15114
- **getTimeline**(collectionId: string,
15115
- orderId: string,
15317
+ **getTimeline**(collectionId: string,
15318
+ orderId: string,
15116
15319
  params?: TimelineRequest) → `Promise<ListResult<TagScanEvent> &`
15117
15320
  Get chronological timeline of all scan events for an order's tags. Supports filtering by date range and admin/customer scans. time (`limit` says how many, default 1000), with the order they belong to ```typescript // The first page of scan events let timeline = await order.getTimeline('coll_123', 'order_abc123') timeline.items.forEach(event => { console.log(`${event.timestamp}: ${event.eventType} by ${event.isAdmin ? 'admin' : 'customer'}`) }) // The next page if (timeline.nextCursor) timeline = await order.getTimeline('coll_123', 'order_abc123', { cursor: timeline.nextCursor }) // 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 }) ```
15118
15321
 
15119
- **getLocationHistory**(collectionId: string,
15120
- orderId: string,
15322
+ **getLocationHistory**(collectionId: string,
15323
+ orderId: string,
15121
15324
  params?: LocationRequest) → `Promise<ListResult<LocationScan> &`
15122
15325
  Get location-based scan history for an order's tags. Shows where the order's tags have been scanned. a page at a time (`limit` says how many, default 1000), with the order they belong to ```typescript let locations = await order.getLocationHistory('coll_123', 'order_abc123', { limit: 100 }) locations.items.forEach(scan => { console.log(`${scan.location} at ${scan.timestamp}`) }) // The next page if (locations.nextCursor) { locations = await order.getLocationHistory('coll_123', 'order_abc123', { limit: 100, cursor: locations.nextCursor }) } ```
15123
15326
 
15124
- **getBulkAnalytics**(collectionId: string,
15327
+ **getBulkAnalytics**(collectionId: string,
15125
15328
  data: BulkAnalyticsRequest) → `Promise<BulkAnalyticsResponse>`
15126
15329
  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`) } }) ```
15127
15330
 
15128
- **getCollectionSummary**(collectionId: string,
15331
+ **getCollectionSummary**(collectionId: string,
15129
15332
  params?: SummaryRequest) → `Promise<CollectionSummaryResponse>`
15130
15333
  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' }) ```
15131
15334
 
@@ -15152,6 +15355,31 @@ Find a tag across the partner's sets by its chip UID (8 or 14 hex) or its code (
15152
15355
  **tagAttempts**(partnerId: string, uid: string, options: ListOptions = {}) → `Promise<ListResult<ClientErrorEvent>>`
15153
15356
  What phones reported about one chip (errors.report with entityType 'tag'), newest first: a tag that failed to program or register, with the host's NFC log in context. For a chip in the partner's sets, or attempts that named one of them. Returns `{ items, nextCursor }`: the latest reports are in `items` (ten unless `limit` says otherwise); `cursor` is the previous page's `nextCursor`. ```typescript const { items: attempts } = await partner.tagAttempts(partnerId, '04A1B2C3D4E5F6', { limit: 20 }) ```
15154
15357
 
15358
+ ### payments
15359
+
15360
+ **config**(collectionId: string) → `Promise<PaymentsPublicConfig>`
15361
+ Can this business take payments, and what Stripe.js needs. `ready` is false until the business has connected Stripe in Studio → Payments. ```typescript const cfg = await payments.config(collectionId) if (cfg.ready) stripePromise = loadStripe(cfg.publishableKey!, { stripeAccount: cfg.accountId! }) ```
15362
+
15363
+ **createIntent**(collectionId: string, input: PaymentIntentInput) → `Promise<PaymentIntentResult>`
15364
+ Start an in-page payment on the business's account. Confirm it in the page with Stripe.js, using the returned publishable key AND account id (`loadStripe(publishableKey, { stripeAccount: accountId })`). `amount` is in minor units (500 = £5.00). The app must be installed in the collection. The browser decides the amount, so use this for pay-what-you-want (donations, tips). For a fixed price use a hosted checkout (`shop.checkout`), where the server prices it. ```typescript const pi = await payments.createIntent(collectionId, { appId: 'tap-to-donate', amount: 500, currency: 'GBP', email }) const stripe = await loadStripe(pi.publishableKey, { stripeAccount: pi.accountId }) // <Elements stripe={stripe} options={{ clientSecret: pi.clientSecret }}> … stripe.confirmPayment(…) ```
15365
+
15366
+ ### payments.admin
15367
+
15368
+ **status**(collectionId: string, params?: { appIds?: string[] }) → `Promise<PaymentsStatus>`
15369
+ The business's payments account: connected, can take payments, can pay out. Pass `appIds` to see what SmartLinks takes from each.
15370
+
15371
+ **connect**(collectionId: string, input: PaymentsConnectInput) → `Promise<`
15372
+ Stripe's page to connect (or finish connecting) the business's Stripe account. Send the person to `url`. The account is made the first time; every app shares it.
15373
+
15374
+ **disconnect**(collectionId: string) → `Promise<`
15375
+ Stop using the business's Stripe account. SmartLinks forgets it (apps can no longer take payments until one is connected again); the Stripe account itself stays the business's own, with the payments already in it. Connecting again makes a new account.
15376
+
15377
+ **intents**(collectionId: string, params?: PaymentListParams) → `Promise<PaymentList>`
15378
+ An app's in-page payments on the business's account, newest first (for reconciling).
15379
+
15380
+ **registerDomain**(collectionId: string, domain: string) → `Promise<PaymentDomainResult>`
15381
+ Let Apple Pay and Google Pay run on a site's own domain (smartlinks.app needs nothing).
15382
+
15155
15383
  ### places
15156
15384
 
15157
15385
  **move**(collectionId: string, params: { to: string | null; items: PlaceMoveItem[]; note?: string }) → `Promise<PlaceMoveResult>`
@@ -15159,7 +15387,7 @@ Move items (by membership), chips without an item (by membership) or containers
15159
15387
 
15160
15388
  ### podcast
15161
15389
 
15162
- **generate**(collectionId: string,
15390
+ **generate**(collectionId: string,
15163
15391
  request: GeneratePodcastRequest) → `Promise<GeneratePodcastResponse>`
15164
15392
  Generate a NotebookLM-style conversational podcast from product documents
15165
15393
 
@@ -15168,219 +15396,219 @@ Get podcast generation status
15168
15396
 
15169
15397
  ### products
15170
15398
 
15171
- **get**(collectionId: string,
15172
- productId: string,
15399
+ **get**(collectionId: string,
15400
+ productId: string,
15173
15401
  admin?: boolean) → `Promise<ProductResponse>`
15174
15402
 
15175
- **list**(collectionId: string,
15176
- admin?: boolean,
15403
+ **list**(collectionId: string,
15404
+ admin?: boolean,
15177
15405
  options: ListOptions & { expand?: Array<'facets'> } = {}) → `Promise<ListResult<ProductResponse>>`
15178
15406
  The products in a collection, a page at a time. For searching, filtering and sorting use `products.query`. as full values instead of their keys ```typescript let page = await products.list(collectionId, false, { limit: 50 }) while (page.nextCursor) { page = await products.list(collectionId, false, { limit: 50, cursor: page.nextCursor }) } // Admin, with full facet values const { items } = await products.list(collectionId, true, { expand: ['facets'] }) ```
15179
15407
 
15180
- **create**(collectionId: string,
15408
+ **create**(collectionId: string,
15181
15409
  data: ProductCreateRequest) → `Promise<ProductResponse>`
15182
15410
  The products in a collection, a page at a time. For searching, filtering and sorting use `products.query`. as full values instead of their keys ```typescript let page = await products.list(collectionId, false, { limit: 50 }) while (page.nextCursor) { page = await products.list(collectionId, false, { limit: 50, cursor: page.nextCursor }) } // Admin, with full facet values const { items } = await products.list(collectionId, true, { expand: ['facets'] }) ```
15183
15411
 
15184
- **update**(collectionId: string,
15185
- productId: string,
15412
+ **update**(collectionId: string,
15413
+ productId: string,
15186
15414
  data: ProductUpdateRequest) → `Promise<ProductResponse>`
15187
15415
  The products in a collection, a page at a time. For searching, filtering and sorting use `products.query`. as full values instead of their keys ```typescript let page = await products.list(collectionId, false, { limit: 50 }) while (page.nextCursor) { page = await products.list(collectionId, false, { limit: 50, cursor: page.nextCursor }) } // Admin, with full facet values const { items } = await products.list(collectionId, true, { expand: ['facets'] }) ```
15188
15416
 
15189
- **remove**(collectionId: string,
15417
+ **remove**(collectionId: string,
15190
15418
  productId: string) → `Promise<void>`
15191
15419
  The products in a collection, a page at a time. For searching, filtering and sorting use `products.query`. as full values instead of their keys ```typescript let page = await products.list(collectionId, false, { limit: 50 }) while (page.nextCursor) { page = await products.list(collectionId, false, { limit: 50, cursor: page.nextCursor }) } // Admin, with full facet values const { items } = await products.list(collectionId, true, { expand: ['facets'] }) ```
15192
15420
 
15193
- **query**(collectionId: string,
15194
- body: ProductQueryRequest,
15421
+ **query**(collectionId: string,
15422
+ body: ProductQueryRequest,
15195
15423
  admin?: boolean) → `Promise<ListResult<ProductResponse> &`
15196
15424
  Query products in a collection with search, filtering, sorting, and paging. and the other filters in `query`, plus `limit` (default 50) and `cursor` for paging authenticated admin context). Defaults to `false`, which targets the `/public` endpoint — consistent with `get`, `list`, and `listAssets`. for the next page (null on the last), how many match in all where the server counted, and `meta` (how the query was run) ```typescript // Public query (default) const { items, nextCursor, count } = await products.query(collectionId, { q: 'cabernet', limit: 20 }) // The next page: the same query with the cursor if (nextCursor) { await products.query(collectionId, { q: 'cabernet', limit: 20, cursor: nextCursor }) } // Newest first, created this month, active only, with full facet values await products.query(collectionId, { orderBy: [{ createdAt: 'desc' }], createdAt: { gte: '2026-11-01T00:00:00Z', lte: '2026-11-30T23:59:59Z' }, query: { status: ['active'] }, expand: ['facets'], }) // Admin query (authenticated) await products.query(collectionId, { q: 'cabernet' }, true) ```
15197
15425
 
15198
- **standardQuery**(collectionId: string,
15426
+ **standardQuery**(collectionId: string,
15199
15427
  body: StandardQuery = {}) → `Promise<QueryResult>`
15200
15428
  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, }) ```
15201
15429
 
15202
15430
  **standardQueryFields**(collectionId: string) → `Promise<QueryDescription>`
15203
15431
  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
15204
15432
 
15205
- **clone**(collectionId: string,
15206
- productId: string,
15433
+ **clone**(collectionId: string,
15434
+ productId: string,
15207
15435
  body: Record<string, JsonValue> = {}) → `Promise<ProductResponse>`
15208
15436
  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
15209
15437
 
15210
- **listAssets**(collectionId: string,
15211
- productId: string,
15212
- admin?: boolean,
15438
+ **listAssets**(collectionId: string,
15439
+ productId: string,
15440
+ admin?: boolean,
15213
15441
  options: ListOptions = {}) → `Promise<ListResult<AssetResponse>>`
15214
15442
  A product's assets (images, documents), a page at a time. ```typescript let page = await products.listAssets(collectionId, productId, false, { limit: 50 }) while (page.nextCursor) { page = await products.listAssets(collectionId, productId, false, { limit: 50, cursor: page.nextCursor }) } ```
15215
15443
 
15216
- **createClaimWindow**(collectionId: string,
15217
- productId: string,
15444
+ **createClaimWindow**(collectionId: string,
15445
+ productId: string,
15218
15446
  body: Record<string, JsonValue>) → `Promise<unknown>`
15219
15447
  A product's assets (images, documents), a page at a time. ```typescript let page = await products.listAssets(collectionId, productId, false, { limit: 50 }) while (page.nextCursor) { page = await products.listAssets(collectionId, productId, false, { limit: 50, cursor: page.nextCursor }) } ```
15220
15448
 
15221
- **updateClaimWindow**(collectionId: string,
15222
- productId: string,
15223
- claimId: string,
15449
+ **updateClaimWindow**(collectionId: string,
15450
+ productId: string,
15451
+ claimId: string,
15224
15452
  body: Record<string, JsonValue>) → `Promise<unknown>`
15225
15453
  A product's assets (images, documents), a page at a time. ```typescript let page = await products.listAssets(collectionId, productId, false, { limit: 50 }) while (page.nextCursor) { page = await products.listAssets(collectionId, productId, false, { limit: 50, cursor: page.nextCursor }) } ```
15226
15454
 
15227
- **refresh**(collectionId: string,
15455
+ **refresh**(collectionId: string,
15228
15456
  productId: string) → `Promise<ProductResponse>`
15229
15457
  A product's assets (images, documents), a page at a time. ```typescript let page = await products.listAssets(collectionId, productId, false, { limit: 50 }) while (page.nextCursor) { page = await products.listAssets(collectionId, productId, false, { limit: 50, cursor: page.nextCursor }) } ```
15230
15458
 
15231
- **getSN**(collectionId: string,
15232
- productId: string,
15233
- startIndex: number = 0,
15459
+ **getSN**(collectionId: string,
15460
+ productId: string,
15461
+ startIndex: number = 0,
15234
15462
  count: number = 10) → `Promise<unknown>`
15235
15463
  A product's assets (images, documents), a page at a time. ```typescript let page = await products.listAssets(collectionId, productId, false, { limit: 50 }) while (page.nextCursor) { page = await products.listAssets(collectionId, productId, false, { limit: 50, cursor: page.nextCursor }) } ```
15236
15464
 
15237
- **lookupSN**(collectionId: string,
15238
- productId: string,
15465
+ **lookupSN**(collectionId: string,
15466
+ productId: string,
15239
15467
  codeId: string) → `Promise<unknown>`
15240
15468
  A product's assets (images, documents), a page at a time. ```typescript let page = await products.listAssets(collectionId, productId, false, { limit: 50 }) while (page.nextCursor) { page = await products.listAssets(collectionId, productId, false, { limit: 50, cursor: page.nextCursor }) } ```
15241
15469
 
15242
- **publicLookupClaim**(collectionId: string,
15243
- productId: string,
15470
+ **publicLookupClaim**(collectionId: string,
15471
+ productId: string,
15244
15472
  claimId: string) → `Promise<unknown>`
15245
15473
  A product's assets (images, documents), a page at a time. ```typescript let page = await products.listAssets(collectionId, productId, false, { limit: 50 }) while (page.nextCursor) { page = await products.listAssets(collectionId, productId, false, { limit: 50, cursor: page.nextCursor }) } ```
15246
15474
 
15247
- **publicCreateClaim**(collectionId: string,
15248
- productId: string,
15475
+ **publicCreateClaim**(collectionId: string,
15476
+ productId: string,
15249
15477
  body: ProductClaimCreateRequestBody) → `Promise<unknown>`
15250
15478
  A product's assets (images, documents), a page at a time. ```typescript let page = await products.listAssets(collectionId, productId, false, { limit: 50 }) while (page.nextCursor) { page = await products.listAssets(collectionId, productId, false, { limit: 50, cursor: page.nextCursor }) } ```
15251
15479
 
15252
15480
  ### proof
15253
15481
 
15254
- **query**(collectionId: string,
15482
+ **query**(collectionId: string,
15255
15483
  body: StandardQuery = {}) → `Promise<QueryResult>`
15256
15484
  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'] }, }) ```
15257
15485
 
15258
15486
  **queryFields**(collectionId: string) → `Promise<QueryDescription>`
15259
15487
  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
15260
15488
 
15261
- **get**(collectionId: string,
15262
- productId: string,
15263
- proofId: string,
15264
- admin?: boolean,
15489
+ **get**(collectionId: string,
15490
+ productId: string,
15491
+ proofId: string,
15492
+ admin?: boolean,
15265
15493
  include?: string[]) → `Promise<ProofResponse>`
15266
15494
  Retrieves a single Proof by Collection ID, Product ID, and Proof ID. Both public and admin endpoints now include productId in the path.
15267
15495
 
15268
- **list**(collectionId: string,
15496
+ **list**(collectionId: string,
15269
15497
  options: ListOptions & { expand?: Array<'product'> } = {}) → `Promise<ListResult<ProofResponse>>`
15270
15498
  List all Proofs for a Collection, a page at a time. GET /public/collection/:collectionId/proof ```typescript let page = await proof.list(collectionId, { limit: 50, expand: ['product'] }) while (page.nextCursor) { page = await proof.list(collectionId, { limit: 50, expand: ['product'], cursor: page.nextCursor }) } ```
15271
15499
 
15272
- **create**(collectionId: string,
15273
- productId: string,
15500
+ **create**(collectionId: string,
15501
+ productId: string,
15274
15502
  request: ProofCreateRequest) → `Promise<ProofResponse>`
15275
15503
  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`.
15276
15504
 
15277
- **update**(collectionId: string,
15278
- productId: string,
15279
- proofId: string,
15505
+ **update**(collectionId: string,
15506
+ productId: string,
15507
+ proofId: string,
15280
15508
  values: ProofUpdateRequest) → `Promise<ProofResponse>`
15281
15509
  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.
15282
15510
 
15283
- **updateValues**(collectionId: string,
15284
- productId: string,
15285
- proofId: string,
15511
+ **updateValues**(collectionId: string,
15512
+ productId: string,
15513
+ proofId: string,
15286
15514
  values: ProofValuesUpdateRequest) → `Promise<ProofResponse>`
15287
15515
  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.
15288
15516
 
15289
- **claim**(collectionId: string,
15290
- productId: string,
15291
- proofId: string,
15517
+ **claim**(collectionId: string,
15518
+ productId: string,
15519
+ proofId: string,
15292
15520
  values: ProofClaimRequest) → `Promise<ProofResponse>`
15293
15521
  Claim a proof for a product using a proof ID (serial number, NFC tag, etc.). PUT /public/collection/:collectionId/product/:productId/proof/:proofId/claim
15294
15522
 
15295
- **claimProduct**(collectionId: string,
15296
- productId: string,
15523
+ **claimProduct**(collectionId: string,
15524
+ productId: string,
15297
15525
  values?: ProofClaimRequest) → `Promise<ProofResponse>`
15298
15526
  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); ```
15299
15527
 
15300
- **remove**(collectionId: string,
15301
- productId: string,
15528
+ **remove**(collectionId: string,
15529
+ productId: string,
15302
15530
  proofId: string) → `Promise<void>`
15303
15531
  Delete a proof for a product (admin only). DELETE /admin/collection/:collectionId/product/:productId/proof/:proofId
15304
15532
 
15305
- **getByUser**(collectionId: string,
15306
- userId: string,
15533
+ **getByUser**(collectionId: string,
15534
+ userId: string,
15307
15535
  options: ListOptions = {}) → `Promise<ListResult<ProofResponse>>`
15308
15536
  Get proofs for a user in a collection (admin only), a page at a time. GET /admin/collection/:collectionId/proof/findByUser/:userId ```typescript let page = await proof.getByUser(collectionId, userId, { limit: 50 }) while (page.nextCursor) page = await proof.getByUser(collectionId, userId, { limit: 50, cursor: page.nextCursor }) ```
15309
15537
 
15310
- **getByProduct**(collectionId: string,
15311
- productId: string,
15538
+ **getByProduct**(collectionId: string,
15539
+ productId: string,
15312
15540
  options: ListOptions = {}) → `Promise<ListResult<ProofResponse>>`
15313
15541
  Get proofs for a product (admin only), a page at a time. GET /admin/collection/:collectionId/product/:productId/proof ```typescript let page = await proof.getByProduct(collectionId, productId, { limit: 50 }) while (page.nextCursor) page = await proof.getByProduct(collectionId, productId, { limit: 50, cursor: page.nextCursor }) ```
15314
15542
 
15315
- **findByProduct**(collectionId: string,
15316
- productId: string,
15543
+ **findByProduct**(collectionId: string,
15544
+ productId: string,
15317
15545
  query: ProofFindQuery = {}) → `Promise<ListResult<ProofResponse>>`
15318
15546
  Find proofs for a product (admin only): the newest ones, `limit` at a time (default 100), or the proofs matching `filterBy`. `expand: ['assets']` attaches each proof's assets. Pass `nextCursor` back as `cursor` for the next page. For counting and sorting a collection's proofs use `proof.query`. POST /admin/collection/:collectionId/product/:productId/proof/find ```typescript const { items, nextCursor } = await proof.findByProduct(collectionId, productId, { limit: 50, expand: ['assets'] }) const red = await proof.findByProduct(collectionId, productId, { filterBy: [{ field: 'values.colour', value: 'red' }] }) ```
15319
15547
 
15320
- **getByBatch**(collectionId: string,
15321
- productId: string,
15322
- batchId: string,
15548
+ **getByBatch**(collectionId: string,
15549
+ productId: string,
15550
+ batchId: string,
15323
15551
  options: ListOptions = {}) → `Promise<ListResult<ProofResponse>>`
15324
15552
  Get proofs for a batch (admin only), a page at a time. GET /admin/collection/:collectionId/product/:productId/batch/:batchId/proof ```typescript let page = await proof.getByBatch(collectionId, productId, batchId, { limit: 50 }) while (page.nextCursor) { page = await proof.getByBatch(collectionId, productId, batchId, { limit: 50, cursor: page.nextCursor }) } ```
15325
15553
 
15326
- **migrate**(collectionId: string,
15327
- productId: string,
15328
- proofId: string,
15329
- /** The destination product ID */
15554
+ **migrate**(collectionId: string,
15555
+ productId: string,
15556
+ proofId: string,
15557
+ /** The destination product ID */
15330
15558
  data: { targetProductId: string }) → `Promise<ProofResponse>`
15331
15559
  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' ```
15332
15560
 
15333
- **createGrant**(collectionId: string,
15334
- productId: string,
15335
- proofId: string,
15561
+ **createGrant**(collectionId: string,
15562
+ productId: string,
15563
+ proofId: string,
15336
15564
  options: CreateGrantOptions) → `Promise<ProofGrant>`
15337
15565
  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}.
15338
15566
 
15339
- **listGrants**(collectionId: string,
15340
- productId: string,
15341
- proofId: string,
15567
+ **listGrants**(collectionId: string,
15568
+ productId: string,
15569
+ proofId: string,
15342
15570
  options: ListOptions = {}) → `Promise<ListResult<ProofGrant>>`
15343
15571
  List the active + past grants on a proof (owner / collection admin only), a page at a time. Tokens are never returned here. ```typescript const { items, nextCursor } = await proof.listGrants(collectionId, productId, proofId, { limit: 50 }) ```
15344
15572
 
15345
- **revokeGrant**(collectionId: string,
15346
- productId: string,
15347
- proofId: string,
15573
+ **revokeGrant**(collectionId: string,
15574
+ productId: string,
15575
+ proofId: string,
15348
15576
  grantId: string) → `Promise<void>`
15349
15577
  Revoke a grant by id (owner / collection admin only). Takes effect immediately.
15350
15578
 
15351
- **redeemGrant**(collectionId: string,
15352
- productId: string,
15353
- proofId: string,
15354
- token: string,
15579
+ **redeemGrant**(collectionId: string,
15580
+ productId: string,
15581
+ proofId: string,
15582
+ token: string,
15355
15583
  options?: RedeemGrantOptions) → `Promise<RedeemGrantResult>`
15356
15584
  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.
15357
15585
 
15358
- **transfer**(collectionId: string,
15359
- productId: string,
15360
- proofId: string,
15586
+ **transfer**(collectionId: string,
15587
+ productId: string,
15588
+ proofId: string,
15361
15589
  options: TransferProofOptions) → `Promise<TransferProofResult>`
15362
15590
  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' } }, }) ```
15363
15591
 
15364
- **acceptTransfer**(collectionId: string,
15365
- productId: string,
15366
- proofId: string,
15592
+ **acceptTransfer**(collectionId: string,
15593
+ productId: string,
15594
+ proofId: string,
15367
15595
  options: AcceptTransferOptions = {}) → `Promise<`
15368
15596
  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.
15369
15597
 
15370
- **cancelTransfer**(collectionId: string,
15371
- productId: string,
15372
- proofId: string,
15598
+ **cancelTransfer**(collectionId: string,
15599
+ productId: string,
15600
+ proofId: string,
15373
15601
  options: CancelTransferOptions = {}) → `Promise<`
15374
15602
  Cancel a pending push transfer (current owner / collection admin only).
15375
15603
 
15376
- **getTransfer**(collectionId: string,
15377
- productId: string,
15604
+ **getTransfer**(collectionId: string,
15605
+ productId: string,
15378
15606
  proofId: string) → `Promise<`
15379
15607
  Get the active transfer/status for a proof (owner, collection admin, or the named recipient). Returns `{ transfer: null }` when nothing is in flight.
15380
15608
 
15381
15609
  ### publicClient
15382
15610
 
15383
- **agentRun**(collectionId: string,
15611
+ **agentRun**(collectionId: string,
15384
15612
  body: PublicAgentRunRequest) → `Promise<AgentRunResult>`
15385
15613
  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
15386
15614
 
@@ -15395,19 +15623,19 @@ Check rate limit status
15395
15623
 
15396
15624
  ### publicClient.sessions
15397
15625
 
15398
- **create**(collectionId: string,
15626
+ **create**(collectionId: string,
15399
15627
  body: AiSessionCreate & { scope?: 'owner' | 'public' } = {}) → `Promise<AiSession>`
15400
15628
 
15401
- **list**(collectionId: string,
15629
+ **list**(collectionId: string,
15402
15630
  params?: { appId?: string; limit?: number }) → `Promise<`
15403
15631
  List the signed-in consumer's own ('owner') sessions — requires an authKit bearer.
15404
15632
 
15405
15633
  **get**(collectionId: string, id: string) → `Promise<AiSession>`
15406
15634
  List the signed-in consumer's own ('owner') sessions — requires an authKit bearer.
15407
15635
 
15408
- **append**(collectionId: string,
15409
- id: string,
15410
- items: ResponseInputItem[],
15636
+ **append**(collectionId: string,
15637
+ id: string,
15638
+ items: ResponseInputItem[],
15411
15639
  opts?: { usage?: Record<string, any> }) → `Promise<AiSession>`
15412
15640
  List the signed-in consumer's own ('owner') sessions — requires an authKit bearer.
15413
15641
 
@@ -15430,7 +15658,7 @@ Reset rate limit for a user
15430
15658
  One of your app's declared channels (manifest `realtime.channels`). ```ts const draw = realtime.channel({ collectionId, appId }, "draw") const off = draw.subscribe("status", (m) => setStatus(m.data)) await draw.publish("status", { phase: "spinning" }) // if the channel lets this viewer publish ```
15431
15659
 
15432
15660
  **onChange**(scope: RealtimeScope, filter: RealtimeChangeFilter, onChangeFn: (change: RealtimeChangeEvent) → `void`
15433
- Something changed: refetch it. IDs only — never data. Admins of the collection see every change; everyone else sees changes to public things (public app records, products). Filter by `type` ('product' | 'proof' | 'asset' | 'record' | 'collection' | 'collection.apps' | 'settings'), `id`, `appId`, `recordType`, `productId`, `proofId`. ```ts const off = realtime.onChange({ collectionId }, { type: "record", appId, recordType: "entry" }, () => refetch()) ```
15661
+ Something changed: refetch it. IDs only — never data. Admins of the collection see every change; everyone else sees changes to public things (public app records, products). Filter by `type` ('product' | 'proof' | 'asset' | 'record' | 'collection' | 'collection.apps' | 'settings'), `id`, `appId`, `recordType`, `productId`, `proofId`. A change with no `id` means many things of that type changed (an import): a `{ type, id }` filter hears it too, so check `change.id` before assuming it is yours. ```ts const off = realtime.onChange({ collectionId }, { type: "record", appId, recordType: "entry" }, () => refetch()) ```
15434
15662
 
15435
15663
  **onStaffChange**(scope: RealtimeScope & { appId: string }, filter: RealtimeChangeFilter, onChangeFn: (change: RealtimeChangeEvent) → `void`
15436
15664
  Something this APP works on changed: one of its work orders, a container or stock it moved, or one of its own records. For the people who use the app, admins or not: someone hears these when they are in one of the app's user groups (the ones its server functions are limited to, or `realtime.staff` in its manifest), and so does a collection admin. IDs only — refetch through your own API. Types: 'workOrder' (`id`, `appId`), 'container' (`id`, `kind` = its container type), 'stock' (`id` = the container, `productId`), 'record' (`id`, `recordType`). Filter as with `onChange`; an empty filter hears them all. ```ts // A production app's screens refetch when anything on the floor changes. useEffect(() => realtime.onStaffChange({ collectionId, appId }, {}, () => queryClient.invalidateQueries()), [collectionId, appId]) ```
@@ -15471,32 +15699,32 @@ Soft-delete a secret. DELETE /secrets/:ref
15471
15699
 
15472
15700
  ### segments
15473
15701
 
15474
- **create**(collectionId: string,
15702
+ **create**(collectionId: string,
15475
15703
  body: Omit<SegmentRecord, 'id' | 'collectionId' | 'createdAt'>) → `Promise<SegmentRecord>`
15476
15704
 
15477
- **list**(collectionId: string,
15705
+ **list**(collectionId: string,
15478
15706
  query: ListSegmentsQuery = {}) → `Promise<ListResult<SegmentRecord>>`
15479
15707
  The collection's segments, a page at a time. Filter by the app that owns them (`appId`) or by `filterType`. ```typescript let page = await segments.list('coll_123', { filterType: 'dynamic', limit: 50 }) page.items // SegmentRecord[] while (page.nextCursor) page = await segments.list('coll_123', { filterType: 'dynamic', limit: 50, cursor: page.nextCursor }) ```
15480
15708
 
15481
- **get**(collectionId: string,
15709
+ **get**(collectionId: string,
15482
15710
  id: string) → `Promise<SegmentRecord>`
15483
15711
  The collection's segments, a page at a time. Filter by the app that owns them (`appId`) or by `filterType`. ```typescript let page = await segments.list('coll_123', { filterType: 'dynamic', limit: 50 }) page.items // SegmentRecord[] while (page.nextCursor) page = await segments.list('coll_123', { filterType: 'dynamic', limit: 50, cursor: page.nextCursor }) ```
15484
15712
 
15485
- **update**(collectionId: string,
15486
- id: string,
15713
+ **update**(collectionId: string,
15714
+ id: string,
15487
15715
  body: Partial<Omit<SegmentRecord, 'id' | 'collectionId' | 'createdAt'>>) → `Promise<SegmentRecord>`
15488
15716
  The collection's segments, a page at a time. Filter by the app that owns them (`appId`) or by `filterType`. ```typescript let page = await segments.list('coll_123', { filterType: 'dynamic', limit: 50 }) page.items // SegmentRecord[] while (page.nextCursor) page = await segments.list('coll_123', { filterType: 'dynamic', limit: 50, cursor: page.nextCursor }) ```
15489
15717
 
15490
- **remove**(collectionId: string,
15718
+ **remove**(collectionId: string,
15491
15719
  id: string) → `Promise<void>`
15492
15720
  The collection's segments, a page at a time. Filter by the app that owns them (`appId`) or by `filterType`. ```typescript let page = await segments.list('coll_123', { filterType: 'dynamic', limit: 50 }) page.items // SegmentRecord[] while (page.nextCursor) page = await segments.list('coll_123', { filterType: 'dynamic', limit: 50, cursor: page.nextCursor }) ```
15493
15721
 
15494
- **calculate**(collectionId: string,
15722
+ **calculate**(collectionId: string,
15495
15723
  id: string) → `Promise<SegmentCalculateResult>`
15496
15724
  The collection's segments, a page at a time. Filter by the app that owns them (`appId`) or by `filterType`. ```typescript let page = await segments.list('coll_123', { filterType: 'dynamic', limit: 50 }) page.items // SegmentRecord[] while (page.nextCursor) page = await segments.list('coll_123', { filterType: 'dynamic', limit: 50, cursor: page.nextCursor }) ```
15497
15725
 
15498
- **recipients**(collectionId: string,
15499
- id: string,
15726
+ **recipients**(collectionId: string,
15727
+ id: string,
15500
15728
  query: ListOptions = {}) → `Promise<SegmentRecipientsResponse>`
15501
15729
  The contacts in a segment, a page at a time. `count` is how many there are in all. ```typescript const page = await segments.recipients('coll_123', 'seg_1', { limit: 100 }) page.items // Recipient[] page.count // total in the segment page.nextCursor // pass back as `cursor` for the next page; null on the last ```
15502
15730
 
@@ -15537,9 +15765,9 @@ List sessions, most-recently-active first (optionally filtered by app).
15537
15765
  **get**(collectionId: string, id: string) → `Promise<AiSession>`
15538
15766
  Get one session, including its full transcript.
15539
15767
 
15540
- **append**(collectionId: string,
15541
- id: string,
15542
- items: ResponseInputItem[],
15768
+ **append**(collectionId: string,
15769
+ id: string,
15770
+ items: ResponseInputItem[],
15543
15771
  opts?: { usage?: Record<string, any> }) → `Promise<AiSession>`
15544
15772
  Append Responses items (input/output/tool) to a session — the manual-persistence path.
15545
15773
 
@@ -15806,17 +16034,17 @@ The global templates this collection may use, 50 at a time unless you give a `li
15806
16034
 
15807
16035
  ### tools
15808
16036
 
15809
- **run**(collectionId: string,
15810
- name: K,
15811
- args: AiToolArgsMap[K],) → `Promise<ToolRunResult>
15812
- export async function run<T = any>(
15813
- collectionId: string,
15814
- name: string,
15815
- args?: Record<string, any>,
15816
- ): Promise<ToolRunResult<T>>
15817
- export async function run(
15818
- collectionId: string,
15819
- name: string,
16037
+ **run**(collectionId: string,
16038
+ name: K,
16039
+ args: AiToolArgsMap[K],) → `Promise<ToolRunResult>
16040
+ export async function run<T = any>(
16041
+ collectionId: string,
16042
+ name: string,
16043
+ args?: Record<string, any>,
16044
+ ): Promise<ToolRunResult<T>>
16045
+ export async function run(
16046
+ collectionId: string,
16047
+ name: string,
15820
16048
  args: Record<string, any> =`
15821
16049
  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
15822
16050
 
@@ -15880,7 +16108,7 @@ Admin: replace the site's translation rules. They apply to new translations from
15880
16108
 
15881
16109
  ### tts
15882
16110
 
15883
- **generate**(collectionId: string,
16111
+ **generate**(collectionId: string,
15884
16112
  request: TTSRequest) → `Promise<Blob>`
15885
16113
  Generate text-to-speech audio
15886
16114