Xero - beautiful accounting software

Xero Developer Help Center

Xero Developer Community

Community > API Endpoints >

Unique email and telephone number via API but not UI

Started by Paul Allen -   in API Endpoints

Could someone give me more information on why there is a discrepancy in data uniqueness between the API and the UI?

For example, if I try to create a contact via the API using an email address that already exists I will receive a validation error stating that emails must be unique.

If I then create the contact via the UI using a duplicated email address it let's me do this and save.

The same appears true for telephone numbers.

It would be great if this was a consistent experience. I'm all for making an email address unique but data integrity is quite difficult when there are different rules for different sources of data.
Hi Paul,
I've just tried to reproduce this without much luck. Through the Api Explorer I can create multiple contacts with the same email and phones.
The only field that I'm aware of that has to be unique, other than IDs, is the Name field for contacts.

If you're still having an issue, perhaps have a play with the explorer in a demo org and share an example request with some dummy data here?
 

Steven Brown (Xero Staff)  

Hi Steven,

Thanks for looking into this. I can't see any recent logs related to email however I did get this error back from the API this morning:

The contact number 042XXXXXXX is already assigned to another contact. The contact number must be unique across all contacts.
 

Paul Allen  

Ah yup, that is a contact number which is not the same thing as a phone number. You can see the description of it here https://developer.xero.com/documentation/api/accounting/contacts#get-contacts

Phone numbers are a collection on the contact and are not unique but do require a type. You can see more information about phone numbers here
https://developer.xero.com/documentation/api/accounting/types#phones
 

Steven Brown (Xero Staff)  

Wow, can't believe I didn't see that before. Thanks!
 

Paul Allen  

No worries at all. Glad we could get you up and running :)
 

Steven Brown (Xero Staff)