Client Site Contacts

Creating

Creating site contacts is a two step process. First you create the contact (without specifying the account), and then you use an action on the clients endpoint to assign the contact.

[POST] /contacts

{
 "firstName": "John",
 "lastName": "Smith",
 "jobTitle": "Assistant",
 "primaryPhone": "555-555-1234",
 "secondaryPhone": "555-555-4321",
 "fax": "string",
 "email": "john.smith@myemail.com",
 "address": {
   "addressLine1" : "123 street",
   "city" : "Cityville",
   "country" : "Canada",
   "State" : "Quebec",
   "postalCode" : "H2W 2R2"
 }
}

After the contact is created, take note of the “id” value in the response. You’ll need that value for assigning the contact to a Client Site:

Response

{
       "firstName": "John",
       "lastName": "Smith",
       "jobTitle": "Assistant",
       "primaryPhone": "555-555-1234",
       "secondaryPhone": "555-555-4321",
       "fax": "string",
       "email": "john.smith@myemail.com",
       "address": 1766,
       "account": 2,
==>    "id": 1766
   }

The id value to make note of is 1766.

Assigning to a Site

[POST] /clients/{id}/actions/assign-contact

{
  "contact": 1766,
  "useAsBillingAddress": true
}


You can only assign a contact to a single site. Attempting to assign them again to another site will produce the validation error:

  { "message": "Contact is already assigned" }

Therefore to assign the same contact to multiple sites, you need to create the contact multiple times so that each contact record has its own unique ID number.

Viewing

image-20230328-142329.png

Include (Contacts Relation List)

To view this list of contacts via the API you can include the relation list of contacts in its parent client data:

[GET] /clients/687?include=contacts,contacts.address

{
       "company": "AB Florists",
       "customId": "687",
       "firstName": "A",
       "lastName": "B",
       "jobTitle": "DevRel",
       "primaryPhone": "abcd1234",
       "secondaryPhone": "abcd1234",
       "type": "CLIENT",
       "region": 2,
       "status": "ACTIVE",
       "address": 1338,
       "email": "ariella@TrackTik.com",
       "closedDate": null,
       "id": 687,
       "avatar": "https://innovation.staffr.net/rest/v1/avatar/clients/687/c5d6ab87281f59db955262be61da6828",
       "contacts": [
           {
               "firstName": "A",
               "lastName": "B",
               "jobTitle": "DevRel",
               "primaryPhone": "abcd1234",
               "secondaryPhone": "abcd1234",
               "fax": "abcd1234",
               "email": "ariella@TrackTik.com",
               "account": 2,
               "id": 1338,
               "address": {
                   "addressLine1": "4201 Saint Laurent",
                   "addressLine2": "",
                   "city": "Montréal",
                   "country": "CA",
                   "state": "",
                   "postalCode": "H2W 2R2",
                   "latitude": 45.5181695,
                   "longitude": -73.5820322,
                   "id": 1338
               }
           },
           {
               "firstName": "API 1",
               "lastName": "API 2",
               "jobTitle": "API Site Contact for AB Florists",
               "primaryPhone": "",
               "secondaryPhone": "",
               "fax": "",
               "email": "ariella@TrackTik.com",
               "account": 2,
               "id": 1513,
               "address": {
                   "addressLine1": "",
                   "addressLine2": "",
                   "city": "",
                   "country": "",
                   "state": "",
                   "postalCode": "",
                   "latitude": null,
                   "longitude": null,
                   "id": 1513
               }
           },
…

Include via Fields (Contacts Relation List)

Or, you can view Contacts in list view using the “fields” parameter which will include the Relation List to “contacts” just like you would with “include”. Not all API endpoints and relation lists will allow fields to double as an include:

[GET] /clients?limit=100&fields=name,id,customId,contacts

{
           "name": "Northern Bank (HQ)",
           "id": 12,
           "customId": "NB-100",
           "contacts": [
               {
                   "firstName": "Martin",
                   "lastName": "Laroche",
                   "jobTitle": "Regional Manager",
                   "primaryPhone": "5145551238",
                   "secondaryPhone": "ext 244",
                   "fax": "",
                   "email": "Martin@email.com",
                   "address": 20,
                   "account": 5,
                   "id": 20
               }
           ]
       },
       {
           "name": "Investment Systems (HQ)",
           "id": 13,
           "customId": "IS-100",
           "contacts": [
               {
                   "firstName": "Robert",
                   "lastName": "Trudeau",
                   "jobTitle": "President",
                   "primaryPhone": "555123456",
                   "secondaryPhone": "",
                   "fax": "",
                   "email": "RT@Isemail.com",
                   "address": 21,
                   "account": 5,
                   "id": 21
               }
           ]
       }

 

Was this article helpful?
0 out of 0 found this helpful

Articles in this section

See more