create_contact
Add new contacts to iCloud Contacts with details like name, phone, email, address, and organization. Manage contact information through structured input for personal or professional use.
Instructions
Create a new contact in iCloud Contacts.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| firstName | No | First name | |
| lastName | No | Last name | |
| fullName | No | Full display name (overrides firstName + lastName for FN field) | |
| org | No | Organization / company name | |
| phone | No | Primary phone number (shorthand for phones array) | |
| No | Primary email address (shorthand for emails array) | ||
| phones | No | Array of phone objects: [{ number, type }] where type is cell/home/work/etc. | |
| emails | No | Array of email objects: [{ email, type }] where type is home/work/etc. | |
| addresses | No | Array of address objects: [{ street, city, state, zip, country, type }] | |
| birthday | No | Birthday in YYYY-MM-DD format | |
| note | No | Notes / free text | |
| url | No | Website URL |
Implementation Reference
- lib/carddav.js:344-360 (handler)The 'createContact' function in 'lib/carddav.js' implements the creation logic by generating a VCard, assigning a new UUID, and performing a PUT request to the iCloud CardDAV server.
export async function createContact(fields) { const { dataHost, addressBookPath } = await discover(); const contactId = randomUUID().toUpperCase(); const vcard = serializeVCard({ ...fields }, contactId); const url = `${dataHost}${addressBookPath}${contactId}.vcf`; const resp = await davRequest('PUT', url, { contentType: 'text/vcard; charset=utf-8', body: vcard, }); if (resp.status !== 201 && resp.status !== 204 && resp.status !== 200) { throw new Error(`CardDAV PUT failed: ${resp.status} — ${resp.body.slice(0, 200)}`); } return { created: true, contactId, etag: resp.etag }; }