Back to Blog

ServiceTitan API Tutorial

(updated ) PipelineOn Research Team
Blog

Key Takeaways

  • Use the authorized Integration tenant, its client credentials, and an app key with Jobs Read and Invoices Read.
  • Check completion on the job record. Then match the invoice ID and the invoice's linked job ID.
  • Keep job status, invoiced amounts and payments separate when you build a report.

Start with one completed job in an authorized ServiceTitan Integration tenant. Read the job, locate its invoice, and compare the two IDs with the records your office expects. That small check tells you whether your app can reach the data and whether the fields answer the question your report needs.

What can the ServiceTitan API actually do?

ServiceTitan’s V2 APIs expose separate job, CRM and accounting records. A job can supply its status, completion date and assigned campaign ID. The accounting record supplies the invoice amounts. Start with those records if your reporting question is whether a completed job has the invoice your office expects. Use the CRM section when your app also needs approved customer or location fields. This example leaves those records out because the job-to-invoice check already has the IDs it needs. ServiceTitan V2 Developer Portal

How do you get API access?

ServiceTitan distinguishes customer admins creating apps for their organization from third-party developers. A customer admin can check the permissions needed for Developer Portal access. Third-party developers request access and register apps in the Integration environment ServiceTitan assigns them. Use the approved tenant and grant only the two read scopes this check needs. ServiceTitan customer access guide · ServiceTitan developer access FAQ

Choose a designated demo job and invoice before running the sample. A customer’s Integration environment can be a clone of its production data. Confirm that the specific records you choose are approved test fixtures and use just those records. ServiceTitan Integration environment guidance

How do you authenticate to the ServiceTitan API?

The Integration token URL is https://auth-integration.servicetitan.io/connect/token. POST the Integration client ID and client secret as form data with grant_type=client_credentials. Then send the returned bearer token and ST-App-Key with the resource GET request. Integration and production use different client credentials. Keep the secret, token and app key in your authorized local environment and out of source code and logs. ServiceTitan’s first API call · App and client keys FAQ

What endpoints do contractors actually need?

Use the two endpoints below on the Integration resource host, https://api-integration.servicetitan.io.

RecordRead endpointRequired OAuth scopeFields to check
One known jobGET /jpm/v2/tenant/{tenant}/jobs/{id}tn.jpm.jobs:rid, jobStatus, completedOn, invoiceId, campaignId
Invoice for that jobGET /accounting/v2/tenant/{tenant}/invoices, filtered by ids and jobIdtn.acc.invoices:rdata[].id, data[].job.id when linked, invoiceDate, total, balance

The Job Planning and Management reference defines completedOn in UTC. The invoice list returns a paginated object with a data array. Its invoice job can be null, and total and balance are strings or null. Check the exact schema before treating these as amounts in a downstream calculation. ServiceTitan Job Planning and Management OpenAPI · ServiceTitan Accounting OpenAPI

Sample: read one completed demo job in Node.js

Save this sample as an .mjs file and run it with Node.js 20 or later. Set ST_INTEGRATION_CLIENT_ID, ST_INTEGRATION_CLIENT_SECRET, ST_APP_KEY, ST_INTEGRATION_TENANT_ID and ST_DEMO_JOB_ID in your approved local environment. Use the internal ID of a known completed demo job with a linked invoice. The job number displayed to the office is a separate field. The script requests a token and then makes, at most, two resource GET requests. The output contains only selected job and invoice fields.

const {
  ST_INTEGRATION_CLIENT_ID: clientId,
  ST_INTEGRATION_CLIENT_SECRET: clientSecret,
  ST_APP_KEY: appKey,
  ST_INTEGRATION_TENANT_ID: tenantId,
  ST_DEMO_JOB_ID: demoJobId,
} = process.env;

function isDemoId(value) {
  return /^\d+$/.test(String(value))
    && Number.isSafeInteger(Number(value))
    && Number(value) > 0;
}

async function fetchJson(label, url, options) {
  const result = await fetch(url, {
    ...options,
    redirect: "error",
    signal: AbortSignal.timeout(15_000),
  });
  if (!result.ok) throw new Error(`${label} returned HTTP ${result.status}`);
  return result.json();
}

async function run() {
  if (!clientId || !clientSecret || !appKey
      || !isDemoId(tenantId) || !isDemoId(demoJobId)) {
    throw new Error("Set Integration credentials and positive integer demo IDs.");
  }

  const auth = await fetchJson(
    "Integration token request",
    "https://auth-integration.servicetitan.io/connect/token",
    {
      method: "POST",
      headers: { "Content-Type": "application/x-www-form-urlencoded" },
      body: new URLSearchParams({
        grant_type: "client_credentials",
        client_id: clientId,
        client_secret: clientSecret,
      }),
    },
  );
  if (typeof auth.access_token !== "string" || !auth.access_token) {
    throw new Error("Integration token response was missing an access token.");
  }

  const host = "https://api-integration.servicetitan.io";
  const headers = {
    Authorization: `Bearer ${auth.access_token}`,
    "ST-App-Key": appKey,
    Accept: "application/json",
  };
  const job = await fetchJson(
    "Demo job read",
    `${host}/jpm/v2/tenant/${tenantId}/jobs/${demoJobId}`,
    { method: "GET", headers },
  );
  if (job.id !== Number(demoJobId) || job.jobStatus !== "Completed"
      || !job.completedOn || !isDemoId(job.invoiceId)) {
    throw new Error("Use the expected completed demo job with a linked invoice.");
  }

  const invoiceUrl = new URL(`/accounting/v2/tenant/${tenantId}/invoices`, host);
  invoiceUrl.search = new URLSearchParams({
    ids: String(job.invoiceId),
    jobId: String(job.id),
    page: "1",
    pageSize: "1",
  }).toString();
  const invoicePage = await fetchJson(
    "Demo invoice read",
    invoiceUrl,
    { method: "GET", headers },
  );
  const invoice = Array.isArray(invoicePage.data) && invoicePage.data[0];
  if (!invoice || invoice.id !== job.invoiceId || invoice.job?.id !== job.id) {
    throw new Error("The demo invoice and job IDs did not match.");
  }

  console.log({
    jobId: job.id,
    completedOn: job.completedOn,
    campaignId: job.campaignId,
    invoiceId: invoice.id,
    invoiceDate: invoice.invoiceDate,
    total: invoice.total,
    balance: invoice.balance,
  });
}

run().catch((error) => {
  console.error(error.message);
  process.exitCode = 1;
});

Compare the printed job and invoice IDs with the same test records in the office view. The sample checks job completion before it reads the invoice. ServiceTitan can create a pending invoice when a job is booked. Check invoice dates, adjustments and payment records separately before counting invoiced revenue or cash collected. ServiceTitan invoicing workflow

The sample prints the job’s campaignId. Before you group bookings by acquisition source, compare the job campaign with the campaign on its linked call for one known record.

What rate limits and gotchas should you know about?

A failed smoke test should stop at the failed request. For an authorization error, check the environment, tenant, app connection and approved read scopes. For HTTP 429, ServiceTitan instructs clients to honor Retry-After or use exponential backoff if that header is absent. Confirm the current rate limits for the APIs you use. ServiceTitan API and rate-limit FAQ

For a report that needs a completed-job list, use the Jobs list filters jobStatus=Completed and the completion date parameters completedOnOrAfter and completedBefore. Read the endpoint’s pagination fields, including hasMore. Use modifiedOnOrAfter only when looking for changed records, since it measures when the record was edited. ServiceTitan publishes webhook documentation for specific configurations. Verify the events and access for your own app before designing around them. ServiceTitan Job Planning and Management OpenAPI · ServiceTitan webhook documentation

Should you build it yourself or use an integration partner?

Start with the report your office needs. When an existing report shows the records and totals you need, use it. If you need the same job and invoice linked in another system, have the implementer show how they would reconcile adjustments, missing invoices and unmatched records. Use this check as the first acceptance test. The home service attribution guide covers how to compare channels once the underlying records agree.

Frequently Asked Questions

PipelineOn

Enter your work email to get started

Already have an account? Sign in