@cfxlabsinc/b2b-services
    Preparing search index...

    Cross-customer admin access to organizations.

    Extends OrganizationCache, so this read shares the organization-search namespace — and therefore the membership-tag vocabulary — with the consumer surface. A consumer write for a customer evicts the admin pages scoped to that customer, and vice versa, without either service referencing the other.

    Hierarchy (View Summary)

    Index
    cache: ServiceCache<CachedSearchPage<OrgWithCustomer>>
    db: B2bDatabase
    instance: (...args: []) => OrganizationAdminService = ...

    The process default: built from each dependency's own instance().

    • Push an operator's decision to AiPrise; the RESULT_UPDATE webhook is the only status writer. A caller that already read the live row passes verificationProfileId to skip the re-read.

      Parameters

      • __namedParameters: {
            decision: "APPROVED" | "DECLINED";
            id: string;
            reason?: { code: string; note?: string };
            verificationProfileId?: string;
        }
        • decision: "APPROVED" | "DECLINED"
        • id: string
        • Optionalreason?: { code: string; note?: string }

          Stored as the MANUAL reason only; AiPrise's business profile takes none.

        • OptionalverificationProfileId?: string

      Returns Promise<
          | { error: ServiceError; ok: false }
          | { ok: true; value: { verificationProfileId: string } },
      >

    • Clear each customer's membership tag and each record tag wherever cached, and always this namespace's collection tag. keys are exact deletes in this instance's key space: the only bust a null client honours.

      Parameters

      • __namedParameters: {
            customerIds: readonly string[];
            keys?: readonly CacheKey[];
            records?: readonly string[];
        }

      Returns Promise<void>

    • Runs KYB again once every live related person is APPROVED. AiPrise evaluates its related-person rules only when a business verification runs, so the run at creation decided REVIEW. The MAKE_DECISION webhook writes the outcome.

      Parameters

      • __namedParameters: { id: string }

      Returns Promise<
          | {
              ok: true;
              value: | { started: true; verificationSessionId: string
              | undefined }
              | {
                  reason:
                      | "NO_VERIFICATION_PROFILE"
                      | "ORGANIZATION_NOT_PENDING_VERIFICATION"
                      | "VERIFICATION_ALREADY_APPROVED"
                      | "NO_RELATED_PEOPLE"
                      | "RELATED_PEOPLE_NOT_APPROVED";
                  started: false;
              };
          }
          | { error: ServiceError; ok: false },
      >

    • Tags for a page: the scope its query searched (each customer's membership tag, else the collection tag), so an empty page is bustable too, plus the records it projects and the fields that chose or ordered its rows.

      Parameters

      • __namedParameters: {
            customerIds: readonly string[] | undefined;
            fields?: readonly string[];
            records?: readonly string[];
        }

      Returns string[]

    • Pin the RouteFusion business entity onto the org — minted once, reused for every VA. The pin is CONDITIONAL (WHERE data->'routeFusionEntity' IS NULL) so two concurrent onboards can't both mint: the loser's UPDATE matches no row, and the subsequent re-read returns the winner's pinned value. A missing org (re-read finds nothing) is NOT_FOUND.

      requiredDocuments is the OR-of-AND document-set snapshot from RF's entityRequiredFields, resolved for the org's real country/business type at mint time (see onboardRouteFusionEntity). Optional so legacy callers (and tests) can still pin without it.

      Parameters

      • __namedParameters: {
            entityId: string;
            id: string;
            programId?: string;
            requiredDocuments?: string[][];
            status: "PENDING" | "VERIFIED" | "REJECTED";
        }

      Returns Promise<
          | { error: ServiceError; ok: false }
          | {
              ok: true;
              value: {
                  achName: string;
                  capabilities: (
                      | "TRANSACT"
                      | "MANAGE_PAYMENT_INSTRUMENT"
                      | "MANAGE_LEDGER_ACCOUNT"
                      | "MANAGE_DEPOSIT_MEMO"
                  )[];
                  countryCode: string;
                  countryOfIncorporation: string;
                  createdAt: Date;
                  deletedAt?: Date;
                  description?: string;
                  email?: string;
                  expectedActivity?: {
                      currencyCount: "TWO_OR_FEWER"
                      | "THREE"
                      | "MORE_THAN_THREE";
                      expectsOnlineGambling: boolean;
                      expectsSanctionedCountryActivity: boolean;
                      monthlyDepositAmount: "UP_TO_30000" | "30000_TO_100000" | "OVER_100000";
                      monthlyDepositCount: "TWO_OR_FEWER" | "THREE" | "MORE_THAN_THREE";
                      monthlyInternationalWireDepositAmount:
                          | "UP_TO_30000"
                          | "30000_TO_100000"
                          | "OVER_100000";
                      monthlyInternationalWireDepositCount: | "1_TO_5"
                      | "6_TO_10"
                      | "11_OR_MORE";
                      monthlyInternationalWirePaymentAmount: | "UP_TO_30000"
                      | "30000_TO_100000"
                      | "OVER_100000";
                      monthlyInternationalWirePaymentCount: | "1_TO_5"
                      | "6_TO_10"
                      | "11_OR_MORE";
                      monthlyPaymentAmount: "UP_TO_30000"
                      | "30000_TO_100000"
                      | "OVER_100000";
                      monthlyPaymentCount: "TWO_OR_FEWER" | "THREE" | "MORE_THAN_THREE";
                      operationsStartDate: string;
                      primaryPurpose:
                          | "RECEIVE_CUSTOMER_PAYMENTS"
                          | "EVERYDAY_PURCHASES"
                          | "PAY_SUPPLIERS_AND_EMPLOYEES"
                          | "MANAGE_MULTIPLE_CURRENCIES"
                          | "OTHER";
                      primaryPurposeDetail?: string;
                      sanctionedCountryActivityDetail?: string;
                      services: ("WIRES" | "ACH" | "FOREIGN_EXCHANGE" | "DEBIT_CARD")[];
                      topCountries: string[];
                  };
                  fullName: string;
                  id: string;
                  incorporationDate?: string;
                  legalEntityType: string;
                  metadata: Record<string, string>;
                  naicsCode?: string;
                  name: string;
                  operatingAddress?: OrganizationAddress;
                  phone?: E164Phone;
                  referenceId?: string;
                  registeredAddress?: OrganizationAddress;
                  registrationNumber?: string;
                  requiredInfo: RequiredInfoField[];
                  routeFusionEntity?: {
                      documentsUploadedAt?: string;
                      entityId: string;
                      lastFinalizeError?: { at: string; message: string } | null;
                      programId?: string;
                      requiredDocuments?: string[][];
                      status: "PENDING" | "VERIFIED" | "REJECTED";
                  } & { statusDescription: string };
                  stateOfIncorporation?: string;
                  status:
                      | "PENDING_VERIFICATION"
                      | "ACTION_REQUIRED"
                      | "APPROVED"
                      | "DISABLED"
                      | "DELETED";
                  statusDescription: string;
                  taxId: string;
                  type: "ORGANIZATION";
                  updatedAt: Date;
                  uuid: string;
                  verificationData?: {
                      status: VerificationStatus;
                      verificationSessionId?: string;
                      verificationTemplateId: string;
                  } & { statusDescription: string };
                  verificationProfileId?: string;
                  verificationReasonCode?:
                      | "OTHER"
                      | "INVALID_TAX_ID"
                      | "ADDRESS_MISMATCH"
                      | "REGISTRY_NOT_FOUND"
                      | "DOCUMENT_ISSUE"
                      | "IDENTITY_MISMATCH";
                  verificationReasonCodeDescription?: string;
                  verifiedAt?: Date;
                  websiteUrl?: string;
                  wireName: string;
              };
          },
      >

    • Update only the pinned entity's KYB status (RF entity webhook → VERIFIED/REJECTED), leaving entityId/programId intact. Matches only when an entity is already pinned; a status-only write on an org with no pinned entity is NOT_FOUND.

      Parameters

      • __namedParameters: { id: string; status: "PENDING" | "VERIFIED" | "REJECTED" }

      Returns Promise<
          | { error: ServiceError; ok: false }
          | {
              ok: true;
              value: {
                  achName: string;
                  capabilities: (
                      | "TRANSACT"
                      | "MANAGE_PAYMENT_INSTRUMENT"
                      | "MANAGE_LEDGER_ACCOUNT"
                      | "MANAGE_DEPOSIT_MEMO"
                  )[];
                  countryCode: string;
                  countryOfIncorporation: string;
                  createdAt: Date;
                  deletedAt?: Date;
                  description?: string;
                  email?: string;
                  expectedActivity?: {
                      currencyCount: "TWO_OR_FEWER"
                      | "THREE"
                      | "MORE_THAN_THREE";
                      expectsOnlineGambling: boolean;
                      expectsSanctionedCountryActivity: boolean;
                      monthlyDepositAmount: "UP_TO_30000" | "30000_TO_100000" | "OVER_100000";
                      monthlyDepositCount: "TWO_OR_FEWER" | "THREE" | "MORE_THAN_THREE";
                      monthlyInternationalWireDepositAmount:
                          | "UP_TO_30000"
                          | "30000_TO_100000"
                          | "OVER_100000";
                      monthlyInternationalWireDepositCount: | "1_TO_5"
                      | "6_TO_10"
                      | "11_OR_MORE";
                      monthlyInternationalWirePaymentAmount: | "UP_TO_30000"
                      | "30000_TO_100000"
                      | "OVER_100000";
                      monthlyInternationalWirePaymentCount: | "1_TO_5"
                      | "6_TO_10"
                      | "11_OR_MORE";
                      monthlyPaymentAmount: "UP_TO_30000"
                      | "30000_TO_100000"
                      | "OVER_100000";
                      monthlyPaymentCount: "TWO_OR_FEWER" | "THREE" | "MORE_THAN_THREE";
                      operationsStartDate: string;
                      primaryPurpose:
                          | "RECEIVE_CUSTOMER_PAYMENTS"
                          | "EVERYDAY_PURCHASES"
                          | "PAY_SUPPLIERS_AND_EMPLOYEES"
                          | "MANAGE_MULTIPLE_CURRENCIES"
                          | "OTHER";
                      primaryPurposeDetail?: string;
                      sanctionedCountryActivityDetail?: string;
                      services: ("WIRES" | "ACH" | "FOREIGN_EXCHANGE" | "DEBIT_CARD")[];
                      topCountries: string[];
                  };
                  fullName: string;
                  id: string;
                  incorporationDate?: string;
                  legalEntityType: string;
                  metadata: Record<string, string>;
                  naicsCode?: string;
                  name: string;
                  operatingAddress?: OrganizationAddress;
                  phone?: E164Phone;
                  referenceId?: string;
                  registeredAddress?: OrganizationAddress;
                  registrationNumber?: string;
                  requiredInfo: RequiredInfoField[];
                  routeFusionEntity?: {
                      documentsUploadedAt?: string;
                      entityId: string;
                      lastFinalizeError?: { at: string; message: string } | null;
                      programId?: string;
                      requiredDocuments?: string[][];
                      status: "PENDING" | "VERIFIED" | "REJECTED";
                  } & { statusDescription: string };
                  stateOfIncorporation?: string;
                  status:
                      | "PENDING_VERIFICATION"
                      | "ACTION_REQUIRED"
                      | "APPROVED"
                      | "DISABLED"
                      | "DELETED";
                  statusDescription: string;
                  taxId: string;
                  type: "ORGANIZATION";
                  updatedAt: Date;
                  uuid: string;
                  verificationData?: {
                      status: VerificationStatus;
                      verificationSessionId?: string;
                      verificationTemplateId: string;
                  } & { statusDescription: string };
                  verificationProfileId?: string;
                  verificationReasonCode?:
                      | "OTHER"
                      | "INVALID_TAX_ID"
                      | "ADDRESS_MISMATCH"
                      | "REGISTRY_NOT_FOUND"
                      | "DOCUMENT_ISSUE"
                      | "IDENTITY_MISMATCH";
                  verificationReasonCodeDescription?: string;
                  verifiedAt?: Date;
                  websiteUrl?: string;
                  wireName: string;
              };
          },
      >

    • Admin org write. Accepts the full editable business-field set, mapping each field exactly as OrganizationService.update does (top-level columns vs data jsonb).

      A change to a field KYB sends AiPrise (KYB_SYNDICATED_FIELDS) writes PENDING_VERIFICATION, then after the commit pushes the fields and re-runs KYB, as the customer path does; a refused run is ORGANIZATION_VERIFICATION_FAILED with the written row. An ACTION_REQUIRED org re-verifies only once the edit supplies what is missing. A caller's explicit status is written instead (the AiPrise decision callback writes APPROVED). statusUpdated is published only when the status changed.

      data.workspaceId links the ORGANIZATION workspace whose members sign in as this organization. Set once: the same workspace again writes nothing, another is refused. Only a link may run in a caller's tx, in a savepoint of it, so a refused link leaves the tx usable.

      Parameters

      • args: {
            data: Partial<
                Pick<
                    {
                        achName: string;
                        capabilities: (
                            | "TRANSACT"
                            | "MANAGE_PAYMENT_INSTRUMENT"
                            | "MANAGE_LEDGER_ACCOUNT"
                            | "MANAGE_DEPOSIT_MEMO"
                        )[];
                        countryCode: string;
                        countryOfIncorporation: string;
                        createdAt: Date;
                        deletedAt?: Date;
                        description?: string;
                        email?: string;
                        expectedActivity?: {
                            currencyCount: "TWO_OR_FEWER"
                            | "THREE"
                            | "MORE_THAN_THREE";
                            expectsOnlineGambling: boolean;
                            expectsSanctionedCountryActivity: boolean;
                            monthlyDepositAmount: "UP_TO_30000" | "30000_TO_100000" | "OVER_100000";
                            monthlyDepositCount: "TWO_OR_FEWER" | "THREE" | "MORE_THAN_THREE";
                            monthlyInternationalWireDepositAmount:
                                | "UP_TO_30000"
                                | "30000_TO_100000"
                                | "OVER_100000";
                            monthlyInternationalWireDepositCount: | "1_TO_5"
                            | "6_TO_10"
                            | "11_OR_MORE";
                            monthlyInternationalWirePaymentAmount: | "UP_TO_30000"
                            | "30000_TO_100000"
                            | "OVER_100000";
                            monthlyInternationalWirePaymentCount: | "1_TO_5"
                            | "6_TO_10"
                            | "11_OR_MORE";
                            monthlyPaymentAmount: "UP_TO_30000"
                            | "30000_TO_100000"
                            | "OVER_100000";
                            monthlyPaymentCount: "TWO_OR_FEWER" | "THREE" | "MORE_THAN_THREE";
                            operationsStartDate: string;
                            primaryPurpose:
                                | "RECEIVE_CUSTOMER_PAYMENTS"
                                | "EVERYDAY_PURCHASES"
                                | "PAY_SUPPLIERS_AND_EMPLOYEES"
                                | "MANAGE_MULTIPLE_CURRENCIES"
                                | "OTHER";
                            primaryPurposeDetail?: string;
                            sanctionedCountryActivityDetail?: string;
                            services: ("WIRES" | "ACH" | "FOREIGN_EXCHANGE" | "DEBIT_CARD")[];
                            topCountries: string[];
                        };
                        fullName: string;
                        id: string;
                        incorporationDate?: string;
                        legalEntityType: string;
                        metadata: Record<string, string>;
                        naicsCode?: string;
                        name: string;
                        operatingAddress?: OrganizationAddress;
                        phone?: E164Phone;
                        referenceId?: string;
                        registeredAddress?: OrganizationAddress;
                        registrationNumber?: string;
                        requiredInfo: RequiredInfoField[];
                        routeFusionEntity?: {
                            documentsUploadedAt?: string;
                            entityId: string;
                            lastFinalizeError?: { at: string; message: string } | null;
                            programId?: string;
                            requiredDocuments?: (...)[][];
                            status: "PENDING" | "VERIFIED" | "REJECTED";
                        } & { statusDescription: string };
                        stateOfIncorporation?: string;
                        status:
                            | "PENDING_VERIFICATION"
                            | "ACTION_REQUIRED"
                            | "APPROVED"
                            | "DISABLED"
                            | "DELETED";
                        statusDescription: string;
                        taxId: string;
                        type: "ORGANIZATION";
                        updatedAt: Date;
                        uuid: string;
                        verificationData?: {
                            status: VerificationStatus;
                            verificationSessionId?: string;
                            verificationTemplateId: string;
                        } & { statusDescription: string };
                        verificationProfileId?: string;
                        verificationReasonCode?:
                            | "OTHER"
                            | "INVALID_TAX_ID"
                            | "ADDRESS_MISMATCH"
                            | "REGISTRY_NOT_FOUND"
                            | "DOCUMENT_ISSUE"
                            | "IDENTITY_MISMATCH";
                        verificationReasonCodeDescription?: string;
                        verifiedAt?: Date;
                        websiteUrl?: string;
                        wireName: string;
                    },
                    | "referenceId"
                    | "name"
                    | "description"
                    | "achName"
                    | "wireName"
                    | "countryOfIncorporation"
                    | "taxId"
                    | "legalEntityType",
                >,
            > & {
                email?: string
                | null;
                incorporationDate?: string | null;
                operatingAddress?: OrganizationAddress | null;
                phone?: string | null;
                registeredAddress?: OrganizationAddress | null;
                registrationNumber?: string | null;
                routeFusionEntity?: Partial<
                    {
                        documentsUploadedAt?: string;
                        entityId: string;
                        lastFinalizeError?: { at: string; message: string }
                        | null;
                        programId?: string;
                        requiredDocuments?: string[][];
                        status: "PENDING" | "VERIFIED" | "REJECTED";
                    },
                >;
                stateOfIncorporation?: string
                | null;
                status?:
                    | "PENDING_VERIFICATION"
                    | "ACTION_REQUIRED"
                    | "APPROVED"
                    | "DISABLED";
                verificationData?: | {
                    status: VerificationStatus;
                    verificationSessionId?: string;
                    verificationTemplateId: string;
                }
                | null;
                verificationReasons?: VerificationReasons
                | null;
                websiteUrl?: string | null;
                zenusOnboardedAt?: string;
                zenusPersonId?: string;
            } & { workspaceId?: undefined } & {
                countryOfIncorporation?: undefined;
                email?: undefined;
                operatingAddress?: undefined;
                phone?: undefined;
                registeredAddress?: undefined;
                registrationNumber?: undefined;
                stateOfIncorporation?: undefined;
                taxId?: undefined;
                websiteUrl?: undefined;
            };
            id: string;
            tx?: undefined;
        }

      Returns Promise<
          | { ok: true; value: AdminOrganization }
          | {
              error:
                  | ServiceError<"NOT_FOUND" | "DUPLICATE">
                  | ServiceError<
                      | "INVALID_PHONE"
                      | "INVALID_EMAIL"
                      | "INVALID_WEBSITE_URL"
                      | "INVALID_US_STATE"
                      | "INVALID_STATE_OF_INCORPORATION",
                  >;
              ok: false;
          },
      >

    • Admin org write. Accepts the full editable business-field set, mapping each field exactly as OrganizationService.update does (top-level columns vs data jsonb).

      A change to a field KYB sends AiPrise (KYB_SYNDICATED_FIELDS) writes PENDING_VERIFICATION, then after the commit pushes the fields and re-runs KYB, as the customer path does; a refused run is ORGANIZATION_VERIFICATION_FAILED with the written row. An ACTION_REQUIRED org re-verifies only once the edit supplies what is missing. A caller's explicit status is written instead (the AiPrise decision callback writes APPROVED). statusUpdated is published only when the status changed.

      data.workspaceId links the ORGANIZATION workspace whose members sign in as this organization. Set once: the same workspace again writes nothing, another is refused. Only a link may run in a caller's tx, in a savepoint of it, so a refused link leaves the tx usable.

      Parameters

      • args: {
            data: Partial<
                Pick<
                    {
                        achName: string;
                        capabilities: (
                            | "TRANSACT"
                            | "MANAGE_PAYMENT_INSTRUMENT"
                            | "MANAGE_LEDGER_ACCOUNT"
                            | "MANAGE_DEPOSIT_MEMO"
                        )[];
                        countryCode: string;
                        countryOfIncorporation: string;
                        createdAt: Date;
                        deletedAt?: Date;
                        description?: string;
                        email?: string;
                        expectedActivity?: {
                            currencyCount: "TWO_OR_FEWER"
                            | "THREE"
                            | "MORE_THAN_THREE";
                            expectsOnlineGambling: boolean;
                            expectsSanctionedCountryActivity: boolean;
                            monthlyDepositAmount: "UP_TO_30000" | "30000_TO_100000" | "OVER_100000";
                            monthlyDepositCount: "TWO_OR_FEWER" | "THREE" | "MORE_THAN_THREE";
                            monthlyInternationalWireDepositAmount:
                                | "UP_TO_30000"
                                | "30000_TO_100000"
                                | "OVER_100000";
                            monthlyInternationalWireDepositCount: | "1_TO_5"
                            | "6_TO_10"
                            | "11_OR_MORE";
                            monthlyInternationalWirePaymentAmount: | "UP_TO_30000"
                            | "30000_TO_100000"
                            | "OVER_100000";
                            monthlyInternationalWirePaymentCount: | "1_TO_5"
                            | "6_TO_10"
                            | "11_OR_MORE";
                            monthlyPaymentAmount: "UP_TO_30000"
                            | "30000_TO_100000"
                            | "OVER_100000";
                            monthlyPaymentCount: "TWO_OR_FEWER" | "THREE" | "MORE_THAN_THREE";
                            operationsStartDate: string;
                            primaryPurpose:
                                | "RECEIVE_CUSTOMER_PAYMENTS"
                                | "EVERYDAY_PURCHASES"
                                | "PAY_SUPPLIERS_AND_EMPLOYEES"
                                | "MANAGE_MULTIPLE_CURRENCIES"
                                | "OTHER";
                            primaryPurposeDetail?: string;
                            sanctionedCountryActivityDetail?: string;
                            services: ("WIRES" | "ACH" | "FOREIGN_EXCHANGE" | "DEBIT_CARD")[];
                            topCountries: string[];
                        };
                        fullName: string;
                        id: string;
                        incorporationDate?: string;
                        legalEntityType: string;
                        metadata: Record<string, string>;
                        naicsCode?: string;
                        name: string;
                        operatingAddress?: OrganizationAddress;
                        phone?: E164Phone;
                        referenceId?: string;
                        registeredAddress?: OrganizationAddress;
                        registrationNumber?: string;
                        requiredInfo: RequiredInfoField[];
                        routeFusionEntity?: {
                            documentsUploadedAt?: string;
                            entityId: string;
                            lastFinalizeError?: { at: string; message: string } | null;
                            programId?: string;
                            requiredDocuments?: (...)[][];
                            status: "PENDING" | "VERIFIED" | "REJECTED";
                        } & { statusDescription: string };
                        stateOfIncorporation?: string;
                        status:
                            | "PENDING_VERIFICATION"
                            | "ACTION_REQUIRED"
                            | "APPROVED"
                            | "DISABLED"
                            | "DELETED";
                        statusDescription: string;
                        taxId: string;
                        type: "ORGANIZATION";
                        updatedAt: Date;
                        uuid: string;
                        verificationData?: {
                            status: VerificationStatus;
                            verificationSessionId?: string;
                            verificationTemplateId: string;
                        } & { statusDescription: string };
                        verificationProfileId?: string;
                        verificationReasonCode?:
                            | "OTHER"
                            | "INVALID_TAX_ID"
                            | "ADDRESS_MISMATCH"
                            | "REGISTRY_NOT_FOUND"
                            | "DOCUMENT_ISSUE"
                            | "IDENTITY_MISMATCH";
                        verificationReasonCodeDescription?: string;
                        verifiedAt?: Date;
                        websiteUrl?: string;
                        wireName: string;
                    },
                    | "referenceId"
                    | "name"
                    | "description"
                    | "achName"
                    | "wireName"
                    | "countryOfIncorporation"
                    | "taxId"
                    | "legalEntityType",
                >,
            > & {
                email?: string
                | null;
                incorporationDate?: string | null;
                operatingAddress?: OrganizationAddress | null;
                phone?: string | null;
                registeredAddress?: OrganizationAddress | null;
                registrationNumber?: string | null;
                routeFusionEntity?: Partial<
                    {
                        documentsUploadedAt?: string;
                        entityId: string;
                        lastFinalizeError?: { at: string; message: string }
                        | null;
                        programId?: string;
                        requiredDocuments?: string[][];
                        status: "PENDING" | "VERIFIED" | "REJECTED";
                    },
                >;
                stateOfIncorporation?: string
                | null;
                status?:
                    | "PENDING_VERIFICATION"
                    | "ACTION_REQUIRED"
                    | "APPROVED"
                    | "DISABLED";
                verificationData?: | {
                    status: VerificationStatus;
                    verificationSessionId?: string;
                    verificationTemplateId: string;
                }
                | null;
                verificationReasons?: VerificationReasons
                | null;
                websiteUrl?: string | null;
                zenusOnboardedAt?: string;
                zenusPersonId?: string;
            } & { workspaceId?: undefined };
            id: string;
            tx?: undefined;
        }

      Returns Promise<
          | { ok: true; value: AdminOrganization }
          | {
              error:
                  | ServiceError<"NOT_FOUND" | "DUPLICATE">
                  | ServiceError<
                      | "INVALID_PHONE"
                      | "INVALID_EMAIL"
                      | "INVALID_WEBSITE_URL"
                      | "INVALID_US_STATE"
                      | "INVALID_STATE_OF_INCORPORATION",
                  >
                  | OrganizationAdminVerificationFailed;
              ok: false;
          },
      >

    • Admin org write. Accepts the full editable business-field set, mapping each field exactly as OrganizationService.update does (top-level columns vs data jsonb).

      A change to a field KYB sends AiPrise (KYB_SYNDICATED_FIELDS) writes PENDING_VERIFICATION, then after the commit pushes the fields and re-runs KYB, as the customer path does; a refused run is ORGANIZATION_VERIFICATION_FAILED with the written row. An ACTION_REQUIRED org re-verifies only once the edit supplies what is missing. A caller's explicit status is written instead (the AiPrise decision callback writes APPROVED). statusUpdated is published only when the status changed.

      data.workspaceId links the ORGANIZATION workspace whose members sign in as this organization. Set once: the same workspace again writes nothing, another is refused. Only a link may run in a caller's tx, in a savepoint of it, so a refused link leaves the tx usable.

      Parameters

      • args: { id: string } & {
            data: Partial<
                Pick<
                    {
                        achName: string;
                        capabilities: (
                            | "TRANSACT"
                            | "MANAGE_PAYMENT_INSTRUMENT"
                            | "MANAGE_LEDGER_ACCOUNT"
                            | "MANAGE_DEPOSIT_MEMO"
                        )[];
                        countryCode: string;
                        countryOfIncorporation: string;
                        createdAt: Date;
                        deletedAt?: Date;
                        description?: string;
                        email?: string;
                        expectedActivity?: {
                            currencyCount: "TWO_OR_FEWER"
                            | "THREE"
                            | "MORE_THAN_THREE";
                            expectsOnlineGambling: boolean;
                            expectsSanctionedCountryActivity: boolean;
                            monthlyDepositAmount: "UP_TO_30000" | "30000_TO_100000" | "OVER_100000";
                            monthlyDepositCount: "TWO_OR_FEWER" | "THREE" | "MORE_THAN_THREE";
                            monthlyInternationalWireDepositAmount:
                                | "UP_TO_30000"
                                | "30000_TO_100000"
                                | "OVER_100000";
                            monthlyInternationalWireDepositCount: | "1_TO_5"
                            | "6_TO_10"
                            | "11_OR_MORE";
                            monthlyInternationalWirePaymentAmount: | "UP_TO_30000"
                            | "30000_TO_100000"
                            | "OVER_100000";
                            monthlyInternationalWirePaymentCount: | "1_TO_5"
                            | "6_TO_10"
                            | "11_OR_MORE";
                            monthlyPaymentAmount: "UP_TO_30000"
                            | "30000_TO_100000"
                            | "OVER_100000";
                            monthlyPaymentCount: "TWO_OR_FEWER" | "THREE" | "MORE_THAN_THREE";
                            operationsStartDate: string;
                            primaryPurpose:
                                | "RECEIVE_CUSTOMER_PAYMENTS"
                                | "EVERYDAY_PURCHASES"
                                | "PAY_SUPPLIERS_AND_EMPLOYEES"
                                | "MANAGE_MULTIPLE_CURRENCIES"
                                | "OTHER";
                            primaryPurposeDetail?: string;
                            sanctionedCountryActivityDetail?: string;
                            services: ("WIRES" | "ACH" | "FOREIGN_EXCHANGE" | "DEBIT_CARD")[];
                            topCountries: string[];
                        };
                        fullName: string;
                        id: string;
                        incorporationDate?: string;
                        legalEntityType: string;
                        metadata: Record<string, string>;
                        naicsCode?: string;
                        name: string;
                        operatingAddress?: OrganizationAddress;
                        phone?: E164Phone;
                        referenceId?: string;
                        registeredAddress?: OrganizationAddress;
                        registrationNumber?: string;
                        requiredInfo: RequiredInfoField[];
                        routeFusionEntity?: {
                            documentsUploadedAt?: string;
                            entityId: string;
                            lastFinalizeError?: { at: ...; message: ... } | null;
                            programId?: string;
                            requiredDocuments?: (...)[];
                            status: "PENDING" | "VERIFIED" | "REJECTED";
                        } & { statusDescription: string };
                        stateOfIncorporation?: string;
                        status:
                            | "PENDING_VERIFICATION"
                            | "ACTION_REQUIRED"
                            | "APPROVED"
                            | "DISABLED"
                            | "DELETED";
                        statusDescription: string;
                        taxId: string;
                        type: "ORGANIZATION";
                        updatedAt: Date;
                        uuid: string;
                        verificationData?: {
                            status: VerificationStatus;
                            verificationSessionId?: string;
                            verificationTemplateId: string;
                        } & { statusDescription: string };
                        verificationProfileId?: string;
                        verificationReasonCode?:
                            | "OTHER"
                            | "INVALID_TAX_ID"
                            | "ADDRESS_MISMATCH"
                            | "REGISTRY_NOT_FOUND"
                            | "DOCUMENT_ISSUE"
                            | "IDENTITY_MISMATCH";
                        verificationReasonCodeDescription?: string;
                        verifiedAt?: Date;
                        websiteUrl?: string;
                        wireName: string;
                    },
                    | "referenceId"
                    | "name"
                    | "description"
                    | "achName"
                    | "wireName"
                    | "countryOfIncorporation"
                    | "taxId"
                    | "legalEntityType",
                >,
            > & {
                email?: string
                | null;
                incorporationDate?: string | null;
                operatingAddress?: OrganizationAddress | null;
                phone?: string | null;
                registeredAddress?: OrganizationAddress | null;
                registrationNumber?: string | null;
                routeFusionEntity?: Partial<
                    {
                        documentsUploadedAt?: string;
                        entityId: string;
                        lastFinalizeError?: { at: string; message: string }
                        | null;
                        programId?: string;
                        requiredDocuments?: string[][];
                        status: "PENDING" | "VERIFIED" | "REJECTED";
                    },
                >;
                stateOfIncorporation?: string
                | null;
                status?:
                    | "PENDING_VERIFICATION"
                    | "ACTION_REQUIRED"
                    | "APPROVED"
                    | "DISABLED";
                verificationData?: | {
                    status: VerificationStatus;
                    verificationSessionId?: string;
                    verificationTemplateId: string;
                }
                | null;
                verificationReasons?: VerificationReasons
                | null;
                websiteUrl?: string | null;
                zenusOnboardedAt?: string;
                zenusPersonId?: string;
            } & { workspaceId?: string };
            tx?: undefined;
        }

      Returns Promise<
          | { ok: true; value: AdminOrganization }
          | {
              error:
                  | ServiceError<"NOT_FOUND" | "DUPLICATE">
                  | ServiceError<
                      | "INVALID_PHONE"
                      | "INVALID_EMAIL"
                      | "INVALID_WEBSITE_URL"
                      | "INVALID_US_STATE"
                      | "INVALID_STATE_OF_INCORPORATION",
                  >
                  | OrganizationAdminVerificationFailed
                  | OrganizationWorkspaceLinkError;
              ok: false;
          },
      >

    • Admin org write. Accepts the full editable business-field set, mapping each field exactly as OrganizationService.update does (top-level columns vs data jsonb).

      A change to a field KYB sends AiPrise (KYB_SYNDICATED_FIELDS) writes PENDING_VERIFICATION, then after the commit pushes the fields and re-runs KYB, as the customer path does; a refused run is ORGANIZATION_VERIFICATION_FAILED with the written row. An ACTION_REQUIRED org re-verifies only once the edit supplies what is missing. A caller's explicit status is written instead (the AiPrise decision callback writes APPROVED). statusUpdated is published only when the status changed.

      data.workspaceId links the ORGANIZATION workspace whose members sign in as this organization. Set once: the same workspace again writes nothing, another is refused. Only a link may run in a caller's tx, in a savepoint of it, so a refused link leaves the tx usable.

      Parameters

      • args: OrganizationAdminUpdateArgs

      Returns Promise<
          | { ok: true; value: AdminOrganization }
          | {
              error:
                  | ServiceError<"NOT_FOUND" | "DUPLICATE">
                  | ServiceError<
                      | "INVALID_PHONE"
                      | "INVALID_EMAIL"
                      | "INVALID_WEBSITE_URL"
                      | "INVALID_US_STATE"
                      | "INVALID_STATE_OF_INCORPORATION",
                  >
                  | OrganizationWorkspaceLinkError;
              ok: false;
          },
      >

    • The exact key OrganizationAdminQueryService.get reads through, for its includeDeleted: false callers.

      The includeDeleted: true variant hashes differently and is reached only by the collection tag, which every Valkey-backed environment has. That gap is deliberate and pre-existing: it only matters in memory mode, where no admin get runs with includeDeleted: true.

      Parameters

      • __namedParameters: { id: string }

      Returns Record<string, unknown>

    • The exact key OrganizationQueryService.get reads through.

      get folds onto search, so these args must stay identical to the ones it passes ({ customerId, ids: [id], pageSize: 1 }) plus the defaults search bakes into its own key — includeDeleted: false and page: 1. Every other filter is undefined there, and serviceCacheKey canonicalizes with JCS, which drops undefined properties. organizationCache.test.ts pins the equivalence.

      Parameters

      • __namedParameters: { customerId: string; id: string }

      Returns Record<string, unknown>