1. Contacts
  2. Create & Update Contacts

Contacts

Create & Update Contacts

Request Body

name string (required for creation)

email string

phone string

address string

address_line2 string

alternate_names object

Show Details
alternate_names.0 string
alternate_names.1 string
alternate_names.2 string
alternate_names.3 string
alternate_names.4 string

alternate_emails object

Show Details
alternate_emails.education string
alternate_emails.personal string
alternate_emails.other string
alternate_emails.work string
alternate_emails.social string

alternate_phones object

Show Details
alternate_phones.education string
alternate_phones.home string
alternate_phones.mobile string
alternate_phones.work string
alternate_phones.other string

alternate_addresses object

Show Details
alternate_addresses.secondary string
alternate_addresses.secondary_line2 string
alternate_addresses.home string
alternate_addresses.home_line2 string
alternate_addresses.other string
alternate_addresses.other_line2 string
alternate_addresses.work string
alternate_addresses.work_line2 string
alternate_addresses.education string
alternate_addresses.education_line2 string

id_number string

groups object

Show Details
groups.add Array<group_id>
groups.remove Array<group_id>
groups.set Array<group_id>
Overrides contact's groups

locations object

Show Details
locations.add Array<location_id>
locations.remove Array<location_id>
locations.set Array<location_id>
Overrides contact's locations

is_primary boolean

notes string

metadata object

external_id string

Create Contact(s)

POST
`/v1/contacts`

This API will allow you to create a single contact using a traditional REST approach.

Create Single Contact

The only required property for a contact is the name, but we recommend adding some more information like the email or phone.

js
        const data = {
  name: "Jamie Jones",
};

fetch(`https://api.packagex.io/v1/contacts`, {
  method: "POST",
  headers: {
    "PX-API-KEY": process.env.PX_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify(data),
});

      

Update Contact

POST
`/v1/contacts/:contact`

To update a contact, you'll need to pass the contact's ID along with any properties that you want to manage.

Update Contact

The address field can also include the address ID or location ID and we'll parse it successfully.

js
        const data = {
  name: "Jamie Jones",
  email: "jamie@packagex.xyz",
  phone: "+11234567890",
  address: "500 7th Ave, New York, NY 10018",
  address_line2: "Floor 14",
  metadata: {
    prop: "Whatever I want",
  },
  notes: "Will be out of town until Friday",
};

fetch(`https://api.packagex.io/v1/contacts/${contact.id}`, {
  method: "POST",
  headers: {
    "PX-API-KEY": process.env.PX_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify(data),
});

      

Contacts can only be added to the groups with locations only if contact is also associated to that location. Contacts can be added to groups with location freely. Removing a location from contact also removes all the groups associated with location from the contact.

js
        const data = {
  groups: {
    set: ["grp_1b8aUvyn4SyUD6SBUiaeD5"]
  },
  locations: {
    add: ["loc_11BHHB8ax6bRKyzb5vqWDw", "loc_1291JfypM9jp3tg3sHsPDu"],
    remove: ["loc_12QFYJmdpMLHDq6WufAqLW"]
  }
};

fetch(`https://api.packagex.io/v1/contacts/${contact.id}`, {
  method: "POST",
  headers: {
    "PX-API-KEY": process.env.PX_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify(data),
});