Dev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubDev CommunityOptimizely AcademySubmit a ticketLog In
Dev Guide

Order module RMA and shipment API handler

Manage Return Merchandise Authorizations (RMAs) and shipment tracking.

POST RMA (Add)

HTTP Verb – POST

URL – /api/v1/orders/{orderid}/returns

Description – Submit a new Return Merchandise Authorization request

BaseHandlerBase\<AddRmaParameter, AddRmaResult\>

Handlers

OrderHandlerDescription
500ValidateContextVerifies the current user is logged in (UserProfileDto is not null) and has a BillTo customer assigned. Returns NotFound error if either is missing.
600ValidateRmaRetrieves the OrderHistory matching the current customer's CustomerNumber and the specified OrderNumber (checks both WebOrderNumber and ErpOrderNumber). Returns NotFound if the order is not found. Validates that at least one RMA line has a quantity requested. For each RMA line, validates the requested quantity is greater than zero, does not exceed QtyOrdered, and that a return reason code is provided when reason codes are configured.
700PopulateEmailModelBuilds a dynamic email model containing order details (OrderNumber, OrderDate, PONumber, Notes, billing address fields) and a collection of order line items with their RMA quantities and return reasons.
800SendEmailSends the RMA request email using the "RequestRma" email list. Sends to both the configured RmaDestinationEmail and the current user's email address, using the populated email model as the template data.

GET Shipment Collection

HTTP Verb – N/A (internal service call)

Description – Get a collection of shipments for an order

BaseHandlerBase\<GetShipmentCollectionParameter, GetShipmentCollectionResult\>

Handlers

OrderHandlerDescription
500GetShipmentQueryCreates a query for Shipment entities (with ShipmentPackages included) filtered by either WebOrderNumber or ErpOrderNumber from the parameter.
600ApplySortSorts the shipment query by the parameter Sort value. If Sort is not specified, defaults to sorting by ShipmentNumber.
700ApplyPagingApplies standard paging to the shipment query using the base ApplyPaging method.
800ExecuteQueryExecutes the query by calling ToList() and sets the result to the Shipments collection.
900CreateShipmentDtosFor each shipment in the collection, calls ShipmentService.GetShipment to create a detailed ShipmentDto (including package lines if requested). Returns error if any individual shipment retrieval fails.

GET Shipment

HTTP Verb – N/A (internal service call)

Description – Get a single shipment by shipment number

BaseHandlerBase\<GetShipmentParameter, GetShipmentResult\>

Handlers

OrderHandlerDescription
500GetShipmentRetrieves the Shipment entity either from the parameter (if pre-loaded) or by querying the repository by ShipmentNumber (includes ShipmentPackages). Returns NotFound error if not found. Maps the Shipment to a ShipmentDto and processes shipment package details including package lines and tracking URLs via the shipment package utilities.