Create a new contact for a customer in the system.
Creates a new contact document within a specific customer’s Contacts subcollection. It assigns a unique numeric contactId using a transaction based on the account’s counters.
{
"type": "object",
"properties": {
"customer": { "type": "string", "description": "Firestore path to the parent customer document (e.g., Accounts/acc123/Customers/cust456)" },
"greeting": { "type": "string", "minLength": 1 },
"firstName": { "type": "string", "minLength": 1 },
"lastName": { "type": "string", "minLength": 1 },
"email": { "type": "string", "format": "email" },
"mobilePhone": { "type": "string" },
"telePhone": { "type": "string" },
"tags": { "type": "array", "items": { "type": "string" } },
"opt_out_email": { "type": "boolean", "default": false },
"opt_out_letter": { "type": "boolean", "default": false },
"metadata": { "type": "object", "default": {} }
},
"required": ["customer", "greeting", "firstName", "lastName"]
}
{
"type": "object",
"properties": {
"success": { "type": "boolean" },
"contactId": { "type": "number" },
"id": { "type": "string" },
"path": { "type": "string" }
}
}
const result = await client.createContact({
customer: "Accounts/acc_123/Customers/cust_456",
greeting: "Mr.",
firstName: "John",
lastName: "Doe",
email: "john.doe@example.com",
tags: ["vip", "new"]
});