ml-connector
SAP S/4HANAServiceTitan

SAP S/4HANA and ServiceTitan integration

SAP S/4HANA runs finance and procurement for the enterprise. ServiceTitan runs field service operations for HVAC, plumbing, and electrical contractors. Connecting the two keeps procurement and AP synchronized across the two systems. Purchase requisitions raised in ServiceTitan flow into SAP S/4HANA as purchase orders, and vendor invoices in SAP S/4HANA post into ServiceTitan's AP bills so the service business sees its true vendor costs. Vendor master data and cost centers stay aligned in both directions without manual re-entry.

How SAP S/4HANA works

SAP S/4HANA exposes purchase orders, purchase requisitions, supplier invoices, GL accounts, cost centers, and business partners through OData V2 and OData V4 REST APIs at a tenant-specific base URL (https://<tenant-id>-api.s4hana.ondemand.com/sap/opu/odata/sap/<SERVICE_NAME>/). It authenticates with OAuth2 client credentials configured in a SAP Communication Arrangement, and tokens are long-lived (typically 12 hours) and must be cached to avoid repetitive token requests. SAP S/4HANA has no native webhooks, so purchase and invoice records are read via polling with LastChangeDateTime filters or delta tokens for initial bulk sync. On-premise deployments require the sap-client query parameter; cloud public editions do not. GL accounts and cost centers are read-only and maintained in SAP only.

How ServiceTitan works

ServiceTitan exposes purchase orders, AP bills, vendors, invoices, customers, and inventory through REST APIs at a tenant-specific URL (https://api.servicetitan.io/{namespace}/v2/tenant/{tenantId}/). It authenticates with OAuth2 client credentials plus an ST-App-Key header sent on every request, and tokens expire in 15 minutes and must be refreshed frequently. ServiceTitan supports outbound webhooks with HMAC-SHA256 signature verification for real-time event notifications (job.created, invoice.created, payment.created, etc.), but AP bills are read-only and auto-generated when a purchase order is marked received. GL accounts are not exposed via API; gl mapping is done in the ServiceTitan UI or via native QuickBooks and Intacct connectors. The platform enforces a 60-calls-per-second rate limit and a 100-second server timeout per request.

What moves between them

The main flow is from SAP S/4HANA into ServiceTitan. Purchase orders and supplier invoices are read from SAP S/4HANA via OData polling on a schedule you define and written into ServiceTitan as purchase orders and AP bills. Vendor master data, business partners, and cost centers are synced in both directions so that service dispatch and costing in ServiceTitan always reference vendors and cost allocations that exist in SAP S/4HANA. AP bills are read-only in ServiceTitan, so ml-connector does not write financial records back into SAP S/4HANA's GL; instead, the service business reads the bills and posts them into SAP through its normal AP workflow.

How ml-connector handles it

ml-connector stores SAP OAuth credentials and manages the long-lived token per the Communication Arrangement configuration, refreshing before the 12-hour window expires. On the ServiceTitan side, it caches the short-lived 15-minute OAuth token and refreshes it on every call that returns 401, and it includes the required ST-App-Key header on every request. It accepts the tenant-specific URL paths for both systems and validates API entity keys against those instances. Because SAP S/4HANA is pull-only, ml-connector polls purchase orders and invoices on a schedule you define, filtering by LastChangeDateTime to detect changes since the last run. ServiceTitan can also push events to a registered endpoint if webhooks are enabled; ml-connector verifies the HMAC-SHA256 signature on each webhook and deduplicates based on the event ID. Vendor records are synced first so that every purchase order references a vendor that already exists in ServiceTitan. Both systems enforce rate limits and timeouts; ml-connector backs off on HTTP 429 and respects the 100-second server timeout on ServiceTitan requests. Every record carries a full audit trail and can be replayed if a downstream call fails.

A real-world example

A mid-size HVAC and plumbing contractor runs SAP S/4HANA for corporate finance and procurement across multiple branches, and uses ServiceTitan for field dispatch, job costing, and service invoicing. Before integration, the procurement team managed vendor contracts and issued purchase orders in SAP S/4HANA, but the field supervisors in ServiceTitan ordered materials independently or re-entered purchase orders by hand, creating duplicate vendor records and cost tracking gaps. When an invoice arrived from a supplier, the finance team had to track which ServiceTitan jobs had received materials against which SAP purchase orders, slowing reconciliation and creating audit risk. After connecting SAP S/4HANA and ServiceTitan, all purchase orders flow from SAP into ServiceTitan in real time, vendors are synchronized automatically, and incoming supplier invoices post into ServiceTitan's AP bills without manual re-entry. Field supervisors see the full purchase order lifecycle in ServiceTitan, and the finance team closes out AP with data already aligned between the two systems.

What you can do

  • Sync purchase orders and purchase requisitions from SAP S/4HANA into ServiceTitan as purchase orders, aligned to vendor master data.
  • Read supplier invoices from SAP S/4HANA and write them into ServiceTitan as AP bills, with cost allocations and job references mapped correctly.
  • Keep vendor records and master data synchronized in both directions between SAP S/4HANA and ServiceTitan so procurement references consistent vendor IDs.
  • Bridge SAP S/4HANA's long-lived OAuth tokens and Communication Arrangement configuration with ServiceTitan's 15-minute token expiry and ST-App-Key header requirements.
  • Poll SAP S/4HANA on a schedule you control with LastChangeDateTime filtering, and optionally receive ServiceTitan webhook events with HMAC-SHA256 signature verification.

Questions

How does ml-connector handle the difference between SAP S/4HANA's long-lived tokens and ServiceTitan's 15-minute token expiry?
ml-connector caches SAP S/4HANA's long-lived OAuth token (typically 12 hours) per the Communication Arrangement configuration and refreshes it before expiry to avoid repeated token requests. For ServiceTitan, it caches the 15-minute token and refreshes it on every call that returns 401, ensuring fresh credentials without blocking on token latency. Both caches are encrypted and stored per-customer.
Can SAP S/4HANA push purchase order changes to ServiceTitan in real time?
SAP S/4HANA has no native webhooks, so ml-connector polls OData APIs on a schedule you define, filtering by LastChangeDateTime to detect changes. ServiceTitan can push events via webhooks if enabled; ml-connector verifies the HMAC-SHA256 signature on each webhook and deduplicates by event ID. The two systems can be configured to sync on different cadences depending on your procurement cycle.
Are GL accounts and cost centers synced between SAP S/4HANA and ServiceTitan?
Cost centers and business units are synced in both directions so that purchase orders and AP bills reference cost allocations that exist in SAP S/4HANA. GL accounts are not exposed by ServiceTitan's API; gl mapping is done in the ServiceTitan UI or via native QuickBooks and Intacct connectors, so ml-connector aligns at the cost-center and vendor level only.

Related integrations

Connect SAP S/4HANA and ServiceTitan

Free to use. Add your credentials, ping your real systems, and see if we fit.

Get started