@flexops/sdk 3.2.0 → 3.4.0

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.
package/README.md CHANGED
@@ -159,7 +159,10 @@ const status = await client.shipping.getBatchStatus(batch.data!.jobId);
159
159
 
160
160
  One order shipped in several boxes with the same carrier and service. Each box gets its own label;
161
161
  a box that fails does not stop the others. Multi-package labels cannot carry HAZMAT: send
162
- `HazmatClassification.None` or leave `hazmatClassification` out.
162
+ `HazmatClassification.None` or leave `hazmatClassification` out. `maximumPostageAmount` is required: the most the
163
+ whole shipment may cost in USD (positive, at most two decimals). The Gateway refuses to buy a box that would take the
164
+ total above it (`PriceCeilingExceeded`; once the amount is used up the remaining boxes report `PriceCeilingReached`),
165
+ and a request without a valid ceiling is 400 `ApprovalRequired`.
163
166
 
164
167
  ```typescript
165
168
  import { FlexOpsError, HazmatClassification } from '@flexops/sdk';
@@ -171,6 +174,7 @@ try {
171
174
  carrierCode: 'USPS',
172
175
  serviceCode: 'PRIORITY',
173
176
  hazmatClassification: HazmatClassification.None,
177
+ maximumPostageAmount: 25, // required: the most the whole shipment may cost, in USD
174
178
  packages: [
175
179
  { weightInOunces: 16, lengthInInches: 10, widthInInches: 8, heightInInches: 4, packageReference: 'Box 1 of 2' },
176
180
  { weightInOunces: 8, lengthInInches: 6, widthInInches: 6, heightInInches: 6, packageReference: 'Box 2 of 2' },
@@ -193,7 +197,10 @@ Rates, labels, voids, pickups and scan forms go through `client.shipping`, `clie
193
197
  carrier-specific endpoints through the Gateway's legacy pass-through, which is deprecated and
194
198
  retired on 2027-06-30:
195
199
 
196
- - **Lookups (GET)** work with API keys.
200
+ - **Lookups (GET)** work with API keys that have the permission for the data: `shipping:read` for
201
+ address, ZIP, city, location, service point and reference lookups; `tracking:read` for tracking
202
+ and proof of delivery; `rates:read` for delivery standards, rates and products. Without it the
203
+ Gateway returns 403 `API_KEY_SCOPE_REQUIRED`.
197
204
  - **Writes** (for example `carriers.usps.getDomesticRates`, `carriers.fedex.createPickup`) are marked
198
205
  `@deprecated`. They need a user token (`auth.login`): the Gateway answers an API key with 403
199
206
  `API_KEY_SCOPE_REQUIRED`. Move them to the native resources above.
@@ -228,8 +235,19 @@ await client.workspaces.inviteMember('newuser@company.com', WorkspaceRole.Member
228
235
 
229
236
  ## Webhooks
230
237
 
238
+ Managing webhooks needs a signed-in user's access token. The Gateway refuses API keys on every webhook
239
+ route, reads included (`list()` and `listDeliveryLogs()` as well as create, update, delete, `rotateSecret()`
240
+ and `test()`), with `403` `SIGNED_IN_USER_REQUIRED`, whatever the key's scopes. Reads are refused too because
241
+ webhook delivery logs carry each delivery's payload (order and customer data). A client with an API key
242
+ sends the key even when an access token is also set, so use a client configured without `apiKey`.
243
+ Verifying deliveries (below) makes no request and needs no credentials.
244
+
231
245
  ```typescript
232
- import { WebhookEventType } from '@flexops/sdk';
246
+ import { FlexOps, WebhookEventType } from '@flexops/sdk';
247
+
248
+ // Sign in as a user (or pass `accessToken`); an API key gets 403 SIGNED_IN_USER_REQUIRED here.
249
+ const client = new FlexOps({ workspaceId: 'your-workspace-id' });
250
+ await client.auth.login({ email: 'user@company.com', password: 'your-password' });
233
251
 
234
252
  // Create a subscription. Omit `events` to receive every event.
235
253
  const webhook = await client.webhooks.create({
@@ -459,6 +477,12 @@ const returns = await client.analytics.returnsMetrics();
459
477
  const performance = await client.analytics.deliveryPerformance();
460
478
  ```
461
479
 
480
+ `client.analytics`, `client.orders` and `client.inventory` read through the legacy pass-through. With
481
+ an API key they need the permission for the data they read: `orders:read` for `client.orders`,
482
+ `inventory:read` for `client.inventory`, and for `client.analytics` the permission named on each
483
+ method (`shipping:read`, `inventory:read`, `orders:read` or `returns:read`). A key without it gets
484
+ 403 `API_KEY_SCOPE_REQUIRED`. Keys created with the default permissions have all of these.
485
+
462
486
  ## Automation Rules
463
487
 
464
488
  ```typescript
package/dist/index.d.mts CHANGED
@@ -701,6 +701,14 @@ interface MultiPackageShipmentRequest {
701
701
  * (400 `HazmatNotSupported`); buy those labels one at a time with `shipping.createLabel`.
702
702
  */
703
703
  hazmatClassification?: typeof HazmatClassification.None;
704
+ /**
705
+ * The most the whole shipment may cost, in USD: required, positive, with at most two decimals. It covers the
706
+ * postage of every box. The Gateway refuses to buy a box that would take the total above it, so you never pay
707
+ * more: a box priced above what is left reports `PriceCeilingExceeded`, and once the amount is used up the
708
+ * remaining boxes report `PriceCeilingReached` and are not bought. Boxes already bought stay bought. A missing
709
+ * or invalid value is 400 `ApprovalRequired`. It is part of the request the `Idempotency-Key` identifies.
710
+ */
711
+ maximumPostageAmount: number;
704
712
  /** 1 to 99 boxes. */
705
713
  packages: MultiPackageDetail[];
706
714
  }
@@ -815,14 +823,79 @@ interface PickupConfirmation {
815
823
  errorMessage?: string | null;
816
824
  isSandbox: boolean;
817
825
  }
826
+ /** Body of `POST /api/workspaces/{workspaceId}/scan-forms`. */
818
827
  interface ScanFormRequest {
828
+ /** Tracking numbers of the labels to put on the form: 1 to 1,000. */
819
829
  trackingNumbers: string[];
830
+ /**
831
+ * The labels' mailing date, `YYYY-MM-DD`. Live creation needs it: without it the Gateway answers
832
+ * 400 `Choose the label mailing date.` The sandbox defaults to today (UTC). Optional here so code
833
+ * written for the sandbox keeps compiling.
834
+ */
835
+ manifestDate?: string;
836
+ /**
837
+ * Identifies the operation (a UUID). Repeating a request with the same `requestId` returns the same
838
+ * form instead of creating another; reusing it with different inputs is 409. Keep it with the request
839
+ * to retry it yourself. When omitted, `scanForms.create` generates one per call and sends it on every
840
+ * retry of that call.
841
+ */
842
+ requestId?: string;
843
+ /** The origin ZIP group to manifest. Every selected package must ship from it. */
844
+ originPostalCode?: string;
845
+ /** Limits package selection to one warehouse. */
846
+ warehouseId?: number;
820
847
  }
848
+ /**
849
+ * Where a SCAN form operation stands. `Created`: USPS returned the manifest, and the Gateway saved its number and
850
+ * PDF. `OutcomeUnknown`: the carrier's answer was lost or did not match, so the packages stay reserved and must not
851
+ * be submitted again until the outcome is resolved. Other values may be added; treat them like `OutcomeUnknown`.
852
+ */
853
+ type ScanFormState = 'Created' | 'OutcomeUnknown' | (string & {});
854
+ /**
855
+ * A SCAN form (USPS PS Form 5630 manifest) as the Gateway returns it from `scanForms.create()`, `list()` and
856
+ * `get()`. `create()` resolves only for a created form: an operation that needs review, a `requestId` reused with
857
+ * different inputs, or packages already on another manifest reject with a 409 {@link FlexOpsError}.
858
+ */
821
859
  interface ScanForm {
860
+ /** The form's ID: 32 hexadecimal digits, no dashes. Pass it to `scanForms.get()`. */
822
861
  scanFormId: string;
823
- formData: string;
862
+ /** See {@link ScanFormState}. */
863
+ state: ScanFormState;
864
+ /** The origin ZIP the packages ship from, or null when none was recorded. */
865
+ originPostalCode: string | null;
866
+ /** The packages on the form, in ordinal order. */
824
867
  trackingNumbers: string[];
825
- createdAt: string;
868
+ /** When the operation was recorded, ISO 8601 in UTC (for example `2026-09-08T21:14:03.512Z`). */
869
+ createdAtUtc: string;
870
+ /**
871
+ * The PS Form 5630 PDF, base64-encoded. Null when no PDF was saved: sandbox forms are never sent to USPS, and an
872
+ * operation whose outcome is unknown has none.
873
+ */
874
+ scanFormImage: string | null;
875
+ /** The USPS manifest number. `SBOX…` in the sandbox; empty while the outcome is unknown. */
876
+ manifestNumber: string | null;
877
+ /** The mailing date, as the Gateway writes a date without a zone (for example `2026-09-08T00:00:00`). */
878
+ manifestDate: string | null;
879
+ /** How many packages the form covers. */
880
+ packageCount: number;
881
+ /** A status line for people, for example `Created — USPS acceptance requires a carrier scan.` */
882
+ statusMessage: string | null;
883
+ /** True when `state` is `Created`. */
884
+ success: boolean;
885
+ /** Not set by the current Gateway; errors arrive as a rejected {@link FlexOpsError} instead. */
886
+ errorMessage: string | null;
887
+ /** True for a sandbox (test key) form, which is never transmitted to USPS. */
888
+ isSandbox: boolean;
889
+ /**
890
+ * @deprecated The Gateway never sent `formData`. The SDK now copies `scanFormImage` into it so older code keeps
891
+ * working; read `scanFormImage` instead.
892
+ */
893
+ formData?: string;
894
+ /**
895
+ * @deprecated The Gateway never sent `createdAt`. The SDK now copies `createdAtUtc` into it so older code keeps
896
+ * working; read `createdAtUtc` instead.
897
+ */
898
+ createdAt?: string;
826
899
  }
827
900
  interface CarrierRecommendationRequest {
828
901
  originPostalCode: string;
@@ -1151,7 +1224,7 @@ declare class HttpClient {
1151
1224
  post<T>(path: string, body?: unknown, query?: Record<string, string | number | boolean | undefined>): Promise<T>;
1152
1225
  put<T>(path: string, body?: unknown): Promise<T>;
1153
1226
  patch<T>(path: string, body?: unknown): Promise<T>;
1154
- delete<T>(path: string): Promise<T>;
1227
+ delete<T>(path: string, query?: Record<string, string | number | boolean | undefined>): Promise<T>;
1155
1228
  private buildUrl;
1156
1229
  private buildHeaders;
1157
1230
  /**
@@ -1195,11 +1268,11 @@ declare class WorkspacesResource {
1195
1268
  get(workspaceId?: string): Promise<ApiResponse<WorkspaceDetail>>;
1196
1269
  /** List the current workspace's members and pending invites. */
1197
1270
  listMembers(): Promise<ApiResponse<WorkspaceMemberList>>;
1198
- /** Invite a user to the workspace. */
1271
+ /** Invite a user to the workspace. Signed-in users only: API keys get 403 `SIGNED_IN_USER_REQUIRED`, whatever their scopes. */
1199
1272
  inviteMember(email: string, role?: WorkspaceRole): Promise<ApiResponse<unknown>>;
1200
- /** Remove a member from the workspace. */
1273
+ /** Remove a member from the workspace. Signed-in users only: API keys get 403 `SIGNED_IN_USER_REQUIRED`, whatever their scopes. */
1201
1274
  removeMember(userId: string): Promise<ApiResponse<unknown>>;
1202
- /** Change a member's role. */
1275
+ /** Change a member's role. Signed-in users only: API keys get 403 `SIGNED_IN_USER_REQUIRED`, whatever their scopes. */
1203
1276
  updateMemberRole(userId: string, role: WorkspaceRole): Promise<ApiResponse<unknown>>;
1204
1277
  }
1205
1278
 
@@ -1255,6 +1328,10 @@ declare class ShippingResource {
1255
1328
  * a label may exist: both throw a `FlexOpsError` whose `data` is the `MultiPackageShipmentResponse`.
1256
1329
  * After `OutcomeUnknown`, check the order before buying again.
1257
1330
  *
1331
+ * `maximumPostageAmount` is required: the most the whole shipment may cost in USD. The Gateway refuses to buy
1332
+ * any box that would take the total above it (that box reports `PriceCeilingExceeded`; boxes after the
1333
+ * ceiling is used up report `PriceCeilingReached`), and a request without a valid one is 400 `ApprovalRequired`.
1334
+ *
1258
1335
  * `hazmatClassification` accepts only `HazmatClassification.None` or nothing. Pass a stable
1259
1336
  * `idempotencyKey` to retry safely across processes; otherwise one is generated for this call.
1260
1337
  */
@@ -1273,8 +1350,12 @@ declare class ShippingResource {
1273
1350
  * Direct carrier operations via the VisionSuite Core Services API proxy.
1274
1351
  *
1275
1352
  * Pass-throughs to carrier-specific endpoints (USPS, UPS, FedEx, DHL) via the Gateway's legacy
1276
- * ApiProxy route, deprecated and sunset on 2027-06-30. The GET lookups work with API keys. The
1277
- * writes are marked deprecated: they need a user token (`auth.login`), because the Gateway refuses
1353
+ * ApiProxy route, deprecated and sunset on 2027-06-30. The GET lookups work with API keys that
1354
+ * have the permission for the data they read: address, ZIP, city, location, service point and
1355
+ * reference lookups require `shipping:read`; tracking and proof of delivery require
1356
+ * `tracking:read`; delivery standards, rates and products require `rates:read`. A key without the
1357
+ * permission gets 403 `API_KEY_SCOPE_REQUIRED`; keys created with the default permissions have all
1358
+ * three. The writes are marked deprecated: they need a user token (`auth.login`), because the Gateway refuses
1278
1359
  * API-key writes on the proxy with 403 `API_KEY_SCOPE_REQUIRED`. Label purchases through the proxy are
1279
1360
  * closed (410); rates, labels, voids, pickups and scan forms go through `client.shipping`,
1280
1361
  * `client.pickups` and `client.scanForms` for every carrier.
@@ -1335,19 +1416,21 @@ declare class CarriersResource {
1335
1416
  /**
1336
1417
  * Cancel a domestic label.
1337
1418
  *
1419
+ * @param trackingNumber The label's tracking number.
1338
1420
  * @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
1339
1421
  * `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
1340
1422
  * cover this.
1341
1423
  */
1342
- cancelDomesticLabel: () => Promise<unknown>;
1424
+ cancelDomesticLabel: (trackingNumber: string) => Promise<unknown>;
1343
1425
  /**
1344
1426
  * Cancel an international label.
1345
1427
  *
1428
+ * @param internationalTrackingNumber The label's international tracking number.
1346
1429
  * @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
1347
1430
  * `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
1348
1431
  * cover this.
1349
1432
  */
1350
- cancelInternationalLabel: () => Promise<unknown>;
1433
+ cancelInternationalLabel: (internationalTrackingNumber: string) => Promise<unknown>;
1351
1434
  /** Get tracking summary. */
1352
1435
  trackSummary: (params: Record<string, string>) => Promise<unknown>;
1353
1436
  /** Get detailed tracking info. */
@@ -1363,11 +1446,12 @@ declare class CarriersResource {
1363
1446
  /**
1364
1447
  * Cancel a pickup.
1365
1448
  *
1449
+ * @param confirmationNumber The pickup's confirmation number.
1366
1450
  * @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
1367
1451
  * `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
1368
1452
  * cover this.
1369
1453
  */
1370
- cancelPickup: () => Promise<unknown>;
1454
+ cancelPickup: (confirmationNumber: string) => Promise<unknown>;
1371
1455
  /**
1372
1456
  * Create a scan form.
1373
1457
  *
@@ -1689,33 +1773,78 @@ declare class CarriersResource {
1689
1773
  };
1690
1774
  }
1691
1775
 
1776
+ /**
1777
+ * Webhook subscriptions for the workspace.
1778
+ *
1779
+ * Every method that calls the Gateway needs a signed-in user's access token (`accessToken`,
1780
+ * `setAccessToken()` or `auth.login()`). The Gateway refuses API keys on every webhook route, reads
1781
+ * included, with `403` `SIGNED_IN_USER_REQUIRED` (a {@link FlexOpsError} whose `code` is
1782
+ * `SIGNED_IN_USER_REQUIRED`), whatever the key's scopes. Reads are refused too because webhook delivery
1783
+ * logs carry each delivery's payload (order and customer data). A client with an API key sends the key
1784
+ * even when an access token is also set, so call these methods from a client configured without `apiKey`.
1785
+ *
1786
+ * {@link WebhooksResource.verifySignature} makes no request and needs no credentials.
1787
+ */
1692
1788
  declare class WebhooksResource {
1693
1789
  private readonly http;
1694
1790
  private readonly getWorkspaceId;
1695
1791
  constructor(http: HttpClient, getWorkspaceId: () => string | undefined);
1696
1792
  private wsPath;
1697
- /** List all webhook subscriptions for the workspace. */
1793
+ /**
1794
+ * List all webhook subscriptions for the workspace.
1795
+ *
1796
+ * Needs a signed-in user's access token. Reads are signed-in only, like the writes, because webhook
1797
+ * delivery logs carry each delivery's payload (order and customer data).
1798
+ * @throws FlexOpsError (`403`, `SIGNED_IN_USER_REQUIRED`) when the client authenticates with an API key.
1799
+ */
1698
1800
  list(): Promise<ApiResponse<WebhookSubscription[]>>;
1699
1801
  /**
1700
1802
  * Create a webhook subscription. `events` is sent as the Gateway's comma-separated `eventTypes`;
1701
1803
  * omit it to receive every event. The result's `data.secret` is the signing secret, returned only here.
1804
+ *
1805
+ * Needs a signed-in user's access token.
1702
1806
  * @throws FlexOpsError (`UnknownWebhookEvent`) when `events` is empty or names an event FlexOps does not send.
1807
+ * @throws FlexOpsError (`403`, `SIGNED_IN_USER_REQUIRED`) when the client authenticates with an API key.
1703
1808
  */
1704
1809
  create(request: CreateWebhookRequest): Promise<ApiResponse<WebhookSubscription>>;
1705
1810
  /**
1706
1811
  * Update a webhook subscription. `events`, when given, replaces the subscribed events.
1812
+ *
1813
+ * Needs a signed-in user's access token.
1707
1814
  * @throws FlexOpsError (`UnknownWebhookEvent`) when `events` is empty or names an event FlexOps does not send.
1815
+ * @throws FlexOpsError (`403`, `SIGNED_IN_USER_REQUIRED`) when the client authenticates with an API key.
1708
1816
  */
1709
1817
  update(webhookId: string, data: UpdateWebhookRequest): Promise<ApiResponse<WebhookSubscription>>;
1710
- /** Delete a webhook subscription. The Gateway answers 204 No Content, so there is no result. */
1818
+ /**
1819
+ * Delete a webhook subscription. The Gateway answers 204 No Content, so there is no result.
1820
+ *
1821
+ * Needs a signed-in user's access token.
1822
+ * @throws FlexOpsError (`403`, `SIGNED_IN_USER_REQUIRED`) when the client authenticates with an API key.
1823
+ */
1711
1824
  delete(webhookId: string): Promise<void>;
1712
- /** Rotate the signing secret for a webhook. */
1825
+ /**
1826
+ * Rotate the signing secret for a webhook.
1827
+ *
1828
+ * Needs a signed-in user's access token.
1829
+ * @throws FlexOpsError (`403`, `SIGNED_IN_USER_REQUIRED`) when the client authenticates with an API key.
1830
+ */
1713
1831
  rotateSecret(webhookId: string): Promise<ApiResponse<{
1714
1832
  secret: string;
1715
1833
  }>>;
1716
- /** List delivery logs for a webhook. */
1834
+ /**
1835
+ * List delivery logs for a webhook.
1836
+ *
1837
+ * Needs a signed-in user's access token. Reads are signed-in only, like the writes, because webhook
1838
+ * delivery logs carry each delivery's payload (order and customer data).
1839
+ * @throws FlexOpsError (`403`, `SIGNED_IN_USER_REQUIRED`) when the client authenticates with an API key.
1840
+ */
1717
1841
  listDeliveryLogs(webhookId: string): Promise<ApiResponse<unknown[]>>;
1718
- /** Send a test event to a webhook's endpoint. */
1842
+ /**
1843
+ * Send a test event to a webhook's endpoint.
1844
+ *
1845
+ * Needs a signed-in user's access token.
1846
+ * @throws FlexOpsError (`403`, `SIGNED_IN_USER_REQUIRED`) when the client authenticates with an API key.
1847
+ */
1719
1848
  test(webhookId: string): Promise<ApiResponse<unknown>>;
1720
1849
  /**
1721
1850
  * Verify that an incoming request is a genuine FlexOps webhook delivery.
@@ -1827,46 +1956,61 @@ type DateRange = {
1827
1956
  endDate?: string;
1828
1957
  period?: 'day' | 'week' | 'month';
1829
1958
  };
1959
+ /**
1960
+ * Analytics through the legacy VisionSuite API proxy (`/api/ApiProxy/api/v4/Analytics/...`).
1961
+ *
1962
+ * With an API key, each method requires the permission for the data it reads, named on the method:
1963
+ * `shipping:read` for shipment, carrier and delivery metrics, `inventory:read` for inventory metrics,
1964
+ * `orders:read` for order metrics and `returns:read` for returns metrics. A key without it gets 403
1965
+ * `API_KEY_SCOPE_REQUIRED`. Keys created with the default permissions have all four.
1966
+ */
1830
1967
  declare class AnalyticsResource {
1831
1968
  private readonly http;
1832
1969
  constructor(http: HttpClient);
1833
1970
  private path;
1834
- /** Shipments trend over time. */
1971
+ /** Shipments trend over time. With an API key, requires `shipping:read`. */
1835
1972
  shipmentsTrend(params?: DateRange): Promise<ApiResponse<ShipmentsTrend[]>>;
1836
- /** Carrier usage summary. */
1973
+ /** Carrier usage summary. With an API key, requires `shipping:read`. */
1837
1974
  carrierSummary(params?: DateRange): Promise<ApiResponse<CarrierSummary[]>>;
1838
- /** Top shipping destinations. */
1975
+ /** Top shipping destinations. With an API key, requires `shipping:read`. */
1839
1976
  topDestinations(params?: DateRange & {
1840
1977
  limit?: number;
1841
1978
  }): Promise<ApiResponse<unknown>>;
1842
- /** Inventory metrics (stock levels, low-stock alerts). */
1979
+ /** Inventory metrics (stock levels, low-stock alerts). With an API key, requires `inventory:read`. */
1843
1980
  inventoryMetrics(): Promise<ApiResponse<unknown>>;
1844
- /** Stock levels by warehouse. */
1981
+ /** Stock levels by warehouse. With an API key, requires `inventory:read`. */
1845
1982
  stockByWarehouse(): Promise<ApiResponse<unknown>>;
1846
- /** Order metrics (volume, revenue). */
1983
+ /** Order metrics (volume, revenue). With an API key, requires `orders:read`. */
1847
1984
  orderMetrics(params?: DateRange): Promise<ApiResponse<unknown>>;
1848
- /** Order trend over time. */
1985
+ /** Order trend over time. With an API key, requires `orders:read`. */
1849
1986
  orderTrend(params?: DateRange): Promise<ApiResponse<unknown>>;
1850
- /** Top selling products. */
1987
+ /** Top selling products. With an API key, requires `orders:read`. */
1851
1988
  topSellingProducts(params?: DateRange & {
1852
1989
  limit?: number;
1853
1990
  }): Promise<ApiResponse<unknown>>;
1854
- /** Returns metrics. */
1991
+ /** Returns metrics. With an API key, requires `returns:read`. */
1855
1992
  returnsMetrics(params?: DateRange): Promise<ApiResponse<unknown>>;
1856
- /** Returns trend over time. */
1993
+ /** Returns trend over time. With an API key, requires `returns:read`. */
1857
1994
  returnsTrend(params?: DateRange): Promise<ApiResponse<unknown>>;
1858
- /** Return reasons breakdown. */
1995
+ /** Return reasons breakdown. With an API key, requires `returns:read`. */
1859
1996
  returnReasons(params?: DateRange): Promise<ApiResponse<unknown>>;
1860
- /** Fulfillment performance metrics. */
1997
+ /** Fulfillment performance metrics. With an API key, requires `shipping:read`. */
1861
1998
  performanceMetrics(params?: DateRange): Promise<ApiResponse<unknown>>;
1862
- /** Carrier delivery performance. */
1999
+ /** Carrier delivery performance. With an API key, requires `shipping:read`. */
1863
2000
  carrierPerformance(params?: DateRange): Promise<ApiResponse<unknown>>;
1864
- /** Shipping cost analytics. */
2001
+ /** Shipping cost analytics. With an API key, requires `shipping:read`. */
1865
2002
  shippingCostAnalytics(params?: DateRange): Promise<ApiResponse<unknown>>;
1866
- /** Delivery performance (on-time %). */
2003
+ /** Delivery performance (on-time %). With an API key, requires `shipping:read`. */
1867
2004
  deliveryPerformance(params?: DateRange): Promise<ApiResponse<unknown>>;
1868
2005
  }
1869
2006
 
2007
+ /**
2008
+ * Read-only order lookups through the legacy VisionSuite API proxy (`/api/ApiProxy/api/v1/Order/...`).
2009
+ *
2010
+ * With an API key, every method requires the `orders:read` permission; a key without it gets 403
2011
+ * `API_KEY_SCOPE_REQUIRED`. Keys created with the default permissions include `orders:read`. The
2012
+ * proxy refuses writes from API keys.
2013
+ */
1870
2014
  declare class OrdersResource {
1871
2015
  private readonly http;
1872
2016
  constructor(http: HttpClient);
@@ -1893,6 +2037,14 @@ declare class OrdersResource {
1893
2037
  getStatusTypes(): Promise<ApiResponse<unknown>>;
1894
2038
  }
1895
2039
 
2040
+ /**
2041
+ * Read-only inventory lookups through the legacy VisionSuite API proxy
2042
+ * (`/api/ApiProxy/api/v1/Inventory/...`).
2043
+ *
2044
+ * With an API key, every method requires the `inventory:read` permission; a key without it gets 403
2045
+ * `API_KEY_SCOPE_REQUIRED`. Keys created with the default permissions include `inventory:read`. The
2046
+ * proxy refuses writes from API keys.
2047
+ */
1896
2048
  declare class InventoryResource {
1897
2049
  private readonly http;
1898
2050
  constructor(http: HttpClient);
@@ -1909,13 +2061,13 @@ declare class PickupsResource {
1909
2061
  private readonly getWorkspaceId;
1910
2062
  constructor(http: HttpClient, getWorkspaceId: () => string | undefined);
1911
2063
  private wsPath;
1912
- /** Schedule a carrier pickup. */
2064
+ /** Schedule a carrier pickup. API keys need `shipping:write`; the public demo keys are refused. */
1913
2065
  schedule(request: PickupRequest): Promise<ApiResponse<PickupConfirmation>>;
1914
2066
  /** List scheduled pickups. */
1915
2067
  list(): Promise<ApiResponse<PickupConfirmation[]>>;
1916
2068
  /** Get pickup details. The carrier defaults to `usps` on the Gateway. */
1917
2069
  get(pickupId: string, carrierCode?: string): Promise<ApiResponse<PickupConfirmation>>;
1918
- /** Cancel a scheduled pickup. */
2070
+ /** Cancel a scheduled pickup. API keys need `shipping:write`; the public demo keys are refused. */
1919
2071
  cancel(pickupId: string): Promise<ApiResponse<unknown>>;
1920
2072
  }
1921
2073
 
@@ -1924,11 +2076,20 @@ declare class ScanFormsResource {
1924
2076
  private readonly getWorkspaceId;
1925
2077
  constructor(http: HttpClient, getWorkspaceId: () => string | undefined);
1926
2078
  private wsPath;
1927
- /** Create a USPS scan form (SCAN/manifest). */
2079
+ /**
2080
+ * Create a USPS scan form (SCAN/manifest). API keys need `shipping:write`; the public demo keys are refused.
2081
+ * Sends `request.requestId`, or a UUID generated for this call, on every attempt, so a retried call replays
2082
+ * the same operation instead of creating a second form.
2083
+ *
2084
+ * Resolves with the created form (200), also when the same `requestId` and inputs are sent again. Rejects with a
2085
+ * 409 {@link FlexOpsError} when the `requestId` was used with different inputs, when the packages already belong
2086
+ * to a manifest, or when this or an earlier operation needs review (its message names the operation; do not
2087
+ * resubmit those packages). 400 means the request or package selection was refused.
2088
+ */
1928
2089
  create(request: ScanFormRequest): Promise<ApiResponse<ScanForm>>;
1929
- /** List scan forms. */
2090
+ /** List the workspace's saved scan forms, newest mailing date first, including any whose outcome is unknown. */
1930
2091
  list(): Promise<ApiResponse<ScanForm[]>>;
1931
- /** Get a scan form by ID. */
2092
+ /** Get a saved scan form by its `scanFormId`. A form that does not exist rejects with a 404 {@link FlexOpsError}. */
1932
2093
  get(scanFormId: string): Promise<ApiResponse<ScanForm>>;
1933
2094
  }
1934
2095
 
@@ -1941,15 +2102,24 @@ declare class RulesResource {
1941
2102
  list(): Promise<ApiResponse<ShippingRule[]>>;
1942
2103
  /** Get a rule by ID. */
1943
2104
  get(ruleId: string): Promise<ApiResponse<ShippingRule>>;
1944
- /** Create a shipping rule. */
2105
+ /** Create a shipping rule. Signed-in users only: API keys get 403 `SIGNED_IN_USER_REQUIRED`, whatever their scopes. */
1945
2106
  create(rule: ShippingRuleInput): Promise<ApiResponse<ShippingRule>>;
1946
- /** Replace a shipping rule. */
2107
+ /** Replace a shipping rule. Signed-in users only: API keys get 403 `SIGNED_IN_USER_REQUIRED`, whatever their scopes. */
1947
2108
  update(ruleId: string, rule: ShippingRuleInput): Promise<ApiResponse<ShippingRule>>;
1948
- /** Delete a shipping rule. The Gateway answers 204 No Content, so there is no result. */
2109
+ /**
2110
+ * Delete a shipping rule. The Gateway answers 204 No Content, so there is no result.
2111
+ * Signed-in users only: API keys get 403 `SIGNED_IN_USER_REQUIRED`, whatever their scopes.
2112
+ */
1949
2113
  delete(ruleId: string): Promise<void>;
1950
- /** Reorder rules: each listed rule gets its position in `ruleIds` as its priority (0 first). */
2114
+ /**
2115
+ * Reorder rules: each listed rule gets its position in `ruleIds` as its priority (0 first).
2116
+ * Signed-in users only: API keys get 403 `SIGNED_IN_USER_REQUIRED`, whatever their scopes.
2117
+ */
1951
2118
  reorder(ruleIds: string[]): Promise<ApiResponse<ShippingRule[]>>;
1952
- /** Dry-run the workspace's rules against a sample shipment, without changing anything. */
2119
+ /**
2120
+ * Dry-run the workspace's rules against a sample shipment, without changing anything.
2121
+ * API keys need `shipping:read`; the public demo keys are refused.
2122
+ */
1953
2123
  test(request: ShippingRuleTestRequest): Promise<ApiResponse<unknown>>;
1954
2124
  }
1955
2125
 
@@ -2135,6 +2305,7 @@ declare class FlexOps {
2135
2305
  readonly workspaces: WorkspacesResource;
2136
2306
  readonly shipping: ShippingResource;
2137
2307
  readonly carriers: CarriersResource;
2308
+ /** Webhook subscriptions. Needs a signed-in user's access token; API keys get `403` `SIGNED_IN_USER_REQUIRED`. */
2138
2309
  readonly webhooks: WebhooksResource;
2139
2310
  readonly wallet: WalletResource;
2140
2311
  readonly insurance: InsuranceResource;
@@ -2161,4 +2332,4 @@ declare class FlexOps {
2161
2332
  }
2162
2333
 
2163
2334
  export { AnalyticsResource, AuthResource, CarbonOffsetsResource, CarriersResource, EmailTemplatesResource, FlexOps, FlexOpsAuthError, FlexOpsError, FlexOpsRateLimitError, HazmatClassification, HsCodesResource, InsuranceResource, InventoryResource, OrdersResource, PickupsResource, RecurrenceInterval, RecurringShipmentsResource, ReportFormat, ReportFrequency, ReportSchedulesResource, ReturnsResource, RulesResource, ScanFormsResource, ShippingResource, TrackingEmailEvent, WalletResource, WebhookEventType, WebhooksResource, WorkspaceRole, WorkspacesResource };
2164
- export type { Address, AddressValidationResult, ApiResponse, BatchLabelItem, BatchLabelItemResult, BatchLabelJob, BatchLabelRequest, CanonicalLabelRequest, CanonicalRateRequest, CarbonOffset, CarbonOffsetPurchaseRequest, CarbonOffsetQuote, CarbonOffsetQuoteRequest, CarbonOffsetSettings, CarbonOffsetSummary, CarrierRecommendation, CarrierRecommendationRequest, CarrierRecommendationResponse, CarrierSummary, CostSavingsSummary, CreateBatchLabelRequest, CreateLabelRequest, CreateRecurringShipmentRequest, CreateReportScheduleRequest, CreateWebhookRequest, CustomsItem, DeliveryPredictionRequest, DeliveryPredictionResponse, EmailTemplate, EmailTemplatePreview, EmailTemplatePreviewRequest, FileClaimRequest, FlexOpsConfig, HsCodeResult, InsuranceClaim, InsurancePolicy, InsuranceQuote, InsuranceQuoteRequest, Label, LabelPurchaseApproval, LabelPurchasePreview, LandedCostEstimate, LandedCostRequest, LaneSavingsOpportunity, LegacyRateRequest, LoginRequest, LoginResponse, MultiPackageDetail, MultiPackageLabelResult, MultiPackageShipmentRequest, MultiPackageShipmentResponse, Order, OrderItem, PaginatedResponse, Parcel, PendingInvite, PickupConfirmation, PickupRequest, PurchaseInsuranceRequest, RateRequest, ReceiveReturnRequest, RecurringShipment, ReportSchedule, RetryConfig, ReturnAuthorization, ReturnDetail, ReturnDisposition, ReturnItem, ReturnLabel, ReturnLabelRequest, ReturnRequest, ReturnSummary, Rma, RmaItem, RuleAction, RuleCondition, ScanForm, ScanFormRequest, ShipmentsTrend, ShippingAddress, ShippingPackage, ShippingRate, ShippingRule, ShippingRuleInput, ShippingRuleTestRequest, SuggestedAddress, TrackingEvent, TrackingInfo, UpdateRecurringShipmentRequest, UpdateReportScheduleRequest, UpdateWebhookRequest, UpsertEmailTemplateRequest, VerifySignatureOptions, WalletBalance, WebhookSubscription, Workspace, WorkspaceDetail, WorkspaceMember, WorkspaceMemberList };
2335
+ export type { Address, AddressValidationResult, ApiResponse, BatchLabelItem, BatchLabelItemResult, BatchLabelJob, BatchLabelRequest, CanonicalLabelRequest, CanonicalRateRequest, CarbonOffset, CarbonOffsetPurchaseRequest, CarbonOffsetQuote, CarbonOffsetQuoteRequest, CarbonOffsetSettings, CarbonOffsetSummary, CarrierRecommendation, CarrierRecommendationRequest, CarrierRecommendationResponse, CarrierSummary, CostSavingsSummary, CreateBatchLabelRequest, CreateLabelRequest, CreateRecurringShipmentRequest, CreateReportScheduleRequest, CreateWebhookRequest, CustomsItem, DeliveryPredictionRequest, DeliveryPredictionResponse, EmailTemplate, EmailTemplatePreview, EmailTemplatePreviewRequest, FileClaimRequest, FlexOpsConfig, HsCodeResult, InsuranceClaim, InsurancePolicy, InsuranceQuote, InsuranceQuoteRequest, Label, LabelPurchaseApproval, LabelPurchasePreview, LandedCostEstimate, LandedCostRequest, LaneSavingsOpportunity, LegacyRateRequest, LoginRequest, LoginResponse, MultiPackageDetail, MultiPackageLabelResult, MultiPackageShipmentRequest, MultiPackageShipmentResponse, Order, OrderItem, PaginatedResponse, Parcel, PendingInvite, PickupConfirmation, PickupRequest, PurchaseInsuranceRequest, RateRequest, ReceiveReturnRequest, RecurringShipment, ReportSchedule, RetryConfig, ReturnAuthorization, ReturnDetail, ReturnDisposition, ReturnItem, ReturnLabel, ReturnLabelRequest, ReturnRequest, ReturnSummary, Rma, RmaItem, RuleAction, RuleCondition, ScanForm, ScanFormRequest, ScanFormState, ShipmentsTrend, ShippingAddress, ShippingPackage, ShippingRate, ShippingRule, ShippingRuleInput, ShippingRuleTestRequest, SuggestedAddress, TrackingEvent, TrackingInfo, UpdateRecurringShipmentRequest, UpdateReportScheduleRequest, UpdateWebhookRequest, UpsertEmailTemplateRequest, VerifySignatureOptions, WalletBalance, WebhookSubscription, Workspace, WorkspaceDetail, WorkspaceMember, WorkspaceMemberList };