What is the best approach to update one-to-many relations ? (PostgresSQL)

Hi, i'm struggling to decide what is the best alternative to update a one-to-many relation.
Lets say i have a entity called "Contract". Each contract can have 1 to N many items, so would something like

{
id: 1,
name: Contract 1
items: [ .. ]
}

When we create (or update) a contract, we have to also update the list of items. A item could be removed, modifed or created.

My first attempt was to make a simple for-loop (i'm using Golang in this case) and send each item individually (delete if was removed or creating/updating). But this approach has its drawbacks of multiple round trips do database.

My second attempt was to make a temporary table, bulk copy the provided items and then use CTEs and joins with this temp table to make the necessary changes. But this approach also has a problem, multiple requests will attempt to create the same table, mixing items from different contracts.

My question is: which approach would work best ? and how can i solve its drawbacks ? also, is there any other alternative that i'm not seeing ?