{"openapi":"3.1.0","info":{"title":"PlusCRM Integration API","version":"1.0.0","description":"Server-to-server JSON API for PlusCRM tenants. Authenticate with organisation id and API credentials from CRM \u2192 Settings \u2192 API credentials."},"servers":[{"url":"https://api.fieldcontrol.co.uk/api/v1","description":"This PlusCRM deployment"}],"tags":[{"name":"Clients"},{"name":"Sites"},{"name":"Contacts"},{"name":"Work orders"},{"name":"Quotes"},{"name":"Invoices"},{"name":"Deals"},{"name":"Staff"},{"name":"Tickets"},{"name":"Webhooks"},{"name":"Operations"}],"security":[{"PlusCrmApiKey":[],"PlusCrmApiSecret":[],"PlusCrmClientId":[]}],"components":{"securitySchemes":{"PlusCrmClientId":{"type":"apiKey","in":"header","name":"X-PlusCRM-Client-Id","description":"Numeric organisation id (master clients.id)"},"PlusCrmApiKey":{"type":"apiKey","in":"header","name":"X-API-Key"},"PlusCrmApiSecret":{"type":"apiKey","in":"header","name":"X-API-Secret"}},"schemas":{"Client":{"type":"object","properties":{"id":{"type":"integer"},"name":{"type":"string"},"trading_name":{"type":"string","nullable":true},"email":{"type":"string","nullable":true},"phone":{"type":"string","nullable":true},"address":{"type":"string","nullable":true},"city":{"type":"string","nullable":true},"county":{"type":"string","nullable":true},"postcode":{"type":"string","nullable":true},"country":{"type":"string","nullable":true},"crm_type":{"type":"string","enum":["client","prospect"]},"is_active":{"type":"boolean"},"notes":{"type":"string","nullable":true},"companies_house_data":{"type":"boolean"},"companies_house_number":{"type":"string","nullable":true},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}}},"ClientInput":{"type":"object","required":["name","crm_type"],"properties":{"name":{"type":"string"},"trading_name":{"type":"string"},"email":{"type":"string","format":"email"},"phone":{"type":"string"},"address":{"type":"string"},"city":{"type":"string"},"county":{"type":"string"},"postcode":{"type":"string"},"country":{"type":"string"},"crm_type":{"type":"string","enum":["client","prospect"]},"is_active":{"type":"boolean"},"notes":{"type":"string"},"companies_house_data":{"type":"boolean"},"companies_house_number":{"type":"string"}}},"Site":{"type":"object","properties":{"id":{"type":"integer"},"sub_client_id":{"type":"integer","nullable":true},"name":{"type":"string"},"address":{"type":"string"},"is_active":{"type":"boolean"},"client":{"$ref":"#/components/schemas/ClientSummary"}}},"SiteInput":{"type":"object","required":["name","address"],"properties":{"sub_client_id":{"type":"integer"},"name":{"type":"string"},"site_reference":{"type":"string"},"address":{"type":"string"},"city":{"type":"string"},"postcode":{"type":"string"},"is_active":{"type":"boolean"}}},"Contact":{"type":"object","properties":{"id":{"type":"integer"},"sub_client_id":{"type":"integer","nullable":true},"first_name":{"type":"string"},"last_name":{"type":"string"},"email":{"type":"string","nullable":true},"client":{"$ref":"#/components/schemas/ClientSummary"},"site_ids":{"type":"array","items":{"type":"integer"}}}},"ContactInput":{"type":"object","required":["first_name","last_name"],"properties":{"sub_client_id":{"type":"integer"},"first_name":{"type":"string"},"last_name":{"type":"string"},"email":{"type":"string"},"phone":{"type":"string"},"mobile":{"type":"string"},"job_title":{"type":"string"},"site_ids":{"type":"array","items":{"type":"integer"}}}},"ClientSummary":{"type":"object","properties":{"id":{"type":"integer"},"name":{"type":"string"},"crm_type":{"type":"string"},"is_active":{"type":"boolean"}}},"Quote":{"type":"object","properties":{"id":{"type":"integer"},"quote_number":{"type":"string"},"status":{"type":"string"},"total":{"type":"string"},"client":{"$ref":"#/components/schemas/ClientSummary"},"lines":{"type":"array","items":{"$ref":"#/components/schemas/QuoteLine"}}}},"QuoteLine":{"type":"object","properties":{"description":{"type":"string"},"quantity":{"type":"string"},"unit_price":{"type":"string"},"line_total":{"type":"string"}}},"Invoice":{"type":"object","properties":{"id":{"type":"integer"},"invoice_number":{"type":"string"},"status":{"type":"string"},"total":{"type":"string"},"client":{"$ref":"#/components/schemas/ClientSummary"},"lines":{"type":"array","items":{"$ref":"#/components/schemas/InvoiceLine"}}}},"InvoiceLine":{"type":"object","properties":{"description":{"type":"string"},"quantity":{"type":"string"},"unit_price":{"type":"string"},"line_total":{"type":"string"}}},"ValidationError":{"type":"object","properties":{"message":{"type":"string"},"errors":{"type":"object","additionalProperties":{"type":"array","items":{"type":"string"}}}}}},"parameters":{"PerPage":{"name":"per_page","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":50}}}},"paths":{"/clients":{"get":{"tags":["Clients"],"summary":"List clients","parameters":[{"$ref":"#/components/parameters/PerPage"},{"name":"search","in":"query","schema":{"type":"string"}},{"name":"is_active","in":"query","schema":{"type":"boolean"}},{"name":"crm_type","in":"query","schema":{"type":"string","enum":["client","prospect"]}}],"responses":{"200":{"description":"Paginated clients"}}},"post":{"tags":["Clients"],"summary":"Create client","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ClientInput"},"example":{"name":"Acme Security Ltd","crm_type":"prospect","email":"info@acme.test"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"properties":{"data":{"$ref":"#/components/schemas/Client"}}}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationError"}}}}}}},"/clients/{client}":{"get":{"tags":["Clients"],"summary":"Get client","parameters":[{"name":"client","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Client"},"404":{"description":"Not found"}}},"patch":{"tags":["Clients"],"summary":"Update client","parameters":[{"name":"client","in":"path","required":true,"schema":{"type":"integer"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ClientInput"}}}},"responses":{"200":{"description":"Updated"}}},"delete":{"tags":["Clients"],"summary":"Delete client (soft)","parameters":[{"name":"client","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Deleted"}}}},"/sites":{"get":{"tags":["Sites"],"summary":"List sites","parameters":[{"$ref":"#/components/parameters/PerPage"}],"responses":{"200":{"description":"Paginated sites"}}},"post":{"tags":["Sites"],"summary":"Create site","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SiteInput"},"example":{"sub_client_id":1,"name":"Head office","address":"1 High Street","postcode":"AB1 2CD"}}}},"responses":{"201":{"description":"Created"}}}},"/sites/{site}":{"get":{"tags":["Sites"],"summary":"Get site","parameters":[{"name":"site","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Site"}}},"patch":{"tags":["Sites"],"summary":"Update site","parameters":[{"name":"site","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Updated"}}},"delete":{"tags":["Sites"],"summary":"Delete site (soft)","parameters":[{"name":"site","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Deleted"}}}},"/contacts":{"get":{"tags":["Contacts"],"summary":"List contacts","parameters":[{"$ref":"#/components/parameters/PerPage"}],"responses":{"200":{"description":"Paginated contacts"}}},"post":{"tags":["Contacts"],"summary":"Create contact","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContactInput"},"example":{"sub_client_id":1,"first_name":"Jane","last_name":"Doe","email":"jane@example.com"}}}},"responses":{"201":{"description":"Created"}}}},"/contacts/{contact}":{"get":{"tags":["Contacts"],"summary":"Get contact","parameters":[{"name":"contact","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Contact"}}},"patch":{"tags":["Contacts"],"summary":"Update contact","parameters":[{"name":"contact","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Updated"}}},"delete":{"tags":["Contacts"],"summary":"Delete contact (soft)","parameters":[{"name":"contact","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Deleted"}}}},"/quotes":{"get":{"tags":["Quotes"],"summary":"List quotes","parameters":[{"$ref":"#/components/parameters/PerPage"}],"responses":{"200":{"description":"Paginated quotes"}}},"post":{"tags":["Quotes"],"summary":"Create quote with line items","responses":{"201":{"description":"Created"},"422":{"description":"Validation error"}}}},"/quotes/{quote}":{"get":{"tags":["Quotes"],"summary":"Get quote","parameters":[{"name":"quote","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Quote with lines"}}},"patch":{"tags":["Quotes"],"summary":"Update quote","parameters":[{"name":"quote","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Updated"}}},"delete":{"tags":["Quotes"],"summary":"Delete quote","parameters":[{"name":"quote","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Deleted"}}}},"/invoices":{"get":{"tags":["Invoices"],"summary":"List invoices","parameters":[{"$ref":"#/components/parameters/PerPage"}],"responses":{"200":{"description":"Paginated invoices"}}},"post":{"tags":["Invoices"],"summary":"Create invoice with line items","responses":{"201":{"description":"Created"},"422":{"description":"Validation error"}}}},"/invoices/{invoice}":{"get":{"tags":["Invoices"],"summary":"Get invoice","parameters":[{"name":"invoice","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Invoice with lines"}}},"patch":{"tags":["Invoices"],"summary":"Update invoice","parameters":[{"name":"invoice","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Updated"}}},"delete":{"tags":["Invoices"],"summary":"Delete invoice","parameters":[{"name":"invoice","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Deleted"}}}},"/work-order-types":{"get":{"tags":["Work orders"],"summary":"List work order types (id, base_kind, allowed statuses/priorities)","responses":{"200":{"description":"Work order types"}}}},"/deal-stages":{"get":{"tags":["Deals"],"summary":"List deal pipeline stages","responses":{"200":{"description":"Deal stages"}}}},"/work-orders":{"get":{"tags":["Work orders"],"summary":"List work orders","parameters":[{"$ref":"#/components/parameters/PerPage"}],"responses":{"200":{"description":"Paginated work orders"}}},"post":{"tags":["Work orders"],"summary":"Create work order","responses":{"201":{"description":"Created"}}}},"/work-orders/{work_order}":{"get":{"tags":["Work orders"],"summary":"Get work order","parameters":[{"name":"work_order","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Work order"}}},"patch":{"tags":["Work orders"],"summary":"Update work order","parameters":[{"name":"work_order","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Updated"}}},"delete":{"tags":["Work orders"],"summary":"Delete work order (soft)","parameters":[{"name":"work_order","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Deleted"}}}},"/deals":{"get":{"tags":["Deals"],"summary":"List deals","parameters":[{"$ref":"#/components/parameters/PerPage"}],"responses":{"200":{"description":"Paginated deals"}}},"post":{"tags":["Deals"],"summary":"Create deal","responses":{"201":{"description":"Created"}}}},"/deals/{deal}":{"get":{"tags":["Deals"],"summary":"Get deal","parameters":[{"name":"deal","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Deal"}}},"patch":{"tags":["Deals"],"summary":"Update deal","parameters":[{"name":"deal","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Updated"}}},"delete":{"tags":["Deals"],"summary":"Delete deal","parameters":[{"name":"deal","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Deleted"}}}},"/staff":{"get":{"tags":["Staff"],"summary":"List staff members","parameters":[{"$ref":"#/components/parameters/PerPage"}],"responses":{"200":{"description":"Paginated staff"}}},"post":{"tags":["Staff"],"summary":"Create staff member","responses":{"201":{"description":"Created"}}}},"/staff/{staff_member}":{"get":{"tags":["Staff"],"summary":"Get staff member","parameters":[{"name":"staff_member","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Staff member"}}},"patch":{"tags":["Staff"],"summary":"Update staff member","parameters":[{"name":"staff_member","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Updated"}}},"delete":{"tags":["Staff"],"summary":"Archive staff member","parameters":[{"name":"staff_member","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Archived"}}}},"/tickets":{"get":{"tags":["Tickets"],"summary":"List tickets","parameters":[{"$ref":"#/components/parameters/PerPage"}],"responses":{"200":{"description":"Paginated tickets"}}},"post":{"tags":["Tickets"],"summary":"Create ticket with initial message","responses":{"201":{"description":"Created"}}}},"/tickets/{ticket}":{"get":{"tags":["Tickets"],"summary":"Get ticket","parameters":[{"name":"ticket","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Ticket"}}},"patch":{"tags":["Tickets"],"summary":"Update ticket","parameters":[{"name":"ticket","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Updated"}}}},"/webhooks":{"get":{"tags":["Webhooks"],"summary":"List webhook endpoints","parameters":[{"$ref":"#/components/parameters/PerPage"}],"responses":{"200":{"description":"Paginated webhook endpoints"}}},"post":{"tags":["Webhooks"],"summary":"Create webhook endpoint","description":"Returns signing_secret once in the 201 response.","responses":{"201":{"description":"Created"}}}},"/webhooks/{webhook}":{"get":{"tags":["Webhooks"],"summary":"Get webhook endpoint","parameters":[{"name":"webhook","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Webhook endpoint"}}},"patch":{"tags":["Webhooks"],"summary":"Update webhook endpoint","parameters":[{"name":"webhook","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Updated"}}},"delete":{"tags":["Webhooks"],"summary":"Delete webhook endpoint","parameters":[{"name":"webhook","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Deleted"}}}},"/webhook-events":{"get":{"tags":["Webhooks"],"summary":"List available webhook event names","responses":{"200":{"description":"Event catalog"}}}},"/schedule":{"get":{"tags":["Operations"],"summary":"List schedule","responses":{"200":{"description":"Schedule entries"}}}},"/patrols":{"get":{"tags":["Operations"],"summary":"List patrols","responses":{"200":{"description":"Patrols"}}}},"/patrols/{patrol}":{"get":{"tags":["Operations"],"summary":"Get patrol","parameters":[{"name":"patrol","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Patrol"}}}},"/telematics/pings":{"post":{"tags":["Operations"],"summary":"Record a telematics ping for a vehicle","description":"Updates the vehicle's last-known position and feeds field duty tracking. The device_id must match a vehicle's telematics device id.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["device_id","latitude","longitude"],"properties":{"device_id":{"type":"string","maxLength":128},"latitude":{"type":"number","minimum":-90,"maximum":90},"longitude":{"type":"number","minimum":-180,"maximum":180},"accuracy":{"type":"number","minimum":0},"heading":{"type":"number"},"speed":{"type":"number"},"recorded_at":{"type":"string","format":"date-time"}}}}}},"responses":{"200":{"description":"Ping recorded (ok, vehicle_id, last coordinates)"},"404":{"description":"Unknown telematics device"},"422":{"description":"Validation failed"},"503":{"description":"Vehicles module not available"}}}},"/incidents":{"get":{"tags":["Operations"],"summary":"List incidents","responses":{"200":{"description":"Incidents"}}},"post":{"tags":["Operations"],"summary":"Create incident","responses":{"201":{"description":"Created"}}}},"/incidents/{incident}":{"get":{"tags":["Operations"],"summary":"Get incident","parameters":[{"name":"incident","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Incident"}}},"patch":{"tags":["Operations"],"summary":"Update incident","parameters":[{"name":"incident","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Updated"}}},"delete":{"tags":["Operations"],"summary":"Delete incident (soft)","parameters":[{"name":"incident","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Deleted"}}}}}}