Multiple contacts per client - API/Zapier/Data Import

Hi all, can anyone help point me in the right direction on how to automate, import or API create a client with additional contacts please?

I know this can be done manually, but that’s not practical when importing or managing hundreds of existing clients.

The CSV import only allows a single contact per client.

Zapier and Integromat integrations only seem to allow a single contact per client - They will create a duplicate client with the secondary contact details.

Thanks in advance.

Hi,

This is supported with the API, you can see an example here:

https://docs.invoiceninja.com/api.html#creating-data

Hi @1stBalco

I am not sure about Zapier but in the Integromat module, the contact is an object where it needs to be an array. I have created a custom module for this. If you want, you can create you own app in Integromat for this.

Documentation

https://docs.integromat.com/apps/

Base

{
	"baseUrl": "{{connection.systemurl}}/api/v1",
	"headers": {
		"X-Ninja-Token": "{{connection.apiKey}}"
	},
	"log": {
		"sanitize": ["request.headers.authorization"]
	}
}

Connections

Communication

{
	"url": "{{parameters.systemurl}}/api/v1/accounts",
	"headers": {
		"X-Ninja-Token": "{{parameters.apiKey}}"
	},
	"log": {
		"sanitize": ["request.headers.X-Ninja-Token"]
	}
}

Parameters

[
	{
		"name": "systemurl",
		"type": "url",
		"label": "System URL",
		"required": true
	},
	{
		"name": "apiKey",
		"type": "text",
		"label": "API Key/Token",
		"required": true
	}
]

Module

Type: Action
Module Action: Update

Communication

{
	"url": "/clients/{{parameters.id}}",
	"method": "PUT",
	"body": "{{parameters}}",
	"response": {
		"output": "{{body}}"
	}
}

Mappable parameters

[
	{
		"name": "id",
		"label": "ID",
		"type": "number"
	},
	{
		"name": "name",
		"label": "Name",
		"type": "text"
	},
	{
		"name": "address1",
		"label": "Billing address 1",
		"type": "text"
	},
	{
		"name": "address2",
		"label": "Billing address 2",
		"type": "text"
	},
	{
		"name": "city",
		"label": "Billing city",
		"type": "text"
	},
	{
		"name": "state",
		"label": "Billing state",
		"type": "text"
	},
	{
		"name": "postal_code",
		"label": "Billing postal code",
		"type": "text"
	},
	{
		"name": "country_id",
		"label": "Billing country ID",
		"type": "number"
	},
	{
		"name": "shipping_address1",
		"label": "Shipping address 1",
		"type": "text"
	},
	{
		"name": "shipping_address2",
		"label": "Shipping address 2",
		"type": "text"
	},
	{
		"name": "shipping_city",
		"label": "Shipping city",
		"type": "text"
	},
	{
		"name": "shipping_state",
		"label": "Shipping state",
		"type": "text"
	},
	{
		"name": "shipping_postal_code",
		"label": "Shipping postal code",
		"type": "text"
	},
	{
		"name": "shipping_country_id",
		"label": "Shipping country ID",
		"type": "number"
	},
	{
		"name": "work_phone",
		"label": "Work phone",
		"type": "text"
	},
	{
		"name": "website",
		"label": "Website",
		"type": "text"
	},
	{
		"name": "vat_number",
		"label": "VAT Number",
		"type": "text"
	},
	{
		"name": "id_number",
		"label": "ID Number",
		"type": "text"
	},
	{
		"name": "custom_value1",
		"label": "Custom value 1",
		"type": "text"
	},
	{
		"name": "custom_value2",
		"label": "Custom value 2",
		"type": "text"
	},
	{
		"name": "task_rate",
		"label": "Task rate",
		"type": "number"
	},
	{
		"name": "payment_terms",
		"label": "Payment terms",
		"type": "number"
	},
	{
		"name": "private_notes",
		"label": "Private note",
		"type": "text"
	},
	{
		"name": "public_notes",
		"label": "Public note",
		"type": "text"
	},
	{
		"name": "industry_id",
		"label": "Industry ID",
		"type": "number"
	},
	{
		"name": "size_id",
		"label": "Size ID",
		"type": "number"
	},
	{
		"name": "language_id",
		"label": "Language ID",
		"type": "number"
	},
	{
		"name": "currency_id",
		"label": "Currency ID",
		"type": "number"
	}
	{
		"name": "contacts",
		"label": "Contacts",
		"type": "array",
		"spec": {
			"type": "collection",
			"spec": [
				{
					"name": "id",
					"label": "Contact ID",
					"type": "number"
				},
				{
					"name": "first_name",
					"label": "First name",
					"type": "text"
				},
				{
					"name": "last_name",
					"label": "Last name",
					"type": "text"
				},
				{
					"name": "email",
					"label": "Email",
					"type": "text"
				},
				{
					"name": "phone",
					"label": "Phone",
					"type": "text"
				},
				{
					"name": "custom_value1",
					"label": "Custom value 1",
					"type": "text"
				},
				{
					"name": "custom_value2",
					"label": "Custom value 2",
					"type": "text"
				},
				{
					"name": "send_invoice",
					"label": "Send invoice",
					"type": "boolean"
				}
			]
		}
	}
]

Cheers,
Gijs

2 Likes