OpenAPI 3.1 64 operations

Braiventh CRM API

Local, dependency-free API reference. Browser routes use an HttpOnly session; integrations use scoped bearer API keys. Plaintext API keys and webhook secrets are displayed only by their creation responses and are never embedded here.

64 shown
GET /api/v1/activities

List immutable CRM activity records

Tag
Activities
Operation
listActivities
Auth
sessionbearer API keyactivities:read
Input
PagePageSizeSearchsortordereventTyperelatedEntityTyperelatedEntityIdcompanyIdcontactIdopportunityIdtaskId
Responses
200400401403422429500
GET /api/v1/activities/{id}

Get an immutable activity record

Tag
Activities
Operation
getActivity
Auth
sessionbearer API keyactivities:read
Input
Id
Responses
200400401403404422429500
GET /api/v1/api-keys

List API-key metadata

Stored digests and full API-key secrets are never returned.

Tag
API keys
Operation
listApiKeys
Auth
session
Input
PagePageSizeSearch
Responses
200400401403422429500
POST /api/v1/api-keys

Create an API key

The plaintext key is returned exactly once in this response. Store it securely.

Tag
API keys
Operation
createApiKey
Auth
session
Input
application/json body
Responses
201400401403409413415422429500
GET /api/v1/api-keys/{id}

Get API-key metadata

The plaintext key and stored digest are never returned.

Tag
API keys
Operation
getApiKey
Auth
session
Input
Id
Responses
200400401403404422429500
POST /api/v1/api-keys/{id}/revoke

Revoke an API key

Tag
API keys
Operation
revokeApiKey
Auth
session
Input
Id
Responses
200400401403404409422429500
POST /api/v1/auth/login

Create a browser session

Tag
Authentication
Operation
login
Auth
public
Input
application/json body
Responses
200400401403413415422429500
POST /api/v1/auth/logout

Destroy the current browser session

Revokes the presented session when one exists and always expires the browser cookie. A valid session is optional.

Tag
Authentication
Operation
logout
Auth
session
Responses
204400401403422429500
GET /api/v1/auth/me

Get the current session user

Tag
Authentication
Operation
getCurrentUser
Auth
session
Responses
200400401403422429500
GET /api/v1/auth/session

Get the current browser session

Alias of GET /api/v1/auth/me.

Tag
Authentication
Operation
getCurrentSession
Auth
session
Responses
200400401403422429500
DELETE /api/v1/auth/sessions/others

Revoke the current user's other browser sessions

Tag
Authentication
Operation
revokeOtherSessions
Auth
session
Responses
200400401403422429500
GET /api/v1/auth/setup

Check whether first-run setup is required

Tag
Authentication
Operation
getSetupStatus
Auth
public
Responses
200500
POST /api/v1/auth/setup

Create the first workspace administrator

Available only while the installation has no users and requires the installer-supplied one-time setup token.

Tag
Authentication
Operation
setupWorkspace
Auth
public
Input
application/json body
Responses
201400401403409413415422429500
GET /api/v1/companies

List companies

Tag
Companies
Operation
listCompanies
Auth
sessionbearer API keycompanies:read
Input
PagePageSizeSearchsortorderstatus
Responses
200400401403422429500
POST /api/v1/companies

Create company

Tag
Companies
Operation
createCompany
Auth
sessionbearer API keycompanies:write
Input
application/json body
Responses
201400401403409413415422429500
DELETE /api/v1/companies/{id}

Delete company

Tag
Companies
Operation
deleteCompany
Auth
sessionbearer API keycompanies:write
Input
Id
Responses
204400401403404409422429500
GET /api/v1/companies/{id}

Get company

Tag
Companies
Operation
getCompany
Auth
sessionbearer API keycompanies:read
Input
Id
Responses
200400401403404422429500
PATCH /api/v1/companies/{id}

Update company

Tag
Companies
Operation
updateCompany
Auth
sessionbearer API keycompanies:write
Input
Idapplication/json body
Responses
200400401403404409413415422429500
GET /api/v1/contacts

List contacts

Tag
Contacts
Operation
listContacts
Auth
sessionbearer API keycontacts:read
Input
PagePageSizeSearchsortordercompanyIdstatus
Responses
200400401403422429500
POST /api/v1/contacts

Create contact

Tag
Contacts
Operation
createContact
Auth
sessionbearer API keycontacts:write
Input
application/json body
Responses
201400401403409413415422429500
DELETE /api/v1/contacts/{id}

Delete contact

Tag
Contacts
Operation
deleteContact
Auth
sessionbearer API keycontacts:write
Input
Id
Responses
204400401403404409422429500
GET /api/v1/contacts/{id}

Get contact

Tag
Contacts
Operation
getContact
Auth
sessionbearer API keycontacts:read
Input
Id
Responses
200400401403404422429500
PATCH /api/v1/contacts/{id}

Update contact

Tag
Contacts
Operation
updateContact
Auth
sessionbearer API keycontacts:write
Input
Idapplication/json body
Responses
200400401403404409413415422429500
GET /api/v1/dashboard

Get CRM dashboard metrics

Tag
Dashboard
Operation
getDashboard
Auth
session
Responses
200400401403422429500
GET /api/v1/health

Liveness check

Reports whether the HTTP process is alive. This endpoint does not check dependencies.

Tag
System
Operation
getHealth
Auth
public
Responses
200500
POST /api/v1/integrations/website/opportunities

Ingest a website lead

Atomically creates or links the company and contact, creates an opportunity, and optionally creates a follow-up task. Idempotency records live for 24 hours: replaying the same key and normalized body returns the original IDs, while reusing a key with a different body returns 409. Requests are limited to 32 KiB and rate-limited per API key.

Tag
Website integration
Operation
ingestWebsiteOpportunity
Auth
bearer API keyopportunities:create
Input
IdempotencyKeyapplication/json body
Responses
200201400401403409413415422429500
GET /api/v1/notes

List notes

Tag
Notes
Operation
listNotes
Auth
session
Input
PagePageSizeSearchsortordercompanyIdcontactIdopportunityId
Responses
200400401403422429500
POST /api/v1/notes

Create note

Tag
Notes
Operation
createNote
Auth
session
Input
application/json body
Responses
201400401403409413415422429500
DELETE /api/v1/notes/{id}

Delete note

Tag
Notes
Operation
deleteNote
Auth
session
Input
Id
Responses
204400401403404409422429500
GET /api/v1/notes/{id}

Get note

Tag
Notes
Operation
getNote
Auth
session
Input
Id
Responses
200400401403404422429500
PATCH /api/v1/notes/{id}

Update note

Tag
Notes
Operation
updateNote
Auth
session
Input
Idapplication/json body
Responses
200400401403404409413415422429500
GET /api/v1/opportunities

List opportunities

Tag
Opportunities
Operation
listOpportunities
Auth
sessionbearer API keyopportunities:read
Input
PagePageSizeSearchsortordercompanyIdstageIdownerUserIdstatus
Responses
200400401403422429500
POST /api/v1/opportunities

Create opportunity

Tag
Opportunities
Operation
createOpportunity
Auth
sessionbearer API keyopportunities:create
Input
application/json body
Responses
201400401403409413415422429500
DELETE /api/v1/opportunities/{id}

Delete opportunity

Tag
Opportunities
Operation
deleteOpportunity
Auth
sessionbearer API keyopportunities:write
Input
Id
Responses
204400401403404409422429500
GET /api/v1/opportunities/{id}

Get opportunity

Tag
Opportunities
Operation
getOpportunity
Auth
sessionbearer API keyopportunities:read
Input
Id
Responses
200400401403404422429500
PATCH /api/v1/opportunities/{id}

Update opportunity

Tag
Opportunities
Operation
updateOpportunity
Auth
sessionbearer API keyopportunities:write
Input
Idapplication/json body
Responses
200400401403404409413415422429500
PATCH /api/v1/opportunities/{id}/stage

Move an opportunity to another pipeline stage

Tag
Opportunities
Operation
changeOpportunityStage
Auth
sessionbearer API keyopportunities:write
Input
Idapplication/json body
Responses
200400401403404409413415422429500
GET /api/v1/pipeline-stages

List pipeline stages

Tag
Pipeline stages
Operation
listPipelineStages
Auth
session
Input
PagePageSizeSearchsortordertype
Responses
200400401403422429500
POST /api/v1/pipeline-stages

Create pipeline stage

Tag
Pipeline stages
Operation
createPipelineStage
Auth
session
Input
application/json body
Responses
201400401403409413415422429500
DELETE /api/v1/pipeline-stages/{id}

Delete pipeline stage

Tag
Pipeline stages
Operation
deletePipelineStage
Auth
session
Input
Id
Responses
204400401403404409422429500
GET /api/v1/pipeline-stages/{id}

Get pipeline stage

Tag
Pipeline stages
Operation
getPipelineStage
Auth
session
Input
Id
Responses
200400401403404422429500
PATCH /api/v1/pipeline-stages/{id}

Update pipeline stage

Tag
Pipeline stages
Operation
updatePipelineStage
Auth
session
Input
Idapplication/json body
Responses
200400401403404409413415422429500
GET /api/v1/ready

Readiness check

Checks dependencies required to serve application traffic, including PostgreSQL.

Tag
System
Operation
getReadiness
Auth
public
Responses
200500503
GET /api/v1/search

Search CRM records

Tag
Search
Operation
searchCrm
Auth
session
Input
qlimit
Responses
200400401403422429500
GET /api/v1/settings

Get workspace settings

Tag
Settings
Operation
getWorkspaceSettings
Auth
session
Responses
200400401403422429500
PATCH /api/v1/settings

Replace editable workspace settings

Tag
Settings
Operation
updateWorkspaceSettings
Auth
session
Input
application/json body
Responses
200400401403404413415422429500
GET /api/v1/tags

List tags

Tag
Tags
Operation
listTags
Auth
session
Input
PagePageSizeSearchsortorder
Responses
200400401403422429500
POST /api/v1/tags

Create tag

Tag
Tags
Operation
createTag
Auth
session
Input
application/json body
Responses
201400401403409413415422429500
DELETE /api/v1/tags/{id}

Delete tag

Tag
Tags
Operation
deleteTag
Auth
session
Input
Id
Responses
204400401403404409422429500
GET /api/v1/tags/{id}

Get tag

Tag
Tags
Operation
getTag
Auth
session
Input
Id
Responses
200400401403404422429500
PATCH /api/v1/tags/{id}

Update tag

Tag
Tags
Operation
updateTag
Auth
session
Input
Idapplication/json body
Responses
200400401403404409413415422429500
GET /api/v1/tasks

List tasks

Tag
Tasks
Operation
listTasks
Auth
sessionbearer API keytasks:read
Input
PagePageSizeSearchsortorderstatusassignedUserIdcompanyIdcontactIdopportunityId
Responses
200400401403422429500
POST /api/v1/tasks

Create task

Tag
Tasks
Operation
createTask
Auth
sessionbearer API keytasks:write
Input
application/json body
Responses
201400401403409413415422429500
DELETE /api/v1/tasks/{id}

Delete task

Tag
Tasks
Operation
deleteTask
Auth
sessionbearer API keytasks:write
Input
Id
Responses
204400401403404409422429500
GET /api/v1/tasks/{id}

Get task

Tag
Tasks
Operation
getTask
Auth
sessionbearer API keytasks:read
Input
Id
Responses
200400401403404422429500
PATCH /api/v1/tasks/{id}

Update task

Tag
Tasks
Operation
updateTask
Auth
sessionbearer API keytasks:write
Input
Idapplication/json body
Responses
200400401403404409413415422429500
GET /api/v1/webhooks

List webhooks

Tag
Webhooks
Operation
listWebhooks
Auth
session
Input
PagePageSizeSearch
Responses
200400401403422429500
POST /api/v1/webhooks

Create a webhook endpoint

A signing secret is generated and returned exactly once.

Tag
Webhooks
Operation
createWebhook
Auth
session
Input
application/json body
Responses
201400401403409413415422429500
DELETE /api/v1/webhooks/{id}

Delete webhook

Tag
Webhooks
Operation
deleteWebhook
Auth
session
Input
Id
Responses
204400401403404409422429500
GET /api/v1/webhooks/{id}

Get webhook

Tag
Webhooks
Operation
getWebhook
Auth
session
Input
Id
Responses
200400401403404422429500
PATCH /api/v1/webhooks/{id}

Update webhook

Tag
Webhooks
Operation
updateWebhook
Auth
session
Input
Idapplication/json body
Responses
200400401403404409413415422429500
GET /api/v1/webhooks/{id}/deliveries

List delivery attempts for a webhook

Tag
Webhooks
Operation
listWebhookDeliveries
Auth
session
Input
IdPagePageSize
Responses
200400401403404422429500
POST /api/v1/webhooks/{id}/deliveries/{deliveryId}/retry

Queue a failed webhook delivery for retry

Only failed deliveries belonging to an enabled webhook can be queued again. Each delivery permits at most 3 manual retries and 9 lifetime attempts. Manual retries are limited to 20 per owner and 60 per workspace per minute, with active-work bounds of 50 per webhook and 100 per workspace.

Tag
Webhooks
Operation
retryWebhookDelivery
Auth
session
Input
IdDeliveryId
Responses
202400401403404409422429500
POST /api/v1/webhooks/{id}/test

Send a test webhook delivery

Queues a synthetic webhook.test delivery. Tests are limited to 10 per owner and 30 per workspace per minute, with active-work bounds of 50 per webhook and 100 per workspace.

Tag
Webhooks
Operation
testWebhook
Auth
session
Input
Id
Responses
202400401403404409422429500
Embedded OpenAPI document
{
  "openapi": "3.1.0",
  "jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
  "info": {
    "title": "Braiventh CRM API",
    "version": "1.0.0",
    "summary": "API-first CRM and business operations platform.",
    "description": "JSON success responses use a data envelope. Paginated collection responses also include meta.pagination; global search intentionally returns a bounded data array without pagination metadata. Errors use a stable error.code and error.message envelope. Browser sessions use an HttpOnly cookie. Integrations use scoped bearer API keys."
  },
  "servers": [
    {
      "url": "/",
      "description": "Current Braiventh CRM installation"
    }
  ],
  "externalDocs": {
    "description": "Interactive local documentation",
    "url": "/api/docs"
  },
  "tags": [
    {
      "name": "System"
    },
    {
      "name": "Authentication"
    },
    {
      "name": "Dashboard"
    },
    {
      "name": "Search"
    },
    {
      "name": "Settings"
    },
    {
      "name": "Companies"
    },
    {
      "name": "Contacts"
    },
    {
      "name": "Opportunities"
    },
    {
      "name": "Pipeline stages"
    },
    {
      "name": "Tasks"
    },
    {
      "name": "Notes"
    },
    {
      "name": "Activities"
    },
    {
      "name": "Tags"
    },
    {
      "name": "API keys"
    },
    {
      "name": "Website integration"
    },
    {
      "name": "Webhooks"
    }
  ],
  "paths": {
    "/api/v1/health": {
      "get": {
        "tags": [
          "System"
        ],
        "operationId": "getHealth",
        "summary": "Liveness check",
        "description": "Reports whether the HTTP process is alive. This endpoint does not check dependencies.",
        "security": [],
        "responses": {
          "200": {
            "description": "Process is alive.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Health"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/ready": {
      "get": {
        "tags": [
          "System"
        ],
        "operationId": "getReadiness",
        "summary": "Readiness check",
        "description": "Checks dependencies required to serve application traffic, including PostgreSQL.",
        "security": [],
        "responses": {
          "200": {
            "description": "All required dependencies are ready.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Readiness"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "description": "One or more required dependencies are unavailable.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/auth/setup": {
      "get": {
        "tags": [
          "Authentication"
        ],
        "operationId": "getSetupStatus",
        "summary": "Check whether first-run setup is required",
        "security": [],
        "responses": {
          "200": {
            "description": "Current first-run setup state.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/SetupStatus"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "tags": [
          "Authentication"
        ],
        "operationId": "setupWorkspace",
        "summary": "Create the first workspace administrator",
        "description": "Available only while the installation has no users and requires the installer-supplied one-time setup token.",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SetupRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Workspace and administrator created; session cookie is set.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Session"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLarge"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/auth/login": {
      "post": {
        "tags": [
          "Authentication"
        ],
        "operationId": "login",
        "summary": "Create a browser session",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LoginRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Authenticated; an HttpOnly session cookie is set.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Session"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLarge"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/auth/logout": {
      "post": {
        "tags": [
          "Authentication"
        ],
        "operationId": "logout",
        "summary": "Destroy the current browser session",
        "description": "Revokes the presented session when one exists and always expires the browser cookie. A valid session is optional.",
        "security": [
          {
            "sessionCookie": []
          },
          {}
        ],
        "responses": {
          "204": {
            "description": "Session destroyed.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/auth/me": {
      "get": {
        "tags": [
          "Authentication"
        ],
        "operationId": "getCurrentUser",
        "summary": "Get the current session user",
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "responses": {
          "200": {
            "description": "Current user and workspace.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Session"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/auth/session": {
      "get": {
        "tags": [
          "Authentication"
        ],
        "operationId": "getCurrentSession",
        "summary": "Get the current browser session",
        "description": "Alias of GET /api/v1/auth/me.",
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "responses": {
          "200": {
            "description": "Current user and workspace.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Session"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/auth/sessions/others": {
      "delete": {
        "tags": [
          "Authentication"
        ],
        "operationId": "revokeOtherSessions",
        "summary": "Revoke the current user's other browser sessions",
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "x-required-roles": [
          "owner",
          "admin"
        ],
        "responses": {
          "200": {
            "description": "Other sessions revoked.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/RevokedSessions"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/dashboard": {
      "get": {
        "tags": [
          "Dashboard"
        ],
        "operationId": "getDashboard",
        "summary": "Get CRM dashboard metrics",
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "responses": {
          "200": {
            "description": "Dashboard metrics and recent records.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Dashboard"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/search": {
      "get": {
        "tags": [
          "Search"
        ],
        "operationId": "searchCrm",
        "summary": "Search CRM records",
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": true,
            "description": "Case-insensitive search query.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 120
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum total results across all resource types.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50,
              "default": 20
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Matching CRM records ordered by most recently updated.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/SearchResult"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/settings": {
      "get": {
        "tags": [
          "Settings"
        ],
        "operationId": "getWorkspaceSettings",
        "summary": "Get workspace settings",
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "responses": {
          "200": {
            "description": "Workspace settings.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/WorkspaceSettings"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "patch": {
        "tags": [
          "Settings"
        ],
        "operationId": "updateWorkspaceSettings",
        "summary": "Replace editable workspace settings",
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "x-required-roles": [
          "owner",
          "admin"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WorkspaceSettingsUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Workspace settings updated.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/WorkspaceSettings"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLarge"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/companies": {
      "get": {
        "tags": [
          "Companies"
        ],
        "operationId": "listCompanies",
        "summary": "List companies",
        "security": [
          {
            "sessionCookie": []
          },
          {
            "bearerApiKey": []
          }
        ],
        "x-required-scopes": [
          "companies:read"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Page"
          },
          {
            "$ref": "#/components/parameters/PageSize"
          },
          {
            "$ref": "#/components/parameters/Search"
          },
          {
            "name": "sort",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "name",
                "status",
                "createdAt",
                "updatedAt"
              ],
              "default": "updatedAt"
            }
          },
          {
            "name": "order",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "asc",
                "desc"
              ],
              "default": "desc"
            }
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "prospect",
                "active",
                "inactive",
                "client"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Companies page.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "meta"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Company"
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/PaginationMeta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "tags": [
          "Companies"
        ],
        "operationId": "createCompany",
        "summary": "Create company",
        "security": [
          {
            "sessionCookie": []
          },
          {
            "bearerApiKey": []
          }
        ],
        "x-required-scopes": [
          "companies:write"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CompanyCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Companies record created.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Company"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLarge"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/companies/{id}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/Id"
        }
      ],
      "get": {
        "tags": [
          "Companies"
        ],
        "operationId": "getCompany",
        "summary": "Get company",
        "security": [
          {
            "sessionCookie": []
          },
          {
            "bearerApiKey": []
          }
        ],
        "x-required-scopes": [
          "companies:read"
        ],
        "responses": {
          "200": {
            "description": "Companies record.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Company"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "patch": {
        "tags": [
          "Companies"
        ],
        "operationId": "updateCompany",
        "summary": "Update company",
        "security": [
          {
            "sessionCookie": []
          },
          {
            "bearerApiKey": []
          }
        ],
        "x-required-scopes": [
          "companies:write"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CompanyUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Companies record updated.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Company"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLarge"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "tags": [
          "Companies"
        ],
        "operationId": "deleteCompany",
        "summary": "Delete company",
        "security": [
          {
            "sessionCookie": []
          },
          {
            "bearerApiKey": []
          }
        ],
        "x-required-scopes": [
          "companies:write"
        ],
        "responses": {
          "204": {
            "description": "Companies record deleted.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/contacts": {
      "get": {
        "tags": [
          "Contacts"
        ],
        "operationId": "listContacts",
        "summary": "List contacts",
        "security": [
          {
            "sessionCookie": []
          },
          {
            "bearerApiKey": []
          }
        ],
        "x-required-scopes": [
          "contacts:read"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Page"
          },
          {
            "$ref": "#/components/parameters/PageSize"
          },
          {
            "$ref": "#/components/parameters/Search"
          },
          {
            "name": "sort",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "firstName",
                "lastName",
                "name",
                "email",
                "status",
                "createdAt",
                "updatedAt"
              ],
              "default": "updatedAt"
            }
          },
          {
            "name": "order",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "asc",
                "desc"
              ],
              "default": "desc"
            }
          },
          {
            "name": "companyId",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "active",
                "inactive"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Contacts page.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "meta"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Contact"
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/PaginationMeta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "tags": [
          "Contacts"
        ],
        "operationId": "createContact",
        "summary": "Create contact",
        "security": [
          {
            "sessionCookie": []
          },
          {
            "bearerApiKey": []
          }
        ],
        "x-required-scopes": [
          "contacts:write"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ContactCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Contacts record created.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Contact"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLarge"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/contacts/{id}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/Id"
        }
      ],
      "get": {
        "tags": [
          "Contacts"
        ],
        "operationId": "getContact",
        "summary": "Get contact",
        "security": [
          {
            "sessionCookie": []
          },
          {
            "bearerApiKey": []
          }
        ],
        "x-required-scopes": [
          "contacts:read"
        ],
        "responses": {
          "200": {
            "description": "Contacts record.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Contact"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "patch": {
        "tags": [
          "Contacts"
        ],
        "operationId": "updateContact",
        "summary": "Update contact",
        "security": [
          {
            "sessionCookie": []
          },
          {
            "bearerApiKey": []
          }
        ],
        "x-required-scopes": [
          "contacts:write"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ContactUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Contacts record updated.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Contact"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLarge"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "tags": [
          "Contacts"
        ],
        "operationId": "deleteContact",
        "summary": "Delete contact",
        "security": [
          {
            "sessionCookie": []
          },
          {
            "bearerApiKey": []
          }
        ],
        "x-required-scopes": [
          "contacts:write"
        ],
        "responses": {
          "204": {
            "description": "Contacts record deleted.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/opportunities": {
      "get": {
        "tags": [
          "Opportunities"
        ],
        "operationId": "listOpportunities",
        "summary": "List opportunities",
        "security": [
          {
            "sessionCookie": []
          },
          {
            "bearerApiKey": []
          }
        ],
        "x-required-scopes": [
          "opportunities:read"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Page"
          },
          {
            "$ref": "#/components/parameters/PageSize"
          },
          {
            "$ref": "#/components/parameters/Search"
          },
          {
            "name": "sort",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "title",
                "estimatedValue",
                "probability",
                "priority",
                "expectedCloseDate",
                "status",
                "createdAt",
                "updatedAt"
              ],
              "default": "updatedAt"
            }
          },
          {
            "name": "order",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "asc",
                "desc"
              ],
              "default": "desc"
            }
          },
          {
            "name": "companyId",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "stageId",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "ownerUserId",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "open",
                "won",
                "lost"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Opportunities page.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "meta"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Opportunity"
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/PaginationMeta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "tags": [
          "Opportunities"
        ],
        "operationId": "createOpportunity",
        "summary": "Create opportunity",
        "security": [
          {
            "sessionCookie": []
          },
          {
            "bearerApiKey": []
          }
        ],
        "x-required-scopes": [
          "opportunities:create"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OpportunityCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Opportunities record created.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Opportunity"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLarge"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/opportunities/{id}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/Id"
        }
      ],
      "get": {
        "tags": [
          "Opportunities"
        ],
        "operationId": "getOpportunity",
        "summary": "Get opportunity",
        "security": [
          {
            "sessionCookie": []
          },
          {
            "bearerApiKey": []
          }
        ],
        "x-required-scopes": [
          "opportunities:read"
        ],
        "responses": {
          "200": {
            "description": "Opportunities record.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Opportunity"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "patch": {
        "tags": [
          "Opportunities"
        ],
        "operationId": "updateOpportunity",
        "summary": "Update opportunity",
        "security": [
          {
            "sessionCookie": []
          },
          {
            "bearerApiKey": []
          }
        ],
        "x-required-scopes": [
          "opportunities:write"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OpportunityUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Opportunities record updated.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Opportunity"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLarge"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "tags": [
          "Opportunities"
        ],
        "operationId": "deleteOpportunity",
        "summary": "Delete opportunity",
        "security": [
          {
            "sessionCookie": []
          },
          {
            "bearerApiKey": []
          }
        ],
        "x-required-scopes": [
          "opportunities:write"
        ],
        "responses": {
          "204": {
            "description": "Opportunities record deleted.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/opportunities/{id}/stage": {
      "parameters": [
        {
          "$ref": "#/components/parameters/Id"
        }
      ],
      "patch": {
        "tags": [
          "Opportunities"
        ],
        "operationId": "changeOpportunityStage",
        "summary": "Move an opportunity to another pipeline stage",
        "security": [
          {
            "sessionCookie": []
          },
          {
            "bearerApiKey": []
          }
        ],
        "x-required-scopes": [
          "opportunities:write"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OpportunityStageChange"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Opportunity stage changed.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Opportunity"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLarge"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/pipeline-stages": {
      "get": {
        "tags": [
          "Pipeline stages"
        ],
        "operationId": "listPipelineStages",
        "summary": "List pipeline stages",
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Page"
          },
          {
            "$ref": "#/components/parameters/PageSize"
          },
          {
            "$ref": "#/components/parameters/Search"
          },
          {
            "name": "sort",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "position",
                "name",
                "type",
                "probability",
                "createdAt",
                "updatedAt"
              ],
              "default": "position"
            }
          },
          {
            "name": "order",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "asc",
                "desc"
              ],
              "default": "asc"
            }
          },
          {
            "name": "type",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "open",
                "won",
                "lost"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Pipeline stages page.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "meta"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PipelineStage"
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/PaginationMeta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "tags": [
          "Pipeline stages"
        ],
        "operationId": "createPipelineStage",
        "summary": "Create pipeline stage",
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "x-required-roles": [
          "owner",
          "admin"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PipelineStageCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Pipeline stages record created.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/PipelineStage"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLarge"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/pipeline-stages/{id}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/Id"
        }
      ],
      "get": {
        "tags": [
          "Pipeline stages"
        ],
        "operationId": "getPipelineStage",
        "summary": "Get pipeline stage",
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "responses": {
          "200": {
            "description": "Pipeline stages record.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/PipelineStage"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "patch": {
        "tags": [
          "Pipeline stages"
        ],
        "operationId": "updatePipelineStage",
        "summary": "Update pipeline stage",
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "x-required-roles": [
          "owner",
          "admin"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PipelineStageUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Pipeline stages record updated.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/PipelineStage"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLarge"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "tags": [
          "Pipeline stages"
        ],
        "operationId": "deletePipelineStage",
        "summary": "Delete pipeline stage",
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "x-required-roles": [
          "owner",
          "admin"
        ],
        "responses": {
          "204": {
            "description": "Pipeline stages record deleted.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/tasks": {
      "get": {
        "tags": [
          "Tasks"
        ],
        "operationId": "listTasks",
        "summary": "List tasks",
        "security": [
          {
            "sessionCookie": []
          },
          {
            "bearerApiKey": []
          }
        ],
        "x-required-scopes": [
          "tasks:read"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Page"
          },
          {
            "$ref": "#/components/parameters/PageSize"
          },
          {
            "$ref": "#/components/parameters/Search"
          },
          {
            "name": "sort",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "title",
                "status",
                "priority",
                "dueAt",
                "createdAt",
                "updatedAt"
              ],
              "default": "updatedAt"
            }
          },
          {
            "name": "order",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "asc",
                "desc"
              ],
              "default": "desc"
            }
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "open",
                "in_progress",
                "completed",
                "cancelled"
              ]
            }
          },
          {
            "name": "assignedUserId",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "companyId",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "contactId",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "opportunityId",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Tasks page.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "meta"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Task"
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/PaginationMeta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "tags": [
          "Tasks"
        ],
        "operationId": "createTask",
        "summary": "Create task",
        "security": [
          {
            "sessionCookie": []
          },
          {
            "bearerApiKey": []
          }
        ],
        "x-required-scopes": [
          "tasks:write"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TaskCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Tasks record created.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Task"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLarge"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/tasks/{id}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/Id"
        }
      ],
      "get": {
        "tags": [
          "Tasks"
        ],
        "operationId": "getTask",
        "summary": "Get task",
        "security": [
          {
            "sessionCookie": []
          },
          {
            "bearerApiKey": []
          }
        ],
        "x-required-scopes": [
          "tasks:read"
        ],
        "responses": {
          "200": {
            "description": "Tasks record.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Task"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "patch": {
        "tags": [
          "Tasks"
        ],
        "operationId": "updateTask",
        "summary": "Update task",
        "security": [
          {
            "sessionCookie": []
          },
          {
            "bearerApiKey": []
          }
        ],
        "x-required-scopes": [
          "tasks:write"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TaskUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Tasks record updated.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Task"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLarge"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "tags": [
          "Tasks"
        ],
        "operationId": "deleteTask",
        "summary": "Delete task",
        "security": [
          {
            "sessionCookie": []
          },
          {
            "bearerApiKey": []
          }
        ],
        "x-required-scopes": [
          "tasks:write"
        ],
        "responses": {
          "204": {
            "description": "Tasks record deleted.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/notes": {
      "get": {
        "tags": [
          "Notes"
        ],
        "operationId": "listNotes",
        "summary": "List notes",
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Page"
          },
          {
            "$ref": "#/components/parameters/PageSize"
          },
          {
            "$ref": "#/components/parameters/Search"
          },
          {
            "name": "sort",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "createdAt",
                "updatedAt",
                "isPinned"
              ],
              "default": "createdAt"
            }
          },
          {
            "name": "order",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "asc",
                "desc"
              ],
              "default": "desc"
            }
          },
          {
            "name": "companyId",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "contactId",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "opportunityId",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Notes page.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "meta"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Note"
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/PaginationMeta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "tags": [
          "Notes"
        ],
        "operationId": "createNote",
        "summary": "Create note",
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "x-required-roles": [
          "owner",
          "admin",
          "member"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NoteCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Notes record created.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Note"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLarge"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/notes/{id}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/Id"
        }
      ],
      "get": {
        "tags": [
          "Notes"
        ],
        "operationId": "getNote",
        "summary": "Get note",
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "responses": {
          "200": {
            "description": "Notes record.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Note"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "patch": {
        "tags": [
          "Notes"
        ],
        "operationId": "updateNote",
        "summary": "Update note",
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "x-required-roles": [
          "owner",
          "admin",
          "member"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NoteUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Notes record updated.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Note"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLarge"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "tags": [
          "Notes"
        ],
        "operationId": "deleteNote",
        "summary": "Delete note",
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "x-required-roles": [
          "owner",
          "admin",
          "member"
        ],
        "responses": {
          "204": {
            "description": "Notes record deleted.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/activities": {
      "get": {
        "tags": [
          "Activities"
        ],
        "operationId": "listActivities",
        "summary": "List immutable CRM activity records",
        "security": [
          {
            "sessionCookie": []
          },
          {
            "bearerApiKey": []
          }
        ],
        "x-required-scopes": [
          "activities:read"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Page"
          },
          {
            "$ref": "#/components/parameters/PageSize"
          },
          {
            "$ref": "#/components/parameters/Search"
          },
          {
            "name": "sort",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "occurredAt",
                "createdAt",
                "eventType"
              ],
              "default": "occurredAt"
            }
          },
          {
            "name": "order",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "asc",
                "desc"
              ],
              "default": "desc"
            }
          },
          {
            "name": "eventType",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 120
            }
          },
          {
            "name": "relatedEntityType",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 80
            }
          },
          {
            "name": "relatedEntityId",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "companyId",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "contactId",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "opportunityId",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "taskId",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Activity page.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "meta"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Activity"
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/PaginationMeta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/activities/{id}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/Id"
        }
      ],
      "get": {
        "tags": [
          "Activities"
        ],
        "operationId": "getActivity",
        "summary": "Get an immutable activity record",
        "security": [
          {
            "sessionCookie": []
          },
          {
            "bearerApiKey": []
          }
        ],
        "x-required-scopes": [
          "activities:read"
        ],
        "responses": {
          "200": {
            "description": "Activity record.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Activity"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/tags": {
      "get": {
        "tags": [
          "Tags"
        ],
        "operationId": "listTags",
        "summary": "List tags",
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Page"
          },
          {
            "$ref": "#/components/parameters/PageSize"
          },
          {
            "$ref": "#/components/parameters/Search"
          },
          {
            "name": "sort",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "name",
                "color",
                "createdAt",
                "updatedAt"
              ],
              "default": "name"
            }
          },
          {
            "name": "order",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "asc",
                "desc"
              ],
              "default": "asc"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Tags page.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "meta"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Tag"
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/PaginationMeta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "tags": [
          "Tags"
        ],
        "operationId": "createTag",
        "summary": "Create tag",
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "x-required-roles": [
          "owner",
          "admin",
          "member"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TagCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Tags record created.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Tag"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLarge"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/tags/{id}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/Id"
        }
      ],
      "get": {
        "tags": [
          "Tags"
        ],
        "operationId": "getTag",
        "summary": "Get tag",
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "responses": {
          "200": {
            "description": "Tags record.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Tag"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "patch": {
        "tags": [
          "Tags"
        ],
        "operationId": "updateTag",
        "summary": "Update tag",
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "x-required-roles": [
          "owner",
          "admin",
          "member"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TagUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Tags record updated.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Tag"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLarge"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "tags": [
          "Tags"
        ],
        "operationId": "deleteTag",
        "summary": "Delete tag",
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "x-required-roles": [
          "owner",
          "admin",
          "member"
        ],
        "responses": {
          "204": {
            "description": "Tags record deleted.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/api-keys": {
      "get": {
        "tags": [
          "API keys"
        ],
        "operationId": "listApiKeys",
        "summary": "List API-key metadata",
        "description": "Stored digests and full API-key secrets are never returned.",
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "x-required-roles": [
          "owner",
          "admin"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Page"
          },
          {
            "$ref": "#/components/parameters/PageSize"
          },
          {
            "$ref": "#/components/parameters/Search"
          }
        ],
        "responses": {
          "200": {
            "description": "API-key metadata page.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "meta"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ApiKey"
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/PaginationMeta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "tags": [
          "API keys"
        ],
        "operationId": "createApiKey",
        "summary": "Create an API key",
        "description": "The plaintext key is returned exactly once in this response. Store it securely.",
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "x-required-roles": [
          "owner",
          "admin"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ApiKeyCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "API key created; plaintext key shown once.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/ApiKeyCreated"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLarge"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/api-keys/{id}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/Id"
        }
      ],
      "get": {
        "tags": [
          "API keys"
        ],
        "operationId": "getApiKey",
        "summary": "Get API-key metadata",
        "description": "The plaintext key and stored digest are never returned.",
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "x-required-roles": [
          "owner",
          "admin"
        ],
        "responses": {
          "200": {
            "description": "API-key metadata.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/ApiKey"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/api-keys/{id}/revoke": {
      "parameters": [
        {
          "$ref": "#/components/parameters/Id"
        }
      ],
      "post": {
        "tags": [
          "API keys"
        ],
        "operationId": "revokeApiKey",
        "summary": "Revoke an API key",
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "x-required-roles": [
          "owner",
          "admin"
        ],
        "responses": {
          "200": {
            "description": "API key revoked.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/ApiKey"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/integrations/website/opportunities": {
      "post": {
        "tags": [
          "Website integration"
        ],
        "operationId": "ingestWebsiteOpportunity",
        "summary": "Ingest a website lead",
        "description": "Atomically creates or links the company and contact, creates an opportunity, and optionally creates a follow-up task. Idempotency records live for 24 hours: replaying the same key and normalized body returns the original IDs, while reusing a key with a different body returns 409. Requests are limited to 32 KiB and rate-limited per API key.",
        "security": [
          {
            "bearerApiKey": []
          }
        ],
        "x-required-scopes": [
          "opportunities:create"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "description": "JSON body; maximum encoded size is 32 KiB.",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebsiteLeadRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Previously created result replayed.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/WebsiteLeadResult"
                    }
                  }
                }
              }
            }
          },
          "201": {
            "description": "Website lead ingested.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/WebsiteLeadResult"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLarge"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/webhooks": {
      "get": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "listWebhooks",
        "summary": "List webhooks",
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "x-required-roles": [
          "owner",
          "admin"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Page"
          },
          {
            "$ref": "#/components/parameters/PageSize"
          },
          {
            "$ref": "#/components/parameters/Search"
          }
        ],
        "responses": {
          "200": {
            "description": "Webhooks page.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "meta"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Webhook"
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/PaginationMeta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "createWebhook",
        "summary": "Create a webhook endpoint",
        "description": "A signing secret is generated and returned exactly once.",
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "x-required-roles": [
          "owner",
          "admin"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Webhook created; signing secret shown once.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/WebhookCreated"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLarge"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/webhooks/{id}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/Id"
        }
      ],
      "get": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "getWebhook",
        "summary": "Get webhook",
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "x-required-roles": [
          "owner",
          "admin"
        ],
        "responses": {
          "200": {
            "description": "Webhooks record.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Webhook"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "patch": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "updateWebhook",
        "summary": "Update webhook",
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "x-required-roles": [
          "owner",
          "admin"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Webhooks record updated.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Webhook"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLarge"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "deleteWebhook",
        "summary": "Delete webhook",
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "x-required-roles": [
          "owner",
          "admin"
        ],
        "responses": {
          "204": {
            "description": "Webhooks record deleted.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/webhooks/{id}/deliveries": {
      "parameters": [
        {
          "$ref": "#/components/parameters/Id"
        }
      ],
      "get": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "listWebhookDeliveries",
        "summary": "List delivery attempts for a webhook",
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "x-required-roles": [
          "owner",
          "admin"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Page"
          },
          {
            "$ref": "#/components/parameters/PageSize"
          }
        ],
        "responses": {
          "200": {
            "description": "Webhook delivery page.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "meta"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/WebhookDelivery"
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/PaginationMeta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/webhooks/{id}/deliveries/{deliveryId}/retry": {
      "parameters": [
        {
          "$ref": "#/components/parameters/Id"
        },
        {
          "$ref": "#/components/parameters/DeliveryId"
        }
      ],
      "post": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "retryWebhookDelivery",
        "summary": "Queue a failed webhook delivery for retry",
        "description": "Only failed deliveries belonging to an enabled webhook can be queued again. Each delivery permits at most 3 manual retries and 9 lifetime attempts. Manual retries are limited to 20 per owner and 60 per workspace per minute, with active-work bounds of 50 per webhook and 100 per workspace.",
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "x-required-roles": [
          "owner",
          "admin"
        ],
        "responses": {
          "202": {
            "description": "Delivery queued for retry.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/WebhookDelivery"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/webhooks/{id}/test": {
      "parameters": [
        {
          "$ref": "#/components/parameters/Id"
        }
      ],
      "post": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "testWebhook",
        "summary": "Send a test webhook delivery",
        "description": "Queues a synthetic webhook.test delivery. Tests are limited to 10 per owner and 30 per workspace per minute, with active-work bounds of 50 per webhook and 100 per workspace.",
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "x-required-roles": [
          "owner",
          "admin"
        ],
        "responses": {
          "202": {
            "description": "Test delivery queued.",
            "headers": {
              "X-Request-Id": {
                "description": "Request correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/WebhookDelivery"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    }
  },
  "webhooks": {
    "crmEvent": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "CRM event delivery sent by Braiventh",
        "description": "Receivers should compute HMAC-SHA256 over `<timestamp>.<raw request body>` and compare it in constant time with X-Braiventh-Signature.",
        "parameters": [
          {
            "name": "X-Braiventh-Delivery",
            "in": "header",
            "required": true,
            "description": "Webhook delivery UUID.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "X-Braiventh-Event",
            "in": "header",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/DeliveryWebhookEvent"
            }
          },
          {
            "name": "X-Braiventh-Timestamp",
            "in": "header",
            "required": true,
            "description": "Unix timestamp in whole seconds, serialized as a decimal header value.",
            "schema": {
              "type": "string",
              "pattern": "^[0-9]+$"
            }
          },
          {
            "name": "X-Braiventh-Signature",
            "in": "header",
            "required": true,
            "description": "`sha256=` followed by the lowercase hexadecimal HMAC digest.",
            "schema": {
              "type": "string",
              "pattern": "^sha256=[0-9a-f]{64}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookPayload"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Delivery accepted."
          },
          "204": {
            "description": "Delivery accepted without a response body."
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "sessionCookie": {
        "type": "apiKey",
        "in": "cookie",
        "name": "braiventh_session",
        "description": "HttpOnly, Secure, SameSite browser session cookie."
      },
      "bearerApiKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "Braiventh API key",
        "description": "Send a scoped API key in `Authorization: Bearer <key>`. Keys are only displayed at creation.",
        "x-scopes": {
          "companies:read": "Read companies.",
          "companies:write": "Create, update, and delete companies.",
          "contacts:read": "Read contacts.",
          "contacts:write": "Create, update, and delete contacts.",
          "opportunities:read": "Read opportunities and pipeline information.",
          "opportunities:create": "Create opportunities through the CRM or approved ingestion endpoints.",
          "opportunities:write": "Update, move, and delete opportunities.",
          "tasks:read": "Read tasks.",
          "tasks:write": "Create, update, and delete tasks.",
          "activities:read": "Read immutable activity records."
        }
      }
    },
    "parameters": {
      "Id": {
        "name": "id",
        "in": "path",
        "required": true,
        "description": "Resource UUID.",
        "schema": {
          "type": "string",
          "format": "uuid"
        }
      },
      "DeliveryId": {
        "name": "deliveryId",
        "in": "path",
        "required": true,
        "description": "Webhook delivery UUID.",
        "schema": {
          "type": "string",
          "format": "uuid"
        }
      },
      "Page": {
        "name": "page",
        "in": "query",
        "schema": {
          "type": "integer",
          "minimum": 1,
          "default": 1
        }
      },
      "PageSize": {
        "name": "pageSize",
        "in": "query",
        "schema": {
          "type": "integer",
          "minimum": 1,
          "maximum": 100,
          "default": 25
        }
      },
      "Search": {
        "name": "search",
        "in": "query",
        "schema": {
          "type": "string",
          "maxLength": 120
        }
      },
      "Sort": {
        "name": "sort",
        "in": "query",
        "schema": {
          "type": "string",
          "maxLength": 64
        }
      },
      "Order": {
        "name": "order",
        "in": "query",
        "schema": {
          "type": "string",
          "enum": [
            "asc",
            "desc"
          ],
          "default": "desc"
        }
      },
      "IdempotencyKey": {
        "name": "Idempotency-Key",
        "in": "header",
        "required": true,
        "description": "Opaque caller-generated key. It must have no leading/trailing whitespace or control characters. Reuse it only to retry the same normalized JSON body; records expire after 24 hours.",
        "schema": {
          "type": "string",
          "minLength": 8,
          "maxLength": 200,
          "pattern": "^(?!\\s)(?:[^\\u0000-\\u001F\\u007F]){8,200}(?<!\\s)$"
        }
      }
    },
    "headers": {
      "X-Request-Id": {
        "description": "Request correlation identifier.",
        "schema": {
          "type": "string"
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Malformed request.",
        "headers": {
          "X-Request-Id": {
            "description": "Request correlation identifier.",
            "schema": {
              "type": "string"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Authentication failed or is missing.",
        "headers": {
          "X-Request-Id": {
            "description": "Request correlation identifier.",
            "schema": {
              "type": "string"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "Forbidden": {
        "description": "The caller lacks the required role or API-key scope.",
        "headers": {
          "X-Request-Id": {
            "description": "Request correlation identifier.",
            "schema": {
              "type": "string"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "NotFound": {
        "description": "Resource not found.",
        "headers": {
          "X-Request-Id": {
            "description": "Request correlation identifier.",
            "schema": {
              "type": "string"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "Conflict": {
        "description": "The operation conflicts with current state or an idempotency record.",
        "headers": {
          "X-Request-Id": {
            "description": "Request correlation identifier.",
            "schema": {
              "type": "string"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "ValidationError": {
        "description": "Request validation failed.",
        "headers": {
          "X-Request-Id": {
            "description": "Request correlation identifier.",
            "schema": {
              "type": "string"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "PayloadTooLarge": {
        "description": "Request body exceeded the configured byte limit.",
        "headers": {
          "X-Request-Id": {
            "description": "Request correlation identifier.",
            "schema": {
              "type": "string"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "UnsupportedMediaType": {
        "description": "Content-Type must be application/json.",
        "headers": {
          "X-Request-Id": {
            "description": "Request correlation identifier.",
            "schema": {
              "type": "string"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "RateLimited": {
        "description": "Rate limit exceeded.",
        "headers": {
          "X-Request-Id": {
            "description": "Request correlation identifier.",
            "schema": {
              "type": "string"
            }
          },
          "Retry-After": {
            "description": "Seconds before retrying.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "InternalError": {
        "description": "Unexpected server failure.",
        "headers": {
          "X-Request-Id": {
            "description": "Request correlation identifier.",
            "schema": {
              "type": "string"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "code",
          "message"
        ],
        "properties": {
          "code": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "details": {}
        }
      },
      "ErrorResponse": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "$ref": "#/components/schemas/Error"
          }
        }
      },
      "Pagination": {
        "type": "object",
        "required": [
          "page",
          "pageSize",
          "total",
          "pageCount"
        ],
        "properties": {
          "page": {
            "type": "integer",
            "minimum": 1
          },
          "pageSize": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100
          },
          "total": {
            "type": "integer",
            "minimum": 0
          },
          "pageCount": {
            "type": "integer",
            "minimum": 0
          }
        }
      },
      "PaginationMeta": {
        "type": "object",
        "required": [
          "pagination"
        ],
        "properties": {
          "pagination": {
            "$ref": "#/components/schemas/Pagination"
          }
        }
      },
      "ApiScope": {
        "type": "string",
        "enum": [
          "companies:read",
          "companies:write",
          "contacts:read",
          "contacts:write",
          "opportunities:read",
          "opportunities:create",
          "opportunities:write",
          "tasks:read",
          "tasks:write",
          "activities:read"
        ]
      },
      "WebhookEvent": {
        "type": "string",
        "enum": [
          "company.created",
          "contact.created",
          "opportunity.created",
          "opportunity.updated",
          "opportunity.stage_changed",
          "opportunity.won",
          "opportunity.lost",
          "task.created",
          "task.completed"
        ]
      },
      "DeliveryWebhookEvent": {
        "type": "string",
        "enum": [
          "company.created",
          "contact.created",
          "opportunity.created",
          "opportunity.updated",
          "opportunity.stage_changed",
          "opportunity.won",
          "opportunity.lost",
          "task.created",
          "task.completed",
          "webhook.test"
        ]
      },
      "User": {
        "type": "object",
        "required": [
          "id",
          "email",
          "displayName",
          "role"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "displayName": {
            "type": "string",
            "minLength": 1,
            "maxLength": 160
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "role": {
            "type": "string",
            "enum": [
              "owner",
              "admin",
              "member",
              "viewer"
            ]
          }
        }
      },
      "Session": {
        "type": "object",
        "required": [
          "user",
          "workspace"
        ],
        "properties": {
          "user": {
            "$ref": "#/components/schemas/User"
          },
          "workspace": {
            "type": "object",
            "required": [
              "id",
              "name"
            ],
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "name": {
                "type": "string"
              }
            }
          }
        }
      },
      "SetupStatus": {
        "type": "object",
        "required": [
          "required"
        ],
        "properties": {
          "required": {
            "type": "boolean"
          }
        }
      },
      "RevokedSessions": {
        "type": "object",
        "required": [
          "revokedCount"
        ],
        "properties": {
          "revokedCount": {
            "type": "integer",
            "minimum": 0
          }
        }
      },
      "SetupRequest": {
        "type": "object",
        "required": [
          "setupToken",
          "name",
          "email",
          "password"
        ],
        "properties": {
          "setupToken": {
            "type": "string",
            "minLength": 32,
            "maxLength": 256,
            "writeOnly": true,
            "description": "High-entropy installer proof supplied through the deployment secret mechanism."
          },
          "workspaceName": {
            "type": "string",
            "minLength": 2,
            "maxLength": 120,
            "default": "Braiventh"
          },
          "name": {
            "type": "string",
            "minLength": 2,
            "maxLength": 120
          },
          "email": {
            "type": "string",
            "format": "email",
            "maxLength": 254
          },
          "password": {
            "type": "string",
            "format": "password",
            "minLength": 12,
            "maxLength": 128,
            "writeOnly": true,
            "description": "Must contain lowercase, uppercase, numeric, and symbol characters."
          }
        }
      },
      "LoginRequest": {
        "type": "object",
        "required": [
          "email",
          "password"
        ],
        "properties": {
          "email": {
            "type": "string",
            "format": "email",
            "maxLength": 254
          },
          "password": {
            "type": "string",
            "format": "password",
            "minLength": 1,
            "maxLength": 256,
            "writeOnly": true
          }
        }
      },
      "CompanyCreate": {
        "type": "object",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 160
          },
          "website": {
            "anyOf": [
              {
                "type": "string",
                "format": "uri",
                "maxLength": 2048
              },
              {
                "type": "string",
                "const": ""
              },
              {
                "type": "null"
              }
            ]
          },
          "email": {
            "anyOf": [
              {
                "type": "string",
                "format": "email",
                "maxLength": 254
              },
              {
                "type": "string",
                "const": ""
              },
              {
                "type": "null"
              }
            ]
          },
          "phone": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 40
          },
          "address": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 240
          },
          "city": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 100
          },
          "postalCode": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 24
          },
          "country": {
            "type": "string",
            "minLength": 2,
            "maxLength": 80,
            "default": "Belgium"
          },
          "vatNumber": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 40
          },
          "industry": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 120
          },
          "source": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 80
          },
          "status": {
            "type": "string",
            "enum": [
              "prospect",
              "active",
              "inactive",
              "client"
            ],
            "default": "prospect"
          }
        }
      },
      "CompanyUpdate": {
        "type": "object",
        "minProperties": 1,
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 160
          },
          "website": {
            "anyOf": [
              {
                "type": "string",
                "format": "uri",
                "maxLength": 2048
              },
              {
                "type": "string",
                "const": ""
              },
              {
                "type": "null"
              }
            ]
          },
          "email": {
            "anyOf": [
              {
                "type": "string",
                "format": "email",
                "maxLength": 254
              },
              {
                "type": "string",
                "const": ""
              },
              {
                "type": "null"
              }
            ]
          },
          "phone": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 40
          },
          "address": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 240
          },
          "city": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 100
          },
          "postalCode": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 24
          },
          "country": {
            "type": "string",
            "minLength": 2,
            "maxLength": 80,
            "default": "Belgium"
          },
          "vatNumber": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 40
          },
          "industry": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 120
          },
          "source": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 80
          },
          "status": {
            "type": "string",
            "enum": [
              "prospect",
              "active",
              "inactive",
              "client"
            ],
            "default": "prospect"
          }
        }
      },
      "Company": {
        "allOf": [
          {
            "$ref": "#/components/schemas/CompanyCreate"
          },
          {
            "type": "object",
            "required": [
              "id",
              "workspaceId",
              "status",
              "country",
              "customFields",
              "createdAt",
              "updatedAt",
              "deletedAt"
            ],
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "workspaceId": {
                "type": "string",
                "format": "uuid"
              },
              "ownerUserId": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "uuid"
              },
              "createdByUserId": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "uuid"
              },
              "updatedByUserId": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "uuid"
              },
              "legalName": {
                "type": [
                  "string",
                  "null"
                ],
                "maxLength": 240
              },
              "customFields": {
                "type": "object",
                "additionalProperties": true
              },
              "contactsCount": {
                "type": "integer",
                "minimum": 0
              },
              "opportunitiesCount": {
                "type": "integer",
                "minimum": 0
              },
              "createdAt": {
                "type": "string",
                "format": "date-time"
              },
              "updatedAt": {
                "type": "string",
                "format": "date-time"
              },
              "deletedAt": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              }
            }
          }
        ]
      },
      "ContactCreate": {
        "type": "object",
        "required": [
          "firstName",
          "lastName"
        ],
        "properties": {
          "companyId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "firstName": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "lastName": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "email": {
            "anyOf": [
              {
                "type": "string",
                "format": "email",
                "maxLength": 254
              },
              {
                "type": "string",
                "const": ""
              },
              {
                "type": "null"
              }
            ]
          },
          "phone": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 40
          },
          "jobTitle": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 120
          },
          "preferredLanguage": {
            "type": "string",
            "enum": [
              "nl",
              "fr",
              "en",
              "de"
            ],
            "default": "nl"
          },
          "source": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 80
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "inactive"
            ],
            "default": "active"
          }
        }
      },
      "ContactUpdate": {
        "type": "object",
        "minProperties": 1,
        "properties": {
          "companyId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "firstName": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "lastName": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "email": {
            "anyOf": [
              {
                "type": "string",
                "format": "email",
                "maxLength": 254
              },
              {
                "type": "string",
                "const": ""
              },
              {
                "type": "null"
              }
            ]
          },
          "phone": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 40
          },
          "jobTitle": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 120
          },
          "preferredLanguage": {
            "type": "string",
            "enum": [
              "nl",
              "fr",
              "en",
              "de"
            ],
            "default": "nl"
          },
          "source": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 80
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "inactive"
            ],
            "default": "active"
          }
        }
      },
      "Contact": {
        "allOf": [
          {
            "$ref": "#/components/schemas/ContactCreate"
          },
          {
            "type": "object",
            "required": [
              "id",
              "workspaceId",
              "company",
              "customFields",
              "createdAt",
              "updatedAt",
              "deletedAt"
            ],
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "workspaceId": {
                "type": "string",
                "format": "uuid"
              },
              "ownerUserId": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "uuid"
              },
              "createdByUserId": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "uuid"
              },
              "updatedByUserId": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "uuid"
              },
              "companyName": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "company": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/CompanySummary"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "customFields": {
                "type": "object",
                "additionalProperties": true
              },
              "createdAt": {
                "type": "string",
                "format": "date-time"
              },
              "updatedAt": {
                "type": "string",
                "format": "date-time"
              },
              "deletedAt": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              }
            }
          }
        ]
      },
      "OpportunityCreate": {
        "type": "object",
        "required": [
          "title"
        ],
        "properties": {
          "companyId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "primaryContactId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "title": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 8000
          },
          "stageId": {
            "type": "string",
            "format": "uuid"
          },
          "serviceInterest": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 160
          },
          "estimatedValue": {
            "oneOf": [
              {
                "type": "number",
                "minimum": 0,
                "maximum": 999999999.99
              },
              {
                "type": "string",
                "maxLength": 128,
                "pattern": "^\\s*(?:\\+?(?:(?:[0-9]+(?:\\.[0-9]*)?)|(?:\\.[0-9]+))(?:[eE][+-]?[0-9]+)?)?\\s*$"
              }
            ],
            "description": "A value coercible to a finite number from 0 through 999999999.99; surrounding whitespace is ignored.",
            "default": 0
          },
          "currency": {
            "type": "string",
            "minLength": 3,
            "maxLength": 3,
            "default": "EUR"
          },
          "probability": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100
          },
          "source": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 80
          },
          "priority": {
            "type": "string",
            "enum": [
              "low",
              "normal",
              "high",
              "urgent"
            ],
            "default": "normal"
          },
          "expectedCloseDate": {
            "anyOf": [
              {
                "type": "string",
                "format": "date"
              },
              {
                "type": "string",
                "const": ""
              },
              {
                "type": "null"
              }
            ]
          },
          "lostReason": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 1000
          },
          "nextAction": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 500
          }
        }
      },
      "OpportunityUpdate": {
        "type": "object",
        "minProperties": 1,
        "properties": {
          "companyId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "primaryContactId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "title": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 8000
          },
          "stageId": {
            "type": "string",
            "format": "uuid"
          },
          "serviceInterest": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 160
          },
          "estimatedValue": {
            "oneOf": [
              {
                "type": "number",
                "minimum": 0,
                "maximum": 999999999.99
              },
              {
                "type": "string",
                "maxLength": 128,
                "pattern": "^\\s*(?:\\+?(?:(?:[0-9]+(?:\\.[0-9]*)?)|(?:\\.[0-9]+))(?:[eE][+-]?[0-9]+)?)?\\s*$"
              }
            ],
            "description": "A value coercible to a finite number from 0 through 999999999.99; surrounding whitespace is ignored.",
            "default": 0
          },
          "currency": {
            "type": "string",
            "minLength": 3,
            "maxLength": 3,
            "default": "EUR"
          },
          "probability": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100
          },
          "source": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 80
          },
          "priority": {
            "type": "string",
            "enum": [
              "low",
              "normal",
              "high",
              "urgent"
            ],
            "default": "normal"
          },
          "expectedCloseDate": {
            "anyOf": [
              {
                "type": "string",
                "format": "date"
              },
              {
                "type": "string",
                "const": ""
              },
              {
                "type": "null"
              }
            ]
          },
          "lostReason": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 1000
          },
          "nextAction": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 500
          }
        }
      },
      "Opportunity": {
        "allOf": [
          {
            "$ref": "#/components/schemas/OpportunityCreate"
          },
          {
            "type": "object",
            "required": [
              "id",
              "workspaceId",
              "stageId",
              "status",
              "estimatedValue",
              "currency",
              "priority",
              "company",
              "primaryContact",
              "stage",
              "customFields",
              "createdAt",
              "updatedAt",
              "deletedAt"
            ],
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "workspaceId": {
                "type": "string",
                "format": "uuid"
              },
              "ownerUserId": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "uuid"
              },
              "createdByUserId": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "uuid"
              },
              "updatedByUserId": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "uuid"
              },
              "status": {
                "type": "string",
                "enum": [
                  "open",
                  "won",
                  "lost"
                ]
              },
              "estimatedValue": {
                "type": "string",
                "pattern": "^[0-9]+(?:\\.[0-9]+)?$"
              },
              "probability": {
                "type": [
                  "integer",
                  "null"
                ],
                "minimum": 0,
                "maximum": 100
              },
              "wonAt": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              },
              "lostAt": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              },
              "customFields": {
                "type": "object",
                "additionalProperties": true
              },
              "companyName": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "primaryContactFirstName": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "primaryContactLastName": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "stageName": {
                "type": "string"
              },
              "stageType": {
                "type": "string",
                "enum": [
                  "open",
                  "won",
                  "lost"
                ]
              },
              "stageColor": {
                "type": [
                  "string",
                  "null"
                ],
                "pattern": "^#[0-9a-fA-F]{6}$"
              },
              "company": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/CompanySummary"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "primaryContact": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/ContactSummary"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "stage": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/PipelineStageSummary"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "createdAt": {
                "type": "string",
                "format": "date-time"
              },
              "updatedAt": {
                "type": "string",
                "format": "date-time"
              },
              "deletedAt": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              }
            }
          }
        ]
      },
      "CompanySummary": {
        "type": "object",
        "required": [
          "id",
          "name"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          }
        }
      },
      "ContactSummary": {
        "type": "object",
        "required": [
          "id",
          "firstName",
          "lastName"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "firstName": {
            "type": "string"
          },
          "lastName": {
            "type": "string"
          }
        }
      },
      "PipelineStageSummary": {
        "type": "object",
        "required": [
          "id",
          "name",
          "type",
          "color"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": [
              "open",
              "won",
              "lost"
            ]
          },
          "color": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^#[0-9a-fA-F]{6}$"
          }
        }
      },
      "OpportunityStageChange": {
        "type": "object",
        "required": [
          "stageId"
        ],
        "properties": {
          "stageId": {
            "type": "string",
            "format": "uuid"
          },
          "lostReason": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 1000
          }
        }
      },
      "PipelineStageCreate": {
        "type": "object",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          },
          "type": {
            "type": "string",
            "enum": [
              "open",
              "won",
              "lost"
            ],
            "default": "open"
          },
          "probability": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100
          },
          "position": {
            "type": "integer",
            "minimum": 0
          },
          "color": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^#[0-9a-fA-F]{6}$"
          }
        }
      },
      "PipelineStageUpdate": {
        "type": "object",
        "minProperties": 1,
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          },
          "type": {
            "type": "string",
            "enum": [
              "open",
              "won",
              "lost"
            ]
          },
          "probability": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100
          },
          "position": {
            "type": "integer",
            "minimum": 0
          },
          "color": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^#[0-9a-fA-F]{6}$"
          }
        }
      },
      "PipelineStage": {
        "allOf": [
          {
            "$ref": "#/components/schemas/PipelineStageCreate"
          },
          {
            "type": "object",
            "required": [
              "id",
              "workspaceId",
              "name",
              "type",
              "position",
              "probability",
              "color",
              "isClosed",
              "isWon",
              "isLost",
              "createdAt",
              "updatedAt",
              "deletedAt"
            ],
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "workspaceId": {
                "type": "string",
                "format": "uuid"
              },
              "isClosed": {
                "type": "boolean"
              },
              "isWon": {
                "type": "boolean"
              },
              "isLost": {
                "type": "boolean"
              },
              "createdAt": {
                "type": "string",
                "format": "date-time"
              },
              "updatedAt": {
                "type": "string",
                "format": "date-time"
              },
              "deletedAt": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              }
            }
          }
        ]
      },
      "TaskCreate": {
        "type": "object",
        "required": [
          "title"
        ],
        "description": "At most one of companyId, contactId, and opportunityId may be non-null.",
        "properties": {
          "title": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 4000
          },
          "status": {
            "type": "string",
            "enum": [
              "open",
              "in_progress",
              "completed",
              "cancelled"
            ],
            "default": "open"
          },
          "priority": {
            "type": "string",
            "enum": [
              "low",
              "normal",
              "high",
              "urgent"
            ],
            "default": "normal"
          },
          "dueAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "string",
                "const": ""
              },
              {
                "type": "null"
              }
            ]
          },
          "assignedUserId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "companyId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "contactId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "opportunityId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          }
        }
      },
      "TaskUpdate": {
        "type": "object",
        "minProperties": 1,
        "properties": {
          "title": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 4000
          },
          "status": {
            "type": "string",
            "enum": [
              "open",
              "in_progress",
              "completed",
              "cancelled"
            ],
            "default": "open"
          },
          "priority": {
            "type": "string",
            "enum": [
              "low",
              "normal",
              "high",
              "urgent"
            ],
            "default": "normal"
          },
          "dueAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "string",
                "const": ""
              },
              {
                "type": "null"
              }
            ]
          },
          "assignedUserId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "companyId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "contactId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "opportunityId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          }
        }
      },
      "Task": {
        "allOf": [
          {
            "$ref": "#/components/schemas/TaskCreate"
          },
          {
            "type": "object",
            "required": [
              "id",
              "workspaceId",
              "assignedUser",
              "company",
              "contact",
              "opportunity",
              "completedAt",
              "createdAt",
              "updatedAt",
              "deletedAt"
            ],
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "workspaceId": {
                "type": "string",
                "format": "uuid"
              },
              "createdByUserId": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "uuid"
              },
              "updatedByUserId": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "uuid"
              },
              "assignedUserName": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "assignedUserEmail": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "email"
              },
              "companyName": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "contactFirstName": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "contactLastName": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "opportunityTitle": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "assignedUser": {
                "oneOf": [
                  {
                    "type": "object",
                    "required": [
                      "id",
                      "name",
                      "email"
                    ],
                    "properties": {
                      "id": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "name": {
                        "type": [
                          "string",
                          "null"
                        ]
                      },
                      "email": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "format": "email"
                      }
                    }
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "company": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/CompanySummary"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "contact": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/ContactSummary"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "opportunity": {
                "oneOf": [
                  {
                    "type": "object",
                    "required": [
                      "id",
                      "title"
                    ],
                    "properties": {
                      "id": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "title": {
                        "type": "string"
                      }
                    }
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "completedAt": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              },
              "createdAt": {
                "type": "string",
                "format": "date-time"
              },
              "updatedAt": {
                "type": "string",
                "format": "date-time"
              },
              "deletedAt": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              }
            }
          }
        ]
      },
      "NoteCreate": {
        "type": "object",
        "required": [
          "body"
        ],
        "description": "Exactly one of companyId, contactId, and opportunityId must be non-null.",
        "properties": {
          "body": {
            "type": "string",
            "minLength": 1,
            "maxLength": 20000
          },
          "companyId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "contactId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "opportunityId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          }
        }
      },
      "NoteUpdate": {
        "type": "object",
        "required": [
          "body"
        ],
        "properties": {
          "body": {
            "type": "string",
            "minLength": 1,
            "maxLength": 20000
          }
        }
      },
      "Note": {
        "allOf": [
          {
            "$ref": "#/components/schemas/NoteCreate"
          },
          {
            "type": "object",
            "required": [
              "id",
              "workspaceId",
              "isPinned",
              "createdAt",
              "updatedAt",
              "deletedAt"
            ],
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "workspaceId": {
                "type": "string",
                "format": "uuid"
              },
              "authorUserId": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "uuid"
              },
              "authorName": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "authorEmail": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "email"
              },
              "isPinned": {
                "type": "boolean"
              },
              "createdAt": {
                "type": "string",
                "format": "date-time"
              },
              "updatedAt": {
                "type": "string",
                "format": "date-time"
              },
              "deletedAt": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              }
            }
          }
        ]
      },
      "Activity": {
        "type": "object",
        "required": [
          "id",
          "workspaceId",
          "eventType",
          "event",
          "metadata",
          "occurredAt",
          "createdAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "workspaceId": {
            "type": "string",
            "format": "uuid"
          },
          "eventType": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          },
          "event": {
            "type": "string"
          },
          "actorUserId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "actorApiKeyId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "actorType": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 32
          },
          "actorUserName": {
            "type": [
              "string",
              "null"
            ]
          },
          "actorUserEmail": {
            "type": [
              "string",
              "null"
            ],
            "format": "email"
          },
          "actorName": {
            "type": [
              "string",
              "null"
            ]
          },
          "companyId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "contactId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "opportunityId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "taskId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "type": {
            "type": [
              "string",
              "null"
            ]
          },
          "source": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 80
          },
          "relatedEntityType": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 80
          },
          "relatedEntityId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "entityType": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 80
          },
          "entityId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "subject": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 240
          },
          "title": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 240
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true
          },
          "occurredAt": {
            "type": "string",
            "format": "date-time"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "TagCreate": {
        "type": "object",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 60
          },
          "color": {
            "type": "string",
            "pattern": "^#[0-9a-fA-F]{6}$",
            "default": "#715CFF"
          }
        }
      },
      "TagUpdate": {
        "type": "object",
        "minProperties": 1,
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 60
          },
          "color": {
            "type": "string",
            "pattern": "^#[0-9a-fA-F]{6}$"
          }
        }
      },
      "Tag": {
        "allOf": [
          {
            "$ref": "#/components/schemas/TagCreate"
          },
          {
            "type": "object",
            "required": [
              "id",
              "workspaceId",
              "name",
              "color",
              "createdAt",
              "updatedAt",
              "deletedAt"
            ],
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "workspaceId": {
                "type": "string",
                "format": "uuid"
              },
              "usageCount": {
                "type": "integer",
                "minimum": 0
              },
              "createdAt": {
                "type": "string",
                "format": "date-time"
              },
              "updatedAt": {
                "type": "string",
                "format": "date-time"
              },
              "deletedAt": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              }
            }
          }
        ]
      },
      "ApiKeyCreate": {
        "type": "object",
        "required": [
          "name",
          "scopes"
        ],
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          },
          "scopes": {
            "type": "array",
            "minItems": 1,
            "maxItems": 10,
            "items": {
              "$ref": "#/components/schemas/ApiScope"
            }
          },
          "expiresAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "string",
                "const": ""
              },
              {
                "type": "null"
              }
            ],
            "description": "Optional expiry strictly in the future; an empty string is normalized to null."
          }
        }
      },
      "ApiKey": {
        "type": "object",
        "required": [
          "id",
          "name",
          "prefix",
          "scopes",
          "status",
          "expiresAt",
          "lastUsedAt",
          "revokedAt",
          "createdAt"
        ],
        "description": "Safe API-key metadata. Neither the plaintext key nor its digest is exposed.",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "prefix": {
            "type": "string",
            "description": "Non-secret prefix used to identify the key."
          },
          "scopes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ApiScope"
            }
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "revoked"
            ]
          },
          "expiresAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "lastUsedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "revokedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "ApiKeyCreated": {
        "allOf": [
          {
            "$ref": "#/components/schemas/ApiKey"
          },
          {
            "type": "object",
            "required": [
              "key"
            ],
            "properties": {
              "key": {
                "type": "string",
                "readOnly": true,
                "description": "Plaintext API key. Returned once and never retrievable again."
              }
            }
          }
        ]
      },
      "WebsiteLeadRequest": {
        "type": "object",
        "required": [
          "company",
          "contact",
          "opportunity"
        ],
        "properties": {
          "company": {
            "type": "object",
            "required": [
              "name"
            ],
            "properties": {
              "name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 160
              },
              "website": {
                "type": "string",
                "format": "uri",
                "maxLength": 2048
              },
              "vatNumber": {
                "type": "string",
                "maxLength": 40
              }
            }
          },
          "contact": {
            "type": "object",
            "required": [
              "firstName",
              "lastName",
              "email"
            ],
            "properties": {
              "firstName": {
                "type": "string",
                "minLength": 1,
                "maxLength": 100
              },
              "lastName": {
                "type": "string",
                "minLength": 1,
                "maxLength": 100
              },
              "email": {
                "type": "string",
                "format": "email",
                "maxLength": 254
              },
              "phone": {
                "type": "string",
                "maxLength": 40
              },
              "preferredLanguage": {
                "type": "string",
                "enum": [
                  "nl",
                  "fr",
                  "en",
                  "de"
                ],
                "default": "nl"
              }
            }
          },
          "opportunity": {
            "type": "object",
            "required": [
              "title"
            ],
            "properties": {
              "title": {
                "type": "string",
                "minLength": 1,
                "maxLength": 200
              },
              "description": {
                "type": "string",
                "maxLength": 8000
              },
              "serviceInterest": {
                "type": "string",
                "maxLength": 160
              },
              "estimatedValue": {
                "oneOf": [
                  {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 999999999.99
                  },
                  {
                    "type": "string",
                    "maxLength": 128,
                    "pattern": "^\\s*(?:\\+?(?:(?:[0-9]+(?:\\.[0-9]*)?)|(?:\\.[0-9]+))(?:[eE][+-]?[0-9]+)?)?\\s*$"
                  }
                ],
                "description": "A value coercible to a finite number from 0 through 999999999.99; surrounding whitespace is ignored.",
                "default": 0
              },
              "source": {
                "type": "string",
                "maxLength": 80,
                "default": "website"
              }
            }
          },
          "createFollowUpTask": {
            "type": "boolean",
            "default": true
          }
        }
      },
      "WebsiteLeadResult": {
        "type": "object",
        "required": [
          "companyId",
          "contactId",
          "opportunityId",
          "followUpTaskId",
          "replayed"
        ],
        "properties": {
          "companyId": {
            "type": "string",
            "format": "uuid"
          },
          "contactId": {
            "type": "string",
            "format": "uuid"
          },
          "opportunityId": {
            "type": "string",
            "format": "uuid"
          },
          "followUpTaskId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "replayed": {
            "type": "boolean",
            "description": "True when the result came from an earlier Idempotency-Key request."
          }
        }
      },
      "WebhookCreate": {
        "type": "object",
        "required": [
          "name",
          "destinationUrl",
          "events"
        ],
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          },
          "destinationUrl": {
            "type": "string",
            "format": "uri",
            "pattern": "^https://",
            "maxLength": 2048,
            "description": "HTTPS URL without credentials or a fragment. Its hostname must resolve exclusively to public IP addresses."
          },
          "events": {
            "type": "array",
            "minItems": 1,
            "maxItems": 9,
            "items": {
              "$ref": "#/components/schemas/WebhookEvent"
            }
          },
          "enabled": {
            "type": "boolean",
            "default": true
          }
        }
      },
      "WebhookUpdate": {
        "type": "object",
        "minProperties": 1,
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          },
          "destinationUrl": {
            "type": "string",
            "format": "uri",
            "pattern": "^https://",
            "maxLength": 2048,
            "description": "HTTPS URL without credentials or a fragment. Its hostname must resolve exclusively to public IP addresses."
          },
          "events": {
            "type": "array",
            "minItems": 1,
            "maxItems": 9,
            "items": {
              "$ref": "#/components/schemas/WebhookEvent"
            }
          },
          "enabled": {
            "type": "boolean",
            "default": true
          }
        }
      },
      "Webhook": {
        "allOf": [
          {
            "$ref": "#/components/schemas/WebhookCreate"
          },
          {
            "type": "object",
            "required": [
              "id",
              "name",
              "destinationUrl",
              "events",
              "enabled",
              "createdAt",
              "updatedAt"
            ],
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "createdAt": {
                "type": "string",
                "format": "date-time"
              },
              "updatedAt": {
                "type": "string",
                "format": "date-time"
              }
            }
          }
        ]
      },
      "WebhookCreated": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Webhook"
          },
          {
            "type": "object",
            "required": [
              "signingSecret"
            ],
            "properties": {
              "signingSecret": {
                "type": "string",
                "readOnly": true,
                "description": "Signing secret returned once. Only an AES-GCM encrypted value is persisted."
              }
            }
          }
        ]
      },
      "WebhookDelivery": {
        "type": "object",
        "required": [
          "id",
          "webhookId",
          "eventId",
          "event",
          "status",
          "attemptCount",
          "manualRetryCount",
          "nextAttemptAt",
          "lastAttemptAt",
          "responseStatus",
          "responseBody",
          "error",
          "deliveredAt",
          "createdAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "webhookId": {
            "type": "string",
            "format": "uuid"
          },
          "eventId": {
            "type": "string",
            "format": "uuid"
          },
          "event": {
            "$ref": "#/components/schemas/DeliveryWebhookEvent"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "processing",
              "delivered",
              "failed"
            ]
          },
          "responseStatus": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 100,
            "maximum": 599
          },
          "responseBody": {
            "type": [
              "string",
              "null"
            ]
          },
          "error": {
            "type": [
              "string",
              "null"
            ]
          },
          "attemptCount": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9
          },
          "manualRetryCount": {
            "type": "integer",
            "minimum": 0,
            "maximum": 3
          },
          "nextAttemptAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "lastAttemptAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "deliveredAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "WebhookPayload": {
        "type": "object",
        "required": [
          "id",
          "event",
          "createdAt",
          "data"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "event": {
            "$ref": "#/components/schemas/DeliveryWebhookEvent"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "Dashboard": {
        "type": "object",
        "required": [
          "companies",
          "contacts",
          "openOpportunities",
          "openPipelineValue",
          "weightedPipelineValue",
          "tasks",
          "outcomes",
          "stages",
          "recentActivities"
        ],
        "properties": {
          "companies": {
            "type": "integer",
            "minimum": 0
          },
          "contacts": {
            "type": "integer",
            "minimum": 0
          },
          "openOpportunities": {
            "type": "integer",
            "minimum": 0
          },
          "openPipelineValue": {
            "type": "number",
            "minimum": 0
          },
          "weightedPipelineValue": {
            "type": "number",
            "minimum": 0
          },
          "tasks": {
            "type": "object",
            "required": [
              "open",
              "overdue",
              "dueToday"
            ],
            "properties": {
              "open": {
                "type": "integer",
                "minimum": 0
              },
              "overdue": {
                "type": "integer",
                "minimum": 0
              },
              "dueToday": {
                "type": "integer",
                "minimum": 0
              }
            }
          },
          "outcomes": {
            "type": "object",
            "required": [
              "won",
              "lost",
              "wonValue",
              "wonThisMonth",
              "wonThisMonthValue",
              "conversionRate"
            ],
            "properties": {
              "won": {
                "type": "integer",
                "minimum": 0
              },
              "lost": {
                "type": "integer",
                "minimum": 0
              },
              "wonValue": {
                "type": "number",
                "minimum": 0
              },
              "wonThisMonth": {
                "type": "integer",
                "minimum": 0
              },
              "wonThisMonthValue": {
                "type": "number",
                "minimum": 0
              },
              "conversionRate": {
                "type": "number",
                "minimum": 0,
                "maximum": 100
              }
            }
          },
          "stages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DashboardStage"
            }
          },
          "recentActivities": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Activity"
            }
          }
        }
      },
      "DashboardStage": {
        "type": "object",
        "required": [
          "id",
          "name",
          "type",
          "color",
          "position",
          "probability",
          "opportunityCount",
          "totalValue"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": [
              "open",
              "won",
              "lost"
            ]
          },
          "color": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^#[0-9a-fA-F]{6}$"
          },
          "position": {
            "type": "integer",
            "minimum": 0
          },
          "probability": {
            "type": "number",
            "minimum": 0,
            "maximum": 100
          },
          "opportunityCount": {
            "type": "integer",
            "minimum": 0
          },
          "totalValue": {
            "type": "number",
            "minimum": 0
          }
        }
      },
      "SearchResult": {
        "type": "object",
        "required": [
          "type",
          "id",
          "title",
          "subtitle",
          "path",
          "href",
          "updatedAt"
        ],
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "company",
              "contact",
              "opportunity",
              "task"
            ]
          },
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "title": {
            "type": "string"
          },
          "subtitle": {
            "type": [
              "string",
              "null"
            ]
          },
          "path": {
            "type": "string",
            "pattern": "^/(companies|contacts|opportunities|tasks)/[0-9a-f-]+$"
          },
          "href": {
            "type": "string",
            "pattern": "^/(companies|contacts|opportunities|tasks)\\?selected=[0-9a-f-]+$"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "WorkspaceSettingsUpdate": {
        "type": "object",
        "required": [
          "workspaceName",
          "currency",
          "timezone",
          "locale"
        ],
        "properties": {
          "workspaceName": {
            "type": "string",
            "minLength": 2,
            "maxLength": 160
          },
          "currency": {
            "type": "string",
            "minLength": 3,
            "maxLength": 3
          },
          "timezone": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64
          },
          "locale": {
            "type": "string",
            "minLength": 2,
            "maxLength": 16,
            "pattern": "^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$"
          }
        }
      },
      "WorkspaceSettings": {
        "allOf": [
          {
            "$ref": "#/components/schemas/WorkspaceSettingsUpdate"
          },
          {
            "type": "object",
            "required": [
              "id",
              "workspaceName",
              "name",
              "currency",
              "timezone",
              "locale"
            ],
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "name": {
                "type": "string",
                "minLength": 2,
                "maxLength": 160
              }
            }
          }
        ]
      },
      "Health": {
        "type": "object",
        "required": [
          "status"
        ],
        "properties": {
          "status": {
            "type": "string",
            "const": "ok"
          }
        }
      },
      "Readiness": {
        "type": "object",
        "required": [
          "status",
          "checks"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "ready",
              "not_ready"
            ]
          },
          "checks": {
            "type": "object",
            "required": [
              "database"
            ],
            "properties": {
              "database": {
                "type": "string",
                "enum": [
                  "up",
                  "down"
                ]
              }
            }
          }
        }
      }
    }
  }
}