Replace a company's contact cards
PUT/v1/organizations/:organizationCode/stakeholders/:companyUid/contacts
Makes the persons attached to the company match the list, in one transaction: a card without uid creates a person, a card with uid updates it (a changed name becomes its lastName and clears its firstName; the card's phone number and email replace the ones it showed and become primary, the person's other ones are kept), and an attached person absent from the list is deleted, like DELETE /stakeholders/{uid}, unless it is linked to a contract (409, nothing changed). Each card needs a name and a phone number or an email; at most one card is the primary contact (an omitted isPrimaryContact means false), and no two cards nor another person share an email. Clearing or replacing a card's phone number or email also removes every copy of it from the person's legacy contactsDetails, keeping the entries' other values. Any invalid card rejects the whole list, with every error in one response (errors on contacts[<index>].<field>). The list order is stored and returned by the next reads. Returns the saved list. Requires stonal.contact.write permission, and also stonal.contact.delete when the list leaves out an attached person (403 otherwise, nothing changed)
Request
Responses
- 200
- 400
- 403
- 404
- 409
The saved contact cards
An invalid card, a uid that is not a contact of this company, or a stakeholder that is not a company. Every error is listed at once; match them on field. errors[].code: NAME_REQUIRED, EMAIL_OR_PHONE_REQUIRED, EMAIL_INVALID, EMAIL_DUPLICATE, EMAIL_ALREADY_USED, UID_INVALID, UID_DUPLICATE, UID_NOT_A_CONTACT, PRIMARY_CONTACT_DUPLICATE, NOT_A_COMPANY; errors[].params: value, and firstIndex (the card a duplicate repeats)
Forbidden - Not authorized to access this organization (empty body), or missing stonal.contact.delete for the contacts the list leaves out (ErrorResponse body)
Company not found
The list leaves out a contact linked to a contract; the detail names each such contact, and each has an error with code CONTACT_HAS_CONTRACTS and params uid, name, contractCount