How do you get/set up a Related Object using the API

Are we able to retrieve and set details of related objects that are on Contracts, Orders and Invoices?

As an example. here is how 2 currently showing :

I think this is the array which holding the related object ids