# Contacts ## List `client.contacts.list(ContactListParamsquery?, RequestOptionsoptions?): ContactListResponse` **get** `/api/v2/contacts` Retrieve a list of contacts for the authenticated account ### Parameters - `query: ContactListParams` - `cid?: string` Filter by contact ID - `limit?: number` Maximum number of contacts to return - `offset?: number` Number of contacts to skip - `order_by?: string` Field to sort by - `order_direction?: "asc" | "desc"` Sort direction - `"asc"` - `"desc"` - `phone_number?: string` Filter by phone number ### Returns - `ContactListResponse = Array` - `assigned_to_email?: string` Email of assigned user - `company_name?: string` Company name - `created_at?: string` When the contact was created - `custom_variables?: Record` Custom key-value pairs stored on the contact. Keys are human-readable labels. - `first_name?: string` First name - `last_name?: string` Last name - `phone?: string` Phone number in E.164 format - `sendblue_number?: string` Associated Sendblue phone number - `tags?: Array` Tags associated with the contact - `verified?: boolean` Whether the contact is verified ### Example ```typescript import SendblueAPI from 'sendblue'; const client = new SendblueAPI({ apiKey: process.env['SENDBLUE_API_API_KEY'], // This is the default and can be omitted apiSecret: process.env['SENDBLUE_API_API_SECRET'], // This is the default and can be omitted }); const contacts = await client.contacts.list(); console.log(contacts); ``` ## Create `client.contacts.create(ContactCreateParamsbody, RequestOptionsoptions?): ContactCreateResponse` **post** `/api/v2/contacts` Create a new contact or update existing if update_if_exists is true ### Parameters - `body: ContactCreateParams` - `number: string` Contact's phone number in E.164 format (preferred) - `assigned_to_email?: string` Email of assigned user (preferred) - `assignedToEmail?: string` Email of assigned user (deprecated, use assigned_to_email) - `custom_variables?: Record` Custom key-value pairs. Keys are human-readable labels; new labels are auto-created. - `first_name?: string` Contact's first name (preferred) - `firstName?: string` Contact's first name (deprecated, use first_name) - `last_name?: string` Contact's last name (preferred) - `lastName?: string` Contact's last name (deprecated, use last_name) - `phone_number?: string` Contact's phone number (deprecated, use number) - `phoneNumber?: string` Contact's phone number (deprecated, use number) - `sendblue_number?: string` Associated Sendblue phone number to send with (preferred) - `sendblueNumber?: string` Associated Sendblue phone number (deprecated, use sendblue_number) - `tags?: Array` Tags for the contact - `update_if_exists?: boolean` If true, updates the contact if it already exists ### Returns - `ContactCreateResponse` - `contact?: Contact` - `assigned_to_email?: string` Email of assigned user - `company_name?: string` Company name - `created_at?: string` When the contact was created - `custom_variables?: Record` Custom key-value pairs stored on the contact. Keys are human-readable labels. - `first_name?: string` First name - `last_name?: string` Last name - `phone?: string` Phone number in E.164 format - `sendblue_number?: string` Associated Sendblue phone number - `tags?: Array` Tags associated with the contact - `verified?: boolean` Whether the contact is verified - `status?: string` ### Example ```typescript import SendblueAPI from 'sendblue'; const client = new SendblueAPI({ apiKey: process.env['SENDBLUE_API_API_KEY'], // This is the default and can be omitted apiSecret: process.env['SENDBLUE_API_API_SECRET'], // This is the default and can be omitted }); const contact = await client.contacts.create({ number: 'number' }); console.log(contact.contact); ``` ## Count `client.contacts.count(RequestOptionsoptions?): ContactCountResponse` **get** `/api/v2/contacts/count` Get the total number of contacts ### Returns - `ContactCountResponse` - `count?: number` Total number of contacts ### Example ```typescript import SendblueAPI from 'sendblue'; const client = new SendblueAPI({ apiKey: process.env['SENDBLUE_API_API_KEY'], // This is the default and can be omitted apiSecret: process.env['SENDBLUE_API_API_SECRET'], // This is the default and can be omitted }); const response = await client.contacts.count(); console.log(response.count); ``` ## Verify `client.contacts.verify(ContactVerifyParamsbody, RequestOptionsoptions?): ContactVerifyResponse` **post** `/api/v2/contacts/verify` Send a verification message to a contact ### Parameters - `body: ContactVerifyParams` - `number: string` Phone number to verify ### Returns - `ContactVerifyResponse` - `status?: string` ### Example ```typescript import SendblueAPI from 'sendblue'; const client = new SendblueAPI({ apiKey: process.env['SENDBLUE_API_API_KEY'], // This is the default and can be omitted apiSecret: process.env['SENDBLUE_API_API_SECRET'], // This is the default and can be omitted }); const response = await client.contacts.verify({ number: 'number' }); console.log(response.status); ``` ## Retrieve `client.contacts.retrieve(stringphoneNumber, RequestOptionsoptions?): ContactRetrieveResponse` **get** `/api/v2/contacts/{phone_number}` Retrieve a specific contact by phone number ### Parameters - `phoneNumber: string` ### Returns - `ContactRetrieveResponse` - `contact?: Contact` - `assigned_to_email?: string` Email of assigned user - `company_name?: string` Company name - `created_at?: string` When the contact was created - `custom_variables?: Record` Custom key-value pairs stored on the contact. Keys are human-readable labels. - `first_name?: string` First name - `last_name?: string` Last name - `phone?: string` Phone number in E.164 format - `sendblue_number?: string` Associated Sendblue phone number - `tags?: Array` Tags associated with the contact - `verified?: boolean` Whether the contact is verified - `status?: string` ### Example ```typescript import SendblueAPI from 'sendblue'; const client = new SendblueAPI({ apiKey: process.env['SENDBLUE_API_API_KEY'], // This is the default and can be omitted apiSecret: process.env['SENDBLUE_API_API_SECRET'], // This is the default and can be omitted }); const contact = await client.contacts.retrieve('+1234567890'); console.log(contact.contact); ``` ## Update `client.contacts.update(stringphoneNumber, ContactUpdateParamsbody, RequestOptionsoptions?): ContactUpdateResponse` **put** `/api/v2/contacts/{phone_number}` Update an existing contact ### Parameters - `phoneNumber: string` - `body: ContactUpdateParams` - `assigned_to_email?: string` Email of assigned user (preferred) - `assignedToEmail?: string` Deprecated, use assigned_to_email - `company_name?: string` Company name (preferred) - `companyName?: string` Deprecated, use company_name - `custom_variables?: Record` Custom key-value pairs. Merged with existing variables (not replaced). - `first_name?: string` Contact's first name (preferred) - `firstName?: string` Deprecated, use first_name - `last_name?: string` Contact's last name (preferred) - `lastName?: string` Deprecated, use last_name - `sendblue_number?: string` Associated Sendblue phone number (preferred) - `sendblueNumber?: string` Deprecated, use sendblue_number - `tags?: Array` ### Returns - `ContactUpdateResponse` - `contact?: Contact` - `assigned_to_email?: string` Email of assigned user - `company_name?: string` Company name - `created_at?: string` When the contact was created - `custom_variables?: Record` Custom key-value pairs stored on the contact. Keys are human-readable labels. - `first_name?: string` First name - `last_name?: string` Last name - `phone?: string` Phone number in E.164 format - `sendblue_number?: string` Associated Sendblue phone number - `tags?: Array` Tags associated with the contact - `verified?: boolean` Whether the contact is verified - `status?: string` ### Example ```typescript import SendblueAPI from 'sendblue'; const client = new SendblueAPI({ apiKey: process.env['SENDBLUE_API_API_KEY'], // This is the default and can be omitted apiSecret: process.env['SENDBLUE_API_API_SECRET'], // This is the default and can be omitted }); const contact = await client.contacts.update('+1234567890'); console.log(contact.contact); ``` ## Delete `client.contacts.delete(stringphoneNumber, RequestOptionsoptions?): ContactDeleteResponse` **delete** `/api/v2/contacts/{phone_number}` Delete a specific contact ### Parameters - `phoneNumber: string` ### Returns - `ContactDeleteResponse` - `status?: string` ### Example ```typescript import SendblueAPI from 'sendblue'; const client = new SendblueAPI({ apiKey: process.env['SENDBLUE_API_API_KEY'], // This is the default and can be omitted apiSecret: process.env['SENDBLUE_API_API_SECRET'], // This is the default and can be omitted }); const contact = await client.contacts.delete('+1234567890'); console.log(contact.status); ``` ## Domain Types ### Contact - `Contact` - `assigned_to_email?: string` Email of assigned user - `company_name?: string` Company name - `created_at?: string` When the contact was created - `custom_variables?: Record` Custom key-value pairs stored on the contact. Keys are human-readable labels. - `first_name?: string` First name - `last_name?: string` Last name - `phone?: string` Phone number in E.164 format - `sendblue_number?: string` Associated Sendblue phone number - `tags?: Array` Tags associated with the contact - `verified?: boolean` Whether the contact is verified # Bulk ## Delete `client.contacts.bulk.delete(BulkDeleteParamsbody, RequestOptionsoptions?): BulkDeleteResponse` **delete** `/api/v2/contacts` Delete multiple contacts by their IDs ### Parameters - `body: BulkDeleteParams` - `contact_ids: Array` Array of phone numbers in E.164 format to delete ### Returns - `BulkDeleteResponse` - `amount?: number` Number of contacts deleted - `status?: string` ### Example ```typescript import SendblueAPI from 'sendblue'; const client = new SendblueAPI({ apiKey: process.env['SENDBLUE_API_API_KEY'], // This is the default and can be omitted apiSecret: process.env['SENDBLUE_API_API_SECRET'], // This is the default and can be omitted }); const bulk = await client.contacts.bulk.delete({ contact_ids: ['+1234567890', '+0987654321'] }); console.log(bulk.amount); ``` ## Create `client.contacts.bulk.create(BulkCreateParamsbody, RequestOptionsoptions?): BulkCreateResponse` **post** `/api/v2/contacts/bulk` Create multiple contacts in bulk ### Parameters - `body: BulkCreateParams` - `contacts: Array` - `phone: string` Phone number in E.164 format - `company_name?: string` Company name - `custom_variables?: Record` Custom key-value pairs. Keys are human-readable labels; new labels are auto-created. - `first_name?: string` Contact's first name - `last_name?: string` Contact's last name - `tags?: Array` ### Returns - `BulkCreateResponse` - `contacts?: Array` - `assigned_to_email?: string` Email of assigned user - `company_name?: string` Company name - `created_at?: string` When the contact was created - `custom_variables?: Record` Custom key-value pairs stored on the contact. Keys are human-readable labels. - `first_name?: string` First name - `last_name?: string` Last name - `phone?: string` Phone number in E.164 format - `sendblue_number?: string` Associated Sendblue phone number - `tags?: Array` Tags associated with the contact - `verified?: boolean` Whether the contact is verified - `status?: string` ### Example ```typescript import SendblueAPI from 'sendblue'; const client = new SendblueAPI({ apiKey: process.env['SENDBLUE_API_API_KEY'], // This is the default and can be omitted apiSecret: process.env['SENDBLUE_API_API_SECRET'], // This is the default and can be omitted }); const bulk = await client.contacts.bulk.create({ contacts: [{ phone: 'phone' }] }); console.log(bulk.contacts); ```