Checking access…

Skip to main content
Audience: CCG Platform Engineers

Find or Create Customer β€” Internal API

Use this page when a CCG service calls /customers/find or needs to interpret the returned wallet and vendor status. For the implementation, use Customer Creation β€” Service Flow and Events.

Overview​

ItemDetail
RoutePOST /customers/find in wallet-customer-service
CallerInternal CCG services; merchants use session, payment, or payment-method APIs that invoke it indirectly
VersionsShared by V1 and V2; routing is versioned at the virtual-service and HCP layers
Success200 OK with the resolved CCG customer; vendor provisioning may continue asynchronously
Internal endpoint

Do not call /customers/find directly from a merchant integration. Use the merchant-facing entry points; CCG invokes this route internally.

The internal OpenAPI specification has not yet been updated for this endpoint. Use the request and response behavior below when working with this internal call.

Request​

InputRequirementPurpose
X-Merchant-IdRequiredSelects the merchant context.
enterpriseId, hsid, or metadata (merchant customer identifiers, or MCIDs)At least one requiredIdentifies the customer for lookup or creation.
X-VendorsOptionalLimits the vendor contexts returned. When omitted, all vendors configured for the merchant are included.

enterpriseId has the highest identification precedence, followed by hsid and merchant identifiers. MCID matching uses the merchant's enterpriseSettings; see Customer Lookup Logic (EIMP) for its criteria and Customer Lookup Logic (CCG Database) for the local lookup.

Sample Request
POST /customers/find
X-Merchant-Id: <merchant-id>
X-Vendors: STRIPE,OPTUM_BANK
Content-Type: application/json

{
"metadata": {
"patientId": "222333444"
}
}

The body can instead supply enterpriseId or hsid. metadata contains merchant-specific identifiers such as patientId or subscriberId. The service looks up the customer using the supplied identifiers; an EIMP match yields an enterprise wallet, while a customer without an enterprise match can receive a local wallet. Local wallets can be shared within a merchant group. See Wallet Upgrade Logic for later promotion to an enterprise wallet.

Other valid request bodies include {"enterpriseId": "603041336"} and {"hsid": "123e4567-e89b-12d3-a456-426614174000"}.

How customer lookup resolves​

Input or lookup resultCaller-visible result
A matching CCG customer existsReturns the existing customer, updated with resolved identity data as applicable.
One EIMP golden record matchesReturns an enterprise wallet, creating the CCG customer if needed.
No enterprise match, but hsid or metadata allows local identificationReturns an existing or new local wallet.
Only enterpriseId is supplied and EIMP finds no customerReturns Customer Not found for given Enterprise Id.
No enterpriseId, hsid, or metadata is suppliedReturns Required any one of the identifier. Enterprise Id or hsid or MCID.

Repeated calls with the same identifiers look up and update the existing customer rather than intentionally creating another wallet.

For the customer and wallet decision tree, local-wallet fallback, and record-processing diagrams, use the customer creation service flow. For merchant-configured MCID search order, use MCID criteria-set precedence in EIMP. The CCG database lookup and local-to-enterprise merge guides cover later lookup and wallet consolidation details.

Response and vendor status​

The response includes walletCustomerId and vendor information. vendorContext is keyed by vendor name (for example, STRIPE or OPTUM_BANK); X-Vendors controls which configured vendors are included. A single-vendor response also exposes vendor fields at the top level.

StatusMeaning for the caller
INITIATEDThe CCG customer exists, but at least one requested TWO_TIER vendor's customer mapping is not ready.
CREATEDThe requested vendor customer mapping is ready. With multiple vendors, the overall status is CREATED only when every returned vendor context is CREATED.
A successful response can still need vendor provisioning

200 OK confirms that the CCG customer was resolved. If the response is INITIATED, do not treat its vendor mapping as ready. WALLET_CUSTOMER_CREATION_INITIALIZED starts vendor creation; WALLET_CUSTOMER_UPDATED_EVENT is published after the vendor platform and merchant mappings are available. Check a later customer response for CREATED.

For example, a completed Stripe context includes the vendor's customer identifiers:

Sample Response
{
"walletCustomerId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"status": "CREATED",
"vendorContext": {
"STRIPE": {
"vendorName": "STRIPE",
"status": "CREATED",
"vendorPlatformId": "acct_xxx",
"vendorMerchantCustomerId": "cus_xxx",
"vendorPlatformCustomerId": "cus_xxx"
}
}
}

Before that mapping is ready, a TWO_TIER vendor such as Stripe can have status: "INITIATED" without vendor customer IDs. A PASS_THROUGH vendor such as Optum Bank skips vendor provisioning and can return CREATED immediately; vendorPlatformCustomerId contains the HSID when one is resolved. See vendor model configuration for the service-side rules.

See the service event sequence when tracing either event.

Errors and caller checks​

ScenarioBehavior
Missing all customer identifiersRequest validation fails with Required any one of the identifier. Enterprise Id or hsid or MCID.
enterpriseId alone has no EIMP matchCustomer resolution fails with Customer Not found for given Enterprise Id.
Missing or invalid X-Merchant-IdMerchant lookup or request validation rejects the call before customer resolution.

An internal caller should supply the merchant context and at least one identifier, handle INITIATED separately from CREATED, and use the later customer state or WALLET_CUSTOMER_UPDATED_EVENT when waiting for TWO_TIER vendor provisioning. For errors surfaced by merchant-facing session or payment operations that call this endpoint, see Session Error Codes and Payment Error Codes.