Skip to content

Agency Profile Fields

Extends the Agency entity with corporate identity, contact channels, and fiscal information.

Fields

FieldTypeStorageNotes
masterEmailstring | nullvarcharPrimary agency email
websiteUrlstring | nullvarcharAgency website URL
currencyCurrency | nullvarcharUSD or MXN
timezonestring | nullvarcharIANA timezone, validated via Intl.supportedValuesOf('timeZone')
contactChannelsContactChannelProps[] | nulljsonbArray of { type, label, value }
legalNamestring | nullvarcharFiscal legal name
taxIdstring | nullvarcharTax identification (RFC)
fiscalAddressstring | nulltextFiscal address

All fields are nullable — existing agencies work without backfill.

Shared Enums (in @repo/schemas)

  • Currency: USD | MXN
  • ContactChannelType: EMAIL | PHONE

Contact Channels

Stored as a JSONB column (no separate table). Each entry:

typescript
{ type: ContactChannelType, label: string, value: string }

Max 20 channels per agency.

Validation

  • masterEmail: standard email, max 255 chars
  • websiteUrl: valid URL (z.url())
  • currency: enum (USD, MXN)
  • timezone: refined against Intl.supportedValuesOf('timeZone')
  • contactChannels: array of contact channel schemas, max 20 items
  • legalName: 1–255 chars
  • taxId: 1–50 chars
  • fiscalAddress: 1–500 chars

API

Agency self-service routes live under /api/identity/agency:

  • GET /api/identity/agency/current: returns the agency selected in the current session claims.
  • POST /api/identity/agency: creates a new agency owned by the authenticated user.
  • PUT /api/identity/agency/:id: updates an owned agency profile.

All agency profile fields are returned in the agency response DTO.

Key Files

  • Domain: apps/api/src/modules/identity/domain/entities/agency.entity.ts
  • Persistence: apps/api/src/modules/identity/infrastructure/persistence/agency.persistence.ts
  • Schemas: packages/schemas/src/identity/agency/
  • Mapper: apps/api/src/modules/identity/infrastructure/mappers/agency.mapper.ts