How to consistently map user-selected shipping options in REST API?

1 0 0



I am using the REST API to create draft orders and send customers invoice URLs.

I want to be able to map the shipping line according to what a user selects. 

Basically, a user can choose between UPS ground, UPS next day air, UPS next day saver, etc. 
Based on what they select I want to apply that shipping handle to the draft order so the draft invoice is populated with the same shipping option.

The draft order is made up of line items which are newly created product  variants for a pre-existing product. Shipping options have already been set up for the parent product. How can I get the handle for those shipping options so I can map it to a user's selected method?

What I have tried:
I have tried creating a draft order inside the Shopify admin UI, selecting a shipping method, and then sending a GET request to the REST API for that draft order, and copying the shipping handle in the shipping line.
This works sometimes, but I have found that the handle changes, and therefore is not programmable.

Example shipping handle that is returned: "337d83bdaf87bf6cb63641689df5d706"


Anyone have any guidance?


Replies 0 (0)