{
  "openapi": "3.1.0",
  "info": {
    "description": "Versioned REST contract for NoxCRM. Responses use the standard success/error envelope and include request metadata.",
    "title": "NoxCRM API",
    "version": "1.0.0"
  },
  "servers": [
    {
      "description": "Local development",
      "url": "http://localhost:8080/api/v1"
    },
    {
      "description": "Staging",
      "url": "https://noxcrm-api-staging.noxorigin.com/api/v1"
    },
    {
      "description": "Production",
      "url": "https://noxcrm-api.noxorigin.com/api/v1"
    }
  ],
  "paths": {
    "/agency/clients": {
      "get": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "List agency clients",
        "tags": [
          "Agency"
        ]
      },
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Link an agency client",
        "tags": [
          "Agency"
        ]
      }
    },
    "/auth/2fa/confirm": {
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Confirm TOTP setup",
        "tags": [
          "Authentication"
        ]
      }
    },
    "/auth/2fa/disable": {
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Disable TOTP 2FA",
        "tags": [
          "Authentication"
        ]
      }
    },
    "/auth/2fa/setup": {
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Set up TOTP 2FA",
        "tags": [
          "Authentication"
        ]
      }
    },
    "/auth/api-tokens": {
      "get": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "List API tokens",
        "tags": [
          "Authentication"
        ]
      },
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Create an API token",
        "tags": [
          "Authentication"
        ]
      }
    },
    "/auth/api-tokens/{jti}": {
      "delete": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Revoke an API token",
        "tags": [
          "Authentication"
        ]
      }
    },
    "/auth/email/verify": {
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [],
        "summary": "Verify an email address using a one-time token",
        "tags": [
          "Authentication"
        ]
      }
    },
    "/auth/email/verify-request": {
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [],
        "summary": "Request or resend an email verification link",
        "tags": [
          "Authentication"
        ]
      }
    },
    "/auth/login": {
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [],
        "summary": "Log in with email + password",
        "tags": [
          "Authentication"
        ]
      }
    },
    "/auth/logout": {
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Revoke the current session",
        "tags": [
          "Authentication"
        ]
      }
    },
    "/auth/magic-link/request": {
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [],
        "summary": "Request a passwordless sign-in link",
        "tags": [
          "Authentication"
        ]
      }
    },
    "/auth/magic-link/verify": {
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [],
        "summary": "Exchange a magic-link token for a session",
        "tags": [
          "Authentication"
        ]
      }
    },
    "/auth/otp/request": {
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [],
        "summary": "Request a one-time passcode",
        "tags": [
          "Authentication"
        ]
      }
    },
    "/auth/otp/verify": {
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [],
        "summary": "Verify a one-time passcode",
        "tags": [
          "Authentication"
        ]
      }
    },
    "/auth/passkeys": {
      "get": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "List registered passkeys",
        "tags": [
          "Authentication"
        ]
      },
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Register a passkey",
        "tags": [
          "Authentication"
        ]
      }
    },
    "/auth/passkeys/register/challenge": {
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Start passkey registration",
        "tags": [
          "Authentication"
        ]
      }
    },
    "/auth/passkeys/{id}": {
      "delete": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Remove a passkey",
        "tags": [
          "Authentication"
        ]
      }
    },
    "/auth/password/change": {
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Change password (authenticated)",
        "tags": [
          "Authentication"
        ]
      }
    },
    "/auth/password/reset": {
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [],
        "summary": "Reset password via OTP",
        "tags": [
          "Authentication"
        ]
      }
    },
    "/auth/public-signup": {
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [],
        "summary": "Create a workspace and owner account with email verification",
        "tags": [
          "Authentication"
        ]
      }
    },
    "/auth/refresh": {
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [],
        "summary": "Refresh an expired access token",
        "tags": [
          "Authentication"
        ]
      }
    },
    "/auth/sessions": {
      "delete": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Revoke all refresh-token sessions for the account",
        "tags": [
          "Authentication"
        ]
      },
      "get": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "List active sessions",
        "tags": [
          "Authentication"
        ]
      }
    },
    "/auth/sessions/{id}": {
      "delete": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Revoke a specific session",
        "tags": [
          "Authentication"
        ]
      }
    },
    "/auth/signup": {
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [],
        "summary": "Create a new account",
        "tags": [
          "Authentication"
        ]
      }
    },
    "/blueprints": {
      "get": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "List available blueprints",
        "tags": [
          "Blueprints"
        ]
      },
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Create a blueprint",
        "tags": [
          "Blueprints"
        ]
      }
    },
    "/blueprints/{id}": {
      "get": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Get blueprint details",
        "tags": [
          "Blueprints"
        ]
      }
    },
    "/blueprints/{id}/install": {
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Install a blueprint",
        "tags": [
          "Blueprints"
        ]
      }
    },
    "/blueprints/{id}/installations": {
      "get": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "List blueprint installations",
        "tags": [
          "Blueprints"
        ]
      }
    },
    "/contacts": {
      "get": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "List contacts with search and filtering",
        "tags": [
          "Contacts"
        ]
      },
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Create a contact",
        "tags": [
          "Contacts"
        ]
      }
    },
    "/contacts/{id}": {
      "delete": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Delete a contact",
        "tags": [
          "Contacts"
        ]
      },
      "get": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Get a contact by ID",
        "tags": [
          "Contacts"
        ]
      },
      "patch": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Update a contact",
        "tags": [
          "Contacts"
        ]
      }
    },
    "/contacts/{id}/ai-summary": {
      "get": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Get AI-generated contact summary",
        "tags": [
          "Contacts"
        ]
      }
    },
    "/contacts/{id}/assign": {
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Assign or unassign a contact owner",
        "tags": [
          "Contacts"
        ]
      }
    },
    "/contacts/{id}/custom-fields": {
      "get": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "List custom field values for a contact",
        "tags": [
          "Custom Fields"
        ]
      },
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Upsert a custom field value for a contact",
        "tags": [
          "Custom Fields"
        ]
      }
    },
    "/contacts/{id}/custom-fields/{value_id}": {
      "delete": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Delete a custom field value",
        "tags": [
          "Custom Fields"
        ]
      }
    },
    "/contacts/{id}/enrichment": {
      "get": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Get contact enrichment data",
        "tags": [
          "Contacts"
        ]
      },
      "put": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Upsert contact enrichment data",
        "tags": [
          "Contacts"
        ]
      }
    },
    "/contacts/{id}/events": {
      "get": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "List contact events",
        "tags": [
          "Contacts"
        ]
      },
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Create a contact event",
        "tags": [
          "Contacts"
        ]
      }
    },
    "/contacts/{id}/interactions": {
      "get": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "List contact interactions",
        "tags": [
          "Contacts"
        ]
      },
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Log a contact interaction",
        "tags": [
          "Contacts"
        ]
      }
    },
    "/contacts/{id}/next-action": {
      "get": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Get AI-suggested next action",
        "tags": [
          "Contacts"
        ]
      }
    },
    "/contacts/{id}/relationship": {
      "get": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Get AI-assessed relationship strength",
        "tags": [
          "Contacts"
        ]
      }
    },
    "/contacts/{id}/risks": {
      "get": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Get AI-identified risk factors",
        "tags": [
          "Contacts"
        ]
      }
    },
    "/contacts/{id}/tags": {
      "get": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "List tags attached to a contact",
        "tags": [
          "Contacts"
        ]
      }
    },
    "/contacts/{id}/tags/{tag_id}": {
      "delete": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Detach a tag from a contact",
        "tags": [
          "Contacts"
        ]
      },
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Attach a tag to a contact",
        "tags": [
          "Contacts"
        ]
      }
    },
    "/contacts/{id}/timeline": {
      "get": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Get contact timeline",
        "tags": [
          "Contacts"
        ]
      }
    },
    "/custom-fields/definitions": {
      "get": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "List custom field definitions",
        "tags": [
          "Custom Fields"
        ]
      },
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Create a custom field definition",
        "tags": [
          "Custom Fields"
        ]
      }
    },
    "/custom-fields/definitions/{id}": {
      "delete": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Delete a custom field definition",
        "tags": [
          "Custom Fields"
        ]
      },
      "patch": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Update a custom field definition",
        "tags": [
          "Custom Fields"
        ]
      }
    },
    "/deals": {
      "get": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "List deals with filtering",
        "tags": [
          "Deals"
        ]
      },
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Create a deal",
        "tags": [
          "Deals"
        ]
      }
    },
    "/deals/{id}": {
      "patch": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Update a deal",
        "tags": [
          "Deals"
        ]
      }
    },
    "/deals/{id}/history": {
      "get": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Get deal stage change history",
        "tags": [
          "Deals"
        ]
      }
    },
    "/deals/{id}/probability": {
      "get": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Get AI-predicted close probability",
        "tags": [
          "Deals"
        ]
      }
    },
    "/deals/{id}/stage": {
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Move a deal to a different stage",
        "tags": [
          "Deals"
        ]
      }
    },
    "/forms": {
      "get": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "List forms",
        "tags": [
          "Forms"
        ]
      },
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Create a form",
        "tags": [
          "Forms"
        ]
      }
    },
    "/forms/s/{slug}": {
      "get": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [],
        "summary": "Get a public form by slug",
        "tags": [
          "Forms"
        ]
      }
    },
    "/forms/s/{slug}/submit": {
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [],
        "summary": "Submit a form (public, no auth)",
        "tags": [
          "Forms"
        ]
      }
    },
    "/forms/{id}": {
      "get": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Get a form by ID",
        "tags": [
          "Forms"
        ]
      },
      "patch": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Update a form",
        "tags": [
          "Forms"
        ]
      }
    },
    "/forms/{id}/fields": {
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Add a field to a form",
        "tags": [
          "Forms"
        ]
      }
    },
    "/forms/{id}/submit": {
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Submit a form (authenticated)",
        "tags": [
          "Forms"
        ]
      }
    },
    "/health": {
      "get": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [],
        "summary": "Health check — returns OK when the service is running",
        "tags": [
          "Health & Infrastructure"
        ]
      }
    },
    "/inbox/conversations": {
      "get": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "List conversations",
        "tags": [
          "Inbox & Conversations"
        ]
      },
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Create a conversation",
        "tags": [
          "Inbox & Conversations"
        ]
      }
    },
    "/inbox/conversations/{id}": {
      "patch": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Update a conversation",
        "tags": [
          "Inbox & Conversations"
        ]
      }
    },
    "/inbox/conversations/{id}/messages": {
      "get": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "List messages in a conversation",
        "tags": [
          "Inbox & Conversations"
        ]
      },
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Send a message in a conversation",
        "tags": [
          "Inbox & Conversations"
        ]
      }
    },
    "/lead-sources": {
      "get": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "List lead sources",
        "tags": [
          "Leads & Lead Sources"
        ]
      },
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Create a lead source",
        "tags": [
          "Leads & Lead Sources"
        ]
      }
    },
    "/lead-sources/{id}": {
      "delete": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Delete a lead source",
        "tags": [
          "Leads & Lead Sources"
        ]
      },
      "patch": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Update a lead source",
        "tags": [
          "Leads & Lead Sources"
        ]
      }
    },
    "/leads/capture": {
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [],
        "summary": "Capture a lead (public form submission)",
        "tags": [
          "Leads & Lead Sources"
        ]
      }
    },
    "/leads/submissions": {
      "get": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "List lead submissions",
        "tags": [
          "Leads & Lead Sources"
        ]
      }
    },
    "/me": {
      "get": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Get the current user's profile",
        "tags": [
          "Profile"
        ]
      },
      "patch": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Update the current user's profile",
        "tags": [
          "Profile"
        ]
      },
      "put": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Replace the current user's profile",
        "tags": [
          "Profile"
        ]
      }
    },
    "/metrics/forecast": {
      "get": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Get revenue forecast",
        "tags": [
          "Metrics & Forecasting"
        ]
      }
    },
    "/metrics/pipeline": {
      "get": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Get pipeline metrics summary",
        "tags": [
          "Metrics & Forecasting"
        ]
      }
    },
    "/metrics/pipeline/history": {
      "get": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Get pipeline metrics over time",
        "tags": [
          "Metrics & Forecasting"
        ]
      }
    },
    "/pipeline-stages/{id}": {
      "delete": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Delete a pipeline stage",
        "tags": [
          "Pipelines & Stages"
        ]
      },
      "patch": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Update a pipeline stage",
        "tags": [
          "Pipelines & Stages"
        ]
      }
    },
    "/pipelines": {
      "get": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "List pipelines",
        "tags": [
          "Pipelines & Stages"
        ]
      },
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Create a pipeline",
        "tags": [
          "Pipelines & Stages"
        ]
      }
    },
    "/pipelines/{id}": {
      "delete": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Delete a pipeline",
        "tags": [
          "Pipelines & Stages"
        ]
      },
      "patch": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Update a pipeline",
        "tags": [
          "Pipelines & Stages"
        ]
      }
    },
    "/pipelines/{id}/stages": {
      "get": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "List pipeline stages",
        "tags": [
          "Pipelines & Stages"
        ]
      },
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Create a pipeline stage",
        "tags": [
          "Pipelines & Stages"
        ]
      }
    },
    "/pipelines/{id}/stages/reorder": {
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Reorder pipeline stages",
        "tags": [
          "Pipelines & Stages"
        ]
      }
    },
    "/public-platform/oauth/apps": {
      "get": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "List OAuth apps",
        "tags": [
          "Public Platform — OAuth & Webhooks"
        ]
      },
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Create an OAuth app",
        "tags": [
          "Public Platform — OAuth & Webhooks"
        ]
      }
    },
    "/public-platform/oauth/revoke": {
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [],
        "summary": "Revoke an OAuth token",
        "tags": [
          "Public Platform — OAuth & Webhooks"
        ]
      }
    },
    "/public-platform/oauth/token": {
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [],
        "summary": "Issue an OAuth token",
        "tags": [
          "Public Platform — OAuth & Webhooks"
        ]
      }
    },
    "/public-platform/webhooks/deliveries": {
      "get": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "List webhook deliveries",
        "tags": [
          "Public Platform — OAuth & Webhooks"
        ]
      }
    },
    "/public-platform/webhooks/deliveries/{id}/attempt": {
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "View delivery attempt details",
        "tags": [
          "Public Platform — OAuth & Webhooks"
        ]
      }
    },
    "/public-platform/webhooks/deliveries/{id}/replay": {
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Replay a webhook delivery",
        "tags": [
          "Public Platform — OAuth & Webhooks"
        ]
      }
    },
    "/public-platform/webhooks/endpoints": {
      "get": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "List webhook endpoints",
        "tags": [
          "Public Platform — OAuth & Webhooks"
        ]
      },
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Create a webhook endpoint",
        "tags": [
          "Public Platform — OAuth & Webhooks"
        ]
      }
    },
    "/public-platform/webhooks/test-delivery": {
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Trigger a test webhook delivery",
        "tags": [
          "Public Platform — OAuth & Webhooks"
        ]
      }
    },
    "/ready": {
      "get": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [],
        "summary": "Readiness check — verifies DB connectivity",
        "tags": [
          "Health & Infrastructure"
        ]
      }
    },
    "/realtime/stream": {
      "get": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Subscribe to real-time events via SSE",
        "tags": [
          "Realtime Events (SSE)"
        ]
      }
    },
    "/tags": {
      "get": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "List tags",
        "tags": [
          "Tags"
        ]
      },
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Create a tag",
        "tags": [
          "Tags"
        ]
      }
    },
    "/tags/{id}": {
      "delete": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Delete a tag",
        "tags": [
          "Tags"
        ]
      },
      "patch": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Update a tag",
        "tags": [
          "Tags"
        ]
      }
    },
    "/tasks/queue": {
      "get": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "List task queue items",
        "tags": [
          "Task Queue"
        ]
      },
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Create a task queue item",
        "tags": [
          "Task Queue"
        ]
      }
    },
    "/tasks/queue/{id}": {
      "patch": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Update a task queue item",
        "tags": [
          "Task Queue"
        ]
      }
    },
    "/users": {
      "get": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "List all users in the tenant",
        "tags": [
          "Users"
        ]
      }
    },
    "/workflows": {
      "get": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "List workflows",
        "tags": [
          "Workflows & Automation"
        ]
      },
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Create a workflow",
        "tags": [
          "Workflows & Automation"
        ]
      }
    },
    "/workflows/dlq": {
      "get": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "List dead-letter queue items",
        "tags": [
          "Workflows & Automation"
        ]
      }
    },
    "/workflows/dlq/replay": {
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Replay dead-letter queue items",
        "tags": [
          "Workflows & Automation"
        ]
      }
    },
    "/workflows/runs": {
      "get": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "List recent workflow runs",
        "tags": [
          "Workflows & Automation"
        ]
      }
    },
    "/workflows/runs/{run_id}": {
      "get": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Get workflow run details",
        "tags": [
          "Workflows & Automation"
        ]
      }
    },
    "/workflows/{workflow_id}": {
      "get": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Get a workflow by ID",
        "tags": [
          "Workflows & Automation"
        ]
      }
    },
    "/workflows/{workflow_id}/disable": {
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Disable a workflow",
        "tags": [
          "Workflows & Automation"
        ]
      }
    },
    "/workflows/{workflow_id}/enable": {
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Enable a workflow",
        "tags": [
          "Workflows & Automation"
        ]
      }
    },
    "/workflows/{workflow_id}/publish": {
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Publish a workflow",
        "tags": [
          "Workflows & Automation"
        ]
      }
    },
    "/workflows/{workflow_id}/run": {
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Manually trigger a workflow run",
        "tags": [
          "Workflows & Automation"
        ]
      }
    },
    "/workflows/{workflow_id}/test": {
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Test a workflow",
        "tags": [
          "Workflows & Automation"
        ]
      }
    },
    "/workflows/{workflow_id}/webhook": {
      "post": {
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Error response"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Trigger a workflow via webhook",
        "tags": [
          "Workflows & Automation"
        ]
      }
    }
  },
  "components": {
    "schemas": {
      "ErrorEnvelope": {
        "properties": {
          "error": {
            "properties": {
              "code": {
                "type": "string"
              },
              "details": {
                "items": {
                  "type": "object"
                },
                "type": "array"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "code",
              "message"
            ],
            "type": "object"
          },
          "meta": {
            "$ref": "#/components/schemas/ResponseMeta"
          },
          "success": {
            "const": false,
            "type": "boolean"
          }
        },
        "required": [
          "success",
          "error",
          "meta"
        ],
        "type": "object"
      },
      "ResponseMeta": {
        "properties": {
          "apiVersion": {
            "type": "string"
          },
          "requestId": {
            "type": "string"
          },
          "timestamp": {
            "format": "date-time",
            "type": "string"
          }
        },
        "required": [
          "requestId",
          "apiVersion",
          "timestamp"
        ],
        "type": "object"
      }
    },
    "securitySchemes": {
      "bearerAuth": {
        "bearerFormat": "JWT",
        "scheme": "bearer",
        "type": "http"
      }
    }
  }
}