Skip to main content

Organization

Source: src/models/organization.ts

The Organization document is the root of all per-tenant data. Every other document either references or is embedded inside it. One document exists per tenant; it is looked up by shortName on every request.

Top-level fields

FieldTypeRequiredDefaultNotes
shortNameStringHostname identifier, 2–32 chars. Extracted from the subdomain on every request.
clerkOrganizationIdStringClerk org ID (e.g. org_xxxx). Sparse-indexed; used to match Clerk webhook events.
licenseStartNumber0Unix timestamp (ms).
licenseEndNumber0Unix timestamp (ms).
licenseCostNumber0Amount in € paid for the license.
isBlockedBooleanfalseBlocked orgs return 403 on all public routes.
isPublicBooleantrueWhether the ROPA is publicly accessible without sign-in.
isDemoBooleanfalseMarks shared demo orgs.
schemaVersionNumber13Incremented on each migration.
defaultActivityAttributesMixed{}Attribute defaults applied when creating new activities.
highestOuIdNumber4Auto-increment counter; incremented when a new OU is created.
highestActivityIdNumber6Auto-increment counter; incremented when a new activity is created.
highestPartnerIdNumber0Auto-increment counter; 0 is reserved for self.
highestContractIdNumber0Auto-increment counter for contracts.
createdAt / updatedAtDateMongoose autoManaged by timestamps: true; updatedAt is also reset in a pre('save') hook.

Virtuals

VirtualReturns
selfOrganizationThe partners[] entry where organizationId === 0.
organizationNameorganizationNameLong from selfOrganization; falls back to shortName.
nameSame as organizationName.

Embedded arrays

partners[]

Stores the org's own data and all external parties (processors, joint controllers, etc.). At least one entry with organizationId === 0 is required by the validator. See Partner sub-schema below.

ropas[]

One entry per configured locale. Each entry is a lightweight reference to a separate Ropa document.

FieldTypeNotes
localeString2-letter lowercase code, e.g. "en". Matches /^[a-z]{2}$/.
ropaIdObjectIdReference to the Ropa document for this locale.
isDefaultBooleanExactly one entry should be true; determines which locale the root path redirects to.

templates[]

Org-level and activity-specific template references. The activityId + type pair identifies a unique slot.

FieldTypeNotes
activityIdNumber0 = org-level template; > 0 = activity-specific.
typeStringactivityDeclaration | activityInformation | ropaFrontPage | ropaTOC. Default: activityDeclaration.
templateIdObjectIdReference to a Template document.

contracts[]

Data-processing contracts, embedded since the v13 schema migration (previously a separate Contract collection).

FieldTypeNotes
contractIdNumberRequired; unique per org.
contractNameStringDefault "".
contractUrlStringDefault "".
contractExpirationDateStringDefault null.
contractDescriptionStringDefault "".
activityIdsNumber[]Activity IDs associated with this contract.
partnerIdsNumber[]Partner IDs associated; must be non-negative integers.

Partner sub-schema

Source: src/models/partner.ts — embedded in Organization.partners[].

FieldTypeRequiredDefaultNotes
organizationIdNumber0 = this org; > 0 = external party.
organizationNameStringShort name, 2–32 chars.
organizationNameLongStringFull legal name, 2–100 chars.
organizationColorString"#2196F3"Hex color #RRGGBB.
organizationWebsiteString""URL; validated by regex.
organizationPostalAddressPostalAddressSee below.
organizationLogoBuffernullMax 256 KB.
organizationVatNumberString""Format: CC-XXXXXXXX (2-letter country code, dash, up to 14 alphanumeric chars).
organizationNotesString""Max 200 chars.
organizationContactsContact[]At least one required.
contractOrderNumber[][]Ordered list of contractId values for display.

Virtual: displayName"organizationNameLong (organizationName)"

Method: getPrimaryContact() → returns organizationContacts[0]

Contact

FieldTypeRequiredDefaultNotes
contactIdNumber
contactFirstnameString1–50 chars.
contactLastnameString1–50 chars.
contactRoleString"Primary"3–24 chars.
contactEmailsEmail[]At least one required; at most one isPrimary: true.
contactPhoneNumbersPhoneNumber[][]At most one isPrimary: true.
contactNotesString""Max 200 chars.

Email (_id: false)

FieldTypeDefaultNotes
emailStringLowercased; validated by [^\s@]+@[^\s@]+\.[^\s@]+ regex.
descriptionString"Work"Max 50 chars.
isPrimaryBooleanfalse

PhoneNumber (_id: false)

FieldTypeDefaultNotes
countryCodeString"+1"Format: + followed by 1–4 digits.
phoneNumberString6–15 digits.
descriptionString"Office"Max 50 chars.
isPrimaryBooleanfalse

PostalAddress (_id: false)

FieldTypeRequiredNotes
addressLine1StringMax 100 chars.
addressLine2StringMax 100 chars; default "".
cityStringMax 50 chars.
stateProvinceStringMax 50 chars; default "".
postalCodeStringMax 20 chars.
countryString2 uppercase letters; ISO 3166-1 alpha-2 (e.g. "ES", "DE").