When to use this endpoint

Read the scheduled epoch and stored labour, mileage and stock costs used by contract budget graphs.

Authentication and permissions

Authenticate with signed API-key fields or a logged-in CRM session. These calls use the authenticated account’s data; the handler has no additional job-page, department, assignee or client-admin permission check unless stated below.

Parameters

ParameterTypeRequiredDescription
idInteger stringYesJob ID, converted with intval; the result must be positive. This selects a physical job ID, not an app ID or job reference.

Example request

$result = FM_api('Job_getTimeAndCosts', ['id' => '1042']);

Example response

{"meeting_time_e":"1791795600","hours_cost":"40","mileage_cost":"5","stock_cost":"12","stock_used":"[]","costs":"57"}

Errors and unusual responses

ResponseCondition
{"error":"not logged in"}No authenticated tenant context is available. Invalid signed credentials can be rejected by the dispatcher before the handler runs.
{"error":"missing or invalid parameter: id"}id is absent or nonpositive.
{"error":"job does not exist"}No active job has this ID.
{"error":"could not read job costs"}The database read fails; this is not an empty result.

Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.

Behaviour and edge cases

  • Returns meeting_time_e, hours_cost, mileage_cost, stock_cost, encoded stock_used and costs=COALESCE(hours_cost,0)+COALESCE(mileage_cost,0)+COALESCE(stock_cost,0). It does not recalculate the stored components or include miscellaneous/schedule-of-rates costs.
  • The single-row arithmetic works with ONLY_FULL_GROUP_BY. Missing/deleted jobs return an explicit error rather than an aggregate row containing nulls.
  • Database values remain strings/null. A null cost component contributes zero to costs, while the corresponding returned component remains null. No paging, history or writes occur.

See it in Fieldmotion

CRM1

Open the contract Budget or Stock graph. pageContractsBudgetGraph.js and pageContractsStockGraph.js call Job_getTimeAndCosts for each linked job and use costs in the chart.

CRM2

No direct CRM2 caller was found in the reviewed source. For batched job fields, see Jobs_getById.

Related endpoints

  • Job_getStock extracts stock entries, not monetary totals.
  • Jobs_getById reads selected stored job fields but its allowlist does not include these cost columns.