{"openapi": "3.0.3", "info": {"title": "Kyber Billing API", "version": "2.0.0", "description": "Quotes, proposals, invoices, subscriptions and payment links for KyberApps, KyberGate, KyberAccess, KyberWatch and KyberCopy (payee Kyber Systems LLC), across several Stripe accounts. All amounts are integer cents in USD. Every object carries brand and account_id."}, "servers": [{"url": "https://billing.kyberapps.com/api/v1"}], "components": {"securitySchemes": {"bearer": {"type": "http", "scheme": "bearer", "description": "Token created in Settings. Scopes: read, quotes:write, proposals:write, invoices:write, subscriptions:write, links:write, crm:write, prospects:write, admin"}}}, "paths": {"/me": {"get": {"summary": "Who am I", "description": "Returns the token label and scopes.", "security": [{"bearer": []}], "x-scope": "read", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}}}}, "/pricing-rules": {"get": {"summary": "Pricing rules", "description": "The pricing rules as data: KyberCopy bands, KyberGate floor and bands, manual products, multi-year discounts.", "security": [{"bearer": []}], "x-scope": "read", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}}}}, "/pricing-rules/suggest": {"get": {"summary": "Suggest a line", "description": "Default description, unit and unit price for a product. requires_price=true means the price must be supplied manually.", "security": [{"bearer": []}], "x-scope": "read", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}}, "parameters": [{"name": "product", "in": "query", "schema": {"type": "string"}}, {"name": "qty", "in": "query", "schema": {"type": "string"}}, {"name": "enrollment", "in": "query", "schema": {"type": "string"}}]}}, "/terms": {"get": {"summary": "Agreement text", "description": "Current Master Subscription Agreement text and version.", "security": [{"bearer": []}], "x-scope": "read", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}}}}, "/orgs": {"get": {"summary": "List organizations", "description": "Each org carries tags (list of strings). tag= narrows to one segment (case-insensitive).", "security": [{"bearer": []}], "x-scope": "read", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}}, "parameters": [{"name": "search", "in": "query", "schema": {"type": "string"}}, {"name": "tag", "in": "query", "schema": {"type": "string"}}]}, "post": {"summary": "Create organization", "description": "type is school, district or other. contacts is a list of {name,email,phone,role}. products is a list of product names.", "security": [{"bearer": []}], "x-scope": "quotes:write", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}, "201": {"description": "Created"}}, "requestBody": {"content": {"application/json": {"example": {"name": "Sample Academy", "type": "school", "address": "1 Main St, Albany, NY", "enrollment": 900, "contacts": [{"name": "Dana Lee", "email": "dlee@sample.edu", "phone": "", "role": "IT Director"}], "products": ["KyberCopy"], "tax_exempt": true, "tax_exempt_no": "EX-12345", "tags": ["Renewal 2027"]}}}}, "parameters": [{"name": "Idempotency-Key", "in": "header", "schema": {"type": "string"}, "description": "Replays the stored response for the same key, token and path."}]}}, "/tags": {"get": {"summary": "List tags", "description": "Every customer tag with how many customers carry it, most used first.", "security": [{"bearer": []}], "x-scope": "read", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}}}}, "/orgs/{id}": {"get": {"summary": "Get organization", "description": "Includes the org's quotes, proposals and invoices.", "security": [{"bearer": []}], "x-scope": "read", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}}, "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer"}}]}, "patch": {"summary": "Update organization", "description": "Send only the fields you want to change. tags replaces the customer's tags with exactly this list (max 20, 32 characters each).", "security": [{"bearer": []}], "x-scope": "quotes:write", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}, "201": {"description": "Created"}}, "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer"}}, {"name": "Idempotency-Key", "in": "header", "schema": {"type": "string"}, "description": "Replays the stored response for the same key, token and path."}], "requestBody": {"content": {"application/json": {"example": {"enrollment": 1200, "tags": ["Renewal 2027", "Board approval"]}}}}}}, "/quotes": {"get": {"summary": "List quotes", "description": "status: draft, sent, accepted, expired, declined, converted.", "security": [{"bearer": []}], "x-scope": "read", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}}, "parameters": [{"name": "org_id", "in": "query", "schema": {"type": "string"}}, {"name": "status", "in": "query", "schema": {"type": "string"}}]}, "post": {"summary": "Create quote", "description": "Lines: product (KyberGate, KyberAccess, KyberWatch, KyberCopy), description (optional, defaulted), qty, unit, unit_cents or unit_price (dollars), years, term_start, term_end, is_pilot. KyberCopy price is defaulted from the org's enrollment band when unit_cents is omitted. KyberGate never below 500 cents. KyberAccess and KyberWatch need a manual price. discount_type: none, percent (discount_percent, e.g. 10) or fixed (discount_amount in dollars). multi_year_percent: 0, 10 or 15. valid_until defaults to 30 days.", "security": [{"bearer": []}], "x-scope": "quotes:write", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}, "201": {"description": "Created"}}, "requestBody": {"content": {"application/json": {"example": {"org_id": 1, "lines": [{"product": "KyberCopy", "qty": 1, "term_start": "2026-11-01", "term_end": "2027-10-31"}, {"product": "KyberGate", "qty": 800, "unit_price": "5.50", "description": "KyberGate Basic, per device, annual"}], "discount_type": "percent", "discount_percent": 10, "notes": "Pricing held through the validity date."}}}}, "parameters": [{"name": "Idempotency-Key", "in": "header", "schema": {"type": "string"}, "description": "Replays the stored response for the same key, token and path."}]}}, "/quotes/{id}": {"get": {"summary": "Get quote", "description": "Includes share_path (/q/<token>) for the customer-facing page.", "security": [{"bearer": []}], "x-scope": "read", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}}, "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer"}}]}, "patch": {"summary": "Update quote", "description": "Same fields as create. Pass status: declined to decline. Accepted or converted quotes are locked.", "security": [{"bearer": []}], "x-scope": "quotes:write", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}, "201": {"description": "Created"}}, "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer"}}, {"name": "Idempotency-Key", "in": "header", "schema": {"type": "string"}, "description": "Replays the stored response for the same key, token and path."}], "requestBody": {"content": {"application/json": {"example": {"lines": [{"product": "KyberCopy", "qty": 2, "unit_price": "3600"}]}}}}}}, "/quotes/{id}/send": {"post": {"summary": "Mark quote sent", "description": "Sets status=sent and returns share_url. Nothing is emailed; deliver the link yourself.", "security": [{"bearer": []}], "x-scope": "quotes:write", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}, "201": {"description": "Created"}}, "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer"}}, {"name": "Idempotency-Key", "in": "header", "schema": {"type": "string"}, "description": "Replays the stored response for the same key, token and path."}], "requestBody": {"content": {"application/json": {"example": {}}}}}}, "/quotes/{id}/duplicate": {"post": {"summary": "Duplicate quote", "description": "New draft with a new number.", "security": [{"bearer": []}], "x-scope": "quotes:write", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}, "201": {"description": "Created"}}, "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer"}}, {"name": "Idempotency-Key", "in": "header", "schema": {"type": "string"}, "description": "Replays the stored response for the same key, token and path."}], "requestBody": {"content": {"application/json": {"example": {}}}}}}, "/quotes/{id}/versions": {"get": {"summary": "Quote versions", "description": "Every saved revision (v1, v2, ...) newest first, each with its lines, total and the changes from the one before.", "security": [{"bearer": []}], "x-scope": "read", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}}, "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer"}}]}}, "/quotes/{id}/invoice": {"post": {"summary": "Invoice a quote", "description": "Creates a draft native invoice from the quote's chosen lines (multi-year lines for all years, same discount as a fixed amount) and marks the quote converted. Nothing is emailed.", "security": [{"bearer": []}], "x-scope": "invoices:write", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}, "201": {"description": "Created"}}, "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer"}}, {"name": "Idempotency-Key", "in": "header", "schema": {"type": "string"}, "description": "Replays the stored response for the same key, token and path."}], "requestBody": {"content": {"application/json": {"example": {}}}}}}, "/proposals": {"get": {"summary": "List proposals", "description": "", "security": [{"bearer": []}], "x-scope": "read", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}}, "parameters": [{"name": "org_id", "in": "query", "schema": {"type": "string"}}, {"name": "status", "in": "query", "schema": {"type": "string"}}]}, "post": {"summary": "Create proposal from quote", "description": "Snapshots the quote and org, drafts the cover letter, attaches the current agreement text. payment_terms: net30 (PO, Stripe send_invoice) or card (hosted invoice, charge automatically). send: true also marks it sent.", "security": [{"bearer": []}], "x-scope": "proposals:write", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}, "201": {"description": "Created"}}, "requestBody": {"content": {"application/json": {"example": {"quote_id": 1, "payment_terms": "net30", "po_number": "", "send": true}}}}, "parameters": [{"name": "Idempotency-Key", "in": "header", "schema": {"type": "string"}, "description": "Replays the stored response for the same key, token and path."}]}}, "/proposals/{id}": {"get": {"summary": "Get proposal", "description": "Includes share_url and the quote snapshot.", "security": [{"bearer": []}], "x-scope": "read", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}}, "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer"}}]}, "patch": {"summary": "Update proposal", "description": "cover_letter, payment_terms, po_number, term_start, term_end, status (sent/declined). Locked after acceptance.", "security": [{"bearer": []}], "x-scope": "proposals:write", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}, "201": {"description": "Created"}}, "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer"}}, {"name": "Idempotency-Key", "in": "header", "schema": {"type": "string"}, "description": "Replays the stored response for the same key, token and path."}], "requestBody": {"content": {"application/json": {"example": {"po_number": "PO-2026-118"}}}}}}, "/proposals/{id}/status": {"get": {"summary": "Proposal status", "description": "Acceptance details: accepted_name, accepted_title, accepted_email, accepted_at (UTC), accepted_ip.", "security": [{"bearer": []}], "x-scope": "read", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}}, "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer"}}]}}, "/proposals/{id}/send": {"post": {"summary": "Mark proposal sent", "description": "Returns share_url. Nothing is emailed.", "security": [{"bearer": []}], "x-scope": "proposals:write", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}, "201": {"description": "Created"}}, "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer"}}, {"name": "Idempotency-Key", "in": "header", "schema": {"type": "string"}, "description": "Replays the stored response for the same key, token and path."}], "requestBody": {"content": {"application/json": {"example": {}}}}}}, "/invoices": {"get": {"summary": "List invoices", "description": "Also returns stripe_connected and stripe_test_mode.", "security": [{"bearer": []}], "x-scope": "read", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}}, "parameters": [{"name": "org_id", "in": "query", "schema": {"type": "string"}}, {"name": "status", "in": "query", "schema": {"type": "string"}}]}, "post": {"summary": "Create invoice from accepted proposal", "description": "With Stripe connected: creates a draft Stripe invoice from the proposal snapshot (send_invoice net-30 for PO, charge_automatically for card). send: true finalizes and sends it. Without Stripe, or for check/PO tracking, pass manual: true to create a local invoice record (amount defaults to the proposal total).", "security": [{"bearer": []}], "x-scope": "invoices:write", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}, "201": {"description": "Created"}}, "requestBody": {"content": {"application/json": {"example": {"proposal_id": 1, "send": false}}}}, "parameters": [{"name": "Idempotency-Key", "in": "header", "schema": {"type": "string"}, "description": "Replays the stored response for the same key, token and path."}]}}, "/invoices/{id}": {"get": {"summary": "Get invoice", "description": "", "security": [{"bearer": []}], "x-scope": "read", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}}, "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer"}}]}}, "/invoices/{id}/send": {"post": {"summary": "Finalize and send Stripe invoice", "description": "", "security": [{"bearer": []}], "x-scope": "invoices:write", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}, "201": {"description": "Created"}}, "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer"}}, {"name": "Idempotency-Key", "in": "header", "schema": {"type": "string"}, "description": "Replays the stored response for the same key, token and path."}], "requestBody": {"content": {"application/json": {"example": {}}}}}}, "/invoices/{id}/mark-paid": {"post": {"summary": "Mark paid (check or PO)", "description": "method: check, ach, po, other. reference: check number or remittance id.", "security": [{"bearer": []}], "x-scope": "invoices:write", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}, "201": {"description": "Created"}}, "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer"}}, {"name": "Idempotency-Key", "in": "header", "schema": {"type": "string"}, "description": "Replays the stored response for the same key, token and path."}], "requestBody": {"content": {"application/json": {"example": {"method": "check", "reference": "chk 10422"}}}}}}, "/receipts": {"get": {"summary": "List received payments", "description": "Checks, wires and other payments received by hand. applied_cents, refunded_cents and unapplied_cents (customer credit) per receipt.", "security": [{"bearer": []}], "x-scope": "read", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}}, "parameters": [{"name": "org_id", "in": "query", "schema": {"type": "string"}}, {"name": "status", "in": "query", "schema": {"type": "string"}}]}, "post": {"summary": "Record a received payment", "description": "One payment applied across the customer's invoices. method: check, wire, ach, card, other. applications: [{invoice_id, amount_cents}], or apply_oldest_first: true. What is not applied is kept as customer credit. received_on defaults to today.", "security": [{"bearer": []}], "x-scope": "invoices:write", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}, "201": {"description": "Created"}}, "requestBody": {"content": {"application/json": {"example": {"org_id": 1, "amount_cents": 170000, "method": "check", "reference": "CHK 1042", "applications": [{"invoice_id": 7, "amount_cents": 150000}]}}}}, "parameters": [{"name": "Idempotency-Key", "in": "header", "schema": {"type": "string"}, "description": "Replays the stored response for the same key, token and path."}]}}, "/receipts/{id}": {"get": {"summary": "Get received payment", "description": "With applications, refunds that drew on it, and receipt_url (the customer's receipt page).", "security": [{"bearer": []}], "x-scope": "read", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}}, "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer"}}]}}, "/receipts/{id}/void": {"post": {"summary": "Void received payment", "description": "Bounced check or entered twice: every application is cancelled and the invoices reopen. Refused while a credit refund draws on it.", "security": [{"bearer": []}], "x-scope": "invoices:write", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}, "201": {"description": "Created"}}, "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer"}}, {"name": "Idempotency-Key", "in": "header", "schema": {"type": "string"}, "description": "Replays the stored response for the same key, token and path."}], "requestBody": {"content": {"application/json": {"example": {"reason": "check bounced"}}}}}}, "/orgs/{id}/credit": {"get": {"summary": "Customer credit", "description": "credit_cents and the received payments it sits on, oldest first.", "security": [{"bearer": []}], "x-scope": "read", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}}, "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer"}}]}}, "/orgs/{id}/credit/apply": {"post": {"summary": "Apply customer credit", "description": "applications: [{invoice_id, amount_cents}]. Oldest credit is used first.", "security": [{"bearer": []}], "x-scope": "invoices:write", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}, "201": {"description": "Created"}}, "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer"}}, {"name": "Idempotency-Key", "in": "header", "schema": {"type": "string"}, "description": "Replays the stored response for the same key, token and path."}], "requestBody": {"content": {"application/json": {"example": {"applications": [{"invoice_id": 9, "amount_cents": 20000}]}}}}}}, "/credit-refunds": {"get": {"summary": "List credit refunds", "description": "Customer credit paid back out.", "security": [{"bearer": []}], "x-scope": "read", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}}, "parameters": [{"name": "org_id", "in": "query", "schema": {"type": "string"}}]}, "post": {"summary": "Refund customer credit", "description": "Record credit paid back to the customer. method: check, ach, wire, card, other. Nothing moves money; it records what you sent. Cannot exceed the customer's credit.", "security": [{"bearer": []}], "x-scope": "invoices:write", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}, "201": {"description": "Created"}}, "requestBody": {"content": {"application/json": {"example": {"org_id": 1, "amount_cents": 20000, "method": "check", "reference": "CHK 5511"}}}}, "parameters": [{"name": "Idempotency-Key", "in": "header", "schema": {"type": "string"}, "description": "Replays the stored response for the same key, token and path."}]}}, "/credit-refunds/{id}": {"get": {"summary": "Get credit refund", "description": "With the received payments it drew on and refund_url (the customer's refund advice page; add /pdf for the PDF).", "security": [{"bearer": []}], "x-scope": "read", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}}, "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer"}}]}}, "/credit-refunds/{id}/email": {"post": {"summary": "Email refund advice", "description": "Emails the customer's billing contact a link to the refund advice with the PDF attached (held on the server while MAIL_MODE=log).", "security": [{"bearer": []}], "x-scope": "invoices:write", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}, "201": {"description": "Created"}}, "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer"}}, {"name": "Idempotency-Key", "in": "header", "schema": {"type": "string"}, "description": "Replays the stored response for the same key, token and path."}], "requestBody": {"content": {"application/json": {"example": {}}}}}}, "/payments": {"get": {"summary": "List payments", "description": "The payments ledger: card, ACH and bank payments through Stripe, checks and wires recorded by hand, credit applied. Each has receipt_url (the customer's receipt page).", "security": [{"bearer": []}], "x-scope": "read", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}}, "parameters": [{"name": "org_id", "in": "query", "schema": {"type": "string"}}, {"name": "invoice_id", "in": "query", "schema": {"type": "string"}}, {"name": "status", "in": "query", "schema": {"type": "string"}}]}}, "/payments/{id}": {"get": {"summary": "Get payment", "description": "One ledger row with receipt_url.", "security": [{"bearer": []}], "x-scope": "read", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}}, "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer"}}]}}, "/credit-refunds/{id}/void": {"post": {"summary": "Void credit refund", "description": "The check was never mailed: the amount is customer credit again.", "security": [{"bearer": []}], "x-scope": "invoices:write", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}, "201": {"description": "Created"}}, "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer"}}, {"name": "Idempotency-Key", "in": "header", "schema": {"type": "string"}, "description": "Replays the stored response for the same key, token and path."}], "requestBody": {"content": {"application/json": {"example": {"reason": "never mailed"}}}}}}, "/subscriptions": {"get": {"summary": "List subscriptions", "description": "Annual plans mirrored from Stripe, per brand and per Stripe account. amount_cents is the annualised value; next_invoice_at is the renewal date.", "security": [{"bearer": []}], "x-scope": "read", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}}, "parameters": [{"name": "org_id", "in": "query", "schema": {"type": "string"}}, {"name": "status", "in": "query", "schema": {"type": "string"}}, {"name": "brand", "in": "query", "schema": {"type": "string"}}, {"name": "account", "in": "query", "schema": {"type": "string"}}]}, "post": {"summary": "Create subscription from accepted proposal", "description": "The proposal's quote must have billing_mode=subscription (or pass it anyway to bill an accepted quote annually). Creates the Stripe subscription on the proposal's account (annual, N-year interval for multi-year lines), the first invoice follows Stripe's collection method. Nothing is emailed.", "security": [{"bearer": []}], "x-scope": "subscriptions:write", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}, "201": {"description": "Created"}}, "requestBody": {"content": {"application/json": {"example": {"proposal_id": 1}}}}, "parameters": [{"name": "Idempotency-Key", "in": "header", "schema": {"type": "string"}, "description": "Replays the stored response for the same key, token and path."}]}}, "/subscriptions/{id}": {"get": {"summary": "Get subscription", "description": "", "security": [{"bearer": []}], "x-scope": "read", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}}, "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer"}}]}, "patch": {"summary": "Set subscription brand", "description": "brand: kyberapps, kybergate, kyberaccess, kyberwatch, kybercopy or unassigned.", "security": [{"bearer": []}], "x-scope": "subscriptions:write", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}, "201": {"description": "Created"}}, "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer"}}, {"name": "Idempotency-Key", "in": "header", "schema": {"type": "string"}, "description": "Replays the stored response for the same key, token and path."}], "requestBody": {"content": {"application/json": {"example": {"brand": "kybergate"}}}}}}, "/subscriptions/{id}/sync": {"post": {"summary": "Sync subscription from Stripe", "description": "", "security": [{"bearer": []}], "x-scope": "subscriptions:write", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}, "201": {"description": "Created"}}, "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer"}}, {"name": "Idempotency-Key", "in": "header", "schema": {"type": "string"}, "description": "Replays the stored response for the same key, token and path."}], "requestBody": {"content": {"application/json": {"example": {}}}}}}, "/payment-links": {"get": {"summary": "List payment links", "description": "", "security": [{"bearer": []}], "x-scope": "read", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}}, "parameters": [{"name": "brand", "in": "query", "schema": {"type": "string"}}, {"name": "account", "in": "query", "schema": {"type": "string"}}, {"name": "org_id", "in": "query", "schema": {"type": "string"}}]}, "post": {"summary": "Create payment link", "description": "Stripe-hosted pay page. account (label) defaults to the brand's account. unit_cents or unit_price; qty; recurring: empty (one-off), month or year; product optional (KyberGate, KyberCopy, ...).", "security": [{"bearer": []}], "x-scope": "links:write", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}, "201": {"description": "Created"}}, "requestBody": {"content": {"application/json": {"example": {"brand": "kybergate", "description": "KyberGate \u00b7 1,200 devices \u00b7 2026-27", "unit_price": "6000", "qty": 1, "recurring": "", "org_id": 1}}}}, "parameters": [{"name": "Idempotency-Key", "in": "header", "schema": {"type": "string"}, "description": "Replays the stored response for the same key, token and path."}]}}, "/payment-links/{id}": {"get": {"summary": "Get payment link", "description": "", "security": [{"bearer": []}], "x-scope": "read", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}}, "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer"}}]}}, "/payment-links/{id}/deactivate": {"post": {"summary": "Deactivate payment link", "description": "", "security": [{"bearer": []}], "x-scope": "links:write", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}, "201": {"description": "Created"}}, "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer"}}, {"name": "Idempotency-Key", "in": "header", "schema": {"type": "string"}, "description": "Replays the stored response for the same key, token and path."}], "requestBody": {"content": {"application/json": {"example": {}}}}}}, "/orgs/{id}/portal": {"post": {"summary": "Customer portal session", "description": "Short-lived Stripe customer-portal URL for the org (invoice history, payment methods, billing details; cancel is off). account optional.", "security": [{"bearer": []}], "x-scope": "read", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}, "201": {"description": "Created"}}, "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer"}}, {"name": "Idempotency-Key", "in": "header", "schema": {"type": "string"}, "description": "Replays the stored response for the same key, token and path."}], "requestBody": {"content": {"application/json": {"example": {"account": "kyber-systems"}}}}}}, "/stripe-accounts": {"get": {"summary": "List Stripe accounts", "description": "Label, Stripe account id, display name, default brand, mode, connected, webhook secret set, last sync. Never returns keys.", "security": [{"bearer": []}], "x-scope": "read", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}}}}, "/stripe-accounts/{id}/sync": {"post": {"summary": "Sync one Stripe account", "description": "id is the label or numeric id. full: true also walks products and quotes (the Import existing action). Read-only against Stripe.", "security": [{"bearer": []}], "x-scope": "admin", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}, "201": {"description": "Created"}}, "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer"}}, {"name": "Idempotency-Key", "in": "header", "schema": {"type": "string"}, "description": "Replays the stored response for the same key, token and path."}], "requestBody": {"content": {"application/json": {"example": {"full": false}}}}}}, "/brands": {"get": {"summary": "List brands", "description": "Every brand with legal name, address, support email, website, tax id, accent, logo URL, price family, invoice prefix, its own Stripe account (or null) and bills_from (the account its money goes to: its own, else the umbrella's; null when its own account is disconnected).", "security": [{"bearer": []}], "x-scope": "read", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}}, "parameters": [{"name": "archived", "in": "query", "schema": {"type": "string"}}]}, "post": {"summary": "Create brand", "description": "key (optional, from name), name, tagline, legal_name, accent (hex, 3:1 on white), family, support_email, website, address, tax_id, default_terms, payment_text. Connect its Stripe account in Settings, Brands.", "security": [{"bearer": []}], "x-scope": "admin", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}, "201": {"description": "Created"}}, "requestBody": {"content": {"application/json": {"example": {"name": "KyberLearn", "accent": "#5B3FD6", "support_email": "hello@kyberapps.com"}}}}, "parameters": [{"name": "Idempotency-Key", "in": "header", "schema": {"type": "string"}, "description": "Replays the stored response for the same key, token and path."}]}}, "/brands/{key}": {"get": {"summary": "Get brand", "description": "One brand plus usage counts (customers, quotes, proposals, invoices, subscriptions, payment links, products).", "security": [{"bearer": []}], "x-scope": "read", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}}}, "patch": {"summary": "Update or archive brand", "description": "Any brand field; archived: true hides it from pickers and keeps history (the umbrella cannot be archived).", "security": [{"bearer": []}], "x-scope": "admin", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}, "201": {"description": "Created"}}, "requestBody": {"content": {"application/json": {"example": {"tagline": "Learning platform", "archived": false}}}}, "parameters": [{"name": "Idempotency-Key", "in": "header", "schema": {"type": "string"}, "description": "Replays the stored response for the same key, token and path."}]}}, "/prospects/import": {"post": {"summary": "Import researched prospects", "description": "Fleet research import. accounts: up to 200 schools or districts, each with up to 50 people. Any field may be a plain value or {value, source_url, confidence (0 to 1), found_at (YYYY-MM-DD), notes}; account-level source_url, confidence, found_at and research_notes are the default for its fields and people. Everything lands in the Review queue (/prospects/review); nothing is created or emailed until a person accepts it. Student-pattern and personal mailbox addresses are dropped and counted in blocked_people. Bad accounts come back per index with status invalid and do not stop the rest. Send an Idempotency-Key to retry safely. Schema: GET /api/v1/prospects/import/schema.", "security": [{"bearer": []}], "x-scope": "prospects:write", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}, "201": {"description": "Created"}}, "requestBody": {"content": {"application/json": {"example": {"batch": {"ref": "ny-westchester-2026-11", "brand": "kybergate", "brief": "Westchester public districts, tech directors"}, "accounts": [{"name": "Sample Union Free School District", "type": "district", "nces_id": "3600001", "state": "NY", "county": "Westchester", "website": "sampleufsd.org", "enrollment": 4200, "locale": "suburb", "source_url": "https://nces.ed.gov/ccd/districtsearch/", "confidence": 0.9, "found_at": "2026-11-25", "people": [{"name": "Dana Lee", "title": "Director of Technology", "email": {"value": "dlee@sampleufsd.org", "source_url": "https://sampleufsd.org/staff", "confidence": 0.8}}]}]}}}}, "parameters": [{"name": "Idempotency-Key", "in": "header", "schema": {"type": "string"}, "description": "Replays the stored response for the same key, token and path."}]}}, "/prospects/import/schema": {"get": {"summary": "Prospect import JSON schema", "description": "The JSON schema for the import body, with the sourcing rules.", "security": [{"bearer": []}], "x-scope": "read", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}}}}, "/prospects/match": {"get": {"summary": "Does this prospect exist?", "description": "Check before researching or importing: companies that look like this school or district (same NCES ID or website, staff email domain, same or similar name in the state), strongest first, each with why and a level (exact, likely, possible). Different NCES IDs, states, counties, school levels or a school versus a district never match.", "security": [{"bearer": []}], "x-scope": "read", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}}, "parameters": [{"name": "name", "in": "query", "schema": {"type": "string"}}, {"name": "state", "in": "query", "schema": {"type": "string"}}, {"name": "website", "in": "query", "schema": {"type": "string"}}, {"name": "nces_id", "in": "query", "schema": {"type": "string"}}, {"name": "type", "in": "query", "schema": {"type": "string"}}]}}, "/prospects/batches/{id}": {"get": {"summary": "Import batch status", "description": "Counts for one import batch: accounts, people, blocked, invalid, and how many are pending, accepted and rejected.", "security": [{"bearer": []}], "x-scope": "read", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}}, "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer"}}]}}, "/credit-notes": {"get": {"summary": "List credit notes", "description": "Issued and void credit notes with lines, amounts applied, refunded and kept as credit, and credit_note_url (the customer's copy).", "security": [{"bearer": []}], "x-scope": "read", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}}, "parameters": [{"name": "org_id", "in": "query", "schema": {"type": "string"}}, {"name": "invoice_id", "in": "query", "schema": {"type": "string"}}]}, "post": {"summary": "Issue credit note", "description": "On an issued invoice. Either lines: [{line (index on the invoice), qty}], amount_cents with description, or full: true for everything left. apply_cents (default: as much as is due) goes on the invoice; refund_cents with refund_method (check, ach, wire, other) records money sent back; the rest is customer credit. reason: returned, billing_error, discount, duplicate, other. Card refunds through Stripe are made on the invoice page.", "security": [{"bearer": []}], "x-scope": "invoices:write", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}, "201": {"description": "Created"}}, "requestBody": {"content": {"application/json": {"example": {"invoice_id": 7, "amount_cents": 25000, "description": "Goodwill credit, outage in October", "reason": "discount"}}}}, "parameters": [{"name": "Idempotency-Key", "in": "header", "schema": {"type": "string"}, "description": "Replays the stored response for the same key, token and path."}]}}, "/credit-notes/{id}": {"get": {"summary": "Get credit note", "description": "One credit note with its lines and where the money went.", "security": [{"bearer": []}], "x-scope": "read", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}}, "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer"}}]}}, "/deals": {"get": {"summary": "List deals", "description": "Pipeline deals with stage, value, weighted value, probability, owner, expected close and idle days. status: open, won, lost. Also returns the stages.", "security": [{"bearer": []}], "x-scope": "read", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}}, "parameters": [{"name": "status", "in": "query", "schema": {"type": "string"}}, {"name": "org_id", "in": "query", "schema": {"type": "string"}}, {"name": "owner_id", "in": "query", "schema": {"type": "string"}}, {"name": "brand", "in": "query", "schema": {"type": "string"}}]}, "post": {"summary": "Create deal", "description": "title and org_id are required. value in dollars (or omitted to estimate from products), stage_id (default the first stage), owner_id, expected_close (YYYY-MM-DD), probability, source, notes, contact_ids.", "security": [{"bearer": []}], "x-scope": "crm:write", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}, "201": {"description": "Created"}}, "requestBody": {"content": {"application/json": {"example": {"title": "District renewal 2027", "org_id": 1, "value": "18000", "expected_close": "2027-03-31", "source": "Existing customer"}}}}, "parameters": [{"name": "Idempotency-Key", "in": "header", "schema": {"type": "string"}, "description": "Replays the stored response for the same key, token and path."}]}}, "/deal-stages": {"get": {"summary": "Deal stages", "description": "Pipeline stages in board order with kind (open, won, lost) and probability.", "security": [{"bearer": []}], "x-scope": "read", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}}}}, "/deals/{id}": {"get": {"summary": "Get deal", "description": "One deal with its last 100 events (stage moves, edits, quotes, tasks).", "security": [{"bearer": []}], "x-scope": "read", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}}, "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer"}}]}, "patch": {"summary": "Update or move deal", "description": "Any deal field; stage_id or stage (key or name) moves it. Moving to a Lost stage needs lost_reason. Fires deal.stage_changed, deal.won or deal.lost.", "security": [{"bearer": []}], "x-scope": "crm:write", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}, "201": {"description": "Created"}}, "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer"}}, {"name": "Idempotency-Key", "in": "header", "schema": {"type": "string"}, "description": "Replays the stored response for the same key, token and path."}], "requestBody": {"content": {"application/json": {"example": {"stage": "won"}}}}}}, "/tasks": {"get": {"summary": "List tasks", "description": "Tasks with due date, owner, priority, the record they belong to and bucket (overdue, today, upcoming, nodate, done).", "security": [{"bearer": []}], "x-scope": "read", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}}, "parameters": [{"name": "status", "in": "query", "schema": {"type": "string"}}, {"name": "owner_id", "in": "query", "schema": {"type": "string"}}, {"name": "record_type", "in": "query", "schema": {"type": "string"}}, {"name": "record_id", "in": "query", "schema": {"type": "string"}}]}, "post": {"summary": "Create task", "description": "title is required. due_date, due_time (HH:MM), owner_id, priority (low, normal, high), record_type (deal, customer, contact, quote, invoice, proposal) with record_id.", "security": [{"bearer": []}], "x-scope": "crm:write", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}, "201": {"description": "Created"}}, "requestBody": {"content": {"application/json": {"example": {"title": "Call about the renewal", "due_date": "2026-12-01", "priority": "high", "record_type": "customer", "record_id": 1}}}}, "parameters": [{"name": "Idempotency-Key", "in": "header", "schema": {"type": "string"}, "description": "Replays the stored response for the same key, token and path."}]}}, "/tasks/{id}": {"get": {"summary": "Get task", "description": "", "security": [{"bearer": []}], "x-scope": "read", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}}, "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer"}}]}, "patch": {"summary": "Update or complete task", "description": "Any task field; done: true ticks it (fires task.completed), done: false reopens it.", "security": [{"bearer": []}], "x-scope": "crm:write", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}, "201": {"description": "Created"}}, "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer"}}, {"name": "Idempotency-Key", "in": "header", "schema": {"type": "string"}, "description": "Replays the stored response for the same key, token and path."}], "requestBody": {"content": {"application/json": {"example": {"done": true}}}}}}, "/events": {"get": {"summary": "List events", "description": "Everything that fired a webhook, newest first, kept even when no endpoint listens. type filters (invoice.paid, or invoice.* for a group). Page with before=<next_before>.", "security": [{"bearer": []}], "x-scope": "read", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}}, "parameters": [{"name": "type", "in": "query", "schema": {"type": "string"}}, {"name": "limit", "in": "query", "schema": {"type": "string"}}, {"name": "before", "in": "query", "schema": {"type": "string"}}]}}, "/events/{id}": {"get": {"summary": "Get event", "description": "One event by evt_ id, with the object as it was when it happened.", "security": [{"bearer": []}], "x-scope": "read", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}}, "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer"}}]}}, "/webhook-endpoints": {"get": {"summary": "List webhook endpoints", "description": "Each endpoint with its events, status and the last 24 hours of deliveries. Also returns every event type.", "security": [{"bearer": []}], "x-scope": "admin", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}}}, "post": {"summary": "Create webhook endpoint", "description": "url must be public https on port 443. events: list of event types or [\"*\"] for all. The response carries secret once; verify each delivery with it (see Webhooks below).", "security": [{"bearer": []}], "x-scope": "admin", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}, "201": {"description": "Created"}}, "requestBody": {"content": {"application/json": {"example": {"url": "https://hooks.example.com/kyber", "events": ["invoice.paid", "proposal.signed"], "description": "Accounting sync"}}}}, "parameters": [{"name": "Idempotency-Key", "in": "header", "schema": {"type": "string"}, "description": "Replays the stored response for the same key, token and path."}]}}, "/webhook-endpoints/{id}": {"get": {"summary": "Get webhook endpoint", "description": "With its last 50 deliveries.", "security": [{"bearer": []}], "x-scope": "admin", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}}, "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer"}}]}, "patch": {"summary": "Update webhook endpoint", "description": "url, events, description, status (active or disabled). Turning it back on resets the failure count.", "security": [{"bearer": []}], "x-scope": "admin", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}, "201": {"description": "Created"}}, "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer"}}, {"name": "Idempotency-Key", "in": "header", "schema": {"type": "string"}, "description": "Replays the stored response for the same key, token and path."}], "requestBody": {"content": {"application/json": {"example": {"status": "active"}}}}}}, "/webhook-endpoints/{id}/test": {"post": {"summary": "Send test event", "description": "Sends a webhook.test event now and returns the result.", "security": [{"bearer": []}], "x-scope": "admin", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}, "201": {"description": "Created"}}, "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer"}}, {"name": "Idempotency-Key", "in": "header", "schema": {"type": "string"}, "description": "Replays the stored response for the same key, token and path."}], "requestBody": {"content": {"application/json": {"example": {}}}}}}, "/webhook-endpoints/{id}/delete": {"post": {"summary": "Delete webhook endpoint", "description": "Deletes the endpoint and its delivery log. Events stay.", "security": [{"bearer": []}], "x-scope": "admin", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}, "201": {"description": "Created"}}, "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "integer"}}, {"name": "Idempotency-Key", "in": "header", "schema": {"type": "string"}, "description": "Replays the stored response for the same key, token and path."}], "requestBody": {"content": {"application/json": {"example": {}}}}}}, "/dashboard": {"get": {"summary": "Dashboard numbers", "description": "MRR, ARR, open, overdue, paid YTD, active subscriptions, pilots: total, per brand and per Stripe account.", "security": [{"bearer": []}], "x-scope": "read", "responses": {"200": {"description": "OK"}, "401": {"description": "Missing or invalid token"}, "403": {"description": "Token lacks scope"}, "404": {"description": "Not found"}, "422": {"description": "Validation error, see error field"}, "429": {"description": "Rate limited"}}, "parameters": [{"name": "brand", "in": "query", "schema": {"type": "string"}}, {"name": "account", "in": "query", "schema": {"type": "string"}}]}}}}