{"openapi":"3.1.0","info":{"title":"Caret Integration APIs","version":"1.0.0","description":"Published ACF, communications and external-client contracts. Internal staff route inventories are documented separately."},"servers":[{"url":"https://api.caretlegal.net","description":"Production"},{"url":"http://localhost:3061","description":"Development"}],"paths":{"/acf":{"get":{"summary":"Lookup entity","description":"Query the ledger for an entity and get all linked records","operationId":"lookupEntity","tags":["Entity Mappings"],"parameters":[{"$ref":"#/components/parameters/acf_OrganizationId"},{"name":"connectorName","in":"query","required":true,"schema":{"type":"string"},"description":"External system name","example":"netsuite"},{"name":"entityName","in":"query","required":true,"schema":{"type":"string"},"description":"Type of entity","example":"customer"},{"name":"entityId","in":"query","required":true,"schema":{"type":"string"},"description":"External system's ID","example":"D5720-00"}],"responses":{"200":{"description":"Entity found with linked records","content":{"application/json":{"schema":{"$ref":"#/components/schemas/acf_LookupResponse"}}}},"401":{"description":"Authentication required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/acf_ErrorResponse"}}}},"404":{"description":"Entity not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/acf_ErrorResponse"}}}}},"security":[{"acf_ApiKeyAuth":[]}]},"post":{"summary":"Register entity","description":"Register a new entity mapping in the ledger","operationId":"registerEntity","tags":["Entity Mappings"],"parameters":[{"$ref":"#/components/parameters/acf_OrganizationId"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/acf_RegisterEntityRequest"}}}},"responses":{"200":{"description":"Entity already exists","content":{"application/json":{"schema":{"$ref":"#/components/schemas/acf_RegisterEntityResponse"}}}},"201":{"description":"New entity created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/acf_RegisterEntityResponse"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/acf_ErrorResponse"}}}},"401":{"description":"Authentication required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/acf_ErrorResponse"}}}}},"security":[{"acf_ApiKeyAuth":[]}]}},"/acf/{masterId}":{"get":{"summary":"Get by Master ID","description":"Get all entities linked to a specific Master ID","operationId":"getByMasterId","tags":["Entity Mappings"],"parameters":[{"$ref":"#/components/parameters/acf_OrganizationId"},{"name":"masterId","in":"path","required":true,"schema":{"type":"string","format":"uuid"},"description":"Master ID to lookup"}],"responses":{"200":{"description":"Linked entities found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/acf_LookupResponse"}}}},"401":{"description":"Authentication required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/acf_ErrorResponse"}}}},"404":{"description":"Master ID not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/acf_ErrorResponse"}}}}},"security":[{"acf_ApiKeyAuth":[]}]}},"/acf/customers/resolve":{"get":{"summary":"Resolve and hydrate a customer","description":"Resolves a customer from any supported connector identifier, returns every identity linked by the ACF master ID, and hydrates an allowlisted company projection from each provider. The canonical customer entity maps to customer in Caret, NetSuite, Salesforce, and Stripe; it maps to organization in Clerk and Zendesk. Provider failures are returned as source status unavailable with partial=true and do not suppress successful providers. The operation is read-only and never changes ledger mappings.","operationId":"resolveAcfCustomer","tags":["Customer Resolution"],"parameters":[{"$ref":"#/components/parameters/acf_OrganizationId"},{"name":"connectorName","in":"query","required":true,"schema":{"type":"string","enum":["caret","netsuite","salesforce","stripe","clerk","zendesk","zoho"]},"description":"System whose identifier is supplied."},{"name":"entityId","in":"query","required":true,"schema":{"type":"string","minLength":1},"description":"Customer or organization identifier in the selected connector.","example":"0014v00002jSil8AAC"}],"responses":{"200":{"description":"Resolved customer, including partial provider results when applicable.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/acf_CustomerResolutionResponse"},"examples":{"resolvedFromSalesforce":{"summary":"Resolve using a Salesforce Account ID","value":{"success":true,"data":{"lookup":{"connectorName":"salesforce","entityId":"0014v00002jSil8AAC"},"masterId":"12d37fdd-eff5-46f0-807a-52f7e79e02da","identities":[],"sources":[],"comparison":{"sources":[],"fields":[]},"billing":null,"partial":false,"resolvedAt":"2026-08-04T20:00:00.000Z"}}},"partialProviderFailure":{"summary":"Salesforce is unavailable while other provider data is returned","value":{"success":true,"data":{"lookup":{"connectorName":"netsuite","entityId":"D5720-00"},"masterId":"12d37fdd-eff5-46f0-807a-52f7e79e02da","identities":[],"sources":[{"system":"salesforce","label":"Salesforce","entityName":"customer","recordId":"0014v00002jSil8AAC","status":"unavailable","values":{"name":null,"email":null,"phone":null,"website":null,"address":null}}],"comparison":{"sources":[],"fields":[]},"billing":null,"partial":true,"resolvedAt":"2026-08-04T20:00:00.000Z"}}}}}}},"400":{"description":"Invalid connector, missing identifier, or missing organization context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/acf_ErrorResponse"}}}},"401":{"description":"Authentication required.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/acf_ErrorResponse"}}}},"404":{"description":"No ACF customer mapping exists for the supplied connector identifier.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/acf_ErrorResponse"}}}}},"security":[{"acf_ApiKeyAuth":[]}]}},"/communications/send":{"post":{"summary":"Send a customer communication","operationId":"sendCommunication","tags":["Communications"],"parameters":[{"$ref":"#/components/parameters/communications_OrganizationId"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/communications_SendCommunicationRequest"},"examples":{"salesforceCustomer":{"summary":"Salesforce-initiated customer email","value":{"communicationType":"generic","recipientRef":{"entityType":"customer","acfSource":"salesforce","sourceId":"001xx000003DGbYAAW"},"contact":{"email":"billing@example.com","name":"Example Customer"},"subject":"Action required: billing update","bodyHtml":"<p>Please update your billing information.</p>","metadata":{"campaignId":"sf-campaign-123"}}},"genericWithRecipientEnvelope":{"summary":"Generic email with decorated recipient envelope","value":{"communicationType":"generic","recipientRef":{"entityType":"customer","acfSource":"netsuite","sourceId":"123"},"recipients":{"to":[{"email":"ap@example.com","name":"Accounts Payable"}],"cc":["owner@example.com"],"bcc":[{"email":"audit@example.com"}]},"subject":"Statement available","bodyText":"Please review your statement."}},"netsuiteStatement":{"summary":"NetSuite-initiated statement email","value":{"communicationType":"customer_statement","recipientRef":{"entityType":"customer","acfSource":"netsuite","sourceId":"123"},"dateRange":{"startDate":"2026-01-01","endDate":"2026-01-31"}}}}}}},"responses":{"202":{"description":"Communication accepted, sent through the handler, and logged locally.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/communications_SendCommunicationResponse"}}}},"400":{"description":"Invalid request or organization scope.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/communications_ErrorResponse"}}}},"401":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/communications_ErrorResponse"}}}},"403":{"description":"API key lacks communications:write.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/communications_ErrorResponse"}}}},"404":{"description":"Recipient reference did not resolve to a local customer.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/communications_ErrorResponse"}}}}},"security":[{"communications_InternalApiKey":[]},{"communications_PartnerBearer":[]}]}},"/communications":{"get":{"summary":"Query customer communications","operationId":"queryCommunications","tags":["Communications"],"parameters":[{"$ref":"#/components/parameters/communications_OrganizationId"},{"name":"acfSource","in":"query","schema":{"type":"string","default":"netsuite"},"description":"Connector/source name in the ACF ledger."},{"name":"entityType","in":"query","schema":{"type":"string","enum":["customer"],"default":"customer"}},{"name":"sourceId","in":"query","required":true,"schema":{"type":"string"},"description":"External customer ID, such as a NetSuite customer internal ID."},{"name":"type","in":"query","schema":{"type":"string"},"description":"Comma-separated communication type filter, e.g. customer_statement."},{"name":"status","in":"query","schema":{"type":"string"},"description":"Comma-separated status filter."},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":50}},{"name":"offset","in":"query","schema":{"type":"integer","minimum":0,"default":0}}],"responses":{"200":{"description":"Communications for the resolved customer.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/communications_QueryCommunicationsResponse"}}}},"400":{"description":"Invalid request or organization scope.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/communications_ErrorResponse"}}}},"401":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/communications_ErrorResponse"}}}},"403":{"description":"API key lacks communications:read.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/communications_ErrorResponse"}}}},"404":{"description":"Recipient reference did not resolve to a local customer.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/communications_ErrorResponse"}}}}},"security":[{"communications_InternalApiKey":[]},{"communications_PartnerBearer":[]}]}},"/integrations/external-clients/customers/resolve":{"get":{"operationId":"resolveExternalCustomer","summary":"Resolve an external customer identity","description":"Checks whether a provider internal customer ID maps to an existing local customer.","parameters":[{"name":"x-organization-id","in":"header","required":true,"schema":{"type":"string"}},{"name":"provider","in":"query","required":true,"schema":{"type":"string"},"examples":{"netsuite":{"value":"netsuite"},"salesforce":{"value":"salesforce"}}},{"name":"externalCustomerId","in":"query","required":true,"schema":{"type":"string"},"description":"Provider-generated internal customer/account/entity primary key."}],"responses":{"200":{"description":"Lookup completed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/external_clients_ResolveCustomerResponse"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/external_clients_ErrorResponse"}}}},"401":{"description":"Invalid API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/external_clients_ErrorResponse"}}}},"403":{"description":"Missing scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/external_clients_ErrorResponse"}}}}},"security":[{"external_clients_PartnerApiKey":[]}]}},"/integrations/external-clients/magic-link":{"post":{"operationId":"createCustomerAccessMagicLink","summary":"Create or send a customer-access magic link","description":"Resolves or guarded-creates customer/contact records, ensures Clerk org/user membership, creates a Clerk sign-in token, and either sends or returns the link.","parameters":[{"name":"x-organization-id","in":"header","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/external_clients_MagicLinkRequest"},"examples":{"netsuiteSend":{"summary":"NetSuite send mode","value":{"provider":"netsuite","externalCustomerId":"12345","externalContactId":"67890","email":"ap@example.com","firstName":"Ava","lastName":"Parker","customerName":"Example Law","mode":"send","createIfMissing":true}},"salesforceReturnLink":{"summary":"Salesforce return-link mode","value":{"provider":"salesforce","externalCustomerId":"001xx000003DGbYAAW","externalContactId":"003xx000004TmiYAAS","email":"owner@example.com","customerName":"Example Law","mode":"return_link","createIfMissing":true,"tokenExpiresInSeconds":604800}}}}}},"responses":{"200":{"description":"Magic link returned","content":{"application/json":{"schema":{"$ref":"#/components/schemas/external_clients_MagicLinkResponse"}}}},"202":{"description":"Magic-link send accepted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/external_clients_MagicLinkResponse"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/external_clients_ErrorResponse"}}}},"401":{"description":"Invalid API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/external_clients_ErrorResponse"}}}},"403":{"description":"Missing scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/external_clients_ErrorResponse"}}}},"404":{"description":"Missing customer/contact without createIfMissing","content":{"application/json":{"schema":{"$ref":"#/components/schemas/external_clients_ErrorResponse"}}}},"409":{"description":"Duplicate guard blocked creation","content":{"application/json":{"schema":{"$ref":"#/components/schemas/external_clients_ErrorResponse"}}}}},"security":[{"external_clients_PartnerApiKey":[]}]}},"/integrations/external-clients/salesforce/opportunity-payment-setup":{"post":{"operationId":"startSalesforceOpportunityPaymentSetup","summary":"Start Salesforce Opportunity payment setup","description":"For an eligible Salesforce Opportunity, resolves or creates the customer and bootstrap contact from Account.Email__c, provisions customer portal access, creates a durable payment setup intent, and either sends or returns the one-time link.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/external_clients_SalesforceOpportunityPaymentSetupRequest"},"examples":{"send":{"summary":"Account-email bootstrap send mode","value":{"source":"salesforce","account_id":"001xx000003DGbYAAW","account_name":"Example Law","contact_email":"owner@example.com","opportunity_id":"006xx000004XYZAAA4","stage_name":"4 - Proposal","mode":"send","create_if_missing":true,"returnCtaLabel":"Return to Deal Room"}},"returnLink":{"summary":"Account-email bootstrap return-link mode","value":{"source":"salesforce","account_id":"001xx000003DGbYAAW","account_name":"Example Law","contact_email":"owner@example.com","opportunity_id":"006xx000004XYZAAA4","stage_name":"4 - Proposal","mode":"return_link","create_if_missing":true,"Deal_Room_URL__c":"https://deal-room.example.com/opportunities/006xx000004XYZAAA4"}}}}}},"responses":{"200":{"description":"Magic link returned","content":{"application/json":{"schema":{"$ref":"#/components/schemas/external_clients_SalesforceOpportunityPaymentSetupResponse"}}}},"202":{"description":"Magic-link send accepted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/external_clients_SalesforceOpportunityPaymentSetupResponse"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/external_clients_ErrorResponse"}}}},"401":{"description":"Invalid API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/external_clients_ErrorResponse"}}}},"403":{"description":"Missing scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/external_clients_ErrorResponse"}}}},"409":{"description":"Wrong Opportunity stage or duplicate guard block","content":{"application/json":{"schema":{"$ref":"#/components/schemas/external_clients_ErrorResponse"}}}}},"security":[{"external_clients_PartnerApiKey":[]}]},"get":{"operationId":"getSalesforceOpportunityPaymentSetupStatus","summary":"Get Salesforce Opportunity payment setup status","description":"Looks up the durable payment setup intent by Salesforce Opportunity Id.","parameters":[{"name":"opportunity_id","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Status lookup completed"},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/external_clients_ErrorResponse"}}}},"401":{"description":"Invalid API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/external_clients_ErrorResponse"}}}},"403":{"description":"Missing scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/external_clients_ErrorResponse"}}}}},"security":[{"external_clients_PartnerApiKey":[]}]}},"/integrations/external-clients/dealhub/deal-rooms":{"post":{"operationId":"publishDealHubDealRoom","summary":"Publish a DealHub DealRoom for a CRM Opportunity","description":"Uses the API-owned DealHub service and credential to generate a published DealRoom, waits for asynchronous publication, and returns the quote ID and URL. Requires the payment-setup create scope.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/external_clients_DealHubDealRoomRequest"}}}},"responses":{"200":{"description":"DealRoom published","content":{"application/json":{"schema":{"$ref":"#/components/schemas/external_clients_DealHubDealRoomResponse"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/external_clients_ErrorResponse"}}}},"401":{"description":"Invalid API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/external_clients_ErrorResponse"}}}},"403":{"description":"Missing payment-setup scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/external_clients_ErrorResponse"}}}},"502":{"description":"DealHub provider request failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/external_clients_ErrorResponse"}}}},"503":{"description":"DealHub API runtime configuration is missing","content":{"application/json":{"schema":{"$ref":"#/components/schemas/external_clients_ErrorResponse"}}}},"504":{"description":"DealRoom publication did not complete before the polling deadline","content":{"application/json":{"schema":{"$ref":"#/components/schemas/external_clients_ErrorResponse"}}}}},"security":[{"external_clients_PartnerApiKey":[]}]}},"/integrations/external-clients/customers/merge":{"post":{"operationId":"mergeAcfCustomerMasters","summary":"Merge two ACF customer masters","description":"Moves mappings from targetMasterId to sourceMasterId. Requires an elevated merge scope and an auditable reason.","parameters":[{"name":"x-organization-id","in":"header","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/external_clients_MergeCustomerMastersRequest"}}}},"responses":{"200":{"description":"Masters merged","content":{"application/json":{"schema":{"$ref":"#/components/schemas/external_clients_MergeCustomerMastersResponse"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/external_clients_ErrorResponse"}}}},"401":{"description":"Invalid API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/external_clients_ErrorResponse"}}}},"403":{"description":"Missing merge scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/external_clients_ErrorResponse"}}}}},"security":[{"external_clients_PartnerApiKey":[]}]}}},"components":{"securitySchemes":{"acf_ApiKeyAuth":{"type":"apiKey","in":"header","name":"x-acf-api-key","description":"ACF API key for authentication"},"communications_InternalApiKey":{"type":"apiKey","in":"header","name":"Authorization","description":"Internal service key using the format: ApiKey <key>"},"communications_PartnerBearer":{"type":"http","scheme":"bearer","description":"Partner API key with the communications:write scope."},"external_clients_PartnerApiKey":{"type":"http","scheme":"bearer","description":"Partner API key issued from Admin Settings -> API Keys."}},"schemas":{"acf_ConnectorEntityMapping":{"type":"object","properties":{"id":{"type":"string","format":"uuid","description":"Internal ACF record ID"},"masterId":{"type":"string","format":"uuid","description":"Master ID linking entities across systems"},"organizationId":{"type":"string","format":"uuid","description":"Organization this record belongs to"},"connectorName":{"type":"string","description":"External system name (e.g., netsuite, stripe, zendesk)","example":"stripe"},"entityName":{"type":"string","description":"Type of entity (e.g., customer, invoice)","example":"customer"},"entityId":{"type":"string","description":"External system's ID for this entity","example":"cus_abc123"},"connectorEntityHash":{"type":"string","description":"MD5 hash for deduplication"},"senderObjectHash":{"type":"object","additionalProperties":{"type":"string"},"description":"Tracks which systems have processed this record"},"connectorEntityDetails":{"type":"object","additionalProperties":true,"description":"Additional metadata from the connector"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","masterId","connectorName","entityName","entityId"]},"acf_RegisterEntityRequest":{"type":"object","properties":{"connectorName":{"type":"string","minLength":1,"description":"External system name","example":"stripe"},"entityName":{"type":"string","minLength":1,"description":"Type of entity","example":"customer"},"entityId":{"type":"string","minLength":1,"description":"External system's ID","example":"cus_abc123"},"connectorEntityDetails":{"type":"object","additionalProperties":true,"description":"Optional additional metadata"},"masterId":{"type":"string","format":"uuid","description":"Optional - link to existing master ID"}},"required":["connectorName","entityName","entityId"]},"acf_RegisterEntityResponse":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"type":"object","properties":{"entry":{"$ref":"#/components/schemas/acf_ConnectorEntityMapping"},"isNew":{"type":"boolean","description":"True if a new record was created"}}}}},"acf_LookupResponse":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"type":"array","items":{"$ref":"#/components/schemas/acf_ConnectorEntityMapping"}}}},"acf_CustomerCompanyValues":{"type":"object","description":"Allowlisted CBC company projection. This is not a raw provider payload.","properties":{"name":{"type":["string","null"]},"email":{"type":["string","null"]},"phone":{"type":["string","null"]},"website":{"type":["string","null"]},"address":{"type":["string","null"]}},"required":["name","email","phone","website","address"]},"acf_ConnectorIdentity":{"type":"object","description":"An ACF ledger identity linked to the resolved master ID.","properties":{"connectorEntityDetails":{"type":"object","additionalProperties":true},"entityName":{"type":"string"},"connectorEntityHash":{"type":"string"},"entityId":{"type":"string"},"connectorName":{"type":"string"},"updatedDate":{"type":"string","format":"date-time"},"masterId":{"type":"string","format":"uuid"},"senderObjectHash":{"type":"object","additionalProperties":{"type":"string"}},"configId":{"type":["string","null"]}},"required":["connectorEntityDetails","entityName","connectorEntityHash","entityId","connectorName","updatedDate","masterId","senderObjectHash","configId"]},"acf_CustomerCompanySource":{"type":"object","properties":{"system":{"type":"string","enum":["netsuite","salesforce","stripe","clerk","zendesk","zoho"]},"label":{"type":"string"},"entityName":{"type":"string","enum":["customer","organization"]},"recordId":{"type":["string","null"]},"status":{"type":"string","enum":["available","unavailable","not_linked"]},"values":{"$ref":"#/components/schemas/acf_CustomerCompanyValues"}},"required":["system","label","entityName","recordId","status","values"]},"acf_CustomerComparisonField":{"type":"object","properties":{"key":{"type":"string","enum":["name","email","phone","website","address"]},"label":{"type":"string"},"status":{"type":"string","enum":["match","mismatch","insufficient"]},"values":{"type":"object","additionalProperties":{"type":["string","null"]}}},"required":["key","label","status","values"]},"acf_CustomerResolution":{"type":"object","properties":{"lookup":{"type":"object","properties":{"connectorName":{"type":"string","enum":["caret","netsuite","salesforce","stripe","clerk","zendesk","zoho"]},"entityId":{"type":"string"}},"required":["connectorName","entityId"]},"masterId":{"type":"string","format":"uuid"},"identities":{"type":"array","items":{"$ref":"#/components/schemas/acf_ConnectorIdentity"}},"sources":{"type":"array","items":{"$ref":"#/components/schemas/acf_CustomerCompanySource"}},"comparison":{"type":"object","properties":{"sources":{"type":"array","items":{"$ref":"#/components/schemas/acf_CustomerCompanySource"}},"fields":{"type":"array","items":{"$ref":"#/components/schemas/acf_CustomerComparisonField"}}},"required":["sources","fields"]},"billing":{"type":"object","nullable":true,"description":"Zoho Billing to Stripe payment-method reconciliation. Resolves the Zoho customer from the NetSuite subscription id, firm id, Salesforce account id, or billing email, then compares its payment instruments with the saved payment methods on the linked Stripe customer.","properties":{"verdict":{"type":"string","enum":["match","mismatch","no_zoho_record","no_stripe_customer","no_payment_method","unverified"]},"summary":{"type":"string"},"checks":{"type":"array","items":{"type":"object","properties":{"key":{"type":"string","enum":["last_four","netsuite_link","name","email"]},"label":{"type":"string"},"status":{"type":"string","enum":["match","mismatch","insufficient"]},"zoho":{"type":"string","nullable":true},"stripe":{"type":"string","nullable":true}},"required":["key","label","status","zoho","stripe"]}},"keys":{"type":"object","additionalProperties":{"type":"string","nullable":true}},"zoho":{"type":"object","description":"Zoho customer, subscriptions, and payment instruments on file. `matchedBy` is `acf_ledger` when the Zoho identity registered by ACF sync was reused, otherwise the NetSuite key that located it."},"stripe":{"type":"object","description":"Stripe customer and saved payment methods."},"resolvedAt":{"type":"string","format":"date-time"}},"required":["verdict","summary","checks","keys","zoho","stripe","resolvedAt"]},"partial":{"type":"boolean","description":"True when at least one supported provider is unavailable or not linked."},"resolvedAt":{"type":"string","format":"date-time"}},"required":["lookup","masterId","identities","sources","comparison","billing","partial","resolvedAt"]},"acf_CustomerResolutionResponse":{"type":"object","properties":{"success":{"type":"boolean","const":true},"data":{"$ref":"#/components/schemas/acf_CustomerResolution"}},"required":["success","data"]},"acf_ErrorResponse":{"type":"object","properties":{"success":{"type":"boolean","example":false},"error":{"type":"string","description":"Error message"}}},"communications_RecipientRef":{"type":"object","properties":{"entityType":{"type":"string","enum":["customer"],"description":"Entity type to resolve through ACF."},"acfSource":{"type":"string","example":"salesforce","description":"Connector/source name in the ACF ledger."},"sourceId":{"type":"string","example":"001xx000003DGbYAAW","description":"Source-system entity ID to resolve to a local customer."}},"required":["entityType","acfSource","sourceId"]},"communications_ContactOverride":{"type":"object","properties":{"email":{"type":"string","format":"email","description":"Recipient email. Defaults to the local customer email when omitted."},"firstName":{"type":"string"},"lastName":{"type":"string"},"name":{"type":"string","description":"Display name used by generic email rendering when first/last are omitted."}}},"communications_EmailRecipient":{"oneOf":[{"type":"string","format":"email"},{"type":"object","properties":{"email":{"type":"string","format":"email"},"name":{"type":"string"}},"required":["email"]}]},"communications_RecipientEnvelope":{"type":"object","description":"Canonical recipient envelope. to is required when using recipients; contact.email remains supported as a legacy primary recipient.","properties":{"to":{"type":"array","items":{"$ref":"#/components/schemas/communications_EmailRecipient"},"minItems":1},"cc":{"type":"array","items":{"$ref":"#/components/schemas/communications_EmailRecipient"}},"bcc":{"type":"array","items":{"$ref":"#/components/schemas/communications_EmailRecipient"}}},"required":["to"]},"communications_SendCommunicationRequest":{"type":"object","properties":{"communicationType":{"type":"string","enum":["generic","customer_statement"],"default":"generic","description":"Use generic for ad-hoc email or customer_statement for a statement of account email."},"recipientRef":{"$ref":"#/components/schemas/communications_RecipientRef"},"recipients":{"$ref":"#/components/schemas/communications_RecipientEnvelope"},"contact":{"$ref":"#/components/schemas/communications_ContactOverride","description":"Legacy primary recipient override. Prefer recipients.to for new integrations."},"subject":{"type":"string","example":"Action required: update your billing contact","description":"Required for generic communications. Customer statements generate their own subject."},"bodyHtml":{"type":"string","description":"Rendered HTML body. Either bodyHtml or bodyText is required."},"bodyText":{"type":"string","description":"Plain text body. Used to derive HTML when bodyHtml is omitted."},"metadata":{"type":"object","additionalProperties":true,"description":"Caller metadata. The API fortifies this with local communication and ACF resolution metadata."},"dateRange":{"type":"object","description":"Statement period for customer_statement. Defaults to the trailing 12 months when omitted.","properties":{"startDate":{"type":"string","format":"date"},"endDate":{"type":"string","format":"date"}},"required":["startDate","endDate"]},"ccEmails":{"type":"array","items":{"type":"string","format":"email"},"description":"Additional statement CC recipients."},"customMessage":{"type":"string","description":"Optional custom message for customer_statement emails."},"organizationName":{"type":"string","description":"Optional display name used by the statement email template."},"idempotencyKey":{"type":"string","description":"Optional caller-supplied statement idempotency key."},"templateVariables":{"type":"object","additionalProperties":{"type":"string"}},"replyTo":{"type":"string","format":"email"},"cc":{"oneOf":[{"type":"string","format":"email"},{"type":"array","items":{"type":"string","format":"email"}}]},"bcc":{"oneOf":[{"type":"string","format":"email"},{"type":"array","items":{"type":"string","format":"email"}}]}},"required":["recipientRef"]},"communications_SendCommunicationResponse":{"type":"object","properties":{"success":{"type":"boolean","example":true},"data":{"type":"object","properties":{"communicationId":{"type":"string","format":"uuid","description":"Local customer_communications ID."},"messageId":{"type":"string","description":"Provider message ID when available."},"customerId":{"type":"string","format":"uuid","description":"Resolved local customers.id."},"organizationId":{"type":"string","format":"uuid","description":"Resolved local organizations.id."},"recipientEmail":{"type":"string","format":"email"},"recipientEnvelope":{"type":"object","properties":{"to":{"type":"array","items":{"type":"string","format":"email"}},"cc":{"type":"array","items":{"type":"string","format":"email"}},"bcc":{"type":"array","items":{"type":"string","format":"email"}}}},"strategy":{"type":"string","example":"customer-statement"},"netsuiteCustomerId":{"type":"string","description":"NetSuite customer ID used for statement generation when applicable."},"dateRange":{"type":"object","properties":{"startDate":{"type":"string","format":"date"},"endDate":{"type":"string","format":"date"}}}}}}},"communications_QueryCommunicationsResponse":{"type":"object","properties":{"success":{"type":"boolean","example":true},"data":{"type":"object","properties":{"customerId":{"type":"string","format":"uuid","description":"Resolved local customers.id."},"organizationId":{"type":"string","format":"uuid"},"recipientRef":{"$ref":"#/components/schemas/communications_RecipientRef"},"communications":{"type":"array","items":{"type":"object","additionalProperties":true}},"pagination":{"type":"object","properties":{"limit":{"type":"integer"},"offset":{"type":"integer"},"count":{"type":"integer"}}}}}}},"communications_ErrorResponse":{"type":"object","properties":{"success":{"type":"boolean","example":false},"error":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"path":{"type":"string"},"message":{"type":"string"}}}}}},"external_clients_ErrorResponse":{"type":"object","properties":{"success":{"type":"boolean","const":false},"error":{"type":"string"},"details":{"type":"array","items":{"type":"object"}}},"required":["success","error"]},"external_clients_ResolveCustomerResponse":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"type":"object","properties":{"exists":{"type":"boolean"},"provider":{"type":"string","examples":["netsuite","salesforce"]},"externalCustomerId":{"type":"string"},"customerId":{"type":"string","format":"uuid"},"customerName":{"type":"string"},"customerEmail":{"type":"string","format":"email"},"clerkOrganizationId":{"type":"string"},"masterId":{"type":"string","format":"uuid"}},"required":["exists","provider","externalCustomerId"]}},"required":["success","data"]},"external_clients_MagicLinkRequest":{"type":"object","properties":{"provider":{"type":"string","examples":["netsuite","salesforce"]},"externalCustomerId":{"type":"string","description":"Provider-generated internal customer/account/entity primary key."},"externalContactId":{"type":"string","description":"Provider-generated internal contact primary key."},"email":{"type":"string","format":"email"},"firstName":{"type":"string"},"lastName":{"type":"string"},"fullName":{"type":"string"},"phone":{"type":"string"},"customerName":{"type":"string","description":"Required when createIfMissing is true."},"mode":{"type":"string","enum":["send","return_link"],"default":"return_link"},"createIfMissing":{"type":"boolean","default":false},"overrideDuplicateGuard":{"type":"boolean","default":false},"overrideDuplicateReason":{"type":"string"},"tokenExpiresInSeconds":{"type":"integer","default":604800,"minimum":300,"maximum":604800},"redirectPath":{"type":"string","description":"Optional in-app redirect path after sign-in."},"metadata":{"type":"object","additionalProperties":true}},"required":["provider","externalCustomerId","email"]},"external_clients_MagicLinkResponse":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"type":"object","properties":{"customerId":{"type":"string","format":"uuid"},"contactId":{"type":"string","format":"uuid"},"clerkOrganizationId":{"type":"string"},"clerkUserId":{"type":"string"},"customerCreated":{"type":"boolean"},"contactCreated":{"type":"boolean"},"mappingCreated":{"type":"boolean"},"caretCustomerMappingCreated":{"type":"boolean"},"contactMappingCreated":{"type":"boolean"},"clerkOrganizationCreated":{"type":"boolean"},"clerkOrganizationMappingCreated":{"type":"boolean"},"clerkUserCreated":{"type":"boolean"},"membershipCreated":{"type":"boolean"},"clerkUserMappingCreated":{"type":"boolean"},"duplicateGuardStatus":{"type":"string","enum":["not_applicable","passed","blocked","overridden","matched_existing"]},"magicLinkSent":{"type":"boolean"},"magicLinkUrl":{"type":"string","format":"uri","description":"Only present for return_link mode."},"tokenExpiresInSeconds":{"type":"integer"},"tokenExpiresAt":{"type":"string","format":"date-time"},"communicationId":{"type":"string"},"messageId":{"type":"string"}}}},"required":["success","data"]},"external_clients_SalesforceOpportunityPaymentSetupRequest":{"type":"object","properties":{"source":{"type":"string","const":"salesforce","default":"salesforce"},"account_id":{"type":"string","description":"Salesforce Account Id."},"account_name":{"type":"string","description":"Required when create_if_missing is true."},"contact_id":{"type":"string","description":"Optional Salesforce Contact Id. Omit when Account.Email__c is the bootstrap recipient."},"contact_first_name":{"type":"string"},"contact_last_name":{"type":"string"},"contact_email":{"type":"string","format":"email","description":"Authorized bootstrap email. For CARET Legal v1 this is Salesforce Account.Email__c."},"opportunity_id":{"type":"string","description":"Salesforce Opportunity Id."},"stage_name":{"type":"string","default":"4 - Proposal","description":"Optional eligibility guard for CARET Legal onboarding."},"mode":{"type":"string","enum":["send","return_link"],"default":"send"},"create_if_missing":{"type":"boolean","default":false},"token_expires_in_seconds":{"type":"integer","default":604800,"minimum":300,"maximum":604800},"redirect_path":{"type":"string","description":"Optional in-app redirect path. Defaults to the Salesforce Opportunity payment setup route."},"Deal_Room_URL__c":{"type":"string","format":"uri","description":"Salesforce Opportunity Deal Room URL used by the confirmation return action."},"salesforceReturnUrl":{"type":"string","format":"uri","deprecated":true,"description":"Compatibility alias for Deal_Room_URL__c."},"returnCtaLabel":{"type":"string","default":"Return to Deal Room"},"metadata":{"type":"object","additionalProperties":true}},"required":["source","account_id","contact_email","opportunity_id"]},"external_clients_SalesforceOpportunityPaymentSetupResponse":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"type":"object","properties":{"paymentSetupIntentId":{"type":"string","format":"uuid"},"organizationId":{"type":"string","format":"uuid","description":"Local organization created or resolved by the platform from the Salesforce payload."},"status":{"type":"string","enum":["created","link_sent","link_returned","started","completed","failed"]},"source":{"type":"string","const":"salesforce"},"provider":{"type":"string","const":"salesforce"},"account_id":{"type":"string","description":"Salesforce Account Id."},"contact_id":{"type":"string","nullable":true,"description":"Salesforce Contact Id when supplied; null for Account-email bootstrap."},"opportunity_id":{"type":"string","description":"Salesforce Opportunity Id."},"externalCustomerId":{"type":"string"},"externalContactId":{"type":"string","nullable":true},"opportunityId":{"type":"string"},"customerId":{"type":"string","format":"uuid"},"contactId":{"type":"string","format":"uuid"},"clerkOrganizationId":{"type":"string"},"clerkUserId":{"type":"string"},"salesforceCustomerMappingCreated":{"type":"boolean"},"caretCustomerMappingCreated":{"type":"boolean"},"caretContactMappingCreated":{"type":"boolean"},"clerkOrganizationMappingCreated":{"type":"boolean"},"clerkUserMappingCreated":{"type":"boolean"},"netsuiteCustomerId":{"type":"string","nullable":true,"description":"Resolved NetSuite customer internal id when a NetSuite customer has externalid equal to the Salesforce account_id."},"netsuiteContactId":{"type":"string","nullable":true,"description":"Resolved NetSuite contact internal id when a contact is found under the resolved NetSuite customer."},"netsuiteCustomerCreated":{"type":"boolean","description":"True when the platform created a NetSuite customer because no customer existed with externalid equal to the Salesforce account_id."},"netsuiteCustomerMappingCreated":{"type":"boolean"},"netsuiteContactMappingCreated":{"type":"boolean"},"customerAccessStatus":{"type":"string","example":"payment_setup_enabled"},"paymentOnlyAccess":{"type":"boolean"},"magicLinkSent":{"type":"boolean"},"magicLinkUrl":{"type":"string","format":"uri","description":"Short CARET onboarding URL, present only for return_link mode and suitable for the 255-character Salesforce field."},"redirectPath":{"type":"string"},"returnCtaLabel":{"type":"string"},"salesforceReturnUrl":{"type":"string","format":"uri"},"tokenExpiresInSeconds":{"type":"integer"},"tokenExpiresAt":{"type":"string","format":"date-time"},"communicationId":{"type":"string"},"messageId":{"type":"string"}}}},"required":["success","data"]},"external_clients_DealHubDealRoomRequest":{"type":"object","properties":{"external_opportunity_id":{"type":"string","maxLength":50,"description":"CRM Opportunity ID linked to the DealHub quote."},"opportunity_name":{"type":"string","maxLength":250,"description":"Quote and published DealRoom name."}},"required":["external_opportunity_id","opportunity_name"],"additionalProperties":false},"external_clients_DealHubDealRoomResponse":{"type":"object","properties":{"success":{"type":"boolean","const":true},"data":{"type":"object","properties":{"externalOpportunityId":{"type":"string"},"opportunityName":{"type":"string"},"dealhubQuoteId":{"type":"string"},"dealRoomUrl":{"type":"string","format":"uri"}},"required":["externalOpportunityId","opportunityName","dealhubQuoteId","dealRoomUrl"]}},"required":["success","data"]},"external_clients_MergeCustomerMastersRequest":{"type":"object","properties":{"sourceMasterId":{"type":"string","format":"uuid","description":"ACF masterId to keep."},"targetMasterId":{"type":"string","format":"uuid","description":"ACF masterId to merge into sourceMasterId."},"reason":{"type":"string","description":"Auditable reason for the merge."}},"required":["sourceMasterId","targetMasterId","reason"]},"external_clients_MergeCustomerMastersResponse":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"type":"object","properties":{"sourceMasterId":{"type":"string","format":"uuid"},"targetMasterId":{"type":"string","format":"uuid"},"merged":{"type":"integer"},"reason":{"type":"string"},"initiatedBy":{"type":"string"}}}},"required":["success","data"]}},"parameters":{"acf_OrganizationId":{"name":"x-organization-id","in":"header","required":true,"schema":{"type":"string","format":"uuid"},"description":"Organization UUID"},"communications_OrganizationId":{"name":"x-organization-id","in":"header","required":true,"schema":{"type":"string","format":"uuid"},"description":"Local organization UUID used to scope ACF resolution and communication logging."}}}}