Inserting master+detail

It's present in existing records. If there are no records, then of course there is no $id.

You need to see the JSON response in the network tab.