Contacts

Contacts are WhatsApp users who have messaged your channels. Theyโ€™re created automatically on first message. See Database Schema for the full column reference.

List Contacts

const { data } = await sendhub
  .from('contacts')
  .select('id, name, phone, platform_id, tags, avatar_url, notes')
  .eq('business_id', workspaceId)
  .order('name')
  .limit(50)
const { data } = await sendhub
  .from('contacts')
  .select('id, name, phone, tags')
  .or(`name.ilike.%${query}%,phone.ilike.%${query}%`)
  .eq('business_id', workspaceId)

Update

// Update name and notes
await sendhub
  .from('contacts')
  .update({ name: 'John Smith', notes: 'VIP customer, prefers English' })
  .eq('id', contactId)

// Replace tags
await sendhub
  .from('contacts')
  .update({ tags: ['vip', 'returning', 'q2-campaign'] })
  .eq('id', contactId)

Get Contact with Conversations

const { data: contact } = await sendhub
  .from('contacts')
  .select('*, conversations(id, status, last_message_at, channels(label))')
  .eq('id', contactId)
  .single()