# useDocyrusContactChannels URL: /docs/native/hooks/use-docyrus-contact-channels React Query wiring for the Contact Channels & Consent API — a record's channels, consent and validation ledgers, tenant brands and every channel / consent / validation mutation. ## Installation ```bash pnpm dlx @docyrus/cli add @docyrus/rn-hooks-use-docyrus-contact-channels ``` **Dependencies:** - [@tanstack/react-query](https://www.npmjs.com/package/@tanstack/react-query) A verbatim port of the web hook. It takes a structural `ContactChannelsClient` (`get` / `post` / `patch` / `delete`), which `RestApiClient` satisfies. Queries share the web keys (`['docyrus-contact-channels', , …]`, `['docyrus-tenant-brands']`) and every mutation invalidates the record's channel queries. Read endpoints need `DS.Read.All`, write endpoints `DS.ReadWrite.All`. [rn-contact-channels-panel](/docs/native/docyrus/contact-channels-panel) uses it internally. ## Usage ```tsx import { useDocyrusContactChannels } from '@/hooks/docyrus-native/use-docyrus-contact-channels'; const { channels, brands, createChannel, recordConsent, runValidation } = useDocyrusContactChannels({ client, appSlug: 'base', dataSourceSlug: 'contact', recordId }); await createChannel({ channelKind: 'email', channelType: 'email', value: 'erin@acme.com', isPrimary: true }); await recordConsent(channelId, { purpose: 'marketing', action: 'opt_in', consentStatus: 'opted_in', consentChannel: 'email' }); ``` ## API Reference ### UseDocyrusContactChannelsOptions | Option | Type | Default | Description | |--------|------|---------|-------------| | `client` | `ContactChannelsClient` | - | REST client (required) | | `appSlug` / `dataSourceSlug` / `recordId` | `string` | - | Owning record (required) | | `includeArchived` | `boolean` | `false` | Include archived channels | | `enabled` | `boolean` | `Boolean(recordId)` | Toggle every query | | `loadBrands` | `boolean` | `true` | Fetch `/v1/tenant/brands` | ### UseDocyrusContactChannelsResult | Field | Type | Description | |-------|------|-------------| | `channels` / `brands` / `consentHistory` / `validationHistory` | arrays | Loaded data | | `isLoading` / `error` / `isMutating` / `mutationError` | | State | | `refetch` | `() => Promise` | Invalidate the record's queries | | `createChannel(input)` / `updateChannel(id, input)` | `Promise` | `POST` / `PATCH …/channels` | | `makePrimary(id)` / `archiveChannel(id, reason?)` / `unarchiveChannel(id)` / `deleteChannel(id)` | `Promise` | Channel actions | | `recordConsent(id, entry)` / `bulkRecordConsent(id, items)` / `bulkRecordRecordConsent(items)` | `Promise` | Consent ledger writes | | `listChannelConsent(id)` | `Promise` | Per-channel consent ledger | | `recordValidation(id, entry)` / `runValidation(id)` | `Promise` | Validation writes / engine run | | `listChannelValidations(id)` | `Promise` | Per-channel validation ledger | ### Types | Type | Description | |------|-------------| | `ContactChannelsClient` | `{ get, post, patch, delete }` | | `ContactChannelsPanelData` | Read part of the result | | `ConsentEntryWithChannel` | `ConsentEntryInput & { channelId }` |