@flexops/sdk 3.0.0 → 3.2.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
@@ -28,7 +28,7 @@ npm install @flexops/sdk
28
28
  import { FlexOps, HazmatClassification } from '@flexops/sdk';
29
29
 
30
30
  const client = new FlexOps({
31
- apiKey: 'fxk_live_...',
31
+ apiKey: 'live_...',
32
32
  workspaceId: 'your-workspace-id',
33
33
  });
34
34
  ```
@@ -124,19 +124,66 @@ if (result.validationUnavailable) {
124
124
 
125
125
  ### Batch Labels
126
126
 
127
+ Each item is an order you already have in FlexOps; the addresses come from the order. Leave out
128
+ `carrierCode` and `serviceCode` to let your shipping rules choose.
129
+
127
130
  ```typescript
128
- // Preview (dry-run) before purchasing
129
- const preview = await client.shipping.previewBatch({
130
- items: [/* array of CreateLabelRequest */],
131
- });
131
+ import { HazmatClassification, type CreateBatchLabelRequest } from '@flexops/sdk';
132
+
133
+ const request: CreateBatchLabelRequest = {
134
+ items: [
135
+ {
136
+ orderId: 12345,
137
+ packageWeightInOunces: 12,
138
+ packageLengthInInches: 10,
139
+ packageWidthInInches: 8,
140
+ packageHeightInInches: 4,
141
+ carrierCode: 'USPS',
142
+ serviceCode: 'PRIORITY',
143
+ hazmatClassification: HazmatClassification.None,
144
+ },
145
+ ],
146
+ };
132
147
 
133
- // Create the batch
134
- const batch = await client.shipping.createBatch({
135
- items: [/* array of CreateLabelRequest */],
136
- });
148
+ // Preview (dry-run): per-order rates and the total, nothing bought
149
+ const preview = await client.shipping.previewBatch(request);
150
+
151
+ // Create the batch; it runs in the background
152
+ const batch = await client.shipping.createBatch(request);
137
153
 
138
154
  // Check status
139
- const status = await client.shipping.getBatchStatus(batch.data.jobId);
155
+ const status = await client.shipping.getBatchStatus(batch.data!.jobId);
156
+ ```
157
+
158
+ ### Multi-Package Labels
159
+
160
+ One order shipped in several boxes with the same carrier and service. Each box gets its own label;
161
+ a box that fails does not stop the others. Multi-package labels cannot carry HAZMAT: send
162
+ `HazmatClassification.None` or leave `hazmatClassification` out.
163
+
164
+ ```typescript
165
+ import { FlexOpsError, HazmatClassification } from '@flexops/sdk';
166
+
167
+ try {
168
+ const shipment = await client.shipping.createMultiPackage(
169
+ {
170
+ orderId: 12345,
171
+ carrierCode: 'USPS',
172
+ serviceCode: 'PRIORITY',
173
+ hazmatClassification: HazmatClassification.None,
174
+ packages: [
175
+ { weightInOunces: 16, lengthInInches: 10, widthInInches: 8, heightInInches: 4, packageReference: 'Box 1 of 2' },
176
+ { weightInOunces: 8, lengthInInches: 6, widthInInches: 6, heightInInches: 6, packageReference: 'Box 2 of 2' },
177
+ ],
178
+ },
179
+ 'order-12345-boxes', // optional Idempotency-Key, reuse it when you retry
180
+ );
181
+ // At least one label was bought; check each box
182
+ for (const box of shipment.data!.labels) console.log(box.packageIndex, box.success, box.trackingNumber ?? box.errorMessage);
183
+ } catch (error) {
184
+ // No label was bought: 422 AllPackagesFailed, or 409 OutcomeUnknown when a label may exist (check the order first).
185
+ if (error instanceof FlexOpsError) console.log(error.code, error.data);
186
+ }
140
187
  ```
141
188
 
142
189
  ## Carrier-Specific Calls
@@ -252,7 +299,7 @@ Every SDK method is a thin wrapper around the FlexOps REST API. If you want to v
252
299
  ```bash
253
300
  # Shop rates across all connected carriers
254
301
  curl -X POST https://gateway.flexops.io/api/shipping/rates \
255
- -H "X-API-Key: fxk_live_..." \
302
+ -H "X-API-Key: live_..." \
256
303
  -H "Content-Type: application/json" \
257
304
  -d '{
258
305
  "origin": {"addressLine1": "123 Main St", "city": "New York", "stateProvince": "NY", "postalCode": "10001", "countryCode": "US"},
@@ -262,7 +309,7 @@ curl -X POST https://gateway.flexops.io/api/shipping/rates \
262
309
 
263
310
  # Create a label (hazmatClassification 0 = not hazardous; required when there is no orderId)
264
311
  curl -X POST https://gateway.flexops.io/api/shipping/labels \
265
- -H "X-API-Key: fxk_live_..." \
312
+ -H "X-API-Key: live_..." \
266
313
  -H "Content-Type: application/json" \
267
314
  -d '{
268
315
  "carrierCode": "USPS",
@@ -275,14 +322,14 @@ curl -X POST https://gateway.flexops.io/api/shipping/labels \
275
322
 
276
323
  # Track a shipment
277
324
  curl https://gateway.flexops.io/api/shipping/track/9400111899223456789012 \
278
- -H "X-API-Key: fxk_live_..."
325
+ -H "X-API-Key: live_..."
279
326
 
280
327
  # Cancel (void) a label
281
328
  curl -X DELETE "https://gateway.flexops.io/api/shipping/labels/{labelId}?carrierCode=usps" \
282
- -H "X-API-Key: fxk_live_..."
329
+ -H "X-API-Key: live_..."
283
330
  ```
284
331
 
285
- Use an `fxk_test_...` key instead of `fxk_live_...` to hit the sandbox environment; mock carriers respond, no real charges, no real labels.
332
+ Use a `test_...` key instead of `live_...` to hit the sandbox environment; mock carriers respond, no real charges, no real labels.
286
333
 
287
334
  ## Wallet
288
335
 
@@ -332,22 +379,31 @@ const rma = await client.returns.create({
332
379
  reason: 'Defective product',
333
380
  items: [{ sku: 'WIDGET-001', quantity: 1 }],
334
381
  });
382
+ const { rmaNumber, rmaId } = rma.data!;
383
+
384
+ // Read it back by RMA number, or page through all RMAs
385
+ const current = await client.returns.getRma(rmaNumber);
386
+ const rmas = await client.returns.listRmas({ page: 1, pageSize: 25 });
335
387
 
336
388
  // Generate the return label. Send the package weight and size. Anything left out comes from the
337
389
  // workspace's default shipping preset; with no preset the API answers 400 PackageMeasurementsRequired.
338
- await client.returns.generateLabel('RMA-12345', {
390
+ await client.returns.generateLabel(rmaNumber, {
339
391
  weightOz: 16,
340
392
  lengthIn: 10,
341
393
  widthIn: 8,
342
394
  heightIn: 4,
343
395
  });
344
396
 
345
- // Record the inspected items at a warehouse (disposition 0 restock, 1 refurbish, 2 dispose)
397
+ // Record the inspected items at a warehouse (disposition 0 restock, 1 dispose, 2 forward)
346
398
  await client.returns.markReceived(rmaId, {
347
- rmaNumber: 'RMA-12345',
399
+ rmaNumber,
348
400
  warehouseId: 1,
349
- inspectedItems: [{ partNumber: 'WIDGET-001', quantity: 1, disposition: 2 }],
401
+ inspectedItems: [{ partNumber: 'WIDGET-001', quantity: 1, disposition: 0 }],
350
402
  });
403
+
404
+ // Received returns: list them, then read one by its numeric return id
405
+ const received = await client.returns.list({ startDate: '2026-10-01' });
406
+ const detail = await client.returns.get(received.data![0].returnId);
351
407
  ```
352
408
 
353
409
  Approving, rejecting, cancelling and refunding returns are done in the FlexOps portal.
@@ -449,7 +505,7 @@ try {
449
505
  ```typescript
450
506
  const client = new FlexOps({
451
507
  baseUrl: 'https://gateway.flexops.io', // Default
452
- apiKey: 'fxk_live_...',
508
+ apiKey: 'live_...',
453
509
  workspaceId: 'ws-abc123',
454
510
  timeout: 30000, // 30s default
455
511
  retry: {
package/dist/index.d.mts CHANGED
@@ -335,17 +335,80 @@ interface SuggestedAddress {
335
335
  postalCode: string;
336
336
  country: string;
337
337
  }
338
+ /** One order in a batch: the Gateway `BatchLabelItemRequest`. Addresses come from the order. */
339
+ interface BatchLabelItem {
340
+ /** The order to ship. Required and positive. */
341
+ orderId: number;
342
+ orderNumber?: string;
343
+ /** Package weight in ounces. The order does not store it. */
344
+ packageWeightInOunces: number;
345
+ packageLengthInInches: number;
346
+ packageWidthInInches: number;
347
+ packageHeightInInches: number;
348
+ /** Leave out the carrier and service to let your shipping rules choose. */
349
+ carrierCode?: string;
350
+ serviceCode?: string;
351
+ deliveryConfirmationRequired?: boolean;
352
+ signatureConfirmationRequired?: boolean;
353
+ insuranceCoverageRequested?: boolean;
354
+ /** Coverage in USD. Needs `insuranceCoverageRequested: true`; left out, the order value is insured. */
355
+ insuredValue?: number;
356
+ labelFormat?: 'PDF' | 'PNG' | 'ZPL';
357
+ shipDate?: string;
358
+ /**
359
+ * What the parcel holds. Batch labels accept only `HazmatClassification.None`; buy HAZMAT
360
+ * labels one at a time with `createLabel`. The SDK never fills it in.
361
+ */
362
+ hazmatClassification?: HazmatClassification;
363
+ }
364
+ /** The Gateway `CreateBatchLabelRequest` for `shipping.createBatch` and `shipping.previewBatch`. */
365
+ interface CreateBatchLabelRequest {
366
+ /** 1 to 2000 orders. */
367
+ items: BatchLabelItem[];
368
+ /** Called when the job finishes. */
369
+ callbackUrl?: string;
370
+ }
371
+ /**
372
+ * @deprecated The Gateway refuses this shape: batch items are orders, not labels. Use
373
+ * CreateBatchLabelRequest.
374
+ */
338
375
  interface BatchLabelRequest {
339
376
  items: CreateLabelRequest[];
340
377
  idempotencyKey?: string;
341
378
  }
342
379
  interface BatchLabelJob {
343
380
  jobId: string;
344
- status: 'Queued' | 'Processing' | 'Completed' | 'Failed';
381
+ status: 'Pending' | 'Processing' | 'Completed' | 'CompletedWithErrors' | 'Failed';
345
382
  totalItems: number;
346
383
  completedItems: number;
347
384
  failedItems: number;
385
+ isDryRun?: boolean;
386
+ /** Total estimated cost; set on a preview. */
387
+ totalEstimatedCost?: number | null;
388
+ /** True when the job ran with a test key: no real labels and no wallet charge. */
389
+ isSandbox?: boolean;
348
390
  createdAt: string;
391
+ completedAt?: string | null;
392
+ statusUrl?: string | null;
393
+ /** One row per order on a preview. */
394
+ previewItems?: BatchLabelItemResult[];
395
+ }
396
+ /** One order's outcome in a batch job. */
397
+ interface BatchLabelItemResult {
398
+ itemId: string;
399
+ orderId: number;
400
+ orderNumber?: string | null;
401
+ carrierCode?: string | null;
402
+ serviceCode?: string | null;
403
+ status: 'Pending' | 'Completed' | 'Failed';
404
+ trackingNumber?: string | null;
405
+ labelUrl?: string | null;
406
+ rate?: number | null;
407
+ errorMessage?: string | null;
408
+ /** Stable refusal code when the item failed, such as `SpendCapReached`. */
409
+ errorCode?: string | null;
410
+ /** True only when the label was clearly not bought, so sending the order again is safe. */
411
+ canRetry?: boolean;
349
412
  }
350
413
  interface Order {
351
414
  orderNumber: string;
@@ -512,7 +575,7 @@ interface ReturnLabelRequest {
512
575
  /** USPS rate indicator for the return label's price tier. */
513
576
  rateIndicator?: string;
514
577
  }
515
- /** How a received item is dispositioned: 0 restock, 1 refurbish, 2 dispose. */
578
+ /** How a received item is dispositioned: 0 restock, 1 dispose, 2 forward. */
516
579
  type ReturnDisposition = 0 | 1 | 2;
517
580
  /** Body of `POST /api/workspaces/{workspaceId}/returns/{rmaId}/receive`. */
518
581
  interface ReceiveReturnRequest {
@@ -526,12 +589,143 @@ interface ReceiveReturnRequest {
526
589
  inspectionNotes?: string;
527
590
  }[];
528
591
  }
592
+ /**
593
+ * @deprecated No Gateway route returns this shape. `returns.create()` and `returns.getRma()` return an
594
+ * `Rma`, `returns.list()` returns `ReturnSummary` rows and `returns.get()` returns a `ReturnDetail`.
595
+ */
529
596
  interface ReturnAuthorization {
530
597
  rmaId: string;
531
598
  status: string;
532
599
  returnLabel?: Label;
533
600
  createdAt: string;
534
601
  }
602
+ /** One item on an RMA or a received return. */
603
+ interface RmaItem {
604
+ sku: string;
605
+ description?: string | null;
606
+ quantity: number;
607
+ unitPrice?: number;
608
+ extendedPrice?: number;
609
+ reason?: string | null;
610
+ }
611
+ /** A return authorization (the Gateway `RmaDto`). `rmaNumber` names it in the label and RMA routes. */
612
+ interface Rma {
613
+ rmaNumber: string;
614
+ /** Numeric RMA id, used by `returns.markReceived()`. */
615
+ rmaId: number;
616
+ orderId: number;
617
+ orderNumber?: string | null;
618
+ customerEmail?: string | null;
619
+ status: string;
620
+ reason?: string | null;
621
+ createdAt: string;
622
+ items: RmaItem[];
623
+ itemCount: number;
624
+ returnLabelTrackingNumber?: string | null;
625
+ notes?: string | null;
626
+ /** Numeric return id once the RMA has been received, used by `returns.get()`. */
627
+ returnId?: number | null;
628
+ dispositionStatus?: string | null;
629
+ appliedRuleId?: string | null;
630
+ appliedRuleName?: string | null;
631
+ requirePhotos?: boolean;
632
+ keepItem?: boolean;
633
+ appliedFeeCents?: number;
634
+ }
635
+ /** A received return (the Gateway `ReturnDto`), as `returns.list()` lists it. */
636
+ interface ReturnSummary {
637
+ returnId: number;
638
+ rmaNumber?: string | null;
639
+ orderId: number;
640
+ status: string;
641
+ returnDate: string;
642
+ dispositionType?: string | null;
643
+ }
644
+ /** A received return with its items (the Gateway `ReturnDetailDto`), from `returns.get()`. */
645
+ interface ReturnDetail extends ReturnSummary {
646
+ items: RmaItem[];
647
+ reason?: string | null;
648
+ notes?: string | null;
649
+ trackingNumber?: string | null;
650
+ carrierCode?: string | null;
651
+ }
652
+ /** A return label (the Gateway `ReturnLabelDto`), from `returns.generateLabel()`. */
653
+ interface ReturnLabel {
654
+ trackingNumber?: string | null;
655
+ /** The label image, base64 encoded. */
656
+ labelData?: string | null;
657
+ carrierCode: string;
658
+ rate?: number | null;
659
+ success: boolean;
660
+ errorMessage?: string | null;
661
+ costPolicy?: number;
662
+ deductedFromRefundCents?: number | null;
663
+ customerPaymentRequired?: boolean;
664
+ }
665
+ /** One box in a multi-package shipment (the Gateway `PackageDetail`). */
666
+ interface MultiPackageDetail {
667
+ /** Weight in ounces, 0.1 to 999999. */
668
+ weightInOunces: number;
669
+ /** Length in inches, 0.1 to 999. */
670
+ lengthInInches: number;
671
+ /** Width in inches, 0.1 to 999. */
672
+ widthInInches: number;
673
+ /** Height in inches, 0.1 to 999. */
674
+ heightInInches: number;
675
+ deliveryConfirmationRequired?: boolean;
676
+ signatureConfirmationRequired?: boolean;
677
+ insuranceCoverageRequested?: boolean;
678
+ /** Coverage in USD. Needs `insuranceCoverageRequested: true`; left out, the order value is insured. */
679
+ insuredValue?: number;
680
+ /** Your label for the box, up to 100 characters (for example `Box 1 of 3`). */
681
+ packageReference?: string;
682
+ }
683
+ /**
684
+ * Body of `POST /api/shipping/multi-package` (the Gateway `MultiPackageShipmentRequest`): one order
685
+ * shipped in several boxes with the same carrier and service. Addresses come from the order.
686
+ */
687
+ interface MultiPackageShipmentRequest {
688
+ /** The order to ship. Required and positive. */
689
+ orderId: number;
690
+ /** Carrier for every box. */
691
+ carrierCode: string;
692
+ /** Service for every box. */
693
+ serviceCode?: string;
694
+ /** Defaults to `PDF` on the Gateway. */
695
+ labelFormat?: 'PDF' | 'PNG' | 'ZPL';
696
+ /** ISO 8601 date; defaults to today. */
697
+ shipDate?: string;
698
+ /**
699
+ * What the shipment holds. Multi-package labels cannot carry HAZMAT yet: send `HazmatClassification.None`
700
+ * (0) for no dangerous goods or leave it out for no answer. The Gateway refuses any other class
701
+ * (400 `HazmatNotSupported`); buy those labels one at a time with `shipping.createLabel`.
702
+ */
703
+ hazmatClassification?: typeof HazmatClassification.None;
704
+ /** 1 to 99 boxes. */
705
+ packages: MultiPackageDetail[];
706
+ }
707
+ /** One box's outcome in a multi-package shipment (the Gateway `PackageLabelResult`). */
708
+ interface MultiPackageLabelResult {
709
+ /** Index of the box in the request, from 0. */
710
+ packageIndex: number;
711
+ packageReference?: string | null;
712
+ trackingNumber?: string | null;
713
+ rate?: number | null;
714
+ success: boolean;
715
+ errorMessage?: string | null;
716
+ /** Stable refusal code when the box failed. `OutcomeUnknown` means a label may exist: check before retrying. */
717
+ errorCode?: string | null;
718
+ }
719
+ /** The Gateway `MultiPackageShipmentResponse`. */
720
+ interface MultiPackageShipmentResponse {
721
+ orderId: number;
722
+ carrierCode: string;
723
+ totalPackages: number;
724
+ successfulPackages: number;
725
+ failedPackages: number;
726
+ totalCost: number;
727
+ labels: MultiPackageLabelResult[];
728
+ }
535
729
  interface ShipmentsTrend {
536
730
  date: string;
537
731
  count: number;
@@ -639,6 +833,10 @@ interface CarrierRecommendationRequest {
639
833
  }
640
834
  interface CarrierRecommendationResponse {
641
835
  lane: string;
836
+ /**
837
+ * Shipments analyzed: exact for the workspace's own data, a band floor
838
+ * (5, 10, 25, 50, 100, 250, 500, 1000) for each carrier scored on FlexOps network data.
839
+ */
642
840
  sampleSize: number;
643
841
  recommendations: CarrierRecommendation[];
644
842
  }
@@ -647,7 +845,13 @@ interface CarrierRecommendation {
647
845
  score: number;
648
846
  onTimePercent: number;
649
847
  avgTransitDays: number;
848
+ /**
849
+ * The workspace's own average label cost in USD. `0` when the carrier was scored on
850
+ * FlexOps network data: network cost is not reported, so `0` does not mean free.
851
+ * The API's `dataSource` field (`workspace` or `network`) says which; this type does not include it yet.
852
+ */
650
853
  avgCost: number;
854
+ /** Shipments analyzed for this carrier: exact for workspace data, a band floor for network data. */
651
855
  shipmentCount: number;
652
856
  exceptionRate: number;
653
857
  reason: string;
@@ -669,6 +873,7 @@ interface DeliveryPredictionResponse {
669
873
  worstCaseDelivery: string;
670
874
  predictedTransitDays: number;
671
875
  confidence: number;
876
+ /** Shipments used: exact for the workspace's own data, a band floor for FlexOps network data. */
672
877
  sampleSize: number;
673
878
  onTimeRate: number;
674
879
  }
@@ -909,7 +1114,11 @@ declare class FlexOpsError extends Error {
909
1114
  readonly status: number;
910
1115
  readonly code?: string | undefined;
911
1116
  readonly errors?: string[] | undefined;
912
- constructor(message: string, status: number, code?: string | undefined, errors?: string[] | undefined);
1117
+ /** The envelope's `data` on an error reply, when the Gateway sends one (for example a multi-package 409 or 422). */
1118
+ readonly data?: unknown | undefined;
1119
+ constructor(message: string, status: number, code?: string | undefined, errors?: string[] | undefined,
1120
+ /** The envelope's `data` on an error reply, when the Gateway sends one (for example a multi-package 409 or 422). */
1121
+ data?: unknown | undefined);
913
1122
  }
914
1123
  declare class FlexOpsRateLimitError extends FlexOpsError {
915
1124
  readonly retryAfter?: number | undefined;
@@ -1021,14 +1230,35 @@ declare class ShippingResource {
1021
1230
  track(trackingNumber: string): Promise<TrackingInfo>;
1022
1231
  /** Validate and correct a shipping address. */
1023
1232
  validateAddress(address: Address | ShippingAddress): Promise<AddressValidationResult>;
1024
- /** Create labels in batch. */
1233
+ /**
1234
+ * Create labels for a batch of orders. The job runs in the background; poll `getBatchStatus`.
1235
+ * The request is sent as given; set `hazmatClassification` on an item only when you have a declaration.
1236
+ */
1237
+ createBatch(request: CreateBatchLabelRequest): Promise<ApiResponse<BatchLabelJob>>;
1238
+ /** @deprecated The Gateway refuses label-shaped batch items. Pass a CreateBatchLabelRequest. */
1025
1239
  createBatch(request: BatchLabelRequest): Promise<ApiResponse<BatchLabelJob>>;
1026
- /** Preview a batch without purchasing (dry-run). */
1240
+ /** Preview a batch of orders without buying labels (dry-run): per-order rates and the total cost. */
1241
+ previewBatch(request: CreateBatchLabelRequest): Promise<ApiResponse<BatchLabelJob>>;
1242
+ /** @deprecated The Gateway refuses label-shaped batch items. Pass a CreateBatchLabelRequest. */
1027
1243
  previewBatch(request: BatchLabelRequest): Promise<ApiResponse<BatchLabelJob>>;
1028
1244
  /** Get batch job status. */
1029
1245
  getBatchStatus(jobId: string): Promise<ApiResponse<BatchLabelJob>>;
1030
1246
  /** Download a label from a batch job. */
1031
1247
  downloadBatchLabel(jobId: string, itemId: string): Promise<Response>;
1248
+ /**
1249
+ * Buy labels for one order shipped in several boxes (1 to 99) with the same carrier and service.
1250
+ * Every box's label slot is reserved before any label is bought; a box that fails does not stop the
1251
+ * others, and each box reports its own `success`, `errorMessage` and `errorCode`.
1252
+ *
1253
+ * Resolves when at least one label was bought (check `failedPackages`). When none was, the Gateway
1254
+ * answers 422 `AllPackagesFailed`, or 409 `OutcomeUnknown` when a box's carrier outcome is unknown and
1255
+ * a label may exist: both throw a `FlexOpsError` whose `data` is the `MultiPackageShipmentResponse`.
1256
+ * After `OutcomeUnknown`, check the order before buying again.
1257
+ *
1258
+ * `hazmatClassification` accepts only `HazmatClassification.None` or nothing. Pass a stable
1259
+ * `idempotencyKey` to retry safely across processes; otherwise one is generated for this call.
1260
+ */
1261
+ createMultiPackage(request: MultiPackageShipmentRequest, idempotencyKey?: string): Promise<ApiResponse<MultiPackageShipmentResponse>>;
1032
1262
  /** List available carriers and their services. */
1033
1263
  getCarriers(): Promise<unknown>;
1034
1264
  /** Get AI-ranked carrier recommendations for a lane, scored by cost, speed, and reliability. */
@@ -1477,8 +1707,8 @@ declare class WebhooksResource {
1477
1707
  * @throws FlexOpsError (`UnknownWebhookEvent`) when `events` is empty or names an event FlexOps does not send.
1478
1708
  */
1479
1709
  update(webhookId: string, data: UpdateWebhookRequest): Promise<ApiResponse<WebhookSubscription>>;
1480
- /** Delete a webhook subscription. */
1481
- delete(webhookId: string): Promise<ApiResponse<unknown>>;
1710
+ /** Delete a webhook subscription. The Gateway answers 204 No Content, so there is no result. */
1711
+ delete(webhookId: string): Promise<void>;
1482
1712
  /** Rotate the signing secret for a webhook. */
1483
1713
  rotateSecret(webhookId: string): Promise<ApiResponse<{
1484
1714
  secret: string;
@@ -1555,17 +1785,30 @@ declare class ReturnsResource {
1555
1785
  private readonly getWorkspaceId;
1556
1786
  constructor(http: HttpClient, getWorkspaceId: () => string | undefined);
1557
1787
  private wsPath;
1558
- /** List return authorizations, optionally created between `startDate` and `endDate` (ISO 8601). */
1788
+ /**
1789
+ * List received returns, optionally between `startDate` and `endDate` (ISO 8601). The Gateway
1790
+ * defaults to the last 30 days. To list return authorizations, use `listRmas()`.
1791
+ */
1559
1792
  list(query?: {
1560
1793
  startDate?: string;
1561
1794
  endDate?: string;
1562
1795
  page?: number;
1563
1796
  pageSize?: number;
1564
- }): Promise<ApiResponse<ReturnAuthorization[]>>;
1565
- /** Get a return authorization by ID. */
1566
- get(returnId: string): Promise<ApiResponse<ReturnAuthorization>>;
1567
- /** Create a return authorization (RMA) for an order. */
1568
- create(request: ReturnRequest): Promise<ApiResponse<ReturnAuthorization>>;
1797
+ }): Promise<ApiResponse<ReturnSummary[]>>;
1798
+ /**
1799
+ * Get a received return by its numeric return id (`ReturnSummary.returnId` or `Rma.returnId`).
1800
+ * An RMA number is not a return id: the Gateway has no route for it here. Use `getRma()`.
1801
+ */
1802
+ get(returnId: number | string): Promise<ApiResponse<ReturnDetail>>;
1803
+ /** List return authorizations (RMAs), one page at a time. */
1804
+ listRmas(query?: {
1805
+ page?: number;
1806
+ pageSize?: number;
1807
+ }): Promise<ApiResponse<Rma[]>>;
1808
+ /** Get a return authorization by its RMA number, for example `RMA-1001`. */
1809
+ getRma(rmaNumber: string): Promise<ApiResponse<Rma>>;
1810
+ /** Create a return authorization (RMA) for an order. The Gateway answers 201 with the RMA. */
1811
+ create(request: ReturnRequest): Promise<ApiResponse<Rma>>;
1569
1812
  /**
1570
1813
  * Generate a return label for an approved RMA.
1571
1814
  *
@@ -1574,9 +1817,9 @@ declare class ReturnsResource {
1574
1817
  * shipping preset has nothing else to take the package from and the call fails with a 400 that
1575
1818
  * names the missing fields.
1576
1819
  */
1577
- generateLabel(rmaNumber: string, request?: ReturnLabelRequest): Promise<ApiResponse<unknown>>;
1578
- /** Record the inspected items of a returned package at a warehouse. */
1579
- markReceived(rmaId: string, request: ReceiveReturnRequest): Promise<ApiResponse<unknown>>;
1820
+ generateLabel(rmaNumber: string, request?: ReturnLabelRequest): Promise<ApiResponse<ReturnLabel>>;
1821
+ /** Record the inspected items of a returned package at a warehouse. `rmaId` is the numeric `Rma.rmaId`. */
1822
+ markReceived(rmaId: number | string, request: ReceiveReturnRequest): Promise<ApiResponse<unknown>>;
1580
1823
  }
1581
1824
 
1582
1825
  type DateRange = {
@@ -1702,8 +1945,8 @@ declare class RulesResource {
1702
1945
  create(rule: ShippingRuleInput): Promise<ApiResponse<ShippingRule>>;
1703
1946
  /** Replace a shipping rule. */
1704
1947
  update(ruleId: string, rule: ShippingRuleInput): Promise<ApiResponse<ShippingRule>>;
1705
- /** Delete a shipping rule. */
1706
- delete(ruleId: string): Promise<ApiResponse<unknown>>;
1948
+ /** Delete a shipping rule. The Gateway answers 204 No Content, so there is no result. */
1949
+ delete(ruleId: string): Promise<void>;
1707
1950
  /** Reorder rules: each listed rule gets its position in `ruleIds` as its priority (0 first). */
1708
1951
  reorder(ruleIds: string[]): Promise<ApiResponse<ShippingRule[]>>;
1709
1952
  /** Dry-run the workspace's rules against a sample shipment, without changing anything. */
@@ -1851,8 +2094,8 @@ declare class HsCodesResource {
1851
2094
  * import { FlexOps } from '@flexops/sdk';
1852
2095
  *
1853
2096
  * const client = new FlexOps({
1854
- * apiKey: 'fxk_live_...',
1855
- * workspaceId: 'ws_abc123',
2097
+ * apiKey: 'live_...',
2098
+ * workspaceId: 'your-workspace-id',
1856
2099
  * });
1857
2100
  *
1858
2101
  * // Get shipping rates
@@ -1917,4 +2160,5 @@ declare class FlexOps {
1917
2160
  setApiKey(key: string): void;
1918
2161
  }
1919
2162
 
1920
- export { type Address, type AddressValidationResult, AnalyticsResource, type ApiResponse, AuthResource, type BatchLabelJob, type BatchLabelRequest, type CanonicalLabelRequest, type CanonicalRateRequest, type CarbonOffset, type CarbonOffsetPurchaseRequest, type CarbonOffsetQuote, type CarbonOffsetQuoteRequest, type CarbonOffsetSettings, type CarbonOffsetSummary, CarbonOffsetsResource, type CarrierRecommendation, type CarrierRecommendationRequest, type CarrierRecommendationResponse, type CarrierSummary, CarriersResource, type CostSavingsSummary, type CreateLabelRequest, type CreateRecurringShipmentRequest, type CreateReportScheduleRequest, type CreateWebhookRequest, type CustomsItem, type DeliveryPredictionRequest, type DeliveryPredictionResponse, type EmailTemplate, type EmailTemplatePreview, type EmailTemplatePreviewRequest, EmailTemplatesResource, type FileClaimRequest, FlexOps, FlexOpsAuthError, type FlexOpsConfig, FlexOpsError, FlexOpsRateLimitError, HazmatClassification, type HsCodeResult, HsCodesResource, type InsuranceClaim, type InsurancePolicy, type InsuranceQuote, type InsuranceQuoteRequest, InsuranceResource, InventoryResource, type Label, type LabelPurchaseApproval, type LabelPurchasePreview, type LandedCostEstimate, type LandedCostRequest, type LaneSavingsOpportunity, type LegacyRateRequest, type LoginRequest, type LoginResponse, type Order, type OrderItem, OrdersResource, type PaginatedResponse, type Parcel, type PendingInvite, type PickupConfirmation, type PickupRequest, PickupsResource, type PurchaseInsuranceRequest, type RateRequest, type ReceiveReturnRequest, RecurrenceInterval, type RecurringShipment, RecurringShipmentsResource, ReportFormat, ReportFrequency, type ReportSchedule, ReportSchedulesResource, type RetryConfig, type ReturnAuthorization, type ReturnDisposition, type ReturnItem, type ReturnLabelRequest, type ReturnRequest, ReturnsResource, type RuleAction, type RuleCondition, RulesResource, type ScanForm, type ScanFormRequest, ScanFormsResource, type ShipmentsTrend, type ShippingAddress, type ShippingPackage, type ShippingRate, ShippingResource, type ShippingRule, type ShippingRuleInput, type ShippingRuleTestRequest, type SuggestedAddress, TrackingEmailEvent, type TrackingEvent, type TrackingInfo, type UpdateRecurringShipmentRequest, type UpdateReportScheduleRequest, type UpdateWebhookRequest, type UpsertEmailTemplateRequest, type VerifySignatureOptions, type WalletBalance, WalletResource, WebhookEventType, type WebhookSubscription, WebhooksResource, type Workspace, type WorkspaceDetail, type WorkspaceMember, type WorkspaceMemberList, WorkspaceRole, WorkspacesResource };
2163
+ 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 };