{
  "openapi": "3.0.3",
  "info": {
    "title": "Biky Funnels API",
    "version": "1.0.0",
    "description": "Sales pipelines of your app: funnels, their steps, and the SalesCards (deals) that move through them. Each SalesCard links one or more contacts to a deal with a responsible advisor, value, products and custom fields."
  },
  "servers": [
    {
      "url": "https://crm-funnel.keybeapi.com",
      "description": "Production"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "tags": [
    {
      "name": "Funnels",
      "description": "Pipelines of your app."
    },
    {
      "name": "Steps",
      "description": "Stages of a funnel, in order."
    },
    {
      "name": "SalesCards",
      "description": "Deals of your contacts and how they move through the steps."
    }
  ],
  "paths": {
    "/{appUUID}/funnel": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AppUUID"
        }
      ],
      "get": {
        "tags": [
          "Funnels"
        ],
        "operationId": "listFunnels",
        "summary": "List funnels",
        "description": "Returns all non-deleted funnels of the app, newest first, without their steps. Use `GET /{appUUID}/funnel/with-steps` to get the steps in the same call.",
        "parameters": [
          {
            "name": "search",
            "in": "query",
            "required": false,
            "description": "Case-insensitive text contained in the funnel name.",
            "schema": {
              "type": "string"
            },
            "example": "ventas"
          },
          {
            "name": "isEdit",
            "in": "query",
            "required": false,
            "description": "`0` = only system funnels; `1` = only funnels created by your team.",
            "schema": {
              "type": "integer",
              "enum": [
                0,
                1
              ]
            },
            "example": 1
          }
        ],
        "responses": {
          "200": {
            "description": "Funnels of the app.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Funnel"
                  }
                },
                "example": [
                  {
                    "_id": "665f1c2e8a4b3d0012ab34cd",
                    "app": "app_7f3k2m9x1q",
                    "name": "$funnel_sales$",
                    "isEdit": 0,
                    "type": "sale",
                    "category": "car",
                    "createdBy": {
                      "userId": "9f2c4a7e-1b3d-4e5f-8a6b-7c8d9e0f1a2b",
                      "name": "Integración",
                      "lastname": "ERP",
                      "email": "integraciones@example.com",
                      "type": "admin"
                    },
                    "createdAt": "2026-01-15T14:02:11.000Z",
                    "updatedAt": "2026-01-15T14:02:11.000Z"
                  },
                  {
                    "_id": "665f1c2e8a4b3d0012ab35aa",
                    "app": "app_7f3k2m9x1q",
                    "name": "Ventas corporativas",
                    "isEdit": 1,
                    "type": "sale",
                    "createdBy": {
                      "userId": "9f2c4a7e-1b3d-4e5f-8a6b-7c8d9e0f1a2b",
                      "name": "Integración",
                      "lastname": "ERP",
                      "email": "integraciones@example.com",
                      "type": "admin"
                    },
                    "createdAt": "2026-03-02T16:20:45.000Z",
                    "updatedAt": "2026-03-02T16:20:45.000Z"
                  }
                ]
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      },
      "post": {
        "tags": [
          "Funnels"
        ],
        "operationId": "createFunnel",
        "summary": "Create a funnel",
        "description": "Creates a funnel with `stepsNumber` placeholder steps (named `# 1`, `# 2`…). The response is the funnel without its steps; list them with `GET /{appUUID}/{funnelId}/steps` and rename them as needed.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateFunnelRequest"
              },
              "example": {
                "name": "Ventas corporativas",
                "stepsNumber": 4,
                "type": "sale"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Funnel created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Funnel"
                },
                "example": {
                  "_id": "665f1c2e8a4b3d0012ab35aa",
                  "app": "app_7f3k2m9x1q",
                  "name": "Ventas corporativas",
                  "isEdit": 1,
                  "type": "sale",
                  "createdBy": {
                    "userId": "9f2c4a7e-1b3d-4e5f-8a6b-7c8d9e0f1a2b",
                    "name": "Integración",
                    "lastname": "ERP",
                    "email": "integraciones@example.com",
                    "type": "admin"
                  },
                  "createdAt": "2026-03-02T16:20:45.000Z",
                  "updatedAt": "2026-03-02T16:20:45.000Z"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      }
    },
    "/{appUUID}/funnel/with-steps": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AppUUID"
        }
      ],
      "get": {
        "tags": [
          "Funnels"
        ],
        "operationId": "listFunnelsWithSteps",
        "summary": "List funnels with their steps",
        "description": "Returns every non-deleted funnel of the app with a summary of its steps (`_id`, `name`, `promptName`, `order`), sorted by `order`. The quickest way to resolve the funnel and step ids you need to create or move cards.",
        "parameters": [
          {
            "name": "search",
            "in": "query",
            "required": false,
            "description": "Case-insensitive text contained in the funnel name.",
            "schema": {
              "type": "string"
            },
            "example": "sales"
          },
          {
            "name": "isEdit",
            "in": "query",
            "required": false,
            "description": "`0` = only system funnels; `1` = only funnels created by your team.",
            "schema": {
              "type": "integer",
              "enum": [
                0,
                1
              ]
            },
            "example": 0
          }
        ],
        "responses": {
          "200": {
            "description": "Funnels with their steps.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/FunnelWithSteps"
                  }
                },
                "example": [
                  {
                    "_id": "665f1c2e8a4b3d0012ab34cd",
                    "app": "app_7f3k2m9x1q",
                    "name": "$funnel_sales$",
                    "isEdit": 0,
                    "type": "sale",
                    "steps": [
                      {
                        "_id": "665f1c2e8a4b3d0012ab34d0",
                        "name": "$step_mql$",
                        "order": 1
                      },
                      {
                        "_id": "665f1c2e8a4b3d0012ab34cf",
                        "name": "$step_delivered_mql$",
                        "promptName": "Delivered (MQL)",
                        "order": 2
                      },
                      {
                        "_id": "665f1c2e8a4b3d0012ab34d1",
                        "name": "$step_sql$",
                        "promptName": "Interested SQL",
                        "order": 3
                      },
                      {
                        "_id": "665f1c2e8a4b3d0012ab34d6",
                        "name": "$step_won$",
                        "promptName": "Won",
                        "order": 4
                      },
                      {
                        "_id": "665f1c2e8a4b3d0012ab34d7",
                        "name": "$step_lost$",
                        "promptName": "Lost",
                        "order": 5
                      }
                    ]
                  }
                ]
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      }
    },
    "/{appUUID}/funnel/name/{name}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AppUUID"
        },
        {
          "name": "name",
          "in": "path",
          "required": true,
          "description": "Exact funnel name, e.g. `$funnel_sales$` or the name of one of your funnels (URL-encoded).",
          "schema": {
            "type": "string"
          },
          "example": "$funnel_sales$"
        }
      ],
      "get": {
        "tags": [
          "Funnels"
        ],
        "operationId": "getFunnelByName",
        "summary": "Get a funnel by name",
        "description": "Returns the non-deleted funnel with that exact name and its steps (steps are not sorted; sort them by `order`).",
        "responses": {
          "200": {
            "description": "Funnel and steps.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FunnelByName"
                },
                "example": {
                  "funnel": {
                    "_id": "665f1c2e8a4b3d0012ab34cd",
                    "app": "app_7f3k2m9x1q",
                    "name": "$funnel_sales$",
                    "isEdit": 0,
                    "type": "sale",
                    "category": "car",
                    "createdBy": {
                      "userId": "9f2c4a7e-1b3d-4e5f-8a6b-7c8d9e0f1a2b",
                      "name": "Integración",
                      "lastname": "ERP",
                      "email": "integraciones@example.com",
                      "type": "admin"
                    },
                    "createdAt": "2026-01-15T14:02:11.000Z",
                    "updatedAt": "2026-01-15T14:02:11.000Z"
                  },
                  "steps": [
                    {
                      "_id": "665f1c2e8a4b3d0012ab34d1",
                      "app": "app_7f3k2m9x1q",
                      "funnel": "665f1c2e8a4b3d0012ab34cd",
                      "name": "$step_sql$",
                      "promptName": "Interested SQL",
                      "order": 4,
                      "winProbability": 30,
                      "totalValue": 435000000,
                      "createdBy": {
                        "userId": "9f2c4a7e-1b3d-4e5f-8a6b-7c8d9e0f1a2b",
                        "name": "Integración",
                        "lastname": "ERP",
                        "email": "integraciones@example.com",
                        "type": "admin"
                      },
                      "createdAt": "2026-01-15T14:02:11.000Z",
                      "updatedAt": "2026-10-30T09:12:40.000Z"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/{appUUID}/funnel/{funnelId}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AppUUID"
        },
        {
          "$ref": "#/components/parameters/FunnelId"
        }
      ],
      "get": {
        "tags": [
          "Funnels"
        ],
        "operationId": "getFunnel",
        "summary": "Get a funnel",
        "description": "Returns the funnel. If no funnel has that id the response is `200` with an empty body.",
        "responses": {
          "200": {
            "description": "The funnel.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Funnel"
                },
                "example": {
                  "_id": "665f1c2e8a4b3d0012ab34cd",
                  "app": "app_7f3k2m9x1q",
                  "name": "$funnel_sales$",
                  "isEdit": 0,
                  "type": "sale",
                  "category": "car",
                  "createdBy": {
                    "userId": "9f2c4a7e-1b3d-4e5f-8a6b-7c8d9e0f1a2b",
                    "name": "Integración",
                    "lastname": "ERP",
                    "email": "integraciones@example.com",
                    "type": "admin"
                  },
                  "createdAt": "2026-01-15T14:02:11.000Z",
                  "updatedAt": "2026-01-15T14:02:11.000Z"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      },
      "patch": {
        "tags": [
          "Funnels"
        ],
        "operationId": "updateFunnel",
        "summary": "Update a funnel",
        "description": "Changes the fields you send and returns the updated funnel (empty body if the id does not exist). Steps are managed with the Steps endpoints.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateFunnelRequest"
              },
              "example": {
                "name": "Ventas corporativas 2027"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated funnel.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Funnel"
                },
                "example": {
                  "_id": "665f1c2e8a4b3d0012ab35aa",
                  "app": "app_7f3k2m9x1q",
                  "name": "Ventas corporativas 2027",
                  "isEdit": 1,
                  "type": "sale",
                  "createdBy": {
                    "userId": "9f2c4a7e-1b3d-4e5f-8a6b-7c8d9e0f1a2b",
                    "name": "Integración",
                    "lastname": "ERP",
                    "email": "integraciones@example.com",
                    "type": "admin"
                  },
                  "createdAt": "2026-03-02T16:20:45.000Z",
                  "updatedAt": "2026-03-02T16:20:45.000Z",
                  "updatedBy": {
                    "userId": "9f2c4a7e-1b3d-4e5f-8a6b-7c8d9e0f1a2b",
                    "name": "Integración",
                    "lastname": "ERP",
                    "email": "integraciones@example.com",
                    "type": "admin"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      },
      "delete": {
        "tags": [
          "Funnels"
        ],
        "operationId": "deleteFunnel",
        "summary": "Delete a funnel",
        "description": "Soft-deletes the funnel: it stops appearing in lists. Its steps and cards are not deleted or moved.",
        "responses": {
          "200": {
            "description": "The deleted funnel.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Funnel"
                },
                "example": {
                  "_id": "665f1c2e8a4b3d0012ab35aa",
                  "app": "app_7f3k2m9x1q",
                  "name": "Ventas corporativas",
                  "isEdit": 1,
                  "type": "sale",
                  "createdBy": {
                    "userId": "9f2c4a7e-1b3d-4e5f-8a6b-7c8d9e0f1a2b",
                    "name": "Integración",
                    "lastname": "ERP",
                    "email": "integraciones@example.com",
                    "type": "admin"
                  },
                  "createdAt": "2026-03-02T16:20:45.000Z",
                  "updatedAt": "2026-03-02T16:20:45.000Z"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      }
    },
    "/{appUUID}/{funnelId}/steps": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AppUUID"
        },
        {
          "$ref": "#/components/parameters/FunnelId"
        }
      ],
      "get": {
        "tags": [
          "Steps"
        ],
        "operationId": "listSteps",
        "summary": "List the steps of a funnel",
        "description": "Returns the non-deleted steps of the funnel sorted by `order`, each with its funnel expanded.",
        "responses": {
          "200": {
            "description": "Steps of the funnel.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Step"
                  }
                },
                "example": [
                  {
                    "_id": "665f1c2e8a4b3d0012ab35b1",
                    "app": "app_7f3k2m9x1q",
                    "funnel": {
                      "_id": "665f1c2e8a4b3d0012ab35aa",
                      "app": "app_7f3k2m9x1q",
                      "name": "Ventas corporativas",
                      "isEdit": 1,
                      "type": "sale",
                      "createdBy": {
                        "userId": "9f2c4a7e-1b3d-4e5f-8a6b-7c8d9e0f1a2b",
                        "name": "Integración",
                        "lastname": "ERP",
                        "email": "integraciones@example.com",
                        "type": "admin"
                      },
                      "createdAt": "2026-03-02T16:20:45.000Z",
                      "updatedAt": "2026-03-02T16:20:45.000Z"
                    },
                    "name": "Cotización enviada",
                    "label": "Cotización enviada",
                    "order": 3,
                    "winProbability": 40,
                    "expiration": 3,
                    "expirationLabel": "day",
                    "totalValue": 0,
                    "createdBy": {
                      "userId": "9f2c4a7e-1b3d-4e5f-8a6b-7c8d9e0f1a2b",
                      "name": "Integración",
                      "lastname": "ERP",
                      "email": "integraciones@example.com",
                      "type": "admin"
                    },
                    "createdAt": "2026-03-02T16:25:01.000Z",
                    "updatedAt": "2026-03-02T16:25:01.000Z"
                  }
                ]
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      },
      "post": {
        "tags": [
          "Steps"
        ],
        "operationId": "createStep",
        "summary": "Create a step",
        "description": "Adds a step at the end of the funnel (`order` = last + 1). Fails with `400` if the funnel already has a step with that name.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateStepRequest"
              },
              "example": {
                "name": "Cotización enviada",
                "label": "Cotización enviada",
                "winProbability": 40,
                "expiration": 3,
                "expirationLabel": "day"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Step created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Step"
                },
                "example": {
                  "_id": "665f1c2e8a4b3d0012ab35b1",
                  "app": "app_7f3k2m9x1q",
                  "funnel": {
                    "_id": "665f1c2e8a4b3d0012ab35aa",
                    "app": "app_7f3k2m9x1q",
                    "name": "Ventas corporativas",
                    "isEdit": 1,
                    "type": "sale",
                    "createdBy": {
                      "userId": "9f2c4a7e-1b3d-4e5f-8a6b-7c8d9e0f1a2b",
                      "name": "Integración",
                      "lastname": "ERP",
                      "email": "integraciones@example.com",
                      "type": "admin"
                    },
                    "createdAt": "2026-03-02T16:20:45.000Z",
                    "updatedAt": "2026-03-02T16:20:45.000Z"
                  },
                  "name": "Cotización enviada",
                  "label": "Cotización enviada",
                  "order": 3,
                  "winProbability": 40,
                  "expiration": 3,
                  "expirationLabel": "day",
                  "totalValue": 0,
                  "createdBy": {
                    "userId": "9f2c4a7e-1b3d-4e5f-8a6b-7c8d9e0f1a2b",
                    "name": "Integración",
                    "lastname": "ERP",
                    "email": "integraciones@example.com",
                    "type": "admin"
                  },
                  "createdAt": "2026-03-02T16:25:01.000Z",
                  "updatedAt": "2026-03-02T16:25:01.000Z"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      }
    },
    "/{appUUID}/steps/{stepId}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AppUUID"
        },
        {
          "$ref": "#/components/parameters/StepId"
        }
      ],
      "get": {
        "tags": [
          "Steps"
        ],
        "operationId": "getStep",
        "summary": "Get a step",
        "description": "Returns the step with its funnel expanded. If no non-deleted step has that id the response is `200` with an empty body.",
        "responses": {
          "200": {
            "description": "The step.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Step"
                },
                "example": {
                  "_id": "665f1c2e8a4b3d0012ab35b1",
                  "app": "app_7f3k2m9x1q",
                  "funnel": {
                    "_id": "665f1c2e8a4b3d0012ab35aa",
                    "app": "app_7f3k2m9x1q",
                    "name": "Ventas corporativas",
                    "isEdit": 1,
                    "type": "sale",
                    "createdBy": {
                      "userId": "9f2c4a7e-1b3d-4e5f-8a6b-7c8d9e0f1a2b",
                      "name": "Integración",
                      "lastname": "ERP",
                      "email": "integraciones@example.com",
                      "type": "admin"
                    },
                    "createdAt": "2026-03-02T16:20:45.000Z",
                    "updatedAt": "2026-03-02T16:20:45.000Z"
                  },
                  "name": "Cotización enviada",
                  "label": "Cotización enviada",
                  "order": 3,
                  "winProbability": 40,
                  "expiration": 3,
                  "expirationLabel": "day",
                  "totalValue": 0,
                  "createdBy": {
                    "userId": "9f2c4a7e-1b3d-4e5f-8a6b-7c8d9e0f1a2b",
                    "name": "Integración",
                    "lastname": "ERP",
                    "email": "integraciones@example.com",
                    "type": "admin"
                  },
                  "createdAt": "2026-03-02T16:25:01.000Z",
                  "updatedAt": "2026-03-02T16:25:01.000Z"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      }
    },
    "/{appUUID}/{funnelId}/steps/{stepId}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AppUUID"
        },
        {
          "$ref": "#/components/parameters/FunnelId"
        },
        {
          "$ref": "#/components/parameters/StepId"
        }
      ],
      "patch": {
        "tags": [
          "Steps"
        ],
        "operationId": "updateStep",
        "summary": "Update a step",
        "description": "Changes the fields you send and returns the step (empty body if the step is not in that funnel). Changing `order` does not shift the other steps.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateStepRequest"
              },
              "example": {
                "label": "Cotización enviada",
                "winProbability": 50,
                "order": 2
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated step.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Step"
                },
                "example": {
                  "_id": "665f1c2e8a4b3d0012ab35b1",
                  "app": "app_7f3k2m9x1q",
                  "funnel": {
                    "_id": "665f1c2e8a4b3d0012ab35aa",
                    "app": "app_7f3k2m9x1q",
                    "name": "Ventas corporativas",
                    "isEdit": 1,
                    "type": "sale",
                    "createdBy": {
                      "userId": "9f2c4a7e-1b3d-4e5f-8a6b-7c8d9e0f1a2b",
                      "name": "Integración",
                      "lastname": "ERP",
                      "email": "integraciones@example.com",
                      "type": "admin"
                    },
                    "createdAt": "2026-03-02T16:20:45.000Z",
                    "updatedAt": "2026-03-02T16:20:45.000Z"
                  },
                  "name": "Cotización enviada",
                  "label": "Cotización enviada",
                  "order": 2,
                  "winProbability": 50,
                  "expiration": 3,
                  "expirationLabel": "day",
                  "totalValue": 0,
                  "createdBy": {
                    "userId": "9f2c4a7e-1b3d-4e5f-8a6b-7c8d9e0f1a2b",
                    "name": "Integración",
                    "lastname": "ERP",
                    "email": "integraciones@example.com",
                    "type": "admin"
                  },
                  "createdAt": "2026-03-02T16:25:01.000Z",
                  "updatedAt": "2026-03-02T16:25:01.000Z",
                  "updatedBy": {
                    "userId": "9f2c4a7e-1b3d-4e5f-8a6b-7c8d9e0f1a2b",
                    "name": "Integración",
                    "lastname": "ERP",
                    "email": "integraciones@example.com",
                    "type": "admin"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      },
      "delete": {
        "tags": [
          "Steps"
        ],
        "operationId": "deleteStep",
        "summary": "Delete a step",
        "description": "Soft-deletes the step. Its cards are **not** moved or deleted: move them to another step first.",
        "responses": {
          "200": {
            "description": "The deleted step.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Step"
                },
                "example": {
                  "_id": "665f1c2e8a4b3d0012ab35b1",
                  "app": "app_7f3k2m9x1q",
                  "funnel": {
                    "_id": "665f1c2e8a4b3d0012ab35aa",
                    "app": "app_7f3k2m9x1q",
                    "name": "Ventas corporativas",
                    "isEdit": 1,
                    "type": "sale",
                    "createdBy": {
                      "userId": "9f2c4a7e-1b3d-4e5f-8a6b-7c8d9e0f1a2b",
                      "name": "Integración",
                      "lastname": "ERP",
                      "email": "integraciones@example.com",
                      "type": "admin"
                    },
                    "createdAt": "2026-03-02T16:20:45.000Z",
                    "updatedAt": "2026-03-02T16:20:45.000Z"
                  },
                  "name": "Cotización enviada",
                  "label": "Cotización enviada",
                  "order": 3,
                  "winProbability": 40,
                  "expiration": 3,
                  "expirationLabel": "day",
                  "totalValue": 0,
                  "createdBy": {
                    "userId": "9f2c4a7e-1b3d-4e5f-8a6b-7c8d9e0f1a2b",
                    "name": "Integración",
                    "lastname": "ERP",
                    "email": "integraciones@example.com",
                    "type": "admin"
                  },
                  "createdAt": "2026-03-02T16:25:01.000Z",
                  "updatedAt": "2026-03-02T16:25:01.000Z"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      }
    },
    "/{appUUID}/funnel/{funnelId}/steps/{stepId}/cards": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AppUUID"
        },
        {
          "$ref": "#/components/parameters/CardsFunnelId"
        },
        {
          "$ref": "#/components/parameters/CardsStepId"
        }
      ],
      "get": {
        "tags": [
          "SalesCards"
        ],
        "operationId": "listSalesCards",
        "summary": "List the SalesCards of a step",
        "description": "Returns a page of the non-deleted cards in the step, with `funnel` and `step` expanded. All filters are optional and combine with AND; array filters use `name[]=value` (repeat for several values). If the credential belongs to a user with the agent role, only cards where that user is the `responsible` are returned.",
        "parameters": [
          {
            "$ref": "#/components/parameters/Offset"
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/SortBy"
          },
          {
            "$ref": "#/components/parameters/Search"
          },
          {
            "$ref": "#/components/parameters/Timezone"
          },
          {
            "$ref": "#/components/parameters/Spaces"
          },
          {
            "$ref": "#/components/parameters/Person"
          },
          {
            "$ref": "#/components/parameters/Responsible"
          },
          {
            "$ref": "#/components/parameters/Priority"
          },
          {
            "$ref": "#/components/parameters/Business"
          },
          {
            "$ref": "#/components/parameters/Office"
          },
          {
            "$ref": "#/components/parameters/Reason"
          },
          {
            "$ref": "#/components/parameters/AppointmentPending"
          },
          {
            "$ref": "#/components/parameters/CreatedAtFrom"
          },
          {
            "$ref": "#/components/parameters/CreatedAtTo"
          },
          {
            "$ref": "#/components/parameters/UpdatedAtStepFrom"
          },
          {
            "$ref": "#/components/parameters/UpdatedAtStepTo"
          },
          {
            "$ref": "#/components/parameters/QuoteDateFrom"
          },
          {
            "$ref": "#/components/parameters/QuoteDateTo"
          },
          {
            "$ref": "#/components/parameters/UtmSource"
          },
          {
            "$ref": "#/components/parameters/UtmMedium"
          },
          {
            "$ref": "#/components/parameters/UtmCampaign"
          },
          {
            "$ref": "#/components/parameters/ProductId"
          },
          {
            "$ref": "#/components/parameters/ProductSku"
          },
          {
            "$ref": "#/components/parameters/ProductBrand"
          },
          {
            "$ref": "#/components/parameters/ExtCategory"
          },
          {
            "$ref": "#/components/parameters/ExtField"
          },
          {
            "$ref": "#/components/parameters/ExtValue"
          }
        ],
        "responses": {
          "200": {
            "description": "A page of cards.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SalesCardList"
                },
                "example": {
                  "data": [
                    {
                      "_id": "665f1c2e8a4b3d0012ab3a10",
                      "app": "app_7f3k2m9x1q",
                      "space": "ventas",
                      "funnel": {
                        "_id": "665f1c2e8a4b3d0012ab34cd",
                        "app": "app_7f3k2m9x1q",
                        "name": "$funnel_sales$",
                        "isEdit": 0,
                        "type": "sale",
                        "category": "car",
                        "createdBy": {
                          "userId": "9f2c4a7e-1b3d-4e5f-8a6b-7c8d9e0f1a2b",
                          "name": "Integración",
                          "lastname": "ERP",
                          "email": "integraciones@example.com",
                          "type": "admin"
                        },
                        "createdAt": "2026-01-15T14:02:11.000Z",
                        "updatedAt": "2026-01-15T14:02:11.000Z"
                      },
                      "step": {
                        "_id": "665f1c2e8a4b3d0012ab34d1",
                        "app": "app_7f3k2m9x1q",
                        "funnel": "665f1c2e8a4b3d0012ab34cd",
                        "name": "$step_sql$",
                        "promptName": "Interested SQL",
                        "order": 4,
                        "winProbability": 30,
                        "totalValue": 435000000,
                        "createdBy": {
                          "userId": "9f2c4a7e-1b3d-4e5f-8a6b-7c8d9e0f1a2b",
                          "name": "Integración",
                          "lastname": "ERP",
                          "email": "integraciones@example.com",
                          "type": "admin"
                        },
                        "createdAt": "2026-01-15T14:02:11.000Z",
                        "updatedAt": "2026-10-30T09:12:40.000Z"
                      },
                      "name": "Laura Gómez - SUV híbrida",
                      "description": "Quiere cotizar la SUV híbrida con financiación a 48 meses.",
                      "customId": "ERP-10234",
                      "tags": [
                        "web",
                        "suv"
                      ],
                      "quantity": 1,
                      "amount": 145000000,
                      "discount": 0,
                      "closingProbability": 40,
                      "priority": "medium",
                      "responsible": {
                        "uuid": "u3k8n2v6c1q9",
                        "name": "Andrés Restrepo",
                        "email": "andres@example.com",
                        "phone": "573001234567"
                      },
                      "persons": [
                        "c7hq2k9x4m1z"
                      ],
                      "office": "Sede Norte",
                      "utm": {
                        "source": "web",
                        "medium": "form",
                        "campaign": "lanzamiento-2026"
                      },
                      "productsData": [
                        {
                          "id": "665f1c2e8a4b3d0012ab3b20",
                          "sku": "SUV-HYB-2026",
                          "name": "SUV Híbrida 2026",
                          "brand": "Marca Demo",
                          "price": 145000000
                        }
                      ],
                      "financing": "Crédito vehicular",
                      "financingTermMonths": 48,
                      "extendedData": [
                        {
                          "category": "Preferencias",
                          "field": "preferred_contact_time",
                          "value": "morning"
                        }
                      ],
                      "appointmentPending": false,
                      "updatedAtStep": "2026-11-03T15:40:00.000Z",
                      "stepsDate": [
                        {
                          "stepName": "$step_mql$",
                          "stepId": "665f1c2e8a4b3d0012ab34d0",
                          "updatedAt": "2026-11-01T13:05:00.000Z"
                        },
                        {
                          "stepName": "$step_sql$",
                          "stepId": "665f1c2e8a4b3d0012ab34d1",
                          "updatedAt": "2026-11-03T15:40:00.000Z"
                        }
                      ],
                      "preStep": "665f1c2e8a4b3d0012ab34d0",
                      "preFunnel": "665f1c2e8a4b3d0012ab34cd",
                      "createdBy": {
                        "userId": "9f2c4a7e-1b3d-4e5f-8a6b-7c8d9e0f1a2b",
                        "name": "Integración",
                        "lastname": "ERP",
                        "email": "integraciones@example.com",
                        "type": "admin"
                      },
                      "createdAt": "2026-11-01T13:05:00.000Z",
                      "updatedAt": "2026-11-03T15:40:00.000Z"
                    }
                  ],
                  "paginator": {
                    "totalDocs": 37,
                    "limit": 10,
                    "totalPages": 4,
                    "page": 1,
                    "pagingCounter": 1,
                    "hasPrevPage": false,
                    "hasNextPage": true,
                    "prevPage": null,
                    "nextPage": 2
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      },
      "post": {
        "tags": [
          "SalesCards"
        ],
        "operationId": "createSalesCard",
        "summary": "Create a SalesCard",
        "description": "Creates a deal in the step. `persons` links it to contacts and `responsible` assigns the advisor. With `?findByName=true` the path takes system names instead of ids (e.g. `/funnel/$funnel_sales$/steps/$step_mql$/cards`). If `utm.sourceCardId` already exists in the funnel the existing card is returned unchanged. Incomplete `schedule` objects are dropped silently. The funnel and step in the path must belong to `{appUUID}`; otherwise it answers `400`.",
        "parameters": [
          {
            "name": "findByName",
            "in": "query",
            "required": false,
            "description": "Resolve `{funnelId}` and `{stepId}` as names that start and end with `$` (system funnels and steps). Any value turns it on, even `false`: omit the parameter to use ids.",
            "schema": {
              "type": "boolean"
            },
            "example": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateSalesCardRequest"
              },
              "example": {
                "name": "Laura Gómez - SUV híbrida",
                "persons": [
                  "c7hq2k9x4m1z"
                ],
                "responsible": {
                  "uuid": "u3k8n2v6c1q9",
                  "name": "Andrés Restrepo",
                  "email": "andres@example.com",
                  "phone": "573001234567"
                },
                "description": "Quiere cotizar la SUV híbrida con financiación a 48 meses.",
                "customId": "ERP-10234",
                "tags": [
                  "web",
                  "suv"
                ],
                "amount": 145000000,
                "quantity": 1,
                "priority": "medium",
                "office": "Sede Norte",
                "utm": {
                  "source": "web",
                  "medium": "form",
                  "campaign": "lanzamiento-2026"
                },
                "productsData": [
                  {
                    "id": "665f1c2e8a4b3d0012ab3b20",
                    "sku": "SUV-HYB-2026",
                    "name": "SUV Híbrida 2026",
                    "brand": "Marca Demo",
                    "price": 145000000
                  }
                ],
                "extendedData": [
                  {
                    "category": "Preferencias",
                    "field": "preferred_contact_time",
                    "value": "morning"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Card created (or the existing card, see the description).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedSalesCard"
                },
                "example": {
                  "_id": "665f1c2e8a4b3d0012ab3a10",
                  "app": "app_7f3k2m9x1q",
                  "space": "ventas",
                  "funnel": {
                    "_id": "665f1c2e8a4b3d0012ab34cd",
                    "app": "app_7f3k2m9x1q",
                    "name": "$funnel_sales$",
                    "isEdit": 0,
                    "type": "sale",
                    "category": "car",
                    "createdBy": {
                      "userId": "9f2c4a7e-1b3d-4e5f-8a6b-7c8d9e0f1a2b",
                      "name": "Integración",
                      "lastname": "ERP",
                      "email": "integraciones@example.com",
                      "type": "admin"
                    },
                    "createdAt": "2026-01-15T14:02:11.000Z",
                    "updatedAt": "2026-01-15T14:02:11.000Z"
                  },
                  "step": {
                    "_id": "665f1c2e8a4b3d0012ab34d1",
                    "app": "app_7f3k2m9x1q",
                    "funnel": "665f1c2e8a4b3d0012ab34cd",
                    "name": "$step_sql$",
                    "promptName": "Interested SQL",
                    "order": 4,
                    "winProbability": 30,
                    "totalValue": 435000000,
                    "createdBy": {
                      "userId": "9f2c4a7e-1b3d-4e5f-8a6b-7c8d9e0f1a2b",
                      "name": "Integración",
                      "lastname": "ERP",
                      "email": "integraciones@example.com",
                      "type": "admin"
                    },
                    "createdAt": "2026-01-15T14:02:11.000Z",
                    "updatedAt": "2026-10-30T09:12:40.000Z"
                  },
                  "name": "Laura Gómez - SUV híbrida",
                  "description": "Quiere cotizar la SUV híbrida con financiación a 48 meses.",
                  "customId": "ERP-10234",
                  "tags": [
                    "web",
                    "suv"
                  ],
                  "quantity": 1,
                  "amount": 145000000,
                  "discount": 0,
                  "closingProbability": 40,
                  "priority": "medium",
                  "responsible": {
                    "uuid": "u3k8n2v6c1q9",
                    "name": "Andrés Restrepo",
                    "email": "andres@example.com",
                    "phone": "573001234567"
                  },
                  "persons": [
                    "c7hq2k9x4m1z"
                  ],
                  "office": "Sede Norte",
                  "utm": {
                    "source": "web",
                    "medium": "form",
                    "campaign": "lanzamiento-2026"
                  },
                  "productsData": [
                    {
                      "id": "665f1c2e8a4b3d0012ab3b20",
                      "sku": "SUV-HYB-2026",
                      "name": "SUV Híbrida 2026",
                      "brand": "Marca Demo",
                      "price": 145000000
                    }
                  ],
                  "financing": "Crédito vehicular",
                  "financingTermMonths": 48,
                  "extendedData": [
                    {
                      "category": "Preferencias",
                      "field": "preferred_contact_time",
                      "value": "morning"
                    }
                  ],
                  "appointmentPending": false,
                  "updatedAtStep": "2026-11-03T15:40:00.000Z",
                  "stepsDate": [
                    {
                      "stepName": "$step_mql$",
                      "stepId": "665f1c2e8a4b3d0012ab34d0",
                      "updatedAt": "2026-11-01T13:05:00.000Z"
                    },
                    {
                      "stepName": "$step_sql$",
                      "stepId": "665f1c2e8a4b3d0012ab34d1",
                      "updatedAt": "2026-11-03T15:40:00.000Z"
                    }
                  ],
                  "preStep": "665f1c2e8a4b3d0012ab34d0",
                  "preFunnel": "665f1c2e8a4b3d0012ab34cd",
                  "createdBy": {
                    "userId": "9f2c4a7e-1b3d-4e5f-8a6b-7c8d9e0f1a2b",
                    "name": "Integración",
                    "lastname": "ERP",
                    "email": "integraciones@example.com",
                    "type": "admin"
                  },
                  "createdAt": "2026-11-01T13:05:00.000Z",
                  "updatedAt": "2026-11-03T15:40:00.000Z"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/{appUUID}/funnel/{funnelId}/steps/{stepId}/cards/{cardId}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AppUUID"
        },
        {
          "$ref": "#/components/parameters/FunnelId"
        },
        {
          "$ref": "#/components/parameters/CardStepId"
        },
        {
          "$ref": "#/components/parameters/CardId"
        }
      ],
      "get": {
        "tags": [
          "SalesCards"
        ],
        "operationId": "getSalesCard",
        "summary": "Get a SalesCard",
        "description": "Returns the card with `funnel` and `step` expanded. The card is looked up by `cardId`. If it does not exist the response is `200` with an empty body.",
        "responses": {
          "200": {
            "description": "The card.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SalesCard"
                },
                "example": {
                  "_id": "665f1c2e8a4b3d0012ab3a10",
                  "app": "app_7f3k2m9x1q",
                  "space": "ventas",
                  "funnel": {
                    "_id": "665f1c2e8a4b3d0012ab34cd",
                    "app": "app_7f3k2m9x1q",
                    "name": "$funnel_sales$",
                    "isEdit": 0,
                    "type": "sale",
                    "category": "car",
                    "createdBy": {
                      "userId": "9f2c4a7e-1b3d-4e5f-8a6b-7c8d9e0f1a2b",
                      "name": "Integración",
                      "lastname": "ERP",
                      "email": "integraciones@example.com",
                      "type": "admin"
                    },
                    "createdAt": "2026-01-15T14:02:11.000Z",
                    "updatedAt": "2026-01-15T14:02:11.000Z"
                  },
                  "step": {
                    "_id": "665f1c2e8a4b3d0012ab34d1",
                    "app": "app_7f3k2m9x1q",
                    "funnel": "665f1c2e8a4b3d0012ab34cd",
                    "name": "$step_sql$",
                    "promptName": "Interested SQL",
                    "order": 4,
                    "winProbability": 30,
                    "totalValue": 435000000,
                    "createdBy": {
                      "userId": "9f2c4a7e-1b3d-4e5f-8a6b-7c8d9e0f1a2b",
                      "name": "Integración",
                      "lastname": "ERP",
                      "email": "integraciones@example.com",
                      "type": "admin"
                    },
                    "createdAt": "2026-01-15T14:02:11.000Z",
                    "updatedAt": "2026-10-30T09:12:40.000Z"
                  },
                  "name": "Laura Gómez - SUV híbrida",
                  "description": "Quiere cotizar la SUV híbrida con financiación a 48 meses.",
                  "customId": "ERP-10234",
                  "tags": [
                    "web",
                    "suv"
                  ],
                  "quantity": 1,
                  "amount": 145000000,
                  "discount": 0,
                  "closingProbability": 40,
                  "priority": "medium",
                  "responsible": {
                    "uuid": "u3k8n2v6c1q9",
                    "name": "Andrés Restrepo",
                    "email": "andres@example.com",
                    "phone": "573001234567"
                  },
                  "persons": [
                    "c7hq2k9x4m1z"
                  ],
                  "office": "Sede Norte",
                  "utm": {
                    "source": "web",
                    "medium": "form",
                    "campaign": "lanzamiento-2026"
                  },
                  "productsData": [
                    {
                      "id": "665f1c2e8a4b3d0012ab3b20",
                      "sku": "SUV-HYB-2026",
                      "name": "SUV Híbrida 2026",
                      "brand": "Marca Demo",
                      "price": 145000000
                    }
                  ],
                  "financing": "Crédito vehicular",
                  "financingTermMonths": 48,
                  "extendedData": [
                    {
                      "category": "Preferencias",
                      "field": "preferred_contact_time",
                      "value": "morning"
                    }
                  ],
                  "appointmentPending": false,
                  "updatedAtStep": "2026-11-03T15:40:00.000Z",
                  "stepsDate": [
                    {
                      "stepName": "$step_mql$",
                      "stepId": "665f1c2e8a4b3d0012ab34d0",
                      "updatedAt": "2026-11-01T13:05:00.000Z"
                    },
                    {
                      "stepName": "$step_sql$",
                      "stepId": "665f1c2e8a4b3d0012ab34d1",
                      "updatedAt": "2026-11-03T15:40:00.000Z"
                    }
                  ],
                  "preStep": "665f1c2e8a4b3d0012ab34d0",
                  "preFunnel": "665f1c2e8a4b3d0012ab34cd",
                  "createdBy": {
                    "userId": "9f2c4a7e-1b3d-4e5f-8a6b-7c8d9e0f1a2b",
                    "name": "Integración",
                    "lastname": "ERP",
                    "email": "integraciones@example.com",
                    "type": "admin"
                  },
                  "createdAt": "2026-11-01T13:05:00.000Z",
                  "updatedAt": "2026-11-03T15:40:00.000Z"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      },
      "patch": {
        "tags": [
          "SalesCards"
        ],
        "operationId": "updateSalesCard",
        "summary": "Update or move a SalesCard",
        "description": "Partial update of the card. To move the card send `step` (plus `funnel` if the step is in another funnel) or `stepName`. On a move the API sets `updatedAtStep`, `preStep`/`preFunnel` and `stepsDate`, adjusts the step totals and, when the card enters `$step_billed$` (or `$step_delivery$` of the sales funnel), fills `saleDate` if you did not send it. `{stepId}` must be the card's current step: when the card moves, the API subtracts its `amount` from that step's total. Sending as the target (`step`, or the step `stepName` resolves to) the same id as `{stepId}` fails with `400 The step must be different` whenever that would move the card: when `{stepId}` is not the card's current step, or when `funnel` also changes. Read the card first if you do not know its current step. A `step` or `funnel` in the body that does not belong to `{appUUID}` answers `400`.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateSalesCardRequest"
              },
              "examples": {
                "updateFields": {
                  "summary": "Update fields and merge a custom field",
                  "value": {
                    "amount": 139000000,
                    "closingProbability": 60,
                    "quoteNumber": "COT-2026-0457",
                    "quoteDate": "2026-11-04T15:00:00.000Z",
                    "isPushData": true,
                    "extendedData": [
                      {
                        "category": "Preferencias",
                        "field": "trade_in",
                        "value": "yes"
                      }
                    ]
                  }
                },
                "moveStep": {
                  "summary": "Move to another step of the same funnel",
                  "value": {
                    "step": "665f1c2e8a4b3d0012ab34d6",
                    "saleDate": "2026-11-06T18:30:00.000Z"
                  }
                },
                "moveByName": {
                  "summary": "Move by step name and record the reason",
                  "value": {
                    "stepName": "$step_lost$",
                    "reason": "Precio"
                  }
                },
                "moveFunnel": {
                  "summary": "Move to a step of another funnel",
                  "value": {
                    "funnel": "665f1c2e8a4b3d0012ab35aa",
                    "step": "665f1c2e8a4b3d0012ab35b1"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated card, with `funnel` and `step` expanded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SalesCard"
                },
                "example": {
                  "_id": "665f1c2e8a4b3d0012ab3a10",
                  "app": "app_7f3k2m9x1q",
                  "space": "ventas",
                  "funnel": {
                    "_id": "665f1c2e8a4b3d0012ab34cd",
                    "app": "app_7f3k2m9x1q",
                    "name": "$funnel_sales$",
                    "isEdit": 0,
                    "type": "sale",
                    "category": "car",
                    "createdBy": {
                      "userId": "9f2c4a7e-1b3d-4e5f-8a6b-7c8d9e0f1a2b",
                      "name": "Integración",
                      "lastname": "ERP",
                      "email": "integraciones@example.com",
                      "type": "admin"
                    },
                    "createdAt": "2026-01-15T14:02:11.000Z",
                    "updatedAt": "2026-01-15T14:02:11.000Z"
                  },
                  "step": {
                    "_id": "665f1c2e8a4b3d0012ab34d1",
                    "app": "app_7f3k2m9x1q",
                    "funnel": "665f1c2e8a4b3d0012ab34cd",
                    "name": "$step_sql$",
                    "promptName": "Interested SQL",
                    "order": 4,
                    "winProbability": 30,
                    "totalValue": 435000000,
                    "createdBy": {
                      "userId": "9f2c4a7e-1b3d-4e5f-8a6b-7c8d9e0f1a2b",
                      "name": "Integración",
                      "lastname": "ERP",
                      "email": "integraciones@example.com",
                      "type": "admin"
                    },
                    "createdAt": "2026-01-15T14:02:11.000Z",
                    "updatedAt": "2026-10-30T09:12:40.000Z"
                  },
                  "name": "Laura Gómez - SUV híbrida",
                  "description": "Quiere cotizar la SUV híbrida con financiación a 48 meses.",
                  "customId": "ERP-10234",
                  "tags": [
                    "web",
                    "suv"
                  ],
                  "quantity": 1,
                  "amount": 145000000,
                  "discount": 0,
                  "closingProbability": 40,
                  "priority": "medium",
                  "responsible": {
                    "uuid": "u3k8n2v6c1q9",
                    "name": "Andrés Restrepo",
                    "email": "andres@example.com",
                    "phone": "573001234567"
                  },
                  "persons": [
                    "c7hq2k9x4m1z"
                  ],
                  "office": "Sede Norte",
                  "utm": {
                    "source": "web",
                    "medium": "form",
                    "campaign": "lanzamiento-2026"
                  },
                  "productsData": [
                    {
                      "id": "665f1c2e8a4b3d0012ab3b20",
                      "sku": "SUV-HYB-2026",
                      "name": "SUV Híbrida 2026",
                      "brand": "Marca Demo",
                      "price": 145000000
                    }
                  ],
                  "financing": "Crédito vehicular",
                  "financingTermMonths": 48,
                  "extendedData": [
                    {
                      "category": "Preferencias",
                      "field": "preferred_contact_time",
                      "value": "morning"
                    }
                  ],
                  "appointmentPending": false,
                  "updatedAtStep": "2026-11-03T15:40:00.000Z",
                  "stepsDate": [
                    {
                      "stepName": "$step_mql$",
                      "stepId": "665f1c2e8a4b3d0012ab34d0",
                      "updatedAt": "2026-11-01T13:05:00.000Z"
                    },
                    {
                      "stepName": "$step_sql$",
                      "stepId": "665f1c2e8a4b3d0012ab34d1",
                      "updatedAt": "2026-11-03T15:40:00.000Z"
                    }
                  ],
                  "preStep": "665f1c2e8a4b3d0012ab34d0",
                  "preFunnel": "665f1c2e8a4b3d0012ab34cd",
                  "createdBy": {
                    "userId": "9f2c4a7e-1b3d-4e5f-8a6b-7c8d9e0f1a2b",
                    "name": "Integración",
                    "lastname": "ERP",
                    "email": "integraciones@example.com",
                    "type": "admin"
                  },
                  "createdAt": "2026-11-01T13:05:00.000Z",
                  "updatedAt": "2026-11-03T15:40:00.000Z"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "delete": {
        "tags": [
          "SalesCards"
        ],
        "operationId": "deleteSalesCard",
        "summary": "Delete a SalesCard",
        "description": "Soft-deletes the card and subtracts its `amount` from the step total. Only the user who created the card can delete it (for cards created with an API key, the owner of that key); anyone else gets `403`.",
        "responses": {
          "200": {
            "description": "The deleted card.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SalesCard"
                },
                "example": {
                  "_id": "665f1c2e8a4b3d0012ab3a10",
                  "app": "app_7f3k2m9x1q",
                  "space": "ventas",
                  "funnel": {
                    "_id": "665f1c2e8a4b3d0012ab34cd",
                    "app": "app_7f3k2m9x1q",
                    "name": "$funnel_sales$",
                    "isEdit": 0,
                    "type": "sale",
                    "category": "car",
                    "createdBy": {
                      "userId": "9f2c4a7e-1b3d-4e5f-8a6b-7c8d9e0f1a2b",
                      "name": "Integración",
                      "lastname": "ERP",
                      "email": "integraciones@example.com",
                      "type": "admin"
                    },
                    "createdAt": "2026-01-15T14:02:11.000Z",
                    "updatedAt": "2026-01-15T14:02:11.000Z"
                  },
                  "step": {
                    "_id": "665f1c2e8a4b3d0012ab34d1",
                    "app": "app_7f3k2m9x1q",
                    "funnel": "665f1c2e8a4b3d0012ab34cd",
                    "name": "$step_sql$",
                    "promptName": "Interested SQL",
                    "order": 4,
                    "winProbability": 30,
                    "totalValue": 435000000,
                    "createdBy": {
                      "userId": "9f2c4a7e-1b3d-4e5f-8a6b-7c8d9e0f1a2b",
                      "name": "Integración",
                      "lastname": "ERP",
                      "email": "integraciones@example.com",
                      "type": "admin"
                    },
                    "createdAt": "2026-01-15T14:02:11.000Z",
                    "updatedAt": "2026-10-30T09:12:40.000Z"
                  },
                  "name": "Laura Gómez - SUV híbrida",
                  "description": "Quiere cotizar la SUV híbrida con financiación a 48 meses.",
                  "customId": "ERP-10234",
                  "tags": [
                    "web",
                    "suv"
                  ],
                  "quantity": 1,
                  "amount": 145000000,
                  "discount": 0,
                  "closingProbability": 40,
                  "priority": "medium",
                  "responsible": {
                    "uuid": "u3k8n2v6c1q9",
                    "name": "Andrés Restrepo",
                    "email": "andres@example.com",
                    "phone": "573001234567"
                  },
                  "persons": [
                    "c7hq2k9x4m1z"
                  ],
                  "office": "Sede Norte",
                  "utm": {
                    "source": "web",
                    "medium": "form",
                    "campaign": "lanzamiento-2026"
                  },
                  "productsData": [
                    {
                      "id": "665f1c2e8a4b3d0012ab3b20",
                      "sku": "SUV-HYB-2026",
                      "name": "SUV Híbrida 2026",
                      "brand": "Marca Demo",
                      "price": 145000000
                    }
                  ],
                  "financing": "Crédito vehicular",
                  "financingTermMonths": 48,
                  "extendedData": [
                    {
                      "category": "Preferencias",
                      "field": "preferred_contact_time",
                      "value": "morning"
                    }
                  ],
                  "appointmentPending": false,
                  "updatedAtStep": "2026-11-03T15:40:00.000Z",
                  "stepsDate": [
                    {
                      "stepName": "$step_mql$",
                      "stepId": "665f1c2e8a4b3d0012ab34d0",
                      "updatedAt": "2026-11-01T13:05:00.000Z"
                    },
                    {
                      "stepName": "$step_sql$",
                      "stepId": "665f1c2e8a4b3d0012ab34d1",
                      "updatedAt": "2026-11-03T15:40:00.000Z"
                    }
                  ],
                  "preStep": "665f1c2e8a4b3d0012ab34d0",
                  "preFunnel": "665f1c2e8a4b3d0012ab34cd",
                  "createdBy": {
                    "userId": "9f2c4a7e-1b3d-4e5f-8a6b-7c8d9e0f1a2b",
                    "name": "Integración",
                    "lastname": "ERP",
                    "email": "integraciones@example.com",
                    "type": "admin"
                  },
                  "createdAt": "2026-11-01T13:05:00.000Z",
                  "updatedAt": "2026-11-03T15:40:00.000Z"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Your app's API key (Settings → API keys) or an Identity access token."
      }
    },
    "parameters": {
      "AppUUID": {
        "name": "appUUID",
        "in": "path",
        "required": true,
        "description": "Your app UUID (shown in Settings → API keys). The credential must belong to a member of this app.",
        "schema": {
          "type": "string"
        },
        "example": "app_7f3k2m9x1q"
      },
      "FunnelId": {
        "name": "funnelId",
        "in": "path",
        "required": true,
        "description": "Funnel `_id` (24-character hex id).",
        "schema": {
          "type": "string"
        },
        "example": "665f1c2e8a4b3d0012ab34cd"
      },
      "CardsFunnelId": {
        "name": "funnelId",
        "in": "path",
        "required": true,
        "description": "Funnel `_id`. When creating with `findByName=true`, a system funnel name such as `$funnel_sales$`.",
        "schema": {
          "type": "string"
        },
        "example": "665f1c2e8a4b3d0012ab34cd"
      },
      "CardsStepId": {
        "name": "stepId",
        "in": "path",
        "required": true,
        "description": "Step `_id`. When creating with `findByName=true`, a system step name such as `$step_mql$`.",
        "schema": {
          "type": "string"
        },
        "example": "665f1c2e8a4b3d0012ab34d1"
      },
      "StepId": {
        "name": "stepId",
        "in": "path",
        "required": true,
        "description": "Step `_id` (24-character hex id).",
        "schema": {
          "type": "string"
        },
        "example": "665f1c2e8a4b3d0012ab34d1"
      },
      "CardStepId": {
        "name": "stepId",
        "in": "path",
        "required": true,
        "description": "Step `_id`. It must be the step the card is **currently** in.",
        "schema": {
          "type": "string"
        },
        "example": "665f1c2e8a4b3d0012ab34d1"
      },
      "CardId": {
        "name": "cardId",
        "in": "path",
        "required": true,
        "description": "SalesCard `_id` (24-character hex id).",
        "schema": {
          "type": "string"
        },
        "example": "665f1c2e8a4b3d0012ab3a10"
      },
      "Offset": {
        "name": "offset",
        "in": "query",
        "required": false,
        "description": "Page number, **1-based** (not an item offset): `offset=2&limit=10` returns cards 11–20. `0` and `1` both return the first page.",
        "schema": {
          "type": "integer",
          "minimum": 0,
          "default": 1
        },
        "example": 1
      },
      "Limit": {
        "name": "limit",
        "in": "query",
        "required": false,
        "description": "Cards per page. No maximum is enforced, but big pages are slow; keep it at 100 or less.",
        "schema": {
          "type": "integer",
          "minimum": 1,
          "default": 10
        },
        "example": 20
      },
      "SortBy": {
        "name": "sortBy",
        "in": "query",
        "required": false,
        "description": "Sort field; prefix `-` for descending. Default `-createdAt`, or the date being filtered when `updatedAtStep[...]` is sent.",
        "schema": {
          "type": "string",
          "enum": [
            "createdAt",
            "-createdAt",
            "updatedAt",
            "-updatedAt",
            "updatedAtStep",
            "-updatedAtStep",
            "amount",
            "-amount"
          ]
        },
        "example": "-updatedAtStep"
      },
      "Search": {
        "name": "search",
        "in": "query",
        "required": false,
        "description": "Case-insensitive text matched against the card `name` and `description`. If it looks like a phone number (7–15 digits), cards of contacts with that phone are matched too.",
        "schema": {
          "type": "string"
        },
        "example": "Laura"
      },
      "Timezone": {
        "name": "timezone",
        "in": "query",
        "required": false,
        "description": "IANA time zone used to interpret the date-range filters as whole local days. Default `UTC`.",
        "schema": {
          "type": "string"
        },
        "example": "America/Bogota"
      },
      "Spaces": {
        "name": "spaces[]",
        "in": "query",
        "required": false,
        "description": "Only cards of these Smart Chat spaces (space keys).",
        "schema": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "style": "form",
        "explode": true,
        "example": [
          "ventas"
        ]
      },
      "Person": {
        "name": "person",
        "in": "query",
        "required": false,
        "description": "Only cards linked to this contact `uuid` (Contacts API).",
        "schema": {
          "type": "string"
        },
        "example": "c7hq2k9x4m1z"
      },
      "Responsible": {
        "name": "responsible[]",
        "in": "query",
        "required": false,
        "description": "Only cards whose `responsible.uuid` is one of these user UUIDs. Use the `[]` notation even for a single value.",
        "schema": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "style": "form",
        "explode": true,
        "example": [
          "u3k8n2v6c1q9"
        ]
      },
      "Priority": {
        "name": "priority[]",
        "in": "query",
        "required": false,
        "description": "Only cards with one of these priorities.",
        "schema": {
          "type": "array",
          "items": {
            "$ref": "#/components/schemas/Priority"
          }
        },
        "style": "form",
        "explode": true,
        "example": [
          "high",
          "highest"
        ]
      },
      "Business": {
        "name": "business",
        "in": "query",
        "required": false,
        "description": "Exact match on the card `business`.",
        "schema": {
          "type": "string"
        },
        "example": "Concesionario Centro"
      },
      "Office": {
        "name": "office",
        "in": "query",
        "required": false,
        "description": "Exact match on the card `office`.",
        "schema": {
          "type": "string"
        },
        "example": "Sede Norte"
      },
      "Reason": {
        "name": "reason",
        "in": "query",
        "required": false,
        "description": "Exact match on the card `reason` (e.g. a lost reason).",
        "schema": {
          "type": "string"
        },
        "example": "Precio"
      },
      "AppointmentPending": {
        "name": "appointmentPending",
        "in": "query",
        "required": false,
        "description": "`true`: the contact accepted to book an appointment but no date is confirmed yet. `false`: the appointment is confirmed.",
        "schema": {
          "type": "boolean"
        },
        "example": true
      },
      "CreatedAtFrom": {
        "name": "createdAt[from]",
        "in": "query",
        "required": false,
        "description": "Created on or after this day (`YYYY-MM-DD`, start of day in `timezone`). Send it together with `createdAt[to]`.",
        "schema": {
          "type": "string",
          "format": "date"
        },
        "example": "2026-10-01"
      },
      "CreatedAtTo": {
        "name": "createdAt[to]",
        "in": "query",
        "required": false,
        "description": "Created on or before this day (`YYYY-MM-DD`, end of day in `timezone`). Send it together with `createdAt[from]`.",
        "schema": {
          "type": "string",
          "format": "date"
        },
        "example": "2026-10-31"
      },
      "UpdatedAtStepFrom": {
        "name": "updatedAtStep[from]",
        "in": "query",
        "required": false,
        "description": "Entered the current step on or after this day (`YYYY-MM-DD`). In won/billed steps the filter uses `saleDate`. Send it together with `updatedAtStep[to]`.",
        "schema": {
          "type": "string",
          "format": "date"
        },
        "example": "2026-10-01"
      },
      "UpdatedAtStepTo": {
        "name": "updatedAtStep[to]",
        "in": "query",
        "required": false,
        "description": "Entered the current step on or before this day (`YYYY-MM-DD`). Send it together with `updatedAtStep[from]`.",
        "schema": {
          "type": "string",
          "format": "date"
        },
        "example": "2026-10-31"
      },
      "QuoteDateFrom": {
        "name": "quoteDate[from]",
        "in": "query",
        "required": false,
        "description": "`quoteDate` on or after this day (`YYYY-MM-DD`). Send it together with `quoteDate[to]`.",
        "schema": {
          "type": "string",
          "format": "date"
        },
        "example": "2026-10-01"
      },
      "QuoteDateTo": {
        "name": "quoteDate[to]",
        "in": "query",
        "required": false,
        "description": "`quoteDate` on or before this day (`YYYY-MM-DD`). Send it together with `quoteDate[from]`.",
        "schema": {
          "type": "string",
          "format": "date"
        },
        "example": "2026-10-31"
      },
      "UtmSource": {
        "name": "utm[source][]",
        "in": "query",
        "required": false,
        "description": "Only cards whose `utm.source` is one of these values. `utm[medium][]`, `utm[campaign][]`, `utm[content][]`, `utm[term][]` and `utm[partner][]` work the same way.",
        "schema": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "style": "form",
        "explode": true,
        "example": [
          "web"
        ]
      },
      "UtmMedium": {
        "name": "utm[medium][]",
        "in": "query",
        "required": false,
        "description": "Only cards whose `utm.medium` is one of these values.",
        "schema": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "style": "form",
        "explode": true,
        "example": [
          "form"
        ]
      },
      "UtmCampaign": {
        "name": "utm[campaign][]",
        "in": "query",
        "required": false,
        "description": "Only cards whose `utm.campaign` is one of these values.",
        "schema": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "style": "form",
        "explode": true,
        "example": [
          "lanzamiento-2026"
        ]
      },
      "ProductId": {
        "name": "productsData[id][]",
        "in": "query",
        "required": false,
        "description": "Only cards with at least one product (`productsData`) whose catalog `id` is one of these.",
        "schema": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "style": "form",
        "explode": true,
        "example": [
          "665f1c2e8a4b3d0012ab3b20"
        ]
      },
      "ProductSku": {
        "name": "productsData[sku][]",
        "in": "query",
        "required": false,
        "description": "Only cards with a product whose `sku` is one of these. Combined with `productsData[brand][]`, both must match the same product.",
        "schema": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "style": "form",
        "explode": true,
        "example": [
          "SUV-HYB-2026"
        ]
      },
      "ProductBrand": {
        "name": "productsData[brand][]",
        "in": "query",
        "required": false,
        "description": "Only cards with a product whose `brand` is one of these.",
        "schema": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "style": "form",
        "explode": true,
        "example": [
          "Marca Demo"
        ]
      },
      "ExtCategory": {
        "name": "extendedData[0][category]",
        "in": "query",
        "required": false,
        "description": "Custom-field filter: category of the field. Required when filtering by a custom field. Add more filters with `[1]`, `[2]`… (all must match).",
        "schema": {
          "type": "string"
        },
        "example": "Preferencias"
      },
      "ExtField": {
        "name": "extendedData[0][field]",
        "in": "query",
        "required": false,
        "description": "Custom-field filter: key of the field.",
        "schema": {
          "type": "string"
        },
        "example": "preferred_contact_time"
      },
      "ExtValue": {
        "name": "extendedData[0][value]",
        "in": "query",
        "required": false,
        "description": "Custom-field filter: value to match. Comma-separate several values to match any of them.",
        "schema": {
          "type": "string"
        },
        "example": "morning,afternoon"
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "description": "Error body returned by every endpoint.",
        "properties": {
          "statusCode": {
            "type": "integer",
            "description": "HTTP status code.",
            "example": 400
          },
          "timestamp": {
            "type": "string",
            "format": "date-time",
            "description": "When the error happened."
          },
          "path": {
            "type": "string",
            "description": "Request path."
          },
          "message": {
            "description": "Error message, or the list of validation messages for a 400.",
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            ]
          },
          "error": {
            "type": "string",
            "description": "Exception name, e.g. `BadRequestException`."
          }
        }
      },
      "UserBy": {
        "type": "object",
        "description": "User (or API key owner) that performed the action. Set by the API.",
        "properties": {
          "userId": {
            "type": "string",
            "description": "Identity user id."
          },
          "name": {
            "type": "string",
            "description": "First name."
          },
          "lastname": {
            "type": "string",
            "nullable": true,
            "description": "Last name."
          },
          "email": {
            "type": "string",
            "description": "Email."
          },
          "type": {
            "type": "string",
            "description": "User type."
          }
        }
      },
      "Funnel": {
        "type": "object",
        "description": "A pipeline (funnel) of the app. Its stages are Steps.",
        "properties": {
          "_id": {
            "type": "string",
            "description": "Funnel id."
          },
          "app": {
            "type": "string",
            "description": "App UUID."
          },
          "name": {
            "type": "string",
            "description": "Funnel name. System funnels use keys like `$funnel_sales$`, `$funnel_postsale$` or `$funnel_customer_service$`, which the app translates."
          },
          "isEdit": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "`0` = system funnel created from a Biky template; `1` = funnel created by your team (default)."
          },
          "type": {
            "type": "string",
            "description": "Free-text funnel type, e.g. `sale`, `customer_service`."
          },
          "category": {
            "type": "string",
            "description": "Industry template the funnel came from, e.g. `car`, `retail`, `realestate`."
          },
          "createdBy": {
            "$ref": "#/components/schemas/UserBy"
          },
          "updatedBy": {
            "$ref": "#/components/schemas/UserBy"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "Creation date."
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "description": "Last update date."
          }
        }
      },
      "FunnelWithSteps": {
        "type": "object",
        "description": "Funnel summary with its steps.",
        "properties": {
          "_id": {
            "type": "string",
            "description": "Funnel id."
          },
          "app": {
            "type": "string",
            "description": "App UUID."
          },
          "name": {
            "type": "string",
            "description": "Funnel name."
          },
          "isEdit": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "`0` = system funnel, `1` = custom funnel."
          },
          "type": {
            "type": "string",
            "description": "Funnel type."
          },
          "steps": {
            "type": "array",
            "description": "Non-deleted steps, sorted by `order`.",
            "items": {
              "type": "object",
              "properties": {
                "_id": {
                  "type": "string",
                  "description": "Step id."
                },
                "name": {
                  "type": "string",
                  "description": "Step name (system steps use keys like `$step_sql$`)."
                },
                "promptName": {
                  "type": "string",
                  "description": "Human description of the step used by Biky."
                },
                "order": {
                  "type": "integer",
                  "description": "Position in the funnel (1-based)."
                }
              }
            }
          }
        }
      },
      "FunnelByName": {
        "type": "object",
        "properties": {
          "funnel": {
            "$ref": "#/components/schemas/Funnel"
          },
          "steps": {
            "type": "array",
            "description": "Non-deleted steps of the funnel, in storage order (sort them by `order`).",
            "items": {
              "$ref": "#/components/schemas/Step"
            }
          }
        }
      },
      "CreateFunnelRequest": {
        "type": "object",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Funnel name."
          },
          "stepsNumber": {
            "type": "integer",
            "minimum": 0,
            "maximum": 15,
            "default": 1,
            "description": "How many placeholder steps to create (named `# 1`, `# 2`…, win probability 10%). Rename them later with the Steps endpoints."
          },
          "isEdit": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "default": 1,
            "description": "Leave it at `1` for your own funnels."
          },
          "type": {
            "type": "string",
            "description": "Free-text funnel type, e.g. `sale`."
          },
          "category": {
            "type": "string",
            "description": "Free-text category."
          }
        }
      },
      "UpdateFunnelRequest": {
        "type": "object",
        "description": "Only the fields you send are changed.",
        "properties": {
          "name": {
            "type": "string",
            "description": "New name. Do not rename system funnels (`$funnel_…$`): Biky looks them up by name."
          },
          "isEdit": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "`0` = system funnel, `1` = custom funnel."
          },
          "type": {
            "type": "string",
            "description": "Funnel type."
          },
          "category": {
            "type": "string",
            "description": "Category."
          }
        }
      },
      "Step": {
        "type": "object",
        "description": "A stage of a funnel.",
        "properties": {
          "_id": {
            "type": "string",
            "description": "Step id."
          },
          "app": {
            "type": "string",
            "description": "App UUID."
          },
          "funnel": {
            "description": "Funnel id, or the full funnel object on the endpoints that expand it (list, get, create, update).",
            "oneOf": [
              {
                "type": "string"
              },
              {
                "$ref": "#/components/schemas/Funnel"
              }
            ]
          },
          "name": {
            "type": "string",
            "description": "Step name, unique within the funnel. System steps use keys like `$step_mql$`, `$step_sql$`, `$step_won$`, `$step_lost$`."
          },
          "label": {
            "type": "string",
            "description": "Display label."
          },
          "promptName": {
            "type": "string",
            "description": "Human description of the step used by Biky (system steps)."
          },
          "order": {
            "type": "integer",
            "description": "Position in the funnel (1-based)."
          },
          "winProbability": {
            "type": "number",
            "minimum": 0,
            "maximum": 100,
            "description": "Probability (%) of winning a deal in this step."
          },
          "expiration": {
            "type": "number",
            "description": "How long a card may stay in the step, in `expirationLabel` units."
          },
          "expirationLabel": {
            "type": "string",
            "description": "Unit of `expiration`, e.g. `day`."
          },
          "totalValue": {
            "type": "number",
            "description": "Sum of `amount` of the cards in the step, maintained by the API."
          },
          "createdBy": {
            "$ref": "#/components/schemas/UserBy"
          },
          "updatedBy": {
            "$ref": "#/components/schemas/UserBy"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "Creation date."
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "description": "Last update date."
          }
        }
      },
      "CreateStepRequest": {
        "type": "object",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Step name. Must be unique within the funnel."
          },
          "label": {
            "type": "string",
            "description": "Display label."
          },
          "winProbability": {
            "type": "number",
            "minimum": 0,
            "maximum": 100,
            "default": 0,
            "description": "Probability (%) of winning a deal in this step."
          },
          "expiration": {
            "type": "number",
            "description": "How long a card may stay in the step, in `expirationLabel` units."
          },
          "expirationLabel": {
            "type": "string",
            "description": "Unit of `expiration`, e.g. `day`."
          }
        }
      },
      "UpdateStepRequest": {
        "type": "object",
        "description": "Only the fields you send are changed.",
        "properties": {
          "name": {
            "type": "string",
            "description": "New name. Uniqueness is not checked on update. Do not rename system steps (`$step_…$`)."
          },
          "label": {
            "type": "string",
            "description": "Display label."
          },
          "winProbability": {
            "type": "number",
            "minimum": 0,
            "maximum": 100,
            "description": "Probability (%) of winning."
          },
          "expiration": {
            "type": "number",
            "description": "Expiration amount."
          },
          "expirationLabel": {
            "type": "string",
            "description": "Unit of `expiration`."
          },
          "order": {
            "type": "integer",
            "description": "New position. Other steps are not shifted: update each step you want to reorder."
          }
        }
      },
      "Priority": {
        "type": "string",
        "enum": [
          "emergency",
          "lowest",
          "low",
          "medium",
          "high",
          "highest"
        ],
        "description": "Card priority. Default `low`."
      },
      "Responsible": {
        "type": "object",
        "required": [
          "uuid",
          "name"
        ],
        "description": "Advisor (Biky user) who owns the card. Biky can reassign it automatically when the contact's chat is transferred to another advisor.",
        "properties": {
          "uuid": {
            "type": "string",
            "description": "User UUID of the advisor in your app."
          },
          "name": {
            "type": "string",
            "description": "Advisor full name."
          },
          "email": {
            "type": "string",
            "format": "email",
            "description": "Advisor email."
          },
          "phone": {
            "type": "string",
            "description": "Advisor phone, digits with country code."
          }
        }
      },
      "ExtendedData": {
        "type": "object",
        "required": [
          "category",
          "field"
        ],
        "description": "Value of a custom field of the card. Use `value` for single-value fields, `valueArray` for checkbox/tag fields and `valueMultiple` for grouped fields.",
        "properties": {
          "category": {
            "type": "string",
            "description": "Category of the custom field."
          },
          "field": {
            "type": "string",
            "description": "Key of the custom field."
          },
          "value": {
            "type": "string",
            "description": "Value of a single-value field."
          },
          "valueArray": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "string"
            },
            "description": "Values of a checkbox or tag field."
          },
          "valueMultiple": {
            "type": "array",
            "minItems": 1,
            "description": "Rows of a grouped field: each row is a list of `{ field, value }` pairs.",
            "items": {
              "type": "array",
              "items": {
                "type": "object",
                "required": [
                  "field",
                  "value"
                ],
                "properties": {
                  "field": {
                    "type": "string",
                    "description": "Sub-field key."
                  },
                  "value": {
                    "type": "string",
                    "description": "Sub-field value."
                  }
                }
              }
            }
          }
        }
      },
      "Utm": {
        "type": "object",
        "description": "Where the lead came from. First-touch: on update, a recognized `source`/`medium` and an existing `campaign`/`content`/`term` are kept, and later origins are recorded in `utm.touches`. The response may include attribution fields computed by Biky (`owner`, `billTo`, `setAt`, `touches`).",
        "properties": {
          "source": {
            "type": "string",
            "description": "Lead source, e.g. `facebook`, `google`, `web`."
          },
          "medium": {
            "type": "string",
            "description": "Medium, e.g. `cpc`, `form`, `whatsapp`."
          },
          "campaign": {
            "type": "string",
            "description": "Campaign name."
          },
          "subCampaign": {
            "type": "string",
            "description": "Sub-campaign or ad set."
          },
          "content": {
            "type": "string",
            "description": "Ad or content variant."
          },
          "term": {
            "type": "string",
            "description": "Keyword."
          },
          "value": {
            "type": "string",
            "description": "Free value associated with the origin."
          },
          "partner": {
            "type": "string",
            "description": "Partner or agency that brought the lead."
          },
          "videoUrl": {
            "type": "string",
            "description": "Video URL of the ad."
          },
          "sourceCardId": {
            "type": "string",
            "description": "Id of the record in your system the card was cloned from. Creating a card with a `sourceCardId` that already exists in the funnel returns the existing card instead of a new one."
          }
        }
      },
      "MetaAd": {
        "type": "object",
        "description": "Meta (Facebook/Instagram) ad the lead came from. Merged with the stored value on update.",
        "properties": {
          "adId": {
            "type": "string",
            "description": "Ad id."
          },
          "adSetId": {
            "type": "string",
            "description": "Ad set id."
          },
          "campaignId": {
            "type": "string",
            "description": "Campaign id."
          },
          "accountId": {
            "type": "string",
            "description": "Ad account id."
          },
          "accountName": {
            "type": "string",
            "description": "Ad account name."
          },
          "headline": {
            "type": "string",
            "description": "Ad headline."
          },
          "body": {
            "type": "string",
            "description": "Ad text."
          },
          "sourceUrl": {
            "type": "string",
            "description": "Ad or post URL."
          },
          "sourceType": {
            "type": "string",
            "description": "Source type, e.g. `ad`, `post`."
          },
          "mediaType": {
            "type": "string",
            "description": "Media type, e.g. `image`, `video`."
          },
          "imageUrl": {
            "type": "string",
            "description": "Image URL."
          },
          "thumbnailUrl": {
            "type": "string",
            "description": "Thumbnail URL."
          }
        }
      },
      "ProductData": {
        "type": "object",
        "required": [
          "id",
          "sku",
          "name"
        ],
        "description": "Product of the deal, usually taken from your Biky catalog.",
        "properties": {
          "id": {
            "type": "string",
            "description": "Catalog product id. Key used to merge with `isPushData`."
          },
          "sku": {
            "type": "string",
            "description": "SKU."
          },
          "name": {
            "type": "string",
            "description": "Product name."
          },
          "brand": {
            "type": "string",
            "description": "Brand."
          },
          "price": {
            "type": "number",
            "description": "Unit price."
          },
          "externalId": {
            "type": "string",
            "description": "Product id in your system."
          },
          "importedFrom": {
            "type": "string",
            "description": "Source the product was imported from."
          },
          "options": {
            "type": "array",
            "description": "Selected variant options.",
            "items": {
              "type": "object",
              "required": [
                "label",
                "items"
              ],
              "properties": {
                "label": {
                  "type": "string",
                  "description": "Option label, e.g. `Color`."
                },
                "items": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  },
                  "description": "Selected values."
                },
                "key": {
                  "type": "string",
                  "description": "Option key, e.g. `option1`."
                }
              }
            }
          },
          "downPaymentPercentage": {
            "type": "number",
            "description": "Down payment (%)."
          },
          "downPaymentAmount": {
            "type": "number",
            "description": "Down payment amount."
          },
          "financedPrice": {
            "type": "number",
            "description": "Amount to finance."
          }
        }
      },
      "Schedule": {
        "type": "object",
        "required": [
          "dataTime",
          "advisor",
          "status",
          "meetingUUID"
        ],
        "description": "Appointment linked to the card, normally written by Biky's scheduler. **If any of `dataTime`, `advisor`, `status` or `meetingUUID` is missing, the whole object is silently ignored** (the request still returns 2xx). Sending `schedule: null` cancels the current appointment.",
        "properties": {
          "dataTime": {
            "type": "string",
            "format": "date-time",
            "description": "Appointment date and time."
          },
          "advisor": {
            "type": "string",
            "description": "Email of the advisor who attends the appointment."
          },
          "status": {
            "type": "string",
            "description": "Appointment status, e.g. `scheduled`, `confirmed`, `rescheduled`, `canceled`."
          },
          "meetingUUID": {
            "type": "string",
            "description": "Appointment id in the Biky scheduler. Key used to upsert the appointment."
          },
          "type": {
            "type": "string",
            "description": "Appointment type."
          },
          "location": {
            "type": "string",
            "description": "Place or link."
          },
          "description": {
            "type": "string",
            "description": "Notes."
          },
          "entityUUID": {
            "type": "string",
            "description": "Id of the related entity in the scheduler."
          }
        }
      },
      "SalesCardFields": {
        "type": "object",
        "description": "Writable fields of a SalesCard.",
        "properties": {
          "name": {
            "type": "string",
            "description": "Card title."
          },
          "persons": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "string"
            },
            "description": "Contacts linked to the card: contact `uuid`s from the Contacts API (alphanumeric, 5+ characters). The API does not check that they exist. On update the whole list is replaced."
          },
          "responsible": {
            "$ref": "#/components/schemas/Responsible"
          },
          "responsibleCode": {
            "type": "string",
            "description": "Advisor code in your own system."
          },
          "description": {
            "type": "string",
            "description": "Free text."
          },
          "customId": {
            "type": "string",
            "description": "Your own id for the deal (e.g. the id in your ERP)."
          },
          "category": {
            "type": "string",
            "description": "Free-text category."
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Tags. Replaced as a whole on update."
          },
          "space": {
            "type": "string",
            "description": "Smart Chat space key the card belongs to. On create, defaults to the app's default space (or `no_space`)."
          },
          "chatRoomId": {
            "type": "string",
            "description": "Smart Chat conversation (room) id of the deal."
          },
          "chatSessionId": {
            "type": "string",
            "description": "Smart Chat session id of the deal."
          },
          "amount": {
            "type": "number",
            "description": "Deal value. Counted in the step total (`Step.totalValue`)."
          },
          "quantity": {
            "type": "number",
            "description": "Units."
          },
          "discount": {
            "type": "number",
            "description": "Discount."
          },
          "separationAmount": {
            "type": "number",
            "description": "Reservation (down payment) amount paid to hold the deal."
          },
          "closingProbability": {
            "type": "number",
            "minimum": 0,
            "maximum": 100,
            "description": "Probability (%) of closing this deal."
          },
          "budget": {
            "type": "string",
            "description": "Customer budget (free text)."
          },
          "priority": {
            "$ref": "#/components/schemas/Priority"
          },
          "sentiment": {
            "type": "string",
            "enum": [
              "Angry",
              "Disappointed",
              "Neutral",
              "Mixed",
              "Satisfied",
              "Very Satisfied"
            ],
            "description": "Customer sentiment."
          },
          "ans": {
            "type": "string",
            "description": "Service-level (ANS/SLA) label."
          },
          "business": {
            "type": "string",
            "maxLength": 30,
            "description": "Business unit or dealership."
          },
          "office": {
            "type": "string",
            "maxLength": 30,
            "description": "Branch or office."
          },
          "businessId": {
            "type": "string",
            "description": "Id of the lead's company (B2B)."
          },
          "businessType": {
            "type": "string",
            "description": "Company type (B2B)."
          },
          "businessCategory": {
            "type": "string",
            "description": "Company category (B2B)."
          },
          "businessSubcategory": {
            "type": "string",
            "description": "Company subcategory (B2B)."
          },
          "businessZone": {
            "type": "string",
            "description": "Company zone (B2B)."
          },
          "businessCity": {
            "type": "string",
            "description": "Company city (B2B)."
          },
          "businessState": {
            "type": "string",
            "description": "Company state (B2B)."
          },
          "businessCountry": {
            "type": "string",
            "description": "Company country (B2B)."
          },
          "hearAbout": {
            "type": "string",
            "description": "How the lead heard about you."
          },
          "formId": {
            "type": "string",
            "description": "Id of the lead form."
          },
          "formName": {
            "type": "string",
            "description": "Name of the lead form."
          },
          "leadGenId": {
            "type": "string",
            "description": "Lead id in the ad platform (e.g. Meta Lead Ads)."
          },
          "utm": {
            "$ref": "#/components/schemas/Utm"
          },
          "metaAd": {
            "$ref": "#/components/schemas/MetaAd"
          },
          "promotion": {
            "type": "string",
            "description": "Promotion or coupon."
          },
          "quoteNumber": {
            "type": "string",
            "description": "Quote number."
          },
          "quoteDate": {
            "type": "string",
            "format": "date-time",
            "description": "Quote date."
          },
          "quoteStatus": {
            "type": "string",
            "description": "Quote status (free text)."
          },
          "productsData": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProductData"
            },
            "description": "Products of the deal."
          },
          "paymentType": {
            "type": "string",
            "description": "Payment method (free text)."
          },
          "financing": {
            "type": "string",
            "description": "Financing plan or entity (free text)."
          },
          "financingDate": {
            "type": "string",
            "format": "date-time",
            "description": "Financing date."
          },
          "creditStatus": {
            "type": "string",
            "enum": [
              "in_process",
              "approved",
              "conditioned",
              "rejected"
            ],
            "description": "Credit application status."
          },
          "monthlyPayment": {
            "type": "number",
            "description": "Monthly payment."
          },
          "financialInstitution": {
            "type": "string",
            "description": "Lender."
          },
          "financingTermMonths": {
            "type": "integer",
            "enum": [
              12,
              24,
              36,
              48,
              60,
              72
            ],
            "description": "Financing term in months."
          },
          "demoDate": {
            "type": "string",
            "format": "date-time",
            "description": "Demo or test-drive date."
          },
          "saleDate": {
            "type": "string",
            "format": "date-time",
            "description": "Sale date. If omitted, it is set automatically when the card enters `$step_billed$` (or `$step_delivery$` of the sales funnel)."
          },
          "extendedData": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ExtendedData"
            },
            "description": "Custom fields. Replaced as a whole on update unless `isPushData` is `true`."
          },
          "reason": {
            "type": "string",
            "description": "Reason of the last change, e.g. why the deal was lost."
          },
          "schedule": {
            "$ref": "#/components/schemas/Schedule"
          },
          "appointmentPending": {
            "type": "boolean",
            "description": "`true` when the contact accepted to book an appointment that is not confirmed yet; `false` once it is confirmed."
          }
        }
      },
      "CreateSalesCardRequest": {
        "allOf": [
          {
            "$ref": "#/components/schemas/SalesCardFields"
          }
        ],
        "required": [
          "name",
          "persons",
          "responsible"
        ]
      },
      "UpdateSalesCardRequest": {
        "description": "Partial update: only the fields you send change. Arrays and objects replace the stored value, except `utm` and `metaAd` (merged) and, with `isPushData: true`, `extendedData` (merged by `field`) and `productsData` (merged by `id`).",
        "allOf": [
          {
            "$ref": "#/components/schemas/SalesCardFields"
          },
          {
            "type": "object",
            "properties": {
              "step": {
                "type": "string",
                "description": "Move the card to this step id. When the step is in another funnel, send `funnel` too (the pair is not validated)."
              },
              "funnel": {
                "type": "string",
                "description": "Move the card to this funnel id (send it with `step` or `stepName`)."
              },
              "stepName": {
                "type": "string",
                "description": "Move the card to the step with this name (e.g. `$step_won$` or `Cotización enviada`) in `funnel`, or in the card's current funnel. Takes precedence over `step`. 404 if no step has that name."
              },
              "isPushData": {
                "type": "boolean",
                "default": false,
                "description": "`true` merges `extendedData` by `field` and `productsData` by `id` into the stored lists instead of replacing them."
              }
            }
          }
        ]
      },
      "SalesCard": {
        "description": "A deal (opportunity) of one or more contacts in a funnel step.",
        "allOf": [
          {
            "$ref": "#/components/schemas/SalesCardFields"
          },
          {
            "type": "object",
            "properties": {
              "_id": {
                "type": "string",
                "description": "Card id."
              },
              "app": {
                "type": "string",
                "description": "App UUID."
              },
              "funnel": {
                "$ref": "#/components/schemas/Funnel"
              },
              "step": {
                "$ref": "#/components/schemas/Step"
              },
              "updatedAtStep": {
                "type": "string",
                "format": "date-time",
                "description": "When the card entered its current step."
              },
              "stepsDate": {
                "type": "array",
                "description": "Last date the card entered each step.",
                "items": {
                  "type": "object",
                  "properties": {
                    "stepName": {
                      "type": "string",
                      "description": "Step name."
                    },
                    "stepId": {
                      "type": "string",
                      "description": "Step id."
                    },
                    "updatedAt": {
                      "type": "string",
                      "format": "date-time",
                      "description": "When the card entered it."
                    }
                  }
                }
              },
              "preStep": {
                "type": "string",
                "description": "Previous step id (set on the last move)."
              },
              "preFunnel": {
                "type": "string",
                "description": "Previous funnel id (set on the last move)."
              },
              "schedules": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Schedule"
                },
                "description": "All appointments of the card, including canceled ones. Computed by the API."
              },
              "scheduleHistory": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Schedule"
                },
                "description": "Appointments other than the current `schedule`. Computed by the API."
              },
              "lastTouchAt": {
                "type": "string",
                "format": "date-time",
                "description": "Last touch (activity) registered for the deal."
              },
              "createdBy": {
                "$ref": "#/components/schemas/UserBy"
              },
              "updatedBy": {
                "$ref": "#/components/schemas/UserBy"
              },
              "createdAt": {
                "type": "string",
                "format": "date-time",
                "description": "Creation date."
              },
              "updatedAt": {
                "type": "string",
                "format": "date-time",
                "description": "Last update date."
              }
            }
          }
        ]
      },
      "CreatedSalesCard": {
        "allOf": [
          {
            "$ref": "#/components/schemas/SalesCard"
          },
          {
            "type": "object",
            "properties": {
              "mergedIntoExisting": {
                "type": "boolean",
                "description": "Only in accounts with lead de-duplication enabled: `true` when an existing open card of the contact was updated instead of creating one."
              },
              "mergedFrom": {
                "type": "object",
                "description": "Only with `mergedIntoExisting`: the existing card that was reused.",
                "properties": {
                  "cardId": {
                    "type": "string",
                    "description": "Reused card id."
                  },
                  "source": {
                    "type": "string",
                    "description": "Original `utm.source` of that card."
                  },
                  "stepName": {
                    "type": "string",
                    "description": "Step it was in."
                  },
                  "createdAt": {
                    "type": "string",
                    "format": "date-time",
                    "description": "When it was created."
                  },
                  "advanced": {
                    "type": "boolean",
                    "description": "Whether it was moved forward to the requested step."
                  }
                }
              }
            }
          }
        ]
      },
      "Paginator": {
        "type": "object",
        "properties": {
          "totalDocs": {
            "type": "integer",
            "description": "Total matching cards, **capped at 10,000** (treat 10000 as \"10,000 or more\")."
          },
          "limit": {
            "type": "integer",
            "description": "Page size."
          },
          "totalPages": {
            "type": "integer",
            "description": "Total pages (based on the capped count)."
          },
          "page": {
            "type": "integer",
            "description": "Current page (1-based)."
          },
          "pagingCounter": {
            "type": "integer",
            "description": "Position of the first card of the page (1-based)."
          },
          "hasPrevPage": {
            "type": "boolean",
            "description": "Whether there is a previous page."
          },
          "hasNextPage": {
            "type": "boolean",
            "description": "Whether there is a next page."
          },
          "prevPage": {
            "type": "integer",
            "nullable": true,
            "description": "Previous page number."
          },
          "nextPage": {
            "type": "integer",
            "nullable": true,
            "description": "Next page number."
          }
        }
      },
      "SalesCardList": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SalesCard"
            },
            "description": "Cards of the page, with `funnel` and `step` expanded."
          },
          "paginator": {
            "$ref": "#/components/schemas/Paginator"
          }
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Invalid parameters or body. `message` lists the validation errors.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "statusCode": 400,
              "timestamp": "2026-11-06T15:04:05.000Z",
              "path": "/app_7f3k2m9x1q/funnel/665f1c2e8a4b3d0012ab34cd/steps/665f1c2e8a4b3d0012ab34d1/cards",
              "message": [
                "name should not be empty",
                "persons must contain at least 1 elements"
              ],
              "error": "BadRequestException"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Missing, invalid, expired or revoked credential.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "statusCode": 401,
              "timestamp": "2026-11-06T15:04:05.000Z",
              "path": "/app_7f3k2m9x1q/funnel",
              "message": "Invalid token",
              "error": "UnauthorizedException"
            }
          }
        }
      },
      "Forbidden": {
        "description": "The credential is valid but its user is not a member of `{appUUID}`, or lacks permission for this action.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "statusCode": 403,
              "timestamp": "2026-11-06T15:04:05.000Z",
              "path": "/app_7f3k2m9x1q/funnel",
              "message": "No tiene permiso para esta app app_7f3k2m9x1q",
              "error": "ForbiddenException"
            }
          }
        }
      },
      "NotFound": {
        "description": "The resource does not exist in this app.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "statusCode": 404,
              "timestamp": "2026-11-06T15:04:05.000Z",
              "path": "/app_7f3k2m9x1q/funnel/665f1c2e8a4b3d0012ab34cd/steps/665f1c2e8a4b3d0012ab34d1/cards/665f1c2e8a4b3d0012ab3a10",
              "message": "Card 665f1c2e8a4b3d0012ab3a10 not found",
              "error": "NotFoundException"
            }
          }
        }
      }
    }
  }
}
