openapi: 3.1.0 info: title: Api version: 0.1.0 description: SaaS CRM API servers: - url: /api description: Base API path tags: - name: health description: Health operations - name: dashboard description: Dashboard summary - name: customers description: Customer management - name: invoices description: Invoice management - name: settings description: Company settings paths: /healthz: get: operationId: healthCheck tags: [health] summary: Health check responses: "200": description: Healthy content: application/json: schema: $ref: "#/components/schemas/HealthStatus" /dashboard/summary: get: operationId: getDashboardSummary tags: [dashboard] summary: Get dashboard summary counts parameters: - name: companyId in: query required: true schema: type: string responses: "200": description: Dashboard summary content: application/json: schema: $ref: "#/components/schemas/DashboardSummary" /customers: get: operationId: listCustomers tags: [customers] summary: List customers parameters: - name: companyId in: query required: true schema: type: string - name: search in: query schema: type: string responses: "200": description: List of customers content: application/json: schema: type: array items: $ref: "#/components/schemas/Customer" post: operationId: createCustomer tags: [customers] summary: Create a customer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CustomerInput" responses: "201": description: Created content: application/json: schema: $ref: "#/components/schemas/Customer" /customers/{id}: get: operationId: getCustomer tags: [customers] summary: Get a customer parameters: - name: id in: path required: true schema: type: string responses: "200": description: Customer content: application/json: schema: $ref: "#/components/schemas/Customer" patch: operationId: updateCustomer tags: [customers] summary: Update a customer parameters: - name: id in: path required: true schema: type: string requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CustomerUpdate" responses: "200": description: Updated content: application/json: schema: $ref: "#/components/schemas/Customer" delete: operationId: deleteCustomer tags: [customers] summary: Delete a customer parameters: - name: id in: path required: true schema: type: string responses: "204": description: Deleted /invoices: get: operationId: listInvoices tags: [invoices] summary: List invoices parameters: - name: companyId in: query required: true schema: type: string - name: customerId in: query schema: type: string - name: status in: query schema: type: string responses: "200": description: List of invoices content: application/json: schema: type: array items: $ref: "#/components/schemas/Invoice" post: operationId: createInvoice tags: [invoices] summary: Create an invoice requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/InvoiceInput" responses: "201": description: Created content: application/json: schema: $ref: "#/components/schemas/Invoice" /invoices/{id}: get: operationId: getInvoice tags: [invoices] summary: Get an invoice parameters: - name: id in: path required: true schema: type: string responses: "200": description: Invoice content: application/json: schema: $ref: "#/components/schemas/Invoice" patch: operationId: updateInvoice tags: [invoices] summary: Update an invoice parameters: - name: id in: path required: true schema: type: string requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/InvoiceUpdate" responses: "200": description: Updated content: application/json: schema: $ref: "#/components/schemas/Invoice" delete: operationId: deleteInvoice tags: [invoices] summary: Delete an invoice parameters: - name: id in: path required: true schema: type: string responses: "204": description: Deleted /settings/{companyId}: get: operationId: getSettings tags: [settings] summary: Get company settings parameters: - name: companyId in: path required: true schema: type: string responses: "200": description: Settings content: application/json: schema: $ref: "#/components/schemas/Settings" patch: operationId: updateSettings tags: [settings] summary: Update company settings parameters: - name: companyId in: path required: true schema: type: string requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/SettingsUpdate" responses: "200": description: Updated content: application/json: schema: $ref: "#/components/schemas/Settings" components: schemas: HealthStatus: type: object required: [status] properties: status: type: string DashboardSummary: type: object required: [totalCustomers, totalInvoices, pendingInvoices, paidInvoices, totalRevenue, pendingRevenue] properties: totalCustomers: type: integer totalInvoices: type: integer pendingInvoices: type: integer paidInvoices: type: integer totalRevenue: type: number pendingRevenue: type: number Customer: type: object required: [id, companyId, name, email, createdAt] properties: id: type: string companyId: type: string name: type: string email: type: string phone: type: ["string", "null"] address: type: ["string", "null"] notes: type: ["string", "null"] createdAt: type: string CustomerInput: type: object required: [companyId, name, email] properties: companyId: type: string name: type: string email: type: string phone: type: string address: type: string notes: type: string CustomerUpdate: type: object properties: name: type: string email: type: string phone: type: string address: type: string notes: type: string InvoiceItem: type: object required: [description, quantity, unitPrice] properties: description: type: string quantity: type: number unitPrice: type: number Invoice: type: object required: [id, companyId, customerId, customerName, invoiceNumber, status, items, subtotal, total, createdAt] properties: id: type: string companyId: type: string customerId: type: string customerName: type: string invoiceNumber: type: string status: type: string enum: [draft, sent, paid, overdue, cancelled] items: type: array items: $ref: "#/components/schemas/InvoiceItem" subtotal: type: number taxRate: type: ["number", "null"] taxAmount: type: ["number", "null"] discountType: type: ["string", "null"] discountValue: type: ["number", "null"] discountAmount: type: ["number", "null"] total: type: number notes: type: ["string", "null"] dueDate: type: ["string", "null"] createdAt: type: string InvoiceInput: type: object required: [companyId, customerId, customerName, items] properties: companyId: type: string customerId: type: string customerName: type: string status: type: string items: type: array items: $ref: "#/components/schemas/InvoiceItem" taxRate: type: number taxEnabled: type: boolean discountType: type: string discountValue: type: number discountEnabled: type: boolean notes: type: string dueDate: type: string InvoiceUpdate: type: object properties: status: type: string items: type: array items: $ref: "#/components/schemas/InvoiceItem" taxRate: type: number taxEnabled: type: boolean discountType: type: string discountValue: type: number discountEnabled: type: boolean notes: type: string dueDate: type: string Settings: type: object required: [companyId, companyName, currency, invoicePrefix, taxEnabled, discountEnabled] properties: companyId: type: string companyName: type: string companyLogo: type: ["string", "null"] currency: type: string invoicePrefix: type: string taxEnabled: type: boolean taxRate: type: number discountEnabled: type: boolean address: type: ["string", "null"] phone: type: ["string", "null"] email: type: ["string", "null"] website: type: ["string", "null"] SettingsUpdate: type: object properties: companyName: type: string companyLogo: type: string currency: type: string invoicePrefix: type: string taxEnabled: type: boolean taxRate: type: number discountEnabled: type: boolean address: type: string phone: type: string email: type: string website: type: string