{
  "components": {
    "schemas": {
      "Activity": {
        "properties": {
          "activity_type": {
            "type": "string"
          },
          "body_plain": {
            "type": [
              "string",
              "null"
            ]
          },
          "company_id": {
            "type": [
              "integer",
              "null"
            ]
          },
          "contact_id": {
            "type": [
              "integer",
              "null"
            ]
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "deal_id": {
            "type": [
              "integer",
              "null"
            ]
          },
          "id": {
            "type": "integer"
          },
          "subject": {
            "type": [
              "string",
              "null"
            ]
          },
          "updated_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "user_id": {
            "type": [
              "integer",
              "null"
            ]
          }
        },
        "type": "object"
      },
      "Company": {
        "properties": {
          "annual_revenue": {
            "type": [
              "number",
              "null"
            ]
          },
          "city": {
            "type": [
              "string",
              "null"
            ]
          },
          "company_size": {
            "type": [
              "string",
              "null"
            ]
          },
          "country": {
            "type": [
              "string",
              "null"
            ]
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "domain": {
            "type": [
              "string",
              "null"
            ]
          },
          "id": {
            "type": "integer"
          },
          "industry": {
            "type": [
              "string",
              "null"
            ]
          },
          "name": {
            "type": "string"
          },
          "owner_id": {
            "type": [
              "integer",
              "null"
            ]
          },
          "phone": {
            "type": [
              "string",
              "null"
            ]
          },
          "updated_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "website": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "type": "object"
      },
      "Contact": {
        "properties": {
          "city": {
            "type": [
              "string",
              "null"
            ]
          },
          "country": {
            "type": [
              "string",
              "null"
            ]
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "department": {
            "type": [
              "string",
              "null"
            ]
          },
          "email": {
            "type": [
              "string",
              "null"
            ]
          },
          "first_name": {
            "type": "string"
          },
          "id": {
            "type": "integer"
          },
          "job_title": {
            "type": [
              "string",
              "null"
            ]
          },
          "last_name": {
            "type": "string"
          },
          "lead_status": {
            "type": [
              "string",
              "null"
            ]
          },
          "lifecycle_stage": {
            "type": [
              "string",
              "null"
            ]
          },
          "mobile": {
            "type": [
              "string",
              "null"
            ]
          },
          "owner_id": {
            "type": [
              "integer",
              "null"
            ]
          },
          "phone": {
            "type": [
              "string",
              "null"
            ]
          },
          "source": {
            "type": [
              "string",
              "null"
            ]
          },
          "updated_at": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "type": "object"
      },
      "CustomField": {
        "properties": {
          "entity_type": {
            "type": "string"
          },
          "field_type": {
            "type": "string"
          },
          "id": {
            "type": "integer"
          },
          "is_required": {
            "type": "boolean"
          },
          "label": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "options": {
            "items": {
              "type": "string"
            },
            "type": "array"
          }
        },
        "type": "object"
      },
      "Deal": {
        "properties": {
          "actual_close_date": {
            "type": [
              "string",
              "null"
            ]
          },
          "amount": {
            "type": [
              "number",
              "null"
            ]
          },
          "company_id": {
            "type": [
              "integer",
              "null"
            ]
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "currency": {
            "type": [
              "string",
              "null"
            ]
          },
          "expected_close_date": {
            "type": [
              "string",
              "null"
            ]
          },
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "owner_id": {
            "type": [
              "integer",
              "null"
            ]
          },
          "pipeline_id": {
            "type": "integer"
          },
          "pipeline_name": {
            "type": [
              "string",
              "null"
            ]
          },
          "priority": {
            "type": [
              "string",
              "null"
            ]
          },
          "probability": {
            "type": [
              "integer",
              "null"
            ]
          },
          "source": {
            "type": [
              "string",
              "null"
            ]
          },
          "stage_id": {
            "type": "integer"
          },
          "stage_name": {
            "type": [
              "string",
              "null"
            ]
          },
          "updated_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "weighted_amount": {
            "type": [
              "number",
              "null"
            ]
          }
        },
        "type": "object"
      },
      "Dealer": {
        "properties": {
          "avg_ev_price": {
            "type": [
              "number",
              "null"
            ]
          },
          "category": {
            "type": [
              "string",
              "null"
            ]
          },
          "county": {
            "type": [
              "string",
              "null"
            ]
          },
          "email": {
            "type": [
              "string",
              "null"
            ]
          },
          "ev_active_listings": {
            "type": [
              "integer",
              "null"
            ]
          },
          "id": {
            "type": "integer"
          },
          "linked_company_id": {
            "type": [
              "integer",
              "null"
            ]
          },
          "name": {
            "type": "string"
          },
          "network": {
            "type": [
              "string",
              "null"
            ]
          },
          "phev_active_listings": {
            "type": [
              "integer",
              "null"
            ]
          },
          "phone": {
            "type": [
              "string",
              "null"
            ]
          },
          "postcode": {
            "type": [
              "string",
              "null"
            ]
          },
          "review_count": {
            "type": [
              "integer",
              "null"
            ]
          },
          "review_score": {
            "type": [
              "number",
              "null"
            ]
          },
          "total_active_listings": {
            "type": [
              "integer",
              "null"
            ]
          },
          "town": {
            "type": [
              "string",
              "null"
            ]
          },
          "website": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "type": "object"
      },
      "DealerListing": {
        "properties": {
          "battery_capacity_kwh": {
            "type": [
              "number",
              "null"
            ]
          },
          "battery_range_miles": {
            "type": [
              "integer",
              "null"
            ]
          },
          "battery_usable_kwh": {
            "type": [
              "number",
              "null"
            ]
          },
          "colour": {
            "type": [
              "string",
              "null"
            ]
          },
          "date_listed": {
            "type": [
              "string",
              "null"
            ]
          },
          "days_listed": {
            "type": [
              "integer",
              "null"
            ]
          },
          "first_seen": {
            "type": [
              "string",
              "null"
            ]
          },
          "fuel_type": {
            "type": [
              "string",
              "null"
            ]
          },
          "id": {
            "type": "integer"
          },
          "image_url": {
            "type": [
              "string",
              "null"
            ]
          },
          "is_active": {
            "type": "boolean"
          },
          "last_seen": {
            "type": [
              "string",
              "null"
            ]
          },
          "listing_url": {
            "type": [
              "string",
              "null"
            ]
          },
          "make": {
            "type": [
              "string",
              "null"
            ]
          },
          "mileage": {
            "type": [
              "integer",
              "null"
            ]
          },
          "model": {
            "type": [
              "string",
              "null"
            ]
          },
          "price": {
            "type": [
              "integer",
              "null"
            ]
          },
          "registration": {
            "type": [
              "string",
              "null"
            ]
          },
          "source": {
            "type": [
              "string",
              "null"
            ]
          },
          "transmission": {
            "type": [
              "string",
              "null"
            ]
          },
          "variant": {
            "type": [
              "string",
              "null"
            ]
          },
          "year": {
            "type": [
              "integer",
              "null"
            ]
          }
        },
        "type": "object"
      },
      "Error": {
        "properties": {
          "code": {
            "description": "missing_api_key | invalid_api_key | insufficient_scope | invalid_request | invalid_reference | rate_limited",
            "type": "string"
          },
          "error": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "NissanDealer": {
        "properties": {
          "campaign_wave": {
            "type": [
              "string",
              "null"
            ]
          },
          "company_id": {
            "type": [
              "integer",
              "null"
            ]
          },
          "county": {
            "type": [
              "string",
              "null"
            ]
          },
          "dealer_id": {
            "type": [
              "integer",
              "null"
            ]
          },
          "dealer_match_method": {
            "type": [
              "string",
              "null"
            ]
          },
          "dealer_type": {
            "type": "string"
          },
          "id": {
            "type": "integer"
          },
          "motab_code": {
            "type": [
              "string",
              "null"
            ]
          },
          "nation": {
            "type": [
              "string",
              "null"
            ]
          },
          "nissan_dlr_no": {
            "type": "string"
          },
          "nissan_group": {
            "type": [
              "string",
              "null"
            ]
          },
          "official_name": {
            "type": "string"
          },
          "phone": {
            "type": [
              "string",
              "null"
            ]
          },
          "postcode": {
            "type": [
              "string",
              "null"
            ]
          },
          "sales_zone": {
            "type": [
              "string",
              "null"
            ]
          },
          "town": {
            "type": [
              "string",
              "null"
            ]
          },
          "ucpm_zone": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "type": "object"
      },
      "PaginationMeta": {
        "properties": {
          "has_next": {
            "type": "boolean"
          },
          "has_prev": {
            "type": "boolean"
          },
          "page": {
            "type": "integer"
          },
          "pages": {
            "type": "integer"
          },
          "per_page": {
            "type": "integer"
          },
          "total": {
            "type": "integer"
          }
        },
        "type": "object"
      },
      "Pipeline": {
        "properties": {
          "id": {
            "type": "integer"
          },
          "is_active": {
            "type": "boolean"
          },
          "is_default": {
            "type": "boolean"
          },
          "name": {
            "type": "string"
          },
          "stages": {
            "items": {
              "$ref": "#/components/schemas/PipelineStage"
            },
            "type": "array"
          }
        },
        "type": "object"
      },
      "PipelineStage": {
        "properties": {
          "color": {
            "type": [
              "string",
              "null"
            ]
          },
          "display_order": {
            "type": "integer"
          },
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "probability": {
            "type": [
              "integer",
              "null"
            ]
          },
          "stage_type": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "Segment": {
        "properties": {
          "contact_count": {
            "type": "integer"
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "id": {
            "type": "integer"
          },
          "match_type": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "segment_type": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "Tag": {
        "properties": {
          "color": {
            "type": "string"
          },
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "Task": {
        "properties": {
          "assigned_to_id": {
            "type": [
              "integer",
              "null"
            ]
          },
          "company_id": {
            "type": [
              "integer",
              "null"
            ]
          },
          "contact_id": {
            "type": [
              "integer",
              "null"
            ]
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "created_by_id": {
            "type": [
              "integer",
              "null"
            ]
          },
          "deal_id": {
            "type": [
              "integer",
              "null"
            ]
          },
          "due_date": {
            "type": [
              "string",
              "null"
            ]
          },
          "id": {
            "type": "integer"
          },
          "priority": {
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "type": [
              "string",
              "null"
            ]
          },
          "task_type": {
            "type": [
              "string",
              "null"
            ]
          },
          "title": {
            "type": "string"
          },
          "updated_at": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "type": "object"
      },
      "User": {
        "properties": {
          "email": {
            "type": "string"
          },
          "first_name": {
            "type": "string"
          },
          "id": {
            "type": "integer"
          },
          "last_name": {
            "type": "string"
          }
        },
        "type": "object"
      }
    },
    "securitySchemes": {
      "apiKeyHeader": {
        "in": "header",
        "name": "X-API-Key",
        "type": "apiKey"
      },
      "bearerAuth": {
        "scheme": "bearer",
        "type": "http"
      }
    }
  },
  "info": {
    "description": "REST API for Tonic Desk CRM. Authenticate with an API key from Settings \u2192 API Keys (Authorization: Bearer <key> or X-API-Key header). Keys carry scopes; read-only keys can call GET endpoints only. Rate limit: 60 requests/minute per key (Retry-After is set on 429).",
    "title": "Tonic Desk API",
    "version": "1.0.0"
  },
  "openapi": "3.1.0",
  "paths": {
    "/activities": {
      "get": {
        "parameters": [
          {
            "description": "Page number (default 1)",
            "in": "query",
            "name": "page",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "description": "Results per page (default 25, max 100)",
            "in": "query",
            "name": "per_page",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "description": "ISO 8601 datetime; returns records updated at/after it, ordered (updated_at, id) ascending for stable incremental sync",
            "in": "query",
            "name": "updated_since",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Filter by activity type",
            "in": "query",
            "name": "type",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "data": {
                      "items": {
                        "$ref": "#/components/schemas/Activity"
                      },
                      "type": "array"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/PaginationMeta"
                    }
                  },
                  "type": "object"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "summary": "List activities",
        "x-required-scope": "read:activities"
      },
      "post": {
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "activity_type": {
                    "type": "string"
                  },
                  "body_plain": {
                    "type": "string"
                  },
                  "call_duration_seconds": {
                    "type": "integer"
                  },
                  "call_outcome": {
                    "type": "string"
                  },
                  "company_id": {
                    "type": "integer"
                  },
                  "contact_id": {
                    "type": "integer"
                  },
                  "deal_id": {
                    "type": "integer"
                  },
                  "subject": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Activity"
                    }
                  },
                  "type": "object"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "summary": "Log an activity",
        "x-required-scope": "write:activities"
      }
    },
    "/activities/{id}": {
      "get": {
        "parameters": [
          {
            "description": "Record id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Activity"
                    }
                  },
                  "type": "object"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "summary": "Fetch one activity",
        "x-required-scope": "read:activities"
      }
    },
    "/capabilities": {
      "get": {
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "data": {
                      "properties": {
                        "modules": {
                          "items": {
                            "type": "string"
                          },
                          "type": "array"
                        }
                      },
                      "type": "object"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "OK"
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "summary": "Optional modules enabled for your organization"
      }
    },
    "/companies": {
      "get": {
        "parameters": [
          {
            "description": "Page number (default 1)",
            "in": "query",
            "name": "page",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "description": "Results per page (default 25, max 100)",
            "in": "query",
            "name": "per_page",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "description": "ISO 8601 datetime; returns records updated at/after it, ordered (updated_at, id) ascending for stable incremental sync",
            "in": "query",
            "name": "updated_since",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Match on name",
            "in": "query",
            "name": "search",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "data": {
                      "items": {
                        "$ref": "#/components/schemas/Company"
                      },
                      "type": "array"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/PaginationMeta"
                    }
                  },
                  "type": "object"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "summary": "List companies",
        "x-required-scope": "read:companies"
      },
      "post": {
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "annual_revenue": {
                    "type": "number"
                  },
                  "city": {
                    "type": "string"
                  },
                  "company_size": {
                    "type": "string"
                  },
                  "country": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  },
                  "domain": {
                    "type": "string"
                  },
                  "industry": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "owner_id": {
                    "type": "integer"
                  },
                  "phone": {
                    "type": "string"
                  },
                  "website": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Company"
                    }
                  },
                  "type": "object"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "summary": "Create a company",
        "x-required-scope": "write:companies"
      }
    },
    "/companies/{id}": {
      "delete": {
        "parameters": [
          {
            "description": "Record id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "summary": "Soft-delete a company",
        "x-required-scope": "write:companies"
      },
      "get": {
        "parameters": [
          {
            "description": "Record id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "data": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/Company"
                        },
                        {
                          "properties": {
                            "custom_fields": {
                              "description": "Custom field name \u2192 value for this record",
                              "type": "object"
                            }
                          },
                          "type": "object"
                        }
                      ]
                    }
                  },
                  "type": "object"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "summary": "Fetch one company (includes custom_fields)",
        "x-required-scope": "read:companies"
      },
      "patch": {
        "parameters": [
          {
            "description": "Record id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "annual_revenue": {
                    "type": "number"
                  },
                  "city": {
                    "type": "string"
                  },
                  "company_size": {
                    "type": "string"
                  },
                  "country": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  },
                  "domain": {
                    "type": "string"
                  },
                  "industry": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "owner_id": {
                    "type": "integer"
                  },
                  "phone": {
                    "type": "string"
                  },
                  "website": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Company"
                    }
                  },
                  "type": "object"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "summary": "Update a company (alias of PUT)",
        "x-required-scope": "write:companies"
      },
      "put": {
        "parameters": [
          {
            "description": "Record id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "annual_revenue": {
                    "type": "number"
                  },
                  "city": {
                    "type": "string"
                  },
                  "company_size": {
                    "type": "string"
                  },
                  "country": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  },
                  "domain": {
                    "type": "string"
                  },
                  "industry": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "owner_id": {
                    "type": "integer"
                  },
                  "phone": {
                    "type": "string"
                  },
                  "website": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Company"
                    }
                  },
                  "type": "object"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "summary": "Update a company (partial: only supplied fields change)",
        "x-required-scope": "write:companies"
      }
    },
    "/companies/{id}/timeline": {
      "get": {
        "description": "Also requires read:companies.",
        "parameters": [
          {
            "description": "Record id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "description": "Page number (default 1)",
            "in": "query",
            "name": "page",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "description": "Results per page (default 25, max 100)",
            "in": "query",
            "name": "per_page",
            "required": false,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "data": {
                      "items": {
                        "$ref": "#/components/schemas/Activity"
                      },
                      "type": "array"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/PaginationMeta"
                    }
                  },
                  "type": "object"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "summary": "Activity timeline for one company",
        "x-required-scope": "read:activities"
      }
    },
    "/contacts": {
      "get": {
        "parameters": [
          {
            "description": "Page number (default 1)",
            "in": "query",
            "name": "page",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "description": "Results per page (default 25, max 100)",
            "in": "query",
            "name": "per_page",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "description": "ISO 8601 datetime; returns records updated at/after it, ordered (updated_at, id) ascending for stable incremental sync",
            "in": "query",
            "name": "updated_since",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Match on name or email",
            "in": "query",
            "name": "search",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Only contacts linked to this company",
            "in": "query",
            "name": "company_id",
            "required": false,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "data": {
                      "items": {
                        "$ref": "#/components/schemas/Contact"
                      },
                      "type": "array"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/PaginationMeta"
                    }
                  },
                  "type": "object"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "summary": "List contacts",
        "x-required-scope": "read:contacts"
      },
      "post": {
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "address_line1": {
                    "type": "string"
                  },
                  "city": {
                    "type": "string"
                  },
                  "country": {
                    "type": "string"
                  },
                  "department": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  },
                  "email": {
                    "type": "string"
                  },
                  "first_name": {
                    "type": "string"
                  },
                  "job_title": {
                    "type": "string"
                  },
                  "last_name": {
                    "type": "string"
                  },
                  "lead_status": {
                    "type": "string"
                  },
                  "lifecycle_stage": {
                    "type": "string"
                  },
                  "mobile": {
                    "type": "string"
                  },
                  "owner_id": {
                    "type": "integer"
                  },
                  "phone": {
                    "type": "string"
                  },
                  "source": {
                    "type": "string"
                  },
                  "website": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Contact"
                    }
                  },
                  "type": "object"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "summary": "Create a contact",
        "x-required-scope": "write:contacts"
      }
    },
    "/contacts/{id}": {
      "delete": {
        "parameters": [
          {
            "description": "Record id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "summary": "Soft-delete a contact",
        "x-required-scope": "write:contacts"
      },
      "get": {
        "parameters": [
          {
            "description": "Record id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "data": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/Contact"
                        },
                        {
                          "properties": {
                            "custom_fields": {
                              "description": "Custom field name \u2192 value for this record",
                              "type": "object"
                            }
                          },
                          "type": "object"
                        }
                      ]
                    }
                  },
                  "type": "object"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "summary": "Fetch one contact (includes custom_fields)",
        "x-required-scope": "read:contacts"
      },
      "patch": {
        "parameters": [
          {
            "description": "Record id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "address_line1": {
                    "type": "string"
                  },
                  "city": {
                    "type": "string"
                  },
                  "country": {
                    "type": "string"
                  },
                  "department": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  },
                  "email": {
                    "type": "string"
                  },
                  "first_name": {
                    "type": "string"
                  },
                  "job_title": {
                    "type": "string"
                  },
                  "last_name": {
                    "type": "string"
                  },
                  "lead_status": {
                    "type": "string"
                  },
                  "lifecycle_stage": {
                    "type": "string"
                  },
                  "mobile": {
                    "type": "string"
                  },
                  "owner_id": {
                    "type": "integer"
                  },
                  "phone": {
                    "type": "string"
                  },
                  "source": {
                    "type": "string"
                  },
                  "website": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Contact"
                    }
                  },
                  "type": "object"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "summary": "Update a contact (alias of PUT)",
        "x-required-scope": "write:contacts"
      },
      "put": {
        "parameters": [
          {
            "description": "Record id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "address_line1": {
                    "type": "string"
                  },
                  "city": {
                    "type": "string"
                  },
                  "country": {
                    "type": "string"
                  },
                  "department": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  },
                  "email": {
                    "type": "string"
                  },
                  "first_name": {
                    "type": "string"
                  },
                  "job_title": {
                    "type": "string"
                  },
                  "last_name": {
                    "type": "string"
                  },
                  "lead_status": {
                    "type": "string"
                  },
                  "lifecycle_stage": {
                    "type": "string"
                  },
                  "mobile": {
                    "type": "string"
                  },
                  "owner_id": {
                    "type": "integer"
                  },
                  "phone": {
                    "type": "string"
                  },
                  "source": {
                    "type": "string"
                  },
                  "website": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Contact"
                    }
                  },
                  "type": "object"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "summary": "Update a contact (partial: only supplied fields change)",
        "x-required-scope": "write:contacts"
      }
    },
    "/contacts/{id}/timeline": {
      "get": {
        "description": "Also requires read:contacts.",
        "parameters": [
          {
            "description": "Record id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "description": "Page number (default 1)",
            "in": "query",
            "name": "page",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "description": "Results per page (default 25, max 100)",
            "in": "query",
            "name": "per_page",
            "required": false,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "data": {
                      "items": {
                        "$ref": "#/components/schemas/Activity"
                      },
                      "type": "array"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/PaginationMeta"
                    }
                  },
                  "type": "object"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "summary": "Activity timeline for one contact",
        "x-required-scope": "read:activities"
      }
    },
    "/custom-fields": {
      "get": {
        "parameters": [
          {
            "description": "contact | company | deal",
            "in": "query",
            "name": "entity_type",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "data": {
                      "items": {
                        "$ref": "#/components/schemas/CustomField"
                      },
                      "type": "array"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/PaginationMeta"
                    }
                  },
                  "type": "object"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "summary": "List custom field definitions",
        "x-required-scope": "read:custom_fields"
      }
    },
    "/dealer-links": {
      "post": {
        "description": "Requires the dealer-data module on your organization (403 module_not_enabled otherwise); see /capabilities. Pass company_id to link an existing company, or create_company: true to create one from the dealer record (dedup-guarded). 409 if already linked.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "company_id": {
                    "type": "integer"
                  },
                  "create_company": {
                    "type": "boolean"
                  },
                  "dealer_id": {
                    "type": "integer"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Link created"
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "summary": "Link a market dealer to a CRM company",
        "x-required-scope": "write:dealer_links"
      }
    },
    "/dealers": {
      "get": {
        "description": "Requires the dealer-data module on your organization (403 module_not_enabled otherwise); see /capabilities.",
        "parameters": [
          {
            "description": "Page number (default 1)",
            "in": "query",
            "name": "page",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "description": "Results per page (default 25, max 100)",
            "in": "query",
            "name": "per_page",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "description": "Match on name, town or postcode",
            "in": "query",
            "name": "search",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Restrict to one dealer group/network",
            "in": "query",
            "name": "network_id",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "description": "Minimum live EV listings",
            "in": "query",
            "name": "min_ev_listings",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "description": "true = only dealers linked to a CRM company; false = only unlinked",
            "in": "query",
            "name": "linked",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "data": {
                      "items": {
                        "$ref": "#/components/schemas/Dealer"
                      },
                      "type": "array"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/PaginationMeta"
                    }
                  },
                  "type": "object"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "summary": "List market dealers (scraped directory, not CRM companies)",
        "x-required-scope": "read:dealers"
      }
    },
    "/dealers/nissan-network": {
      "get": {
        "description": "Requires the dealer-data module on your organization (403 module_not_enabled otherwise); see /capabilities.",
        "parameters": [
          {
            "description": "Page number (default 1)",
            "in": "query",
            "name": "page",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "description": "Results per page (default 25, max 100)",
            "in": "query",
            "name": "per_page",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "description": "Match name / dealer number / town",
            "in": "query",
            "name": "q",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Campaign wave, e.g. W1",
            "in": "query",
            "name": "wave",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "MD | AR | Local",
            "in": "query",
            "name": "dealer_type",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "data": {
                      "items": {
                        "$ref": "#/components/schemas/NissanDealer"
                      },
                      "type": "array"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/PaginationMeta"
                    }
                  },
                  "type": "object"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "summary": "Nissan's official network list with dealer/company bridges",
        "x-required-scope": "read:dealers"
      }
    },
    "/dealers/{id}": {
      "get": {
        "description": "Requires the dealer-data module on your organization (403 module_not_enabled otherwise); see /capabilities.",
        "parameters": [
          {
            "description": "Record id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Dealer"
                    }
                  },
                  "type": "object"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "summary": "Fetch one market dealer",
        "x-required-scope": "read:dealers"
      }
    },
    "/dealers/{id}/listings": {
      "get": {
        "description": "Requires the dealer-data module on your organization (403 module_not_enabled otherwise); see /capabilities.",
        "parameters": [
          {
            "description": "Record id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "description": "Page number (default 1)",
            "in": "query",
            "name": "page",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "description": "Results per page (default 25, max 100)",
            "in": "query",
            "name": "per_page",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "description": "Default true; false includes delisted",
            "in": "query",
            "name": "active",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Electric | Plug-in Hybrid",
            "in": "query",
            "name": "fuel",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Only listings on sale at least this many days",
            "in": "query",
            "name": "min_days_listed",
            "required": false,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "data": {
                      "items": {
                        "$ref": "#/components/schemas/DealerListing"
                      },
                      "type": "array"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/PaginationMeta"
                    }
                  },
                  "type": "object"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "summary": "A dealer's live EV/PHEV listings with days_listed",
        "x-required-scope": "read:dealers"
      }
    },
    "/deals": {
      "get": {
        "parameters": [
          {
            "description": "Page number (default 1)",
            "in": "query",
            "name": "page",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "description": "Results per page (default 25, max 100)",
            "in": "query",
            "name": "per_page",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "description": "ISO 8601 datetime; returns records updated at/after it, ordered (updated_at, id) ascending for stable incremental sync",
            "in": "query",
            "name": "updated_since",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Restrict to one pipeline",
            "in": "query",
            "name": "pipeline_id",
            "required": false,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "data": {
                      "items": {
                        "$ref": "#/components/schemas/Deal"
                      },
                      "type": "array"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/PaginationMeta"
                    }
                  },
                  "type": "object"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "summary": "List deals",
        "x-required-scope": "read:deals"
      },
      "post": {
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "amount": {
                    "type": "number"
                  },
                  "company_id": {
                    "type": "integer"
                  },
                  "currency": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  },
                  "expected_close_date": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "owner_id": {
                    "type": "integer"
                  },
                  "pipeline_id": {
                    "type": "integer"
                  },
                  "priority": {
                    "type": "string"
                  },
                  "probability": {
                    "type": "integer"
                  },
                  "source": {
                    "type": "string"
                  },
                  "stage_id": {
                    "type": "integer"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Deal"
                    }
                  },
                  "type": "object"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "summary": "Create a deal",
        "x-required-scope": "write:deals"
      }
    },
    "/deals/{id}": {
      "delete": {
        "parameters": [
          {
            "description": "Record id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "summary": "Soft-delete a deal",
        "x-required-scope": "write:deals"
      },
      "get": {
        "parameters": [
          {
            "description": "Record id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "data": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/Deal"
                        },
                        {
                          "properties": {
                            "custom_fields": {
                              "description": "Custom field name \u2192 value for this record",
                              "type": "object"
                            }
                          },
                          "type": "object"
                        }
                      ]
                    }
                  },
                  "type": "object"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "summary": "Fetch one deal (includes custom_fields)",
        "x-required-scope": "read:deals"
      },
      "patch": {
        "parameters": [
          {
            "description": "Record id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "amount": {
                    "type": "number"
                  },
                  "company_id": {
                    "type": "integer"
                  },
                  "currency": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  },
                  "expected_close_date": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "owner_id": {
                    "type": "integer"
                  },
                  "pipeline_id": {
                    "type": "integer"
                  },
                  "priority": {
                    "type": "string"
                  },
                  "probability": {
                    "type": "integer"
                  },
                  "source": {
                    "type": "string"
                  },
                  "stage_id": {
                    "type": "integer"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Deal"
                    }
                  },
                  "type": "object"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "summary": "Update a deal (alias of PUT)",
        "x-required-scope": "write:deals"
      },
      "put": {
        "parameters": [
          {
            "description": "Record id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "amount": {
                    "type": "number"
                  },
                  "company_id": {
                    "type": "integer"
                  },
                  "currency": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  },
                  "expected_close_date": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "owner_id": {
                    "type": "integer"
                  },
                  "pipeline_id": {
                    "type": "integer"
                  },
                  "priority": {
                    "type": "string"
                  },
                  "probability": {
                    "type": "integer"
                  },
                  "source": {
                    "type": "string"
                  },
                  "stage_id": {
                    "type": "integer"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Deal"
                    }
                  },
                  "type": "object"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "summary": "Update a deal (partial: only supplied fields change)",
        "x-required-scope": "write:deals"
      }
    },
    "/deals/{id}/close-lost": {
      "post": {
        "parameters": [
          {
            "description": "Record id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "reason": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Deal"
                    }
                  },
                  "type": "object"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "summary": "Close a deal as lost",
        "x-required-scope": "write:deals"
      }
    },
    "/deals/{id}/close-won": {
      "post": {
        "parameters": [
          {
            "description": "Record id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "reason": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Deal"
                    }
                  },
                  "type": "object"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "summary": "Close a deal as won",
        "x-required-scope": "write:deals"
      }
    },
    "/deals/{id}/move-stage": {
      "post": {
        "parameters": [
          {
            "description": "Record id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "stage_id": {
                    "type": "integer"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Deal"
                    }
                  },
                  "type": "object"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "summary": "Move a deal to another stage in its pipeline",
        "x-required-scope": "write:deals"
      }
    },
    "/deals/{id}/reopen": {
      "post": {
        "parameters": [
          {
            "description": "Record id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Deal"
                    }
                  },
                  "type": "object"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "summary": "Reopen a closed deal",
        "x-required-scope": "write:deals"
      }
    },
    "/deals/{id}/timeline": {
      "get": {
        "description": "Also requires read:deals.",
        "parameters": [
          {
            "description": "Record id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "description": "Page number (default 1)",
            "in": "query",
            "name": "page",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "description": "Results per page (default 25, max 100)",
            "in": "query",
            "name": "per_page",
            "required": false,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "data": {
                      "items": {
                        "$ref": "#/components/schemas/Activity"
                      },
                      "type": "array"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/PaginationMeta"
                    }
                  },
                  "type": "object"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "summary": "Activity timeline for one deal",
        "x-required-scope": "read:activities"
      }
    },
    "/notes": {
      "get": {
        "parameters": [
          {
            "description": "Page number (default 1)",
            "in": "query",
            "name": "page",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "description": "Results per page (default 25, max 100)",
            "in": "query",
            "name": "per_page",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "description": "Filter by linked record",
            "in": "query",
            "name": "contact_id",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "description": "Filter by linked record",
            "in": "query",
            "name": "company_id",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "description": "Filter by linked record",
            "in": "query",
            "name": "deal_id",
            "required": false,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "data": {
                      "items": {
                        "$ref": "#/components/schemas/Activity"
                      },
                      "type": "array"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/PaginationMeta"
                    }
                  },
                  "type": "object"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "summary": "List notes (activities with type \"note\")",
        "x-required-scope": "read:activities"
      },
      "post": {
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "body": {
                    "type": "string"
                  },
                  "company_id": {
                    "type": "integer"
                  },
                  "contact_id": {
                    "type": "integer"
                  },
                  "deal_id": {
                    "type": "integer"
                  },
                  "subject": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Activity"
                    }
                  },
                  "type": "object"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "summary": "Create a note",
        "x-required-scope": "write:activities"
      }
    },
    "/pipelines": {
      "get": {
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "data": {
                      "items": {
                        "$ref": "#/components/schemas/Pipeline"
                      },
                      "type": "array"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/PaginationMeta"
                    }
                  },
                  "type": "object"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "summary": "List pipelines with ordered stages",
        "x-required-scope": "read:pipelines"
      }
    },
    "/search": {
      "get": {
        "description": "Requires the read scope of each requested type; results only include types the key can read.",
        "parameters": [
          {
            "description": "Search text (min 2 chars); every word must match",
            "in": "query",
            "name": "q",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Comma-separated subset of contacts,companies,deals",
            "in": "query",
            "name": "types",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Max results per type (default 10, max 25)",
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "summary": "Cross-object search over contacts, companies and deals"
      }
    },
    "/segments": {
      "get": {
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "data": {
                      "items": {
                        "$ref": "#/components/schemas/Segment"
                      },
                      "type": "array"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/PaginationMeta"
                    }
                  },
                  "type": "object"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "summary": "List contact segments",
        "x-required-scope": "read:segments"
      }
    },
    "/segments/{id}/contacts": {
      "get": {
        "description": "Also requires read:contacts.",
        "parameters": [
          {
            "description": "Record id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "description": "Page number (default 1)",
            "in": "query",
            "name": "page",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "description": "Results per page (default 25, max 100)",
            "in": "query",
            "name": "per_page",
            "required": false,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "data": {
                      "items": {
                        "$ref": "#/components/schemas/Contact"
                      },
                      "type": "array"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/PaginationMeta"
                    }
                  },
                  "type": "object"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "summary": "Contacts in a segment",
        "x-required-scope": "read:segments"
      }
    },
    "/tags": {
      "get": {
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "data": {
                      "items": {
                        "$ref": "#/components/schemas/Tag"
                      },
                      "type": "array"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/PaginationMeta"
                    }
                  },
                  "type": "object"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "summary": "List tags",
        "x-required-scope": "read:tags"
      }
    },
    "/tasks": {
      "get": {
        "parameters": [
          {
            "description": "Page number (default 1)",
            "in": "query",
            "name": "page",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "description": "Results per page (default 25, max 100)",
            "in": "query",
            "name": "per_page",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "description": "ISO 8601 datetime; returns records updated at/after it, ordered (updated_at, id) ascending for stable incremental sync",
            "in": "query",
            "name": "updated_since",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "pending | in_progress | completed | deferred",
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "data": {
                      "items": {
                        "$ref": "#/components/schemas/Task"
                      },
                      "type": "array"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/PaginationMeta"
                    }
                  },
                  "type": "object"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "summary": "List tasks",
        "x-required-scope": "read:tasks"
      },
      "post": {
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "assigned_to_id": {
                    "type": "integer"
                  },
                  "company_id": {
                    "type": "integer"
                  },
                  "contact_id": {
                    "type": "integer"
                  },
                  "deal_id": {
                    "type": "integer"
                  },
                  "description": {
                    "type": "string"
                  },
                  "due_date": {
                    "type": "string"
                  },
                  "priority": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string"
                  },
                  "task_type": {
                    "type": "string"
                  },
                  "title": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Task"
                    }
                  },
                  "type": "object"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "summary": "Create a task",
        "x-required-scope": "write:tasks"
      }
    },
    "/tasks/{id}": {
      "delete": {
        "parameters": [
          {
            "description": "Record id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "summary": "Soft-delete a task",
        "x-required-scope": "write:tasks"
      },
      "get": {
        "parameters": [
          {
            "description": "Record id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Task"
                    }
                  },
                  "type": "object"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "summary": "Fetch one task",
        "x-required-scope": "read:tasks"
      },
      "patch": {
        "parameters": [
          {
            "description": "Record id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "assigned_to_id": {
                    "type": "integer"
                  },
                  "company_id": {
                    "type": "integer"
                  },
                  "contact_id": {
                    "type": "integer"
                  },
                  "deal_id": {
                    "type": "integer"
                  },
                  "description": {
                    "type": "string"
                  },
                  "due_date": {
                    "type": "string"
                  },
                  "priority": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string"
                  },
                  "task_type": {
                    "type": "string"
                  },
                  "title": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Task"
                    }
                  },
                  "type": "object"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "summary": "Update a task (alias of PUT)",
        "x-required-scope": "write:tasks"
      },
      "put": {
        "parameters": [
          {
            "description": "Record id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "assigned_to_id": {
                    "type": "integer"
                  },
                  "company_id": {
                    "type": "integer"
                  },
                  "contact_id": {
                    "type": "integer"
                  },
                  "deal_id": {
                    "type": "integer"
                  },
                  "description": {
                    "type": "string"
                  },
                  "due_date": {
                    "type": "string"
                  },
                  "priority": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string"
                  },
                  "task_type": {
                    "type": "string"
                  },
                  "title": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Task"
                    }
                  },
                  "type": "object"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "summary": "Update a task (partial: only supplied fields change)",
        "x-required-scope": "write:tasks"
      }
    },
    "/users": {
      "get": {
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "data": {
                      "items": {
                        "$ref": "#/components/schemas/User"
                      },
                      "type": "array"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/PaginationMeta"
                    }
                  },
                  "type": "object"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "summary": "List active teammates (owners for assignment)",
        "x-required-scope": "read:users"
      }
    }
  },
  "servers": [
    {
      "url": "https://app.tonicdesk.com/api/v1"
    }
  ]
}
