{
  "openapi": "3.0.3",
  "info": {
    "title": "Grocito CRM API",
    "version": "1.0.0",
    "description": "REST API of Grocito CRM (plugin \"API & Webhooks\"). Authenticate with `Authorization: Bearer grc_live_…` (never in the URL). JSON in snake_case, times ISO-8601 UTC. Every key acts as one team member: it sees and changes only what that member can in the CRM. A key stops when the admin who created it is no longer an active admin; revoking or rotating a key takes effect within a few seconds, blocking a member or suspending the organisation within a minute; rotation stops the old key at once unless the 24-hour overlap is chosen. A leaked key must be revoked. API writes start Automations like a CRM edit and notify the assignee; Zapier / Microsoft Teams relays are not fired by API writes. Limits per key and per organisation (RateLimit-* headers, 429 + Retry-After). Webhooks: see x-webhooks and https://crm.grocito.com/developers/webhooks.",
    "contact": {
      "url": "https://crm.grocito.com/developers"
    }
  },
  "servers": [
    {
      "url": "https://asia-south2-sales-crm-grc.cloudfunctions.net/publicApi/v1"
    }
  ],
  "tags": [
    {
      "name": "Leads"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/me": {
      "get": {
        "summary": "The key, its organisation, the member it acts as, its scopes and limits",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Me"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          }
        }
      }
    },
    "/leads": {
      "get": {
        "summary": "List leads (newest first)",
        "x-required-scope": "leads:read",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            },
            "description": "1–100 (default 25)."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "next_cursor of the previous page."
          },
          {
            "name": "sort",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "created_at",
                "updated_at"
              ]
            },
            "description": "created_at (default) or updated_at."
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Exact status."
          },
          {
            "name": "source",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Exact source."
          },
          {
            "name": "assigned_to",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "User id."
          },
          {
            "name": "mobile",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Any format; returns every lead with that number (no cursor)."
          },
          {
            "name": "email",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Exact email (no cursor)."
          },
          {
            "name": "archived",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean"
            },
            "description": "true = archived leads only; default false."
          },
          {
            "name": "created_after",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "ISO-8601."
          },
          {
            "name": "updated_after",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "ISO-8601."
          }
        ],
        "responses": {
          "200": {
            "description": "A page of leads",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Lead"
                      }
                    },
                    "next_cursor": {
                      "type": "string",
                      "nullable": true,
                      "description": "Pass as ?cursor= for the next page; null = no more."
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          }
        }
      },
      "post": {
        "summary": "Create a lead",
        "x-required-scope": "leads:write",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 255
            },
            "description": "Repeat a POST safely: the same key + same body within 24 h returns the first answer (Idempotent-Replayed: true)."
          }
        ],
        "responses": {
          "200": {
            "description": "on_duplicate=return / merge: the existing lead",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Lead"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Lead"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "413": {
            "$ref": "#/components/responses/E413"
          },
          "415": {
            "$ref": "#/components/responses/E415"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LeadCreate"
              }
            }
          }
        }
      }
    },
    "/leads/{id}": {
      "get": {
        "summary": "Get a lead",
        "x-required-scope": "leads:read",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Lead"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          }
        }
      },
      "patch": {
        "summary": "Update a lead (only the fields sent)",
        "x-required-scope": "leads:write",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Lead"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "413": {
            "$ref": "#/components/responses/E413"
          },
          "415": {
            "$ref": "#/components/responses/E415"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LeadUpdate"
              }
            }
          }
        }
      }
    },
    "/leads/{id}/archive": {
      "post": {
        "summary": "Archive a lead",
        "x-required-scope": "leads:write",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Lead"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reason": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/leads/{id}/unarchive": {
      "post": {
        "summary": "Restore an archived lead",
        "x-required-scope": "leads:write",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Lead"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reason": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/leads/{id}/notes": {
      "get": {
        "summary": "List a lead's notes (newest first)",
        "x-required-scope": "leads:read",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "description": "1–100 (default 50)."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Note"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      },
      "post": {
        "summary": "Add a note to a lead",
        "x-required-scope": "notes:write",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 255
            },
            "description": "Repeat a POST safely: the same key + same body within 24 h returns the first answer (Idempotent-Replayed: true)."
          }
        ],
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Note"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "413": {
            "$ref": "#/components/responses/E413"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "text": {
                    "type": "string",
                    "description": "Up to 5000 characters."
                  }
                },
                "required": [
                  "text"
                ]
              }
            }
          }
        }
      }
    },
    "/leads/{id}/deals": {
      "get": {
        "summary": "List a lead's deals",
        "x-required-scope": "deals:read",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Deal"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      },
      "post": {
        "summary": "Add a deal to a lead (becomes its primary deal)",
        "x-required-scope": "deals:write",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 255
            },
            "description": "Repeat a POST safely: the same key + same body within 24 h returns the first answer (Idempotent-Replayed: true)."
          }
        ],
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Deal"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "413": {
            "$ref": "#/components/responses/E413"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DealCreate"
              }
            }
          }
        }
      }
    },
    "/leads/{id}/deals/{dealId}": {
      "get": {
        "summary": "Get a deal",
        "x-required-scope": "deals:read",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dealId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Deal"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      },
      "patch": {
        "summary": "Update a deal (stage / value / title / close date …)",
        "x-required-scope": "deals:write",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dealId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Deal"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DealUpdate"
              }
            }
          }
        }
      }
    },
    "/leads/{id}/reminders": {
      "post": {
        "summary": "Add a reminder to a lead",
        "x-required-scope": "reminders:write",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 255
            },
            "description": "Repeat a POST safely: the same key + same body within 24 h returns the first answer (Idempotent-Replayed: true)."
          }
        ],
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Reminder"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReminderCreate"
              }
            }
          }
        }
      }
    },
    "/reminders": {
      "get": {
        "summary": "List reminders (by due time, latest first)",
        "x-required-scope": "reminders:read",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            },
            "description": "1–100 (default 25)."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "next_cursor of the previous page."
          },
          {
            "name": "lead_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Only this lead's reminders (no cursor)."
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "pending / completed / declined."
          },
          {
            "name": "user_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Who is reminded."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Reminder"
                      }
                    },
                    "next_cursor": {
                      "type": "string",
                      "nullable": true,
                      "description": "Pass as ?cursor= for the next page; null = no more."
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          }
        }
      }
    },
    "/reminders/{id}": {
      "get": {
        "summary": "Get a reminder",
        "x-required-scope": "reminders:read",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Reminder"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/reminders/{id}/complete": {
      "post": {
        "summary": "Mark a reminder done (its creator, its assignee or an admin key)",
        "x-required-scope": "reminders:write",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 255
            },
            "description": "Repeat a POST safely: the same key + same body within 24 h returns the first answer (Idempotent-Replayed: true)."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Reminder"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/calls": {
      "get": {
        "summary": "List call logs (newest first)",
        "x-required-scope": "calls:read",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            },
            "description": "1–100 (default 25)."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "next_cursor of the previous page."
          },
          {
            "name": "lead_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Only this lead's calls (no cursor)."
          },
          {
            "name": "user_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Agent."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Call"
                      }
                    },
                    "next_cursor": {
                      "type": "string",
                      "nullable": true,
                      "description": "Pass as ?cursor= for the next page; null = no more."
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          }
        }
      }
    },
    "/calls/{id}": {
      "get": {
        "summary": "Get a call log",
        "x-required-scope": "calls:read",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Call"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/users": {
      "get": {
        "summary": "List team members",
        "x-required-scope": "users:read",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/User"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/users/{id}": {
      "get": {
        "summary": "Get a team member",
        "x-required-scope": "users:read",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/User"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/config": {
      "get": {
        "summary": "Statuses, sources, priorities, custom fields, deal stages",
        "x-required-scope": "config:read",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Config"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/quotations": {
      "get": {
        "summary": "List quotations (Quotation Manager plugin)",
        "x-required-scope": "quotes:read",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            },
            "description": "1–100 (default 25)."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "next_cursor of the previous page."
          },
          {
            "name": "lead_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Only this lead's (no cursor)."
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "draft / sent / accepted / rejected / invoiced."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Quotation"
                      }
                    },
                    "next_cursor": {
                      "type": "string",
                      "nullable": true,
                      "description": "Pass as ?cursor= for the next page; null = no more."
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          }
        }
      }
    },
    "/quotations/{id}": {
      "get": {
        "summary": "Get a quotation",
        "x-required-scope": "quotes:read",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Quotation"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/invoices": {
      "get": {
        "summary": "List invoices (Quotation Manager plugin)",
        "x-required-scope": "invoices:read",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            },
            "description": "1–100 (default 25)."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "next_cursor of the previous page."
          },
          {
            "name": "lead_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Only this lead's (no cursor)."
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "created / sent / partial / paid."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Invoice"
                      }
                    },
                    "next_cursor": {
                      "type": "string",
                      "nullable": true,
                      "description": "Pass as ?cursor= for the next page; null = no more."
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          }
        }
      }
    },
    "/invoices/{id}": {
      "get": {
        "summary": "Get an invoice",
        "x-required-scope": "invoices:read",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Invoice"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/orders": {
      "get": {
        "summary": "List online store orders (E-commerce plugin)",
        "x-required-scope": "orders:read",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            },
            "description": "1–100 (default 25)."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "next_cursor of the previous page."
          },
          {
            "name": "lead_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Linked lead."
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Order status."
          },
          {
            "name": "customer_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Store customer."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Order"
                      }
                    },
                    "next_cursor": {
                      "type": "string",
                      "nullable": true,
                      "description": "Pass as ?cursor= for the next page; null = no more."
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          }
        }
      }
    },
    "/orders/{id}": {
      "get": {
        "summary": "Get a store order",
        "x-required-scope": "orders:read",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Order"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/customers": {
      "get": {
        "summary": "List online store customers (E-commerce plugin)",
        "x-required-scope": "customers:read",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            },
            "description": "1–100 (default 25)."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "next_cursor of the previous page."
          },
          {
            "name": "lead_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Linked lead."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Customer"
                      }
                    },
                    "next_cursor": {
                      "type": "string",
                      "nullable": true,
                      "description": "Pass as ?cursor= for the next page; null = no more."
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          }
        }
      }
    },
    "/customers/{id}": {
      "get": {
        "summary": "Get a store customer",
        "x-required-scope": "customers:read",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Customer"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "grc_live_<key id>_<secret>"
      }
    },
    "responses": {
      "E400": {
        "description": "Bad request (invalid JSON / parameter / cursor, key in the URL).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E401": {
        "description": "Invalid or missing API key (one message for every reason — unknown, wrong, revoked, expired, IP not allowed, or its creator is no longer an active admin).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E403": {
        "description": "Scope missing, member lacks the right, read-only trial, plugin off, organisation inactive, acts-as member inactive.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E404": {
        "description": "Not found — or not visible to this key (other organisation / outside the member's data scope).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E409": {
        "description": "Duplicate lead / Idempotency-Key still in progress.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E413": {
        "description": "Body over 256 KB / lead too large.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E415": {
        "description": "Body is not application/json.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E422": {
        "description": "Validation error (unknown_field, invalid_mobile …).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E429": {
        "description": "Rate limit / daily quota / too many failed authentications. See Retry-After.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E503": {
        "description": "API switched off or temporarily unavailable. See Retry-After.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "description": "Machine-readable code, e.g. invalid_key, insufficient_scope, not_found, rate_limited."
              },
              "message": {
                "type": "string",
                "description": "Human-readable message."
              },
              "field": {
                "type": "string",
                "description": "The field at fault, when there is one."
              },
              "request_id": {
                "type": "string",
                "description": "Quote this when contacting support."
              }
            },
            "required": [
              "code",
              "message",
              "request_id"
            ]
          }
        },
        "required": [
          "error"
        ]
      },
      "Lead": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "type": "string",
            "enum": [
              "lead"
            ]
          },
          "name": {
            "type": "string"
          },
          "mobile": {
            "type": "string",
            "nullable": true,
            "description": "Indian mobile, 10 digits."
          },
          "phone": {
            "type": "string",
            "nullable": true,
            "description": "Same as mobile, or an international number with + and country code."
          },
          "email": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "string",
            "nullable": true
          },
          "source": {
            "type": "string",
            "nullable": true
          },
          "priority": {
            "type": "string",
            "nullable": true
          },
          "assigned_to": {
            "type": "string",
            "nullable": true,
            "description": "User id of the owner; null = unassigned."
          },
          "remark": {
            "type": "string",
            "nullable": true
          },
          "company": {
            "type": "string",
            "nullable": true
          },
          "archived": {
            "type": "boolean"
          },
          "archived_at": {
            "type": "string",
            "nullable": true,
            "format": "date-time"
          },
          "archived_reason": {
            "type": "string",
            "nullable": true
          },
          "decline_reason": {
            "type": "string",
            "nullable": true
          },
          "custom_fields": {
            "type": "object",
            "additionalProperties": true,
            "description": "Custom field values by field id (see GET /v1/config)."
          },
          "deal_value": {
            "type": "number",
            "nullable": true,
            "description": "Value of the primary deal."
          },
          "primary_deal_id": {
            "type": "string",
            "nullable": true
          },
          "deals_count": {
            "type": "integer"
          },
          "received_at": {
            "type": "string",
            "nullable": true,
            "format": "date-time"
          },
          "created_at": {
            "type": "string",
            "nullable": true,
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "nullable": true,
            "format": "date-time"
          },
          "created_by": {
            "type": "string",
            "nullable": true,
            "description": "User id (or integration name) that created the lead."
          },
          "updated_by": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "LeadCreate": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Required. Up to 200 characters."
          },
          "mobile": {
            "type": "string",
            "description": "Indian mobile in any common form: 9876543210, +91 98765 43210, 098765 43210. Stored as 10 digits."
          },
          "phone_international": {
            "type": "string",
            "description": "A non-Indian number with its country code (e.g. +44 7911 123456). Use instead of mobile."
          },
          "email": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "description": "One of GET /v1/config statuses (case-insensitive). Default: the first status."
          },
          "source": {
            "type": "string",
            "description": "One of GET /v1/config sources. Default: API."
          },
          "priority": {
            "type": "string",
            "description": "One of GET /v1/config priorities. Default: Medium."
          },
          "assigned_to": {
            "type": "string",
            "description": "User id of an active member. Default: the key's round robin, else unassigned."
          },
          "remark": {
            "type": "string",
            "description": "Up to 5000 characters."
          },
          "company": {
            "type": "string"
          },
          "received_at": {
            "type": "string",
            "description": "ISO-8601 date or date-time (India time when no zone)."
          },
          "custom_fields": {
            "type": "object",
            "additionalProperties": true,
            "description": "By custom field id or label."
          },
          "on_duplicate": {
            "type": "string",
            "description": "What to do when a lead with the same mobile (or email) exists: error (409, default), return (200 with the existing lead), merge (fill its empty fields).",
            "enum": [
              "error",
              "return",
              "merge"
            ]
          }
        },
        "required": [
          "name"
        ]
      },
      "LeadUpdate": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "mobile": {
            "type": "string"
          },
          "phone_international": {
            "type": "string"
          },
          "email": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "source": {
            "type": "string"
          },
          "priority": {
            "type": "string"
          },
          "assigned_to": {
            "type": "string",
            "nullable": true,
            "description": "null = unassign"
          },
          "remark": {
            "type": "string"
          },
          "company": {
            "type": "string"
          },
          "received_at": {
            "type": "string"
          },
          "custom_fields": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "Note": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "type": "string",
            "enum": [
              "note"
            ]
          },
          "lead_id": {
            "type": "string"
          },
          "text": {
            "type": "string"
          },
          "author": {
            "type": "string",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "nullable": true,
            "format": "date-time"
          },
          "via": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "Deal": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "type": "string",
            "enum": [
              "deal"
            ]
          },
          "lead_id": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "value": {
            "type": "number"
          },
          "stage": {
            "type": "string",
            "nullable": true,
            "description": "Stage key (GET /v1/config deal_stages)."
          },
          "probability": {
            "type": "number",
            "nullable": true
          },
          "type": {
            "type": "string",
            "nullable": true
          },
          "billing_frequency": {
            "type": "string",
            "nullable": true
          },
          "priority": {
            "type": "string",
            "nullable": true
          },
          "assigned_to": {
            "type": "string",
            "nullable": true
          },
          "expected_close_date": {
            "type": "string",
            "nullable": true,
            "description": "YYYY-MM-DD"
          },
          "next_step": {
            "type": "string",
            "nullable": true
          },
          "loss_reason": {
            "type": "string",
            "nullable": true
          },
          "closed_at": {
            "type": "string",
            "nullable": true,
            "format": "date-time"
          },
          "sub_deals_count": {
            "type": "integer"
          },
          "created_at": {
            "type": "string",
            "nullable": true,
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "nullable": true,
            "format": "date-time"
          }
        }
      },
      "DealCreate": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string"
          },
          "value": {
            "type": "number"
          },
          "stage": {
            "type": "string",
            "description": "Stage key; default the first stage."
          },
          "expected_close_date": {
            "type": "string",
            "description": "YYYY-MM-DD"
          },
          "priority": {
            "type": "string",
            "enum": [
              "low",
              "medium",
              "high",
              "urgent",
              "critical"
            ]
          },
          "assigned_to": {
            "type": "string"
          },
          "next_step": {
            "type": "string"
          },
          "loss_reason": {
            "type": "string"
          }
        },
        "required": [
          "title"
        ]
      },
      "DealUpdate": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string"
          },
          "value": {
            "type": "number",
            "description": "Refused (422 has_sub_deals) for a deal with sub-deals."
          },
          "stage": {
            "type": "string"
          },
          "expected_close_date": {
            "type": "string"
          },
          "priority": {
            "type": "string"
          },
          "assigned_to": {
            "type": "string",
            "nullable": true
          },
          "next_step": {
            "type": "string"
          },
          "loss_reason": {
            "type": "string"
          }
        }
      },
      "Reminder": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "type": "string",
            "enum": [
              "reminder"
            ]
          },
          "lead_id": {
            "type": "string",
            "nullable": true
          },
          "lead_name": {
            "type": "string",
            "nullable": true
          },
          "user_id": {
            "type": "string",
            "nullable": true
          },
          "date_time": {
            "type": "string",
            "nullable": true,
            "format": "date-time"
          },
          "remark": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "string"
          },
          "created_by": {
            "type": "string",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "nullable": true,
            "format": "date-time"
          }
        }
      },
      "ReminderCreate": {
        "type": "object",
        "properties": {
          "date_time": {
            "type": "string",
            "description": "ISO-8601 date-time (India time when no zone)."
          },
          "remark": {
            "type": "string",
            "description": "Up to 1000 characters."
          },
          "user_id": {
            "type": "string",
            "description": "Who is reminded; default the acts-as member. Other members only with an admin key."
          }
        },
        "required": [
          "date_time"
        ]
      },
      "Call": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "type": "string",
            "enum": [
              "call"
            ]
          },
          "lead_id": {
            "type": "string",
            "nullable": true
          },
          "user_id": {
            "type": "string",
            "nullable": true
          },
          "type": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "string",
            "nullable": true
          },
          "duration_seconds": {
            "type": "number",
            "nullable": true
          },
          "from": {
            "type": "string",
            "nullable": true
          },
          "to": {
            "type": "string",
            "nullable": true
          },
          "customer_number": {
            "type": "string",
            "nullable": true
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "notes": {
            "type": "string",
            "nullable": true
          },
          "source": {
            "type": "string",
            "nullable": true
          },
          "date_time": {
            "type": "string",
            "nullable": true,
            "format": "date-time"
          },
          "created_at": {
            "type": "string",
            "nullable": true,
            "format": "date-time"
          }
        }
      },
      "User": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "type": "string",
            "enum": [
              "user"
            ]
          },
          "name": {
            "type": "string"
          },
          "email": {
            "type": "string",
            "nullable": true
          },
          "role": {
            "type": "string",
            "enum": [
              "admin",
              "member"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "blocked",
              "pending"
            ]
          },
          "designation": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "Config": {
        "type": "object",
        "properties": {
          "object": {
            "type": "string"
          },
          "statuses": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "priorities": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "custom_fields": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CustomField"
            }
          },
          "deal_stages": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "key": {
                  "type": "string"
                },
                "label": {
                  "type": "string"
                },
                "probability": {
                  "type": "number",
                  "nullable": true
                }
              }
            }
          },
          "deal_custom_fields": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CustomField"
            }
          }
        }
      },
      "CustomField": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "label": {
            "type": "string"
          },
          "type": {
            "type": "string"
          },
          "required": {
            "type": "boolean"
          },
          "options": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "LineItem": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "nullable": true
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "sku": {
            "type": "string",
            "nullable": true
          },
          "hsn_sac": {
            "type": "string",
            "nullable": true
          },
          "quantity": {
            "type": "number",
            "nullable": true
          },
          "rate": {
            "type": "number",
            "nullable": true
          },
          "tax_rate": {
            "type": "number",
            "nullable": true
          },
          "total": {
            "type": "number",
            "nullable": true
          }
        }
      },
      "DocCustomer": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "nullable": true
          },
          "email": {
            "type": "string",
            "nullable": true
          },
          "phone": {
            "type": "string",
            "nullable": true
          },
          "address": {
            "type": "string",
            "nullable": true
          },
          "gstin": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "Quotation": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "type": "string",
            "enum": [
              "quotation"
            ]
          },
          "number": {
            "type": "string",
            "nullable": true
          },
          "version": {
            "type": "number",
            "nullable": true
          },
          "lead_id": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "string",
            "nullable": true
          },
          "type": {
            "type": "string",
            "nullable": true
          },
          "subject": {
            "type": "string",
            "nullable": true
          },
          "customer": {
            "$ref": "#/components/schemas/DocCustomer"
          },
          "currency": {
            "type": "string"
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LineItem"
            }
          },
          "discount_amount": {
            "type": "number",
            "nullable": true
          },
          "tax_amount": {
            "type": "number",
            "nullable": true
          },
          "total": {
            "type": "number",
            "nullable": true
          },
          "valid_until": {
            "type": "string",
            "nullable": true,
            "format": "date-time"
          },
          "created_at": {
            "type": "string",
            "nullable": true,
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "nullable": true,
            "format": "date-time"
          }
        }
      },
      "Invoice": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "type": "string",
            "enum": [
              "invoice"
            ]
          },
          "number": {
            "type": "string",
            "nullable": true
          },
          "lead_id": {
            "type": "string",
            "nullable": true
          },
          "quotation_id": {
            "type": "string",
            "nullable": true
          },
          "quotation_number": {
            "type": "string",
            "nullable": true
          },
          "order_number": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "string",
            "nullable": true
          },
          "customer": {
            "$ref": "#/components/schemas/DocCustomer"
          },
          "currency": {
            "type": "string"
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LineItem"
            }
          },
          "discount_amount": {
            "type": "number",
            "nullable": true
          },
          "tax_amount": {
            "type": "number",
            "nullable": true
          },
          "total": {
            "type": "number",
            "nullable": true
          },
          "paid_amount": {
            "type": "number",
            "nullable": true
          },
          "balance_due": {
            "type": "number",
            "nullable": true
          },
          "due_date": {
            "type": "string",
            "nullable": true,
            "format": "date-time"
          },
          "created_at": {
            "type": "string",
            "nullable": true,
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "nullable": true,
            "format": "date-time"
          }
        }
      },
      "Order": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "type": "string",
            "enum": [
              "order"
            ]
          },
          "number": {
            "type": "string",
            "nullable": true
          },
          "source": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "string",
            "nullable": true
          },
          "payment_status": {
            "type": "string",
            "nullable": true
          },
          "payment_method": {
            "type": "string",
            "nullable": true
          },
          "customer_id": {
            "type": "string",
            "nullable": true
          },
          "lead_id": {
            "type": "string",
            "nullable": true
          },
          "customer": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "nullable": true
              },
              "email": {
                "type": "string",
                "nullable": true
              },
              "phone": {
                "type": "string",
                "nullable": true
              }
            }
          },
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "product_id": {
                  "type": "string",
                  "nullable": true
                },
                "name": {
                  "type": "string",
                  "nullable": true
                },
                "sku": {
                  "type": "string",
                  "nullable": true
                },
                "variant": {
                  "type": "string",
                  "nullable": true
                },
                "quantity": {
                  "type": "number",
                  "nullable": true
                },
                "price": {
                  "type": "number",
                  "nullable": true
                },
                "total": {
                  "type": "number",
                  "nullable": true
                }
              }
            }
          },
          "currency": {
            "type": "string"
          },
          "subtotal": {
            "type": "number",
            "nullable": true
          },
          "discount": {
            "type": "number",
            "nullable": true
          },
          "shipping": {
            "type": "number",
            "nullable": true
          },
          "tax": {
            "type": "number",
            "nullable": true
          },
          "total": {
            "type": "number",
            "nullable": true
          },
          "coupon_code": {
            "type": "string",
            "nullable": true
          },
          "shipping_address": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "nullable": true
              },
              "phone": {
                "type": "string",
                "nullable": true
              },
              "line1": {
                "type": "string",
                "nullable": true
              },
              "line2": {
                "type": "string",
                "nullable": true
              },
              "city": {
                "type": "string",
                "nullable": true
              },
              "state": {
                "type": "string",
                "nullable": true
              },
              "pincode": {
                "type": "string",
                "nullable": true
              },
              "country": {
                "type": "string",
                "nullable": true
              }
            },
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "nullable": true,
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "nullable": true,
            "format": "date-time"
          }
        }
      },
      "Customer": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "type": "string",
            "enum": [
              "customer"
            ]
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "email": {
            "type": "string",
            "nullable": true
          },
          "phone": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "string"
          },
          "total_orders": {
            "type": "number"
          },
          "total_spent": {
            "type": "number"
          },
          "created_at": {
            "type": "string",
            "nullable": true,
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "nullable": true,
            "format": "date-time"
          }
        }
      },
      "Me": {
        "type": "object",
        "properties": {
          "object": {
            "type": "string"
          },
          "organization": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              }
            }
          },
          "key": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "prefix": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "scopes": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "expires_at": {
                "type": "string",
                "nullable": true,
                "format": "date-time"
              }
            }
          },
          "acts_as": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "role": {
                "type": "string"
              },
              "data_scope": {
                "type": "string",
                "enum": [
                  "all",
                  "team",
                  "own"
                ]
              }
            }
          },
          "read_only": {
            "type": "boolean"
          },
          "limits": {
            "type": "object",
            "properties": {
              "per_key_per_minute": {
                "type": "integer"
              },
              "per_org_per_minute": {
                "type": "integer"
              },
              "per_org_per_day": {
                "type": "integer"
              }
            }
          }
        }
      },
      "WebhookEvent": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Event id = the webhook-id header. Deliveries can repeat: skip ids you already handled."
          },
          "type": {
            "type": "string",
            "enum": [
              "lead.created",
              "lead.updated",
              "lead.status_changed",
              "lead.assigned",
              "lead.archived",
              "lead.unarchived",
              "note.added",
              "deal.created",
              "deal.stage_changed",
              "deal.won",
              "reminder.created",
              "reminder.completed",
              "call.logged",
              "order.created"
            ]
          },
          "api_version": {
            "type": "string",
            "enum": [
              "v1"
            ]
          },
          "created_at": {
            "type": "string",
            "nullable": true,
            "format": "date-time"
          },
          "organization_id": {
            "type": "string"
          },
          "data": {
            "type": "object",
            "properties": {
              "object": {
                "description": "The lead / reminder / call / order, exactly as the API returns it.",
                "type": "object"
              },
              "previous": {
                "type": "object",
                "description": "Changed fields before the change (lead.updated / status_changed / assigned / deal.stage_changed)."
              },
              "deal": {
                "$ref": "#/components/schemas/Deal"
              },
              "note": {
                "$ref": "#/components/schemas/Note"
              }
            }
          },
          "meta": {
            "type": "object",
            "properties": {
              "caused_by": {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "description": "api = made through the public API (api_key_id says which key); crm = any other change (a CRM user, an automation or an integration). Decided only from server-set data.",
                    "enum": [
                      "api",
                      "crm"
                    ]
                  },
                  "api_key_id": {
                    "type": "string"
                  }
                }
              },
              "truncated": {
                "type": "boolean"
              }
            }
          }
        }
      }
    }
  },
  "x-scopes": [
    {
      "scope": "leads:read",
      "description": "Read leads",
      "write": false,
      "plugin": null
    },
    {
      "scope": "leads:write",
      "description": "Create, update and archive leads",
      "write": true,
      "plugin": null
    },
    {
      "scope": "notes:write",
      "description": "Add notes to leads",
      "write": true,
      "plugin": null
    },
    {
      "scope": "deals:read",
      "description": "Read deals",
      "write": false,
      "plugin": null
    },
    {
      "scope": "deals:write",
      "description": "Create and update deals",
      "write": true,
      "plugin": null
    },
    {
      "scope": "reminders:read",
      "description": "Read reminders",
      "write": false,
      "plugin": null
    },
    {
      "scope": "reminders:write",
      "description": "Add and complete reminders",
      "write": true,
      "plugin": null
    },
    {
      "scope": "calls:read",
      "description": "Read call logs",
      "write": false,
      "plugin": null
    },
    {
      "scope": "users:read",
      "description": "Read team members",
      "write": false,
      "plugin": null
    },
    {
      "scope": "config:read",
      "description": "Read statuses, sources, custom fields, deal stages",
      "write": false,
      "plugin": null
    },
    {
      "scope": "quotes:read",
      "description": "Read quotations",
      "write": false,
      "plugin": "quotationManager"
    },
    {
      "scope": "invoices:read",
      "description": "Read invoices",
      "write": false,
      "plugin": "quotationManager"
    },
    {
      "scope": "orders:read",
      "description": "Read store orders",
      "write": false,
      "plugin": "ecommerce"
    },
    {
      "scope": "customers:read",
      "description": "Read store customers",
      "write": false,
      "plugin": "ecommerce"
    }
  ],
  "x-webhooks": {
    "description": "Standard Webhooks (https://www.standardwebhooks.com): headers webhook-id, webhook-timestamp, webhook-signature \"v1,<base64 HMAC-SHA256(secret, id.timestamp.body)>\" (secret = base64 after \"whsec_\"). Reject timestamps more than 5 minutes off. Answer 2xx within 10 s; 429 / 5xx / timeouts are retried up to 7 more times over about an hour (30 s, 1, 2, 4, 8, 16, 32 min); 410 switches the webhook off. Deliveries can repeat — deduplicate on webhook-id.",
    "events": [
      {
        "type": "lead.created",
        "description": "Lead created",
        "plugin": null
      },
      {
        "type": "lead.updated",
        "description": "Lead updated",
        "plugin": null
      },
      {
        "type": "lead.status_changed",
        "description": "Lead status changed",
        "plugin": null
      },
      {
        "type": "lead.assigned",
        "description": "Lead assigned",
        "plugin": null
      },
      {
        "type": "lead.archived",
        "description": "Lead archived",
        "plugin": null
      },
      {
        "type": "lead.unarchived",
        "description": "Lead restored from archive",
        "plugin": null
      },
      {
        "type": "note.added",
        "description": "Note added",
        "plugin": null
      },
      {
        "type": "deal.created",
        "description": "Deal created",
        "plugin": null
      },
      {
        "type": "deal.stage_changed",
        "description": "Deal stage changed",
        "plugin": null
      },
      {
        "type": "deal.won",
        "description": "Deal won",
        "plugin": null
      },
      {
        "type": "reminder.created",
        "description": "Reminder created",
        "plugin": null
      },
      {
        "type": "reminder.completed",
        "description": "Reminder completed",
        "plugin": null
      },
      {
        "type": "call.logged",
        "description": "Call logged",
        "plugin": null
      },
      {
        "type": "order.created",
        "description": "Store order placed",
        "plugin": "ecommerce"
      }
    ],
    "payload": {
      "$ref": "#/components/schemas/WebhookEvent"
    }
  }
}
