Re: How to get archieved (after fulfilled) orders using REST order API?

How to get archieved (after fulfilled) orders using REST order API?

Iceey
Shopify Partner
1 0 0

Hi,
I have all read_orders,read_draft_orders, read_all_orders scopes, but when I try to get an order that is archieved after fulfilled, it retrun empty product.

I try to call by this 

orders.json?name=${orderId}&status=any
or
orders.json?status=any

both cannnot get the archieved orders.

This is my code for reference
static async getOrderById(session: Session, orderId: string): Promise<Record<string, unknown>> {
        const client = new shopify.clients.Rest({ session: session });

        const result = await client.get({
            path: `orders.json?name=${orderId}&status=any`,
        });

        const order = (result.body as Record<string, unknown>).orders as Record<string, unknown>;
        
        return order;
}
Reply 1 (1)

muhammadsalmank
Shopify Partner
26 1 4

Thanks for getting in touch! If you're looking for archived orders, in REST you could call a GET for example to orders.json?status=closed which would give you a store's orders that show as 'archived' in the Shopify Admin. There's a closed_at timestamp present on the orders object too. Feel free to check out the docs here that will show you what status(s) you can GET. Hope that helps!