Skip to main content

CRM Module (ItBuild.CRM)

The CRM module manages user profiles, personal data, external identifiers, and social connections. It serves as the central user database for the ItBuild platform.

Overview

PropertyValue
TypeOptional standard module
PortInternal only (behind AuthProxy)
DatabaseSeparate SQL Server database
Admin panel/CrmAdmin/

Key Capabilities

User Management

  • User profiles — name, contacts, metadata
  • External IDs — phone numbers, emails, social accounts (Telegram, Google, Discord, VK, GitHub)
  • User flags — status bits for permissions and states
  • Project isolation — users belong to specific projects in multi-tenant setup

Standard Features (February 2026)

  • Notes — comments, call logs, meeting records attached to users
  • Tags — color-coded segmentation labels with groups
  • Audit Log — automatic fire-and-forget action tracking
  • Addresses — user addresses with types (Home, Work, Shipping, Billing)
  • Custom Fields — dynamic user attributes (String, Number, Date, Bool, Enum)

See CRM Features for details.

Friends System

  • Friend connections — bidirectional friend relationships between users
  • Friend management — add, remove, list friends
  • Friend flags — custom relationship metadata

External ID Management

Users can have multiple external identifiers (user_exid) linked:

ID TypeSourceExample
PhoneSMS verification+1234567890
EmailEmail verification / magic linkuser@example.com
TelegramTelegram Login123456789
GoogleGoogle OAuthgoogle-sub-id
AppleSign In with Appleapple-sub-id
MicrosoftMicrosoft OAuthms-oid
GitHubGitHub OAuthgithub-user-id
FacebookFacebook OAuthfb-user-id
VKVK OAuthvk-user-id
DiscordDiscord OAuthdiscord-user-id

user_exid_flags (since 2026-05)

Each user_exid row carries a bitmask that distinguishes how the contact came to be:

BitNameWhen set
1VerifiedThe contact was confirmed end-to-end (OTP, magic link, OAuth handshake completed).
2ManuallyAddedThe contact was created by an operator through /CrmAdmin/ExternalIds and has not yet been verified.
4PrimaryReserved for the user's primary contact of a given type.
128DeletedSoft-delete; the row is kept for audit.

Verified and ManuallyAdded are independent — an operator can pre-create a contact and the user can later verify it, leaving both bits set. AML, KYC, and payout-eligibility checks rely on Verified, never on the mere presence of the row. See docs.authproxy.tech/docs/authentication/verified-contacts.md for the full flag semantics and OAuth verified-email matrix.

API Endpoints

CRM Controller

EndpointMethodDescription
get_clientGETGet user profile by CRM ID
update_clientPOSTUpdate user data
create_clientPOSTCreate new user
search_clientsGETSearch users by criteria

Friends Controller

EndpointMethodDescription
get_friendsGETList user's friends
add_friendPOSTAdd friend connection
remove_friendPOSTRemove friend

Private Controller (/private/v1/)

Internal API used by AuthProxy and other modules:

EndpointMethodDescription
get_userPOSTGet user by CRM ID (inter-service)
create_userPOSTCreate user (called by AuthProxy on first login)
update_userPOSTUpdate user (inter-service)
find_by_external_idGETFind user by phone/email/social ID

Data Model

Main Entities

CRM stores user profiles, verified external ids, relationships, notes, tags, and audit records. Public documentation describes the entity purpose and admin workflows; exact schema is maintained in the module source and generated delivery artifacts.

Integration

How AuthProxy Uses CRM

When a user authenticates (via any method), AuthProxy:

  1. Checks if the external ID exists in CRM (phone, email, Telegram ID, etc.)
  2. If found — returns the existing crm_id for the session
  3. If not found — creates a new CRM user, links the external ID

This is transparent to the end user — first login automatically creates their CRM profile.

Wallet Provisioning (TrexWallet)

When TrexWallet is part of the deployment, CRM can auto-provision a wallet for each client by calling TrexWallet private/v1/create_wallet. The trigger is controlled by the WalletProvision config setting:

WalletProvisionBehavior
OnPhoneConfirm (default)Create the wallet when a phone login id is attached (ext_id_upsert), if the client has no wallet yet. This is also the behavior when the key is absent.
OnRegistrationCreate the wallet as soon as the CRM client record is created (client_upsert).
NoneNever auto-create. Use for CRM-only deployments without TrexWallet, or when wallets are provisioned manually/elsewhere.

The wallet group is taken from TrexDefaultGroup (or the referring agent's tariff group); project from Config.Project. The per-client wallet cap lives on TrexWallet (MaxWalletsPerUser). Provisioning is best-effort: a wallet failure is logged but never blocks registration or phone attachment. CRM has no login endpoint (authentication is AuthProxy's domain), so there is no "on first login" mode here.

How Core Module Uses CRM

The Core module accesses CRM through the shared CRM client instead of querying CRM tables directly.

CRM ID as Universal Identifier

The CRM timetick (CRM ID) is the universal user identifier across all platform modules:

AuthProxy → session contains crm_id
→ X-Crm header sent to all backend modules
→ TrexWallet uses crm_id for wallet ownership
→ Chat uses crm_id for message ownership
→ Core uses crm_id for business logic

Admin Panel

Built-in Razor admin at /CrmAdmin/ (proxied via AuthProxy). Page inventory matches the current ItBuild.CRM Pages/CrmAdmin tree and platform admin docs.

PageRouteNotes
Index (dashboard)/CrmAdminStats, charts, recent activity
CrmUser/CrmAdmin/CrmUserUser list; filters (e.g. timetick, name, phone, email, flags)
UserDetail/CrmAdmin/UserDetail?timetick=Dossier / detail view
EditUser/CrmAdmin/EditUser?timetick=Profile edit form; requires crm.admin scope
ExternalIds/CrmAdmin/ExternalIdsExternal identifiers; crm.admin for mutations
Friends/CrmAdmin/FriendsFriend graph; crm.admin where applicable
Notes/CrmAdmin/NotesNotes registry (filters required before list load)
Tags/CrmAdmin/TagsTag definitions and assignments
Addresses/CrmAdmin/AddressesUser addresses
CustomFields/CrmAdmin/CustomFieldsDynamic field defs and values
AuditLog/CrmAdmin/AuditLogcrm_audit registry (filters required)
ReferralTree/CrmAdmin/ReferralTreeReferral hierarchy
CreateUser/CrmAdmin/CreateUserCreate user; crm.admin
MergeUsers/CrmAdmin/MergeUsersMerge flow; crm.admin

Operator help anchor for EditUser + related navigation: CRM admin — operator guide.

Configuration

{
"Config": {
"DBConnections": {
"CrmDB": "Server=...;Database=crm_db;..."
},
"TrexDefaultGroup": 1,
"WalletProvision": "OnPhoneConfirm"
}
}

Error Codes

CRM-specific errors (via ApiCrmError):

CodeDescription
-11001User not found
-11002User already exists
-11003Invalid external ID
5006Note not found
5007Tag not found
5008Tag already assigned
5009Address not found
5010Custom field definition not found
5011Field value invalid (type mismatch)
4008Add chat member: contact already a member
4009Add chat member: not a friend (cannot add)