When to use this endpoint

Contract_addAppointment is the legacy wire name for Contract_addJob. New integrations should call the canonical job-named route.

The alias remains useful only when maintaining an existing client that cannot yet change its route name.

Authentication and permissions

The request must authenticate with signed API-key fields or a logged-in CRM session. The handler performs no additional page or role-permission check.

The lookup and any write use the authenticated tenant; an ID from another tenant cannot be addressed through this call.

Parameters

ParameterTypeRequiredDescription
idInteger stringYesPositive contract ID. The lookup does not exclude a soft-deleted contract.
aidInteger stringYesPositive job ID. This legacy parameter name is retained by both aliases. The handler does not verify that the job exists.

Example request

$result = FM_api('Contract_addAppointment', [
	'id' => '720',
	'aid' => '2039001',
]);

Example response

{
  "ok": 1
}

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 missing or does not convert to a positive integer.
{"error":"missing or invalid parameter: aid"}aid is missing or does not convert to a positive integer.
{"error":"Contract does not exist"}No contract row, including a soft-deleted row, has the supplied ID.
{"ok":1,"warning":"job already linked to contract"}The same job/contract link already exists.

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

Behaviour and edge cases

  • The handler reads and writes manymany rows with link type 6; it does not update the job row’s contract_id.
  • Before inserting, it removes every type-6 link for the job, so the job can have only one contract in this legacy link store.
  • It does not validate the job ID, synchronize the former contract’s customer cache, or provide filtering or pagination.

Side effects

  • Inserts a legacy job/contract link with the current Unix edit time, writes a contract audit entry, and marks the target contract’s cached customer/asset list dirty.

See it in Fieldmotion

CRM1

No direct production CRM1 request to this compatibility alias was found. Current job creation and save paths use Contract_addJob internally.

CRM2

No direct production CRM2 request to this compatibility alias was found. Assigning a contract through the job editor reaches the canonical internal route instead.

Related endpoints