Hi @fancyHS,
Your logic in attempting this is correct. However, it looks like the “primary unique identifier” does not necessarily mean that the property itself actually is a unique property (it does not require unique values) - as it is possible to enter the same domain name for multiple company records. Certainly confusing.
Someone else recently asked about the Company upsert endpoint and I provided a suggestion on how to work around this limitation in this thread: https://community.hubspot.com/t5/APIs-Integrations/Create-or-update-a-batch-of-contacts-by-unique-property-values/m-p/1119484/highlight/true#M80755
I realize the solution is not ideal but hopefully helps explain the situation.