{
  "openapi": "3.1.0",
  "info": {
    "title": "Meerko API",
    "version": "1",
    "description": "Everything the Meerko dashboard, CLI and MCP server do, over HTTP: they are clients of this same API. Authenticate with an API key from Connections → API keys (`Authorization: Bearer mk_…`)."
  },
  "servers": [
    {
      "url": "https://api.meerko.ai"
    }
  ],
  "security": [
    {
      "bearer": []
    }
  ],
  "tags": [
    {
      "name": "workspace",
      "description": "Who the credential acts as, and the workspaces (brands) a person moves between"
    },
    {
      "name": "tables",
      "description": "Tables of leads and their rows"
    },
    {
      "name": "leads",
      "description": "Finding people and companies, and enriching rows with emails"
    },
    {
      "name": "mailboxes",
      "description": "Mailboxes that send sequences and receive replies"
    },
    {
      "name": "sequences",
      "description": "Multi-step email sequences"
    },
    {
      "name": "replies",
      "description": "Replies to sequences, and the drafts answering them"
    },
    {
      "name": "credits",
      "description": "Credits and the BYOK provider keys that bypass them"
    },
    {
      "name": "autopilot",
      "description": "Routines your own AI runs, started by new replies or on a schedule"
    },
    {
      "name": "settings",
      "description": "API keys, connected apps, Slack, CRM, the daily digest and billing"
    }
  ],
  "paths": {
    "/v1/me": {
      "get": {
        "operationId": "getMe",
        "tags": [
          "workspace"
        ],
        "summary": "The workspace (and person, for a session) this credential acts as",
        "x-meerko-replies-scope": true,
        "responses": {
          "200": {
            "description": "The workspace (and person, for a session) this credential acts as",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Me"
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/workspaces": {
      "get": {
        "operationId": "listWorkspaces",
        "tags": [
          "workspace"
        ],
        "summary": "List your workspaces, marking the current one",
        "description": "An API key sees only its own workspace.",
        "responses": {
          "200": {
            "description": "List your workspaces, marking the current one",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "workspaces": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/WorkspaceListItem"
                      }
                    }
                  },
                  "required": [
                    "workspaces"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/tables": {
      "get": {
        "operationId": "listTables",
        "tags": [
          "tables"
        ],
        "summary": "List tables",
        "responses": {
          "200": {
            "description": "List tables",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "tables": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Table"
                      }
                    }
                  },
                  "required": [
                    "tables"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createTable",
        "tags": [
          "tables"
        ],
        "summary": "Create a table",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1
                  },
                  "columns": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "string",
                          "minLength": 1
                        },
                        "type": {
                          "default": "text",
                          "type": "string",
                          "enum": [
                            "text",
                            "number",
                            "email",
                            "url",
                            "boolean",
                            "json"
                          ]
                        },
                        "prompt": {
                          "description": "Makes it an AI column: an instruction filled in for each row by your agent",
                          "type": "string",
                          "minLength": 1
                        }
                      },
                      "required": [
                        "name"
                      ]
                    }
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Create a table",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "table": {
                      "$ref": "#/components/schemas/Table"
                    }
                  },
                  "required": [
                    "table"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/tables/{id}": {
      "get": {
        "operationId": "getTable",
        "tags": [
          "tables"
        ],
        "summary": "Get a table and its columns",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Get a table and its columns",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "table": {
                      "$ref": "#/components/schemas/Table"
                    }
                  },
                  "required": [
                    "table"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteTable",
        "tags": [
          "tables"
        ],
        "summary": "Delete a table, its rows and its sequences",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Delete a table, its rows and its sequences",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "deleted": {
                      "type": "boolean"
                    },
                    "rows": {
                      "type": "number"
                    },
                    "sequences": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "deleted",
                    "rows",
                    "sequences"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/tables/{id}/columns": {
      "post": {
        "operationId": "addColumn",
        "tags": [
          "tables"
        ],
        "summary": "Add a column (with `prompt`, an AI column)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1
                  },
                  "type": {
                    "default": "text",
                    "type": "string",
                    "enum": [
                      "text",
                      "number",
                      "email",
                      "url",
                      "boolean",
                      "json"
                    ]
                  },
                  "prompt": {
                    "description": "Makes it an AI column: an instruction filled in for each row by your agent",
                    "type": "string",
                    "minLength": 1
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Add a column (with `prompt`, an AI column)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "table": {
                      "$ref": "#/components/schemas/Table"
                    }
                  },
                  "required": [
                    "table"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/tables/{id}/columns/{column}/pending": {
      "get": {
        "operationId": "getPendingCells",
        "tags": [
          "tables"
        ],
        "summary": "Rows whose AI column is still empty, with the instruction for each",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "column",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "filter",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "A JSON object matched against row data, e.g. {\"country\":\"Spain\"}"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            }
          },
          {
            "name": "stage",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "new",
                "contacted",
                "replied",
                "meeting",
                "won",
                "lost"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Rows whose AI column is still empty, with the instruction for each",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PendingCells"
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/tables/{id}/rows": {
      "get": {
        "operationId": "queryRows",
        "tags": [
          "tables"
        ],
        "summary": "Query rows",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "filter",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "A JSON object matched against row data, e.g. {\"country\":\"Spain\"}"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            }
          },
          {
            "name": "stage",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "new",
                "contacted",
                "replied",
                "meeting",
                "won",
                "lost"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Query rows",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "rows": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Row"
                      }
                    }
                  },
                  "required": [
                    "rows"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "insertRows",
        "tags": [
          "tables"
        ],
        "summary": "Insert rows; unknown keys become new columns",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "rows": {
                    "maxItems": 10000,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {}
                    }
                  }
                },
                "required": [
                  "rows"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Insert rows; unknown keys become new columns",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "inserted": {
                      "type": "number"
                    },
                    "addedColumns": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Column"
                      }
                    }
                  },
                  "required": [
                    "inserted",
                    "addedColumns"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateRows",
        "tags": [
          "tables"
        ],
        "summary": "Update row data",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "updates": {
                    "maxItems": 1000,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "data": {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {}
                        }
                      },
                      "required": [
                        "id",
                        "data"
                      ]
                    }
                  }
                },
                "required": [
                  "updates"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Update row data",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "updated": {
                      "type": "number"
                    },
                    "addedColumns": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Column"
                      }
                    }
                  },
                  "required": [
                    "updated",
                    "addedColumns"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/tables/{id}/rows/delete": {
      "post": {
        "operationId": "deleteRows",
        "tags": [
          "tables"
        ],
        "summary": "Delete rows",
        "description": "POST rather than DELETE with a body, which some HTTP clients drop.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "row_ids": {
                    "minItems": 1,
                    "maxItems": 1000,
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                },
                "required": [
                  "row_ids"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Delete rows",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "deleted": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "deleted"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/tables/{id}/rows/stage": {
      "post": {
        "operationId": "moveStage",
        "tags": [
          "tables"
        ],
        "summary": "Move rows to a pipeline stage",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "row_ids": {
                    "minItems": 1,
                    "maxItems": 1000,
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "stage": {
                    "type": "string",
                    "enum": [
                      "new",
                      "contacted",
                      "replied",
                      "meeting",
                      "won",
                      "lost"
                    ]
                  }
                },
                "required": [
                  "row_ids",
                  "stage"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Move rows to a pipeline stage",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "moved": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "moved"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/pipeline": {
      "get": {
        "operationId": "getPipeline",
        "tags": [
          "tables"
        ],
        "summary": "Rows per pipeline stage, for one table or all",
        "parameters": [
          {
            "name": "table_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Rows per pipeline stage, for one table or all",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Pipeline"
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/search/people/count": {
      "post": {
        "operationId": "countPeople",
        "tags": [
          "leads"
        ],
        "summary": "Count people matching a search (free)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "query": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {}
                    },
                    "description": "Icypeas filters, e.g. {\"currentJobTitle\":{\"include\":[\"CTO\"]},\"currentCompany.headcount\":{\">=\":20}}"
                  }
                },
                "required": [
                  "query"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Count people matching a search (free)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "total": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "total"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/search/people": {
      "post": {
        "operationId": "searchPeople",
        "tags": [
          "leads"
        ],
        "summary": "Find people and add them to a table (spends credits)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "query": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {}
                    },
                    "description": "Icypeas filters, e.g. {\"currentJobTitle\":{\"include\":[\"CTO\"]},\"currentCompany.headcount\":{\">=\":20}}"
                  },
                  "limit": {
                    "default": 25,
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 1000
                  },
                  "table_id": {
                    "description": "Add the leads to this table",
                    "type": "string"
                  },
                  "table_name": {
                    "description": "Or create a table with this name",
                    "type": "string",
                    "minLength": 1
                  }
                },
                "required": [
                  "query"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Find people and add them to a table (spends credits)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchResult"
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/search/companies/count": {
      "post": {
        "operationId": "countCompanies",
        "tags": [
          "leads"
        ],
        "summary": "Count companies matching a search (free)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "query": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {}
                    },
                    "description": "Icypeas filters, e.g. {\"currentJobTitle\":{\"include\":[\"CTO\"]},\"currentCompany.headcount\":{\">=\":20}}"
                  }
                },
                "required": [
                  "query"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Count companies matching a search (free)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "total": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "total"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/icp": {
      "get": {
        "operationId": "getIcp",
        "tags": [
          "leads"
        ],
        "summary": "The workspace's ideal customer profile (ICP)",
        "description": "Null until one is set. Every row read is scored against it.",
        "responses": {
          "200": {
            "description": "The workspace's ideal customer profile (ICP)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "icp": {
                      "anyOf": [
                        {
                          "$ref": "#/components/schemas/Icp"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "icp"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "setIcp",
        "tags": [
          "leads"
        ],
        "summary": "Set the ideal customer profile; every lead is rescored against it",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Icp"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Set the ideal customer profile; every lead is rescored against it",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "icp": {
                      "$ref": "#/components/schemas/Icp"
                    }
                  },
                  "required": [
                    "icp"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "clearIcp",
        "tags": [
          "leads"
        ],
        "summary": "Remove the ideal customer profile (scores go blank)",
        "responses": {
          "200": {
            "description": "Remove the ideal customer profile (scores go blank)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "cleared": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "cleared"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/tables/{id}/icp-review": {
      "post": {
        "operationId": "reviewIcpFit",
        "tags": [
          "leads"
        ],
        "summary": "Adjust rows' ICP scores with a reason (the agent's judgement)",
        "description": "Moves each row's rules-based score by up to ±30.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "rows": {
                    "minItems": 1,
                    "maxItems": 200,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "row_id": {
                          "type": "string"
                        },
                        "adjust": {
                          "anyOf": [
                            {
                              "type": "integer",
                              "minimum": -30,
                              "maximum": 30
                            },
                            {
                              "type": "null"
                            }
                          ],
                          "description": "Move the score by up to ±30; null clears it"
                        },
                        "note": {
                          "description": "Why, in one line",
                          "type": "string",
                          "maxLength": 300
                        }
                      },
                      "required": [
                        "row_id",
                        "adjust"
                      ]
                    }
                  }
                },
                "required": [
                  "rows"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Adjust rows' ICP scores with a reason (the agent's judgement)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "updated": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "updated"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/tables/{id}/crm-sync": {
      "post": {
        "operationId": "syncCrm",
        "tags": [
          "tables"
        ],
        "summary": "Push rows to the connected CRM as contacts, matched by email",
        "description": "Up to 100 rows per call; `remaining` says how many are left.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "row_ids": {
                    "description": "Only these rows (up to 100). Without it, every row not yet pushed or changed since, 100 per call",
                    "minItems": 1,
                    "maxItems": 100,
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Push rows to the connected CRM as contacts, matched by email",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CrmSyncResult"
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/websites/read": {
      "post": {
        "operationId": "readWebsite",
        "tags": [
          "leads"
        ],
        "summary": "Read a website's text, to work out who it sells to (free)",
        "description": "Meerko fetches the home page and returns its text; your agent decides the ideal customer from it. Public sites only.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 500,
                    "description": "The website, e.g. acme.com"
                  }
                },
                "required": [
                  "url"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Read a website's text, to work out who it sells to (free)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Website"
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/search/companies": {
      "post": {
        "operationId": "searchCompanies",
        "tags": [
          "leads"
        ],
        "summary": "Find companies and add them to a table (spends credits)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "query": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {}
                    },
                    "description": "Icypeas filters, e.g. {\"currentJobTitle\":{\"include\":[\"CTO\"]},\"currentCompany.headcount\":{\">=\":20}}"
                  },
                  "limit": {
                    "default": 25,
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 1000
                  },
                  "table_id": {
                    "description": "Add the leads to this table",
                    "type": "string"
                  },
                  "table_name": {
                    "description": "Or create a table with this name",
                    "type": "string",
                    "minLength": 1
                  }
                },
                "required": [
                  "query"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Find companies and add them to a table (spends credits)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchResult"
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/tables/{id}/enrich": {
      "post": {
        "operationId": "enrichRows",
        "tags": [
          "leads"
        ],
        "summary": "Find and verify emails, or find phone numbers, for rows (spends credits)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "fields": {
                    "default": [
                      "email",
                      "email_verification"
                    ],
                    "description": "phone is opt-in (80 credits per number found, Pro on Meerko Cloud); the default finds and verifies emails",
                    "minItems": 1,
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "email",
                        "email_verification",
                        "phone"
                      ]
                    }
                  },
                  "filter": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {}
                  },
                  "row_ids": {
                    "description": "Only these rows",
                    "maxItems": 1000,
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "min_icp_score": {
                    "description": "Only rows whose ICP fit is at least this (0-100); needs an ICP",
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 100
                  },
                  "limit": {
                    "default": 25,
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 50
                  },
                  "overwrite": {
                    "default": false,
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Find and verify emails, or find phone numbers, for rows (spends credits)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EnrichResult"
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/mailboxes": {
      "get": {
        "operationId": "listMailboxes",
        "tags": [
          "mailboxes"
        ],
        "summary": "List mailboxes",
        "responses": {
          "200": {
            "description": "List mailboxes",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "mailboxes": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Mailbox"
                      }
                    }
                  },
                  "required": [
                    "mailboxes"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/mailboxes/connect": {
      "get": {
        "operationId": "mailboxConnectOptions",
        "tags": [
          "mailboxes"
        ],
        "summary": "How this server connects mailboxes, and where a person enters a password",
        "responses": {
          "200": {
            "description": "How this server connects mailboxes, and where a person enters a password",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "oauth": {
                      "type": "boolean"
                    },
                    "outlook": {
                      "type": "boolean"
                    },
                    "url": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "oauth",
                    "outlook",
                    "url"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/mailboxes/gmail/app-password": {
      "post": {
        "operationId": "connectGmailAppPassword",
        "tags": [
          "mailboxes"
        ],
        "summary": "Connect Gmail with an app password",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email",
                    "pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                  },
                  "password": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100,
                    "description": "A Google app password, entered by a person: agents must never handle it"
                  },
                  "login": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "email",
                        "pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "display_name": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 100
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": [
                  "email",
                  "password"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Connect Gmail with an app password",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "mailbox": {
                      "$ref": "#/components/schemas/Mailbox"
                    }
                  },
                  "required": [
                    "mailbox"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/mailboxes/imap": {
      "post": {
        "operationId": "connectImapMailbox",
        "tags": [
          "mailboxes"
        ],
        "summary": "Connect any IMAP/SMTP mailbox",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email",
                    "pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                  },
                  "password": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "login": {
                    "anyOf": [
                      {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 200
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "display_name": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 100
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "imap_host": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 253
                  },
                  "imap_port": {
                    "default": 993,
                    "type": "integer",
                    "minimum": -9007199254740991,
                    "maximum": 9007199254740991
                  },
                  "smtp_host": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 253
                  },
                  "smtp_port": {
                    "default": 465,
                    "type": "integer",
                    "minimum": -9007199254740991,
                    "maximum": 9007199254740991
                  }
                },
                "required": [
                  "email",
                  "password",
                  "imap_host",
                  "smtp_host"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Connect any IMAP/SMTP mailbox",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "mailbox": {
                      "$ref": "#/components/schemas/Mailbox"
                    }
                  },
                  "required": [
                    "mailbox"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/mailboxes/gmail/connect": {
      "post": {
        "operationId": "connectGmail",
        "tags": [
          "mailboxes"
        ],
        "summary": "Start connecting Gmail through Google's consent screen (when the server enables it)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "login_hint": {
                    "type": "string",
                    "format": "email",
                    "pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                  },
                  "return_to": {
                    "type": "string",
                    "format": "uri"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Start connecting Gmail through Google's consent screen (when the server enables it)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Url"
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/mailboxes/outlook/connect": {
      "post": {
        "operationId": "connectOutlook",
        "tags": [
          "mailboxes"
        ],
        "summary": "Start connecting Outlook / Microsoft 365",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "login_hint": {
                    "type": "string",
                    "format": "email",
                    "pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                  },
                  "return_to": {
                    "type": "string",
                    "format": "uri"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Start connecting Outlook / Microsoft 365",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Url"
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/mailboxes/health": {
      "get": {
        "operationId": "mailboxHealth",
        "tags": [
          "mailboxes"
        ],
        "summary": "SPF, DKIM and DMARC for each sending domain",
        "responses": {
          "200": {
            "description": "SPF, DKIM and DMARC for each sending domain",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "domains": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/DomainHealth"
                      }
                    }
                  },
                  "required": [
                    "domains"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/mailboxes/{id}": {
      "patch": {
        "operationId": "updateMailbox",
        "tags": [
          "mailboxes"
        ],
        "summary": "Change a mailbox's daily limit, name or ramp-up, or resume it after a hold",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "daily_limit": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 500
                  },
                  "display_name": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 100
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "ramp": {
                    "type": "boolean"
                  },
                  "resume": {
                    "description": "Lift a hold Meerko put on the mailbox (heldAt) after too many bounces or spam rejections",
                    "type": "boolean",
                    "const": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Change a mailbox's daily limit, name or ramp-up, or resume it after a hold",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "mailbox": {
                      "$ref": "#/components/schemas/Mailbox"
                    }
                  },
                  "required": [
                    "mailbox"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteMailbox",
        "tags": [
          "mailboxes"
        ],
        "summary": "Disconnect a mailbox",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Disconnect a mailbox",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "deleted": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "deleted"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/mailboxes/{id}/test": {
      "post": {
        "operationId": "sendTestEmail",
        "tags": [
          "mailboxes"
        ],
        "summary": "Send a test email from a mailbox",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "to": {
                    "type": "string",
                    "format": "email",
                    "pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                  }
                },
                "required": [
                  "to"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Send a test email from a mailbox",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "sent": {
                      "type": "boolean"
                    },
                    "messageId": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "sent",
                    "messageId"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/sequences": {
      "get": {
        "operationId": "listSequences",
        "tags": [
          "sequences"
        ],
        "summary": "List sequences",
        "responses": {
          "200": {
            "description": "List sequences",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "sequences": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/SequenceSummary"
                      }
                    }
                  },
                  "required": [
                    "sequences"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createSequence",
        "tags": [
          "sequences"
        ],
        "summary": "Create a sequence (as a draft)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "table_id": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "mailbox_ids": {
                    "description": "The mailbox pool: each lead gets one and keeps it for every step",
                    "minItems": 1,
                    "maxItems": 50,
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "mailbox_id": {
                    "description": "Deprecated: use mailbox_ids",
                    "type": "string"
                  },
                  "assignment": {
                    "description": "How new leads are spread over the pool. Default \"capacity\"",
                    "type": "string",
                    "enum": [
                      "capacity",
                      "even"
                    ]
                  },
                  "steps": {
                    "minItems": 1,
                    "maxItems": 10,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "subject": {
                          "anyOf": [
                            {
                              "type": "string",
                              "maxLength": 300
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "body": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 20000
                        },
                        "delay_days": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 60
                        }
                      },
                      "required": [
                        "body"
                      ]
                    },
                    "description": "1–10 emails: { subject?, body, delay_days? }. The first needs a subject; follow-ups reply in the same thread. {{var}} fills in row data, and rows missing a used variable are skipped at enrollment"
                  },
                  "timezone": {
                    "type": "string"
                  },
                  "window_start_hour": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 23
                  },
                  "window_end_hour": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 24
                  }
                },
                "required": [
                  "table_id",
                  "name",
                  "steps"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Create a sequence (as a draft)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "sequence": {
                      "$ref": "#/components/schemas/Sequence"
                    }
                  },
                  "required": [
                    "sequence"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/sending-mode": {
      "get": {
        "operationId": "getSendingMode",
        "tags": [
          "sequences"
        ],
        "summary": "Whether a person approves each email before it goes, for sequences and for reply drafts",
        "responses": {
          "200": {
            "description": "Whether a person approves each email before it goes, for sequences and for reply drafts",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "mode": {
                      "$ref": "#/components/schemas/SendingMode"
                    }
                  },
                  "required": [
                    "mode"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/pending-emails": {
      "get": {
        "operationId": "listPendingEmails",
        "tags": [
          "sequences"
        ],
        "summary": "Sequence emails waiting for approval, soonest first, as each lead will get them",
        "parameters": [
          {
            "name": "sequence_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sequence emails waiting for approval, soonest first, as each lead will get them",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "emails": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PendingEmail"
                      }
                    }
                  },
                  "required": [
                    "emails"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/pending-emails/approve": {
      "post": {
        "operationId": "approveEmails",
        "tags": [
          "sequences"
        ],
        "summary": "Approve leads' next sequence email; each goes when it's due",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "enrollment_ids": {
                    "description": "Approve these leads' next email",
                    "maxItems": 1000,
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "sequence_id": {
                    "description": "Approve the next email of every lead waiting in this sequence",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Approve leads' next sequence email; each goes when it's due",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "approved": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "approved"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/sequences/{id}": {
      "get": {
        "operationId": "getSequence",
        "tags": [
          "sequences"
        ],
        "summary": "Get a sequence and its steps",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Get a sequence and its steps",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "sequence": {
                      "$ref": "#/components/schemas/Sequence"
                    }
                  },
                  "required": [
                    "sequence"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateSequence",
        "tags": [
          "sequences"
        ],
        "summary": "Change a sequence's steps, mailboxes or sending window",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "mailbox_ids": {
                    "description": "The mailbox pool: each lead gets one and keeps it for every step",
                    "minItems": 1,
                    "maxItems": 50,
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "mailbox_id": {
                    "description": "Deprecated: use mailbox_ids",
                    "type": "string"
                  },
                  "assignment": {
                    "description": "How new leads are spread over the pool. Default \"capacity\"",
                    "type": "string",
                    "enum": [
                      "capacity",
                      "even"
                    ]
                  },
                  "steps": {
                    "minItems": 1,
                    "maxItems": 10,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "subject": {
                          "anyOf": [
                            {
                              "type": "string",
                              "maxLength": 300
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "body": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 20000
                        },
                        "delay_days": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 60
                        }
                      },
                      "required": [
                        "body"
                      ]
                    },
                    "description": "1–10 emails: { subject?, body, delay_days? }. The first needs a subject; follow-ups reply in the same thread. {{var}} fills in row data, and rows missing a used variable are skipped at enrollment"
                  },
                  "timezone": {
                    "type": "string"
                  },
                  "window_start_hour": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 23
                  },
                  "window_end_hour": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 24
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Change a sequence's steps, mailboxes or sending window",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "sequence": {
                      "$ref": "#/components/schemas/Sequence"
                    }
                  },
                  "required": [
                    "sequence"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteSequence",
        "tags": [
          "sequences"
        ],
        "summary": "Delete a paused or draft sequence, its steps and enrollments; replies stay",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Delete a paused or draft sequence, its steps and enrollments; replies stay",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "deleted": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "deleted"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/sequences/{id}/preview": {
      "get": {
        "operationId": "previewSequence",
        "tags": [
          "sequences"
        ],
        "summary": "Render each step for one row, with any missing variables",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "row_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Render each step for one row, with any missing variables",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SequencePreview"
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/sequences/{id}/enroll": {
      "post": {
        "operationId": "enrollRows",
        "tags": [
          "sequences"
        ],
        "summary": "Enroll rows, by id or filter",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "row_ids": {
                    "maxItems": 5000,
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "filter": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {}
                  },
                  "limit": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 5000
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Enroll rows, by id or filter",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EnrollResult"
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/sequences/{id}/start": {
      "post": {
        "operationId": "startSequence",
        "tags": [
          "sequences"
        ],
        "summary": "Start sending",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Start sending",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "sequence": {
                      "$ref": "#/components/schemas/Sequence"
                    }
                  },
                  "required": [
                    "sequence"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/sequences/{id}/pause": {
      "post": {
        "operationId": "pauseSequence",
        "tags": [
          "sequences"
        ],
        "summary": "Pause sending",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Pause sending",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "sequence": {
                      "$ref": "#/components/schemas/Sequence"
                    }
                  },
                  "required": [
                    "sequence"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/sequences/{id}/pool": {
      "get": {
        "operationId": "sequencePool",
        "tags": [
          "sequences"
        ],
        "summary": "The sequence's mailboxes and today's sending",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The sequence's mailboxes and today's sending",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SequencePool"
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/sequences/{id}/stats": {
      "get": {
        "operationId": "sequenceStats",
        "tags": [
          "sequences"
        ],
        "summary": "Sent, replied and per-step numbers",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sent, replied and per-step numbers",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SequenceStats"
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/sequences/{id}/recipients": {
      "get": {
        "operationId": "sequenceRecipients",
        "tags": [
          "sequences"
        ],
        "summary": "Everyone enrolled and where they are",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Everyone enrolled and where they are",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "recipients": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Recipient"
                      }
                    }
                  },
                  "required": [
                    "recipients"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/replies": {
      "get": {
        "operationId": "listReplies",
        "tags": [
          "replies"
        ],
        "summary": "List replies, with their threads",
        "x-meerko-replies-scope": true,
        "parameters": [
          {
            "name": "sequence_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "intent",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "unclassified",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "true",
                "false"
              ]
            }
          },
          {
            "name": "include_automatic",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "true",
                "false"
              ]
            }
          },
          {
            "name": "needs_you",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "true",
                "false"
              ]
            },
            "description": "Unclassified replies plus unhandled ones with a draft waiting: what waits on the person"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "List replies, with their threads",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "replies": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Reply"
                      }
                    }
                  },
                  "required": [
                    "replies"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/replies/{id}/classify": {
      "post": {
        "operationId": "classifyReply",
        "tags": [
          "replies"
        ],
        "summary": "Set a reply's intent",
        "x-meerko-replies-scope": true,
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "intent": {
                    "type": "string",
                    "enum": [
                      "interested",
                      "not_interested",
                      "not_now",
                      "question",
                      "referral",
                      "wrong_person",
                      "other"
                    ]
                  },
                  "handled": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "intent"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Set a reply's intent",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "reply": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "intent": {
                          "type": "string"
                        },
                        "handledAt": {
                          "type": [
                            "string",
                            "null"
                          ]
                        }
                      },
                      "required": [
                        "id",
                        "intent",
                        "handledAt"
                      ]
                    }
                  },
                  "required": [
                    "reply"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/replies/{id}/draft": {
      "post": {
        "operationId": "draftReply",
        "tags": [
          "replies"
        ],
        "summary": "Save a draft answer for a person to approve",
        "description": "When the workspace sends reply drafts on its own (sending mode `reply_drafts: auto`), the draft is sent straight away and `sent` says so; if sending fails it stays pending, with `send_error`.",
        "x-meerko-replies-scope": true,
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "body": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 20000
                  }
                },
                "required": [
                  "body"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Save a draft answer for a person to approve",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "draft": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "body": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "body"
                      ]
                    },
                    "sent": {
                      "type": "object",
                      "properties": {
                        "sent": {
                          "type": "boolean"
                        },
                        "to": {
                          "type": "string"
                        },
                        "subject": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "sent",
                        "to",
                        "subject"
                      ]
                    },
                    "send_error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "draft"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/drafts": {
      "get": {
        "operationId": "listDrafts",
        "tags": [
          "replies"
        ],
        "summary": "List drafts",
        "x-meerko-replies-scope": true,
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "pending",
                "sent",
                "discarded"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "List drafts",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "drafts": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Draft"
                      }
                    }
                  },
                  "required": [
                    "drafts"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/drafts/{id}/approve": {
      "post": {
        "operationId": "approveDraft",
        "tags": [
          "replies"
        ],
        "summary": "Send a draft",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "body": {
                    "description": "Send this instead of the saved draft",
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 20000
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Send a draft",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "sent": {
                      "type": "boolean"
                    },
                    "to": {
                      "type": "string"
                    },
                    "subject": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "sent",
                    "to",
                    "subject"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/drafts/{id}/discard": {
      "post": {
        "operationId": "discardDraft",
        "tags": [
          "replies"
        ],
        "summary": "Discard a draft",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Discard a draft",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "discarded": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "discarded"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/credits": {
      "get": {
        "operationId": "getCredits",
        "tags": [
          "credits"
        ],
        "summary": "Credit balance, and where a person tops up",
        "responses": {
          "200": {
            "description": "Credit balance, and where a person tops up",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Credits"
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/provider-keys": {
      "get": {
        "operationId": "listProviderKeys",
        "tags": [
          "credits"
        ],
        "summary": "Your own provider keys (last 4 only)",
        "responses": {
          "200": {
            "description": "Your own provider keys (last 4 only)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "keys": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ProviderKey"
                      }
                    }
                  },
                  "required": [
                    "keys"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/provider-keys/{provider}": {
      "put": {
        "operationId": "setProviderKey",
        "tags": [
          "credits"
        ],
        "summary": "Store your own Icypeas, Firecrawl or Generect key; lookups through it spend no credits",
        "parameters": [
          {
            "name": "provider",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "key": {
                    "type": "string",
                    "minLength": 8
                  }
                },
                "required": [
                  "key"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Store your own Icypeas, Firecrawl or Generect key; lookups through it spend no credits",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "provider": {
                      "type": "string"
                    },
                    "last4": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "provider",
                    "last4"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteProviderKey",
        "tags": [
          "credits"
        ],
        "summary": "Remove a provider key",
        "parameters": [
          {
            "name": "provider",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Remove a provider key",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "deleted": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "deleted"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/api-keys": {
      "get": {
        "operationId": "listApiKeys",
        "tags": [
          "settings"
        ],
        "summary": "List API keys",
        "responses": {
          "200": {
            "description": "List API keys",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "api_keys": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ApiKey"
                      }
                    }
                  },
                  "required": [
                    "api_keys"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/connected-apps": {
      "get": {
        "operationId": "listConnectedApps",
        "tags": [
          "settings"
        ],
        "summary": "List OAuth apps connected to the workspace",
        "responses": {
          "200": {
            "description": "List OAuth apps connected to the workspace",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "apps": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ConnectedApp"
                      }
                    }
                  },
                  "required": [
                    "apps"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/routines": {
      "get": {
        "operationId": "listRoutines",
        "tags": [
          "autopilot"
        ],
        "summary": "List the workspace's Autopilot routines, with their latest runs",
        "responses": {
          "200": {
            "description": "List the workspace's Autopilot routines, with their latest runs",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "routines": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Routine"
                      }
                    }
                  },
                  "required": [
                    "routines"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createRoutine",
        "tags": [
          "autopilot"
        ],
        "summary": "Create a routine",
        "description": "It starts on your AI's own scheduler; a person connects a Claude routine or a webhook in the dashboard so Meerko starts it.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 80
                  },
                  "brief": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 4000,
                    "description": "What the AI does on each run, in plain words"
                  },
                  "when": {
                    "type": "string",
                    "enum": [
                      "replies",
                      "schedule"
                    ],
                    "description": "`replies`: when new replies wait (one per workspace). `schedule`: on `cadence`"
                  },
                  "cadence": {
                    "description": "Required for `schedule`",
                    "type": "object",
                    "properties": {
                      "days": {
                        "minItems": 1,
                        "type": "array",
                        "items": {
                          "type": "integer",
                          "minimum": 1,
                          "maximum": 7
                        },
                        "description": "ISO weekdays: 1 = Monday … 7 = Sunday"
                      },
                      "time": {
                        "type": "string",
                        "description": "HH:MM, 24-hour, in `timezone`"
                      },
                      "timezone": {
                        "type": "string",
                        "description": "IANA zone, e.g. Europe/Madrid"
                      }
                    },
                    "required": [
                      "days",
                      "time",
                      "timezone"
                    ]
                  }
                },
                "required": [
                  "name",
                  "brief",
                  "when"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Create a routine",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "routine": {
                      "$ref": "#/components/schemas/Routine"
                    }
                  },
                  "required": [
                    "routine"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/routines/{id}": {
      "get": {
        "operationId": "getRoutine",
        "tags": [
          "autopilot"
        ],
        "summary": "Get a routine, how it runs and its latest runs",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Get a routine, how it runs and its latest runs",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "routine": {
                      "$ref": "#/components/schemas/Routine"
                    }
                  },
                  "required": [
                    "routine"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateRoutine",
        "tags": [
          "autopilot"
        ],
        "summary": "Edit, pause or resume a routine",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 80
                  },
                  "brief": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 4000
                  },
                  "when": {
                    "type": "string",
                    "enum": [
                      "replies",
                      "schedule"
                    ]
                  },
                  "cadence": {
                    "type": "object",
                    "properties": {
                      "days": {
                        "minItems": 1,
                        "type": "array",
                        "items": {
                          "type": "integer",
                          "minimum": 1,
                          "maximum": 7
                        },
                        "description": "ISO weekdays: 1 = Monday … 7 = Sunday"
                      },
                      "time": {
                        "type": "string",
                        "description": "HH:MM, 24-hour, in `timezone`"
                      },
                      "timezone": {
                        "type": "string",
                        "description": "IANA zone, e.g. Europe/Madrid"
                      }
                    },
                    "required": [
                      "days",
                      "time",
                      "timezone"
                    ],
                    "description": "When a scheduled routine is due"
                  },
                  "status": {
                    "description": "`paused` stops it; `active` resumes it from now",
                    "type": "string",
                    "enum": [
                      "active",
                      "paused"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Edit, pause or resume a routine",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "routine": {
                      "$ref": "#/components/schemas/Routine"
                    }
                  },
                  "required": [
                    "routine"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteRoutine",
        "tags": [
          "autopilot"
        ],
        "summary": "Delete a routine",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Delete a routine"
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/routines/{id}/run": {
      "post": {
        "operationId": "runRoutine",
        "tags": [
          "autopilot"
        ],
        "summary": "Run it now",
        "description": "Meerko starts it through its Claude routine or webhook. A routine on your AI's own scheduler isn't started: `started` is false and `routine.setup.prompt` is what to run.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Run it now",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "started": {
                      "type": "boolean"
                    },
                    "run": {
                      "anyOf": [
                        {
                          "$ref": "#/components/schemas/RoutineRun"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "error": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "routine": {
                      "$ref": "#/components/schemas/Routine"
                    }
                  },
                  "required": [
                    "started",
                    "run",
                    "error",
                    "routine"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/routines/{id}/start": {
      "post": {
        "operationId": "startRoutineRun",
        "tags": [
          "autopilot"
        ],
        "summary": "Check in at the start of a run and get the brief",
        "description": "Call it first on every run: it records that the run happened and returns what to do.",
        "x-meerko-replies-scope": true,
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Check in at the start of a run and get the brief",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RoutineStart"
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/slack": {
      "get": {
        "operationId": "getSlack",
        "tags": [
          "settings"
        ],
        "summary": "Where replies and drafts are posted in Slack",
        "responses": {
          "200": {
            "description": "Where replies and drafts are posted in Slack",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "connection": {
                      "anyOf": [
                        {
                          "$ref": "#/components/schemas/SlackConnection"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "app_available": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "connection",
                    "app_available"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/crm": {
      "get": {
        "operationId": "getCrm",
        "tags": [
          "settings"
        ],
        "summary": "The CRM leads are pushed to (HubSpot or Attio)",
        "responses": {
          "200": {
            "description": "The CRM leads are pushed to (HubSpot or Attio)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "connection": {
                      "anyOf": [
                        {
                          "$ref": "#/components/schemas/CrmConnection"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "connection"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "connectCrm",
        "tags": [
          "settings"
        ],
        "summary": "Connect HubSpot or Attio",
        "description": "The token is checked with the CRM first, then stored encrypted. Replaces any CRM already connected.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "provider": {
                    "type": "string",
                    "enum": [
                      "hubspot",
                      "attio"
                    ]
                  },
                  "token": {
                    "type": "string",
                    "minLength": 8,
                    "maxLength": 500,
                    "description": "A HubSpot private app token or an Attio API key, entered by a person"
                  },
                  "auto_sync": {
                    "description": "Push leads automatically once Meerko has contacted them. Defaults to true",
                    "type": "boolean"
                  }
                },
                "required": [
                  "provider",
                  "token"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Connect HubSpot or Attio",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "connection": {
                      "$ref": "#/components/schemas/CrmConnection"
                    }
                  },
                  "required": [
                    "connection"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateCrm",
        "tags": [
          "settings"
        ],
        "summary": "Turn automatic CRM sync on or off",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "auto_sync": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "auto_sync"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Turn automatic CRM sync on or off",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "connection": {
                      "$ref": "#/components/schemas/CrmConnection"
                    }
                  },
                  "required": [
                    "connection"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteCrm",
        "tags": [
          "settings"
        ],
        "summary": "Disconnect the CRM (contacts already there stay)",
        "responses": {
          "200": {
            "description": "Disconnect the CRM (contacts already there stay)"
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/billing": {
      "get": {
        "operationId": "getBilling",
        "tags": [
          "settings"
        ],
        "summary": "Plan, subscription and balance (Meerko Cloud)",
        "responses": {
          "200": {
            "description": "Plan, subscription and balance (Meerko Cloud)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Billing"
                }
              }
            }
          },
          "default": {
            "description": "An error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "An API key (mk_…) or an OAuth access token (mo_…)"
      }
    },
    "schemas": {
      "ApiError": {
        "$ref": "#/components/schemas/ApiError"
      },
      "ApiKey": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "prefix": {
            "type": "string"
          },
          "scope": {
            "type": "string",
            "enum": [
              "full",
              "replies"
            ]
          },
          "lastUsedAt": {
            "anyOf": [
              {
                "type": "string",
                "description": "ISO 8601 timestamp"
              },
              {
                "type": "null"
              }
            ]
          },
          "createdAt": {
            "type": "string",
            "description": "ISO 8601 timestamp"
          }
        },
        "required": [
          "id",
          "name",
          "prefix",
          "scope",
          "lastUsedAt",
          "createdAt"
        ]
      },
      "Billing": {
        "$ref": "#/components/schemas/Billing"
      },
      "Column": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": [
              "text",
              "number",
              "email",
              "url",
              "boolean",
              "json"
            ]
          },
          "prompt": {
            "type": "string"
          }
        },
        "required": [
          "key",
          "name",
          "type"
        ]
      },
      "ConnectedApp": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "userEmail": {
            "type": "string"
          },
          "createdAt": {
            "type": "string",
            "description": "ISO 8601 timestamp"
          },
          "lastUsedAt": {
            "anyOf": [
              {
                "type": "string",
                "description": "ISO 8601 timestamp"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "id",
          "name",
          "userEmail",
          "createdAt",
          "lastUsedAt"
        ]
      },
      "Credits": {
        "$ref": "#/components/schemas/Credits"
      },
      "CrmConnection": {
        "type": "object",
        "properties": {
          "provider": {
            "type": "string",
            "enum": [
              "hubspot",
              "attio"
            ]
          },
          "last4": {
            "type": "string"
          },
          "accountName": {
            "type": [
              "string",
              "null"
            ]
          },
          "autoSync": {
            "type": "boolean"
          },
          "lastSyncedAt": {
            "anyOf": [
              {
                "type": "string",
                "description": "ISO 8601 timestamp"
              },
              {
                "type": "null"
              }
            ]
          },
          "lastError": {
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "type": "string",
            "description": "ISO 8601 timestamp"
          }
        },
        "required": [
          "provider",
          "last4",
          "accountName",
          "autoSync",
          "lastSyncedAt",
          "lastError",
          "createdAt"
        ]
      },
      "CrmSyncResult": {
        "$ref": "#/components/schemas/CrmSyncResult"
      },
      "DomainHealth": {
        "type": "object",
        "properties": {
          "domain": {
            "type": "string"
          },
          "spf": {
            "type": "string",
            "enum": [
              "pass",
              "missing",
              "managed"
            ]
          },
          "dkim": {
            "type": "string",
            "enum": [
              "pass",
              "missing",
              "managed"
            ]
          },
          "dmarc": {
            "type": "string",
            "enum": [
              "pass",
              "missing",
              "managed"
            ]
          }
        },
        "required": [
          "domain",
          "spf",
          "dkim",
          "dmarc"
        ]
      },
      "Draft": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "body": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "sent",
              "discarded"
            ]
          },
          "updatedAt": {
            "type": "string",
            "description": "ISO 8601 timestamp"
          },
          "replyId": {
            "type": "string"
          },
          "to": {
            "type": "string"
          },
          "replySubject": {
            "type": [
              "string",
              "null"
            ]
          },
          "replyBody": {
            "type": "string"
          },
          "intent": {
            "type": [
              "string",
              "null"
            ]
          },
          "row": {
            "anyOf": [
              {
                "type": "object",
                "propertyNames": {
                  "type": "string"
                },
                "additionalProperties": {}
              },
              {
                "type": "null"
              }
            ]
          },
          "thread": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "direction": {
                  "type": "string",
                  "enum": [
                    "in",
                    "out"
                  ]
                },
                "step": {
                  "type": [
                    "number",
                    "null"
                  ]
                },
                "subject": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "body": {
                  "type": "string"
                },
                "sentAt": {
                  "type": "string",
                  "description": "ISO 8601 timestamp"
                }
              },
              "required": [
                "id",
                "direction",
                "step",
                "subject",
                "body",
                "sentAt"
              ]
            }
          }
        },
        "required": [
          "id",
          "body",
          "status",
          "updatedAt",
          "replyId",
          "to",
          "replySubject",
          "replyBody",
          "intent",
          "row",
          "thread"
        ]
      },
      "EnrichResult": {
        "$ref": "#/components/schemas/EnrichResult"
      },
      "EnrollResult": {
        "$ref": "#/components/schemas/EnrollResult"
      },
      "Icp": {
        "$ref": "#/components/schemas/Icp"
      },
      "IcpFit": {
        "type": "object",
        "properties": {
          "score": {
            "description": "0-100; null without an ICP or data to compare",
            "type": [
              "number",
              "null"
            ]
          },
          "base": {
            "description": "The rules-only score, before the agent's adjustment",
            "type": [
              "number",
              "null"
            ]
          },
          "checks": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "criterion": {
                  "type": "string",
                  "enum": [
                    "industry",
                    "headcount",
                    "country",
                    "title",
                    "keywords",
                    "exclude"
                  ]
                },
                "matched": {
                  "type": "boolean"
                },
                "detail": {
                  "type": "string"
                }
              },
              "required": [
                "criterion",
                "matched",
                "detail"
              ]
            }
          },
          "adjust": {
            "type": [
              "number",
              "null"
            ]
          },
          "note": {
            "type": [
              "string",
              "null"
            ]
          },
          "reason": {
            "description": "One line on why: the agent's note, else what matched and what didn't",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "score",
          "base",
          "checks",
          "adjust",
          "note",
          "reason"
        ]
      },
      "Mailbox": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "provider": {
            "type": "string",
            "enum": [
              "gmail",
              "gmail_imap",
              "imap",
              "outlook"
            ]
          },
          "email": {
            "type": "string"
          },
          "login": {
            "type": [
              "string",
              "null"
            ]
          },
          "servers": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "imap": {
                    "type": "object",
                    "properties": {
                      "host": {
                        "type": "string"
                      },
                      "port": {
                        "type": "number"
                      }
                    },
                    "required": [
                      "host",
                      "port"
                    ]
                  },
                  "smtp": {
                    "type": "object",
                    "properties": {
                      "host": {
                        "type": "string"
                      },
                      "port": {
                        "type": "number"
                      }
                    },
                    "required": [
                      "host",
                      "port"
                    ]
                  }
                },
                "required": [
                  "imap",
                  "smtp"
                ]
              },
              {
                "type": "null"
              }
            ]
          },
          "displayName": {
            "type": [
              "string",
              "null"
            ]
          },
          "dailyLimit": {
            "type": "number"
          },
          "rampStartedAt": {
            "anyOf": [
              {
                "type": "string",
                "description": "ISO 8601 timestamp"
              },
              {
                "type": "null"
              }
            ]
          },
          "effectiveLimit": {
            "type": "number",
            "description": "What it may send in the next 24 hours: lower than dailyLimit while ramping"
          },
          "rampDay": {
            "type": [
              "number",
              "null"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "error"
            ]
          },
          "lastError": {
            "type": [
              "string",
              "null"
            ]
          },
          "heldAt": {
            "anyOf": [
              {
                "type": "string",
                "description": "ISO 8601 timestamp"
              },
              {
                "type": "null"
              }
            ],
            "description": "Set while Meerko holds the mailbox for bounces or spam rejections: it sends nothing until resumed"
          },
          "holdReason": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "bounces",
                  "rejections"
                ]
              },
              {
                "type": "null"
              }
            ]
          },
          "holdDetail": {
            "description": "What tripped the hold, e.g. \"6 hard bounces in 80 emails over 7 days (7.5%)\"",
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "type": "string",
            "description": "ISO 8601 timestamp"
          }
        },
        "required": [
          "id",
          "provider",
          "email",
          "login",
          "servers",
          "displayName",
          "dailyLimit",
          "rampStartedAt",
          "effectiveLimit",
          "rampDay",
          "status",
          "lastError",
          "heldAt",
          "holdReason",
          "holdDetail",
          "createdAt"
        ]
      },
      "Me": {
        "$ref": "#/components/schemas/Me"
      },
      "PendingCells": {
        "$ref": "#/components/schemas/PendingCells"
      },
      "PendingEmail": {
        "type": "object",
        "properties": {
          "enrollment_id": {
            "type": "string"
          },
          "sequence_id": {
            "type": "string"
          },
          "sequence_name": {
            "type": "string"
          },
          "to": {
            "type": "string"
          },
          "step": {
            "type": "number"
          },
          "subject": {
            "type": "string"
          },
          "body": {
            "type": "string"
          },
          "send_at": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "enrollment_id",
          "sequence_id",
          "sequence_name",
          "to",
          "step",
          "subject",
          "body",
          "send_at"
        ]
      },
      "Pipeline": {
        "$ref": "#/components/schemas/Pipeline"
      },
      "ProviderKey": {
        "type": "object",
        "properties": {
          "provider": {
            "type": "string"
          },
          "last4": {
            "type": "string"
          },
          "createdAt": {
            "type": "string",
            "description": "ISO 8601 timestamp"
          }
        },
        "required": [
          "provider",
          "last4",
          "createdAt"
        ]
      },
      "Recipient": {
        "type": "object",
        "properties": {
          "enrollmentId": {
            "type": "string"
          },
          "rowId": {
            "type": "string"
          },
          "email": {
            "type": "string"
          },
          "firstName": {
            "type": [
              "string",
              "null"
            ]
          },
          "lastName": {
            "type": [
              "string",
              "null"
            ]
          },
          "company": {
            "type": [
              "string",
              "null"
            ]
          },
          "mailboxEmail": {
            "type": [
              "string",
              "null"
            ]
          },
          "state": {
            "type": "string",
            "enum": [
              "active",
              "completed",
              "replied",
              "unsubscribed",
              "bounced",
              "stopped",
              "failed"
            ]
          },
          "stepsSent": {
            "type": "number"
          },
          "nextSendAt": {
            "anyOf": [
              {
                "type": "string",
                "description": "ISO 8601 timestamp"
              },
              {
                "type": "null"
              }
            ]
          },
          "lastError": {
            "type": [
              "string",
              "null"
            ]
          },
          "lastSentAt": {
            "anyOf": [
              {
                "type": "string",
                "description": "ISO 8601 timestamp"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "enrollmentId",
          "rowId",
          "email",
          "firstName",
          "lastName",
          "company",
          "mailboxEmail",
          "state",
          "stepsSent",
          "nextSendAt",
          "lastError",
          "lastSentAt"
        ]
      },
      "Reply": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "from": {
            "type": "string"
          },
          "subject": {
            "type": [
              "string",
              "null"
            ]
          },
          "body": {
            "type": "string"
          },
          "intent": {
            "type": [
              "string",
              "null"
            ]
          },
          "receivedAt": {
            "type": "string",
            "description": "ISO 8601 timestamp"
          },
          "handledAt": {
            "anyOf": [
              {
                "type": "string",
                "description": "ISO 8601 timestamp"
              },
              {
                "type": "null"
              }
            ]
          },
          "sequenceId": {
            "type": [
              "string",
              "null"
            ]
          },
          "sequenceName": {
            "type": [
              "string",
              "null"
            ]
          },
          "row": {
            "anyOf": [
              {
                "type": "object",
                "propertyNames": {
                  "type": "string"
                },
                "additionalProperties": {}
              },
              {
                "type": "null"
              }
            ]
          },
          "thread": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "direction": {
                  "type": "string",
                  "enum": [
                    "in",
                    "out"
                  ]
                },
                "step": {
                  "type": [
                    "number",
                    "null"
                  ]
                },
                "subject": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "body": {
                  "type": "string"
                },
                "sentAt": {
                  "type": "string",
                  "description": "ISO 8601 timestamp"
                }
              },
              "required": [
                "id",
                "direction",
                "step",
                "subject",
                "body",
                "sentAt"
              ]
            }
          }
        },
        "required": [
          "id",
          "from",
          "subject",
          "body",
          "intent",
          "receivedAt",
          "handledAt",
          "sequenceId",
          "sequenceName",
          "row",
          "thread"
        ]
      },
      "Routine": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "brief": {
            "type": "string"
          },
          "when": {
            "type": "string",
            "enum": [
              "replies",
              "schedule"
            ]
          },
          "cadence": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "days": {
                    "minItems": 1,
                    "type": "array",
                    "items": {
                      "type": "integer",
                      "minimum": 1,
                      "maximum": 7
                    },
                    "description": "ISO weekdays: 1 = Monday … 7 = Sunday"
                  },
                  "time": {
                    "type": "string",
                    "description": "HH:MM, 24-hour, in `timezone`"
                  },
                  "timezone": {
                    "type": "string",
                    "description": "IANA zone, e.g. Europe/Madrid"
                  }
                },
                "required": [
                  "days",
                  "time",
                  "timezone"
                ],
                "description": "When a scheduled routine is due"
              },
              {
                "type": "null"
              }
            ]
          },
          "schedule": {
            "type": "string",
            "description": "In words: \"Weekdays at 09:00 (Europe/Madrid)\""
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "paused"
            ]
          },
          "statusReason": {
            "type": [
              "string",
              "null"
            ]
          },
          "trigger": {
            "type": "string",
            "enum": [
              "own_scheduler",
              "claude_routine",
              "chatgpt_events",
              "webhook"
            ]
          },
          "triggerUrl": {
            "type": [
              "string",
              "null"
            ]
          },
          "secretLast4": {
            "type": [
              "string",
              "null"
            ]
          },
          "needsSetup": {
            "type": "boolean"
          },
          "nextDueAt": {
            "anyOf": [
              {
                "type": "string",
                "description": "ISO 8601 timestamp"
              },
              {
                "type": "null"
              }
            ]
          },
          "lastFiredAt": {
            "anyOf": [
              {
                "type": "string",
                "description": "ISO 8601 timestamp"
              },
              {
                "type": "null"
              }
            ]
          },
          "lastError": {
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "type": "string",
            "description": "ISO 8601 timestamp"
          },
          "updatedAt": {
            "type": "string",
            "description": "ISO 8601 timestamp"
          },
          "runs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RoutineRun"
            },
            "description": "The latest runs, newest first"
          },
          "setup": {
            "$ref": "#/components/schemas/RoutineSetup"
          }
        },
        "required": [
          "id",
          "name",
          "brief",
          "when",
          "cadence",
          "schedule",
          "status",
          "statusReason",
          "trigger",
          "triggerUrl",
          "secretLast4",
          "needsSetup",
          "nextDueAt",
          "lastFiredAt",
          "lastError",
          "createdAt",
          "updatedAt",
          "runs",
          "setup"
        ]
      },
      "RoutineRun": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "dueAt": {
            "anyOf": [
              {
                "type": "string",
                "description": "ISO 8601 timestamp"
              },
              {
                "type": "null"
              }
            ],
            "description": "The scheduled time it ran for; null for replies, Run it now and runs the AI started itself"
          },
          "reason": {
            "type": "string",
            "description": "`schedule`, `replies`, `manual` (Run it now) or `ai`"
          },
          "outcome": {
            "type": "string",
            "enum": [
              "firing",
              "fired",
              "fire_failed",
              "ran",
              "missed",
              "no_callback"
            ]
          },
          "firedAt": {
            "anyOf": [
              {
                "type": "string",
                "description": "ISO 8601 timestamp"
              },
              {
                "type": "null"
              }
            ]
          },
          "startedAt": {
            "anyOf": [
              {
                "type": "string",
                "description": "ISO 8601 timestamp"
              },
              {
                "type": "null"
              }
            ],
            "description": "When the AI checked in with start_routine_run"
          },
          "httpStatus": {
            "type": [
              "number",
              "null"
            ]
          },
          "error": {
            "type": [
              "string",
              "null"
            ]
          },
          "replies": {
            "type": [
              "number",
              "null"
            ]
          },
          "sessionUrl": {
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "type": "string",
            "description": "ISO 8601 timestamp"
          }
        },
        "required": [
          "id",
          "dueAt",
          "reason",
          "outcome",
          "firedAt",
          "startedAt",
          "httpStatus",
          "error",
          "replies",
          "sessionUrl",
          "createdAt"
        ]
      },
      "RoutineSetup": {
        "type": "object",
        "properties": {
          "howItRuns": {
            "type": "string"
          },
          "prompt": {
            "type": "string"
          },
          "setupPrompt": {
            "type": "string"
          },
          "steps": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "client": {
                  "type": "string"
                },
                "text": {
                  "type": "string"
                }
              },
              "required": [
                "client",
                "text"
              ]
            }
          }
        },
        "required": [
          "howItRuns"
        ]
      },
      "RoutineStart": {
        "$ref": "#/components/schemas/RoutineStart"
      },
      "Row": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "data": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {}
          },
          "stage": {
            "type": "string",
            "enum": [
              "new",
              "contacted",
              "replied",
              "meeting",
              "won",
              "lost"
            ]
          },
          "stageChangedAt": {
            "anyOf": [
              {
                "type": "string",
                "description": "ISO 8601 timestamp"
              },
              {
                "type": "null"
              }
            ]
          },
          "createdAt": {
            "type": "string",
            "description": "ISO 8601 timestamp"
          },
          "icp": {
            "description": "How well the lead fits the workspace ICP",
            "$ref": "#/components/schemas/IcpFit"
          }
        },
        "required": [
          "id",
          "data",
          "stage",
          "stageChangedAt",
          "createdAt",
          "icp"
        ]
      },
      "SearchResult": {
        "$ref": "#/components/schemas/SearchResult"
      },
      "SendingMode": {
        "type": "object",
        "properties": {
          "sequence_emails": {
            "type": "string",
            "enum": [
              "approve",
              "auto"
            ]
          },
          "reply_drafts": {
            "type": "string",
            "enum": [
              "approve",
              "auto"
            ]
          }
        },
        "required": [
          "sequence_emails",
          "reply_drafts"
        ]
      },
      "Sequence": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "active",
              "paused"
            ]
          },
          "tableId": {
            "type": "string"
          },
          "mailboxIds": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "assignment": {
            "type": "string",
            "enum": [
              "capacity",
              "even"
            ]
          },
          "timezone": {
            "type": "string"
          },
          "windowStartHour": {
            "type": "number"
          },
          "windowEndHour": {
            "type": "number"
          },
          "steps": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "position": {
                  "type": "number"
                },
                "delayDays": {
                  "type": "number"
                },
                "subject": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "body": {
                  "type": "string"
                }
              },
              "required": [
                "position",
                "delayDays",
                "subject",
                "body"
              ]
            }
          }
        },
        "required": [
          "id",
          "name",
          "status",
          "tableId",
          "mailboxIds",
          "assignment",
          "timezone",
          "windowStartHour",
          "windowEndHour",
          "steps"
        ]
      },
      "SequencePool": {
        "$ref": "#/components/schemas/SequencePool"
      },
      "SequencePreview": {
        "$ref": "#/components/schemas/SequencePreview"
      },
      "SequenceStats": {
        "$ref": "#/components/schemas/SequenceStats"
      },
      "SequenceSummary": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "active",
              "paused"
            ]
          },
          "tableId": {
            "type": "string"
          },
          "mailboxIds": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "assignment": {
            "type": "string",
            "enum": [
              "capacity",
              "even"
            ]
          },
          "enrolled": {
            "type": "number"
          }
        },
        "required": [
          "id",
          "name",
          "status",
          "tableId",
          "mailboxIds",
          "assignment",
          "enrolled"
        ]
      },
      "SlackConnection": {
        "type": "object",
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "app",
              "webhook"
            ]
          },
          "teamName": {
            "type": [
              "string",
              "null"
            ]
          },
          "channelName": {
            "type": [
              "string",
              "null"
            ]
          },
          "enabled": {
            "type": "boolean"
          },
          "lastPostedAt": {
            "anyOf": [
              {
                "type": "string",
                "description": "ISO 8601 timestamp"
              },
              {
                "type": "null"
              }
            ]
          },
          "lastError": {
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "type": "string",
            "description": "ISO 8601 timestamp"
          }
        },
        "required": [
          "kind",
          "teamName",
          "channelName",
          "enabled",
          "lastPostedAt",
          "lastError",
          "createdAt"
        ]
      },
      "Table": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "columns": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Column"
            }
          },
          "rowCount": {
            "type": "number"
          },
          "createdAt": {
            "type": "string",
            "description": "ISO 8601 timestamp"
          }
        },
        "required": [
          "id",
          "name",
          "columns",
          "rowCount",
          "createdAt"
        ]
      },
      "Url": {
        "$ref": "#/components/schemas/Url"
      },
      "Website": {
        "$ref": "#/components/schemas/Website"
      },
      "WorkspaceListItem": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "role": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "owner",
                  "member"
                ]
              },
              {
                "type": "null"
              }
            ],
            "description": "Null for an API key, which belongs to the workspace rather than a person"
          },
          "current": {
            "type": "boolean",
            "description": "The workspace this credential acts on now"
          }
        },
        "required": [
          "id",
          "name",
          "role",
          "current"
        ]
      }
    }
  }
}
