ContactGroups
Query, insert, update and delete contact groups for a Xero organisation.
Table Specific Information
The ContactGroups table allows you to manage both contact groups as well as the members of those contact groups.
SELECT
The Xero API allows extensive filtering and ordering. You can define WHERE and ORDER BY clauses in a query to filter and order the results using any non-line-item column.
Note: The Xero API does not support filtering on line items or journal lines.
INSERT
When inserting with a contact group, you can either insert a new contact group or add contacts into an existing group.
To insert a new contact group, only the Name field should be given:
INSERT INTO ContactGroups (Name) VALUES ('Contractors')
To add a contact into an existing group, both the ContactGroupId and the Contact_ContactId must be provided. The
value for the Contact_ContactId field can be retrieved by querying the Contacts table.
INSERT INTO ContactGroups (ContactGroupId, Contact_ContactId) VALUES ('11111-11111-11111-11111', '22222-22222-22222-22222')
Multiple contacts may be provided using the ContactAggregate:
INSERT INTO ContactGroups (ContactGroupId, ContactAggregate) VALUES ( '11111-11111-11111-11111', '<Contact><ContactID>22222-22222-22222-22222</ContactID></Contact> <Contact><ContactID>33333-33333-33333-33333</ContactID></Contact>')
UPDATE
When updating a contact group, the only fields that can be changed are the Name and Status field. Changing the Status field to DELETED will delete the contact group.-- Renaming the group UPDATE ContactGroup SET Name = 'External Contractors' WHERE ContactGroupId = '11111-11111-11111-1111' -- Deleting the group UPDATE ContactGroup SET Status = 'DELETED' WHERE ContactGroupId = '11111-11111-11111-1111'
DELETE
Deleting entries from a contact group will remove individual contacts from the group.DELETE FROM ContactGroups WHERE Id = '3|11111-11111-11111-11111'
Columns
Name | Type | ReadOnly | Description |
Id [KEY] | String | True |
The line item index combined with the Id of the Contact Group |
ContactGroupId | String | False |
The unique Xero identifier for the contact group. |
Name | String | False |
The contact group name. |
Status | String | False |
The status of the contact group. |
ContactAggregate | String | False |
Used to define Contact rows using XML values. Only allowed when performing an INSERT into an existing ContactGroup. |
Contact_ContactId | String | False |
The unique identifier of the contact group member |
Contact_Name | String | True |
THe name of the contact group member |
TenantId | String | False |
The ID of the tenant to query instead of the connection tenant |