How to identify related OrderID from subscription Id using RestApi or XML-RPC? Which Table Can be used to identify Linkage between RecurringOrderId and OrderId

1. When a New Order (For Subscription) is placed, I am redirecting User to Thank You Page URL. In this process i get OrderID ,Contact Id (ex. orderId=135715, ContactId=1370925). I store this info on my local database.
2. I have setup RestHook Event to Subscription.edit Event. So whenever a Subscription( started by Step 1) is edited, I receive subscrption Id ,which is actually RecurringOrdersTable Id.
From this Subscription ID , how can I identify the original OrderID (135715)? Which table contains the linkage between OrderID (At Step1.) and SubscriptionID (Received at Step2).

I cant seem to find the table that will help in corelating these two IDs

@Nicholas_Trecina @John_Borelli

@mike.christianson please

@Connor_Rossiter on the RecurringOrder Table there is an “OriginatingOrderId” which should give you what you are looking for. You can query this table by doing 'Id' => $subscriptionId

@MichaelFairchild I had already tried that. Unfortunately the OriginatingOrderID field value is always 0 across all tables. Here is the sample Response i got from the RecurringOrder Table Query Call using ID->SubscriptionID

<methodResponse>
    <params>
        <param>
            <value>
                <array>
                    <data>
                        <value>
                            <struct>
                                <member>
                                    <name>OriginatingOrderId</name>
                                    <value>
                                        <i4>0</i4>
                                    </value>
                                </member>
                                <member>
                                    <name>Id</name>
                                    <value>
                                        <i4>21389</i4>
                                    </value>
                                </member>
                                <member>
                                    <name>ContactId</name>
                                    <value>
                                        <i4>1370925</i4>
                                    </value>
                                </member>
                            </struct>
                        </value>
                    </data>
                </array>
            </value>
        </param>
    </params>
</methodResponse>

@Connor_Rossiter it looks like that specific subscription Id may have been created manually in the interface or via API and so it has no OriginatingOrderID.

I think you’ll want to start with the Job table and use the JobRecurringId to identify the recurring order. Doing it the other way around is kind of approaching it backwards.