{"openapi":"3.1.0","info":{"title":"Tonbab API","version":"2026-11-15","description":"API for Tonbab (ต้นแบบ) — the Thai-first all-in-one ERP.\n\n**Auth.** `/v1/public/*` is keyless and cacheable. Everything else needs `Authorization: Bearer <key>` — a company API key from Settings → API (`tnb_live_…`, or `tnb_test_…` whose writes validate without saving), OAuth tokens from AI connectors are bound to the MCP server. A key's scopes are Tonbab permission keys (`product.view`, `pr.create`…); every endpoint lists what it needs.\n\n**Pages.** List endpoints return `{ data, has_more, next_cursor }`; pass `cursor` for the next page. Add `updated_since` to sync incrementally (oldest-first).\n\n**Writes are drafts.** The API prepares work (PR / stock-count drafts, deals, activities, companies); submitting, approving and posting stay with people in Tonbab. POSTs accept `Idempotency-Key` (24 h).\n\n**Limits & errors.** `RateLimit-*` headers on every response, 429 + `Retry-After` when exceeded. Errors: `{ error: { code, message, request_id } }`. Quote `Request-Id` to support.\n\n**Events.** Webhooks (Settings → API) are signed `Tonbab-Signature: t=<unix>,v1=<hex HMAC-SHA256 of \"t.body\">`; see GET /v1/event-types, or poll GET /v1/events.\n\n**AI agents.** The same operations are tools on the MCP server at `https://api.tonbab.com/mcp` (OAuth 2.1 or API key).\n\n**Version** `2026-11-15` (sent back as `Tonbab-Version`).","contact":{"name":"Tonbab support","url":"https://api.tonbab.com/docs","email":"sales@codustry.com"}},"servers":[{"url":"https://api.tonbab.com","description":"Production"},{"url":"https://dev.app.tonbab.com","description":"Development"}],"externalDocs":{"description":"Tonbab API reference","url":"https://api.tonbab.com/docs"},"tags":[{"name":"Account"},{"name":"Products"},{"name":"Inventory"},{"name":"Parties"},{"name":"Documents"},{"name":"Procurement"},{"name":"Sales"},{"name":"CRM"},{"name":"Manufacturing"},{"name":"People"},{"name":"Docs"},{"name":"Events"},{"name":"Careers","description":"Public job-board feed for tenant careers pages"}],"components":{"securitySchemes":{"bearer":{"type":"http","scheme":"bearer","description":"A company API key (`tnb_live_…` / `tnb_test_…`, Settings → API). OAuth tokens from AI connectors are bound to the MCP server and are not accepted here."}},"schemas":{"JobListResponse":{"type":"object","properties":{"company":{"type":"string"},"profile":{"$ref":"#/components/schemas/CompanyProfile"},"jobs":{"type":"array","items":{"$ref":"#/components/schemas/Job"}}},"required":["company","profile","jobs"]},"CompanyProfile":{"type":"object","properties":{"logo_url":{"type":"string","nullable":true},"tagline_en":{"type":"string","nullable":true},"tagline_th":{"type":"string","nullable":true},"benefits":{"type":"array","items":{"type":"object","properties":{"key":{"type":"string"},"label_en":{"type":"string"},"label_th":{"type":"string"}},"required":["key","label_en","label_th"]}},"custom_benefits_en":{"type":"string","nullable":true},"custom_benefits_th":{"type":"string","nullable":true}},"required":["logo_url","tagline_en","tagline_th","benefits","custom_benefits_en","custom_benefits_th"]},"Job":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"number":{"type":"string","example":"JOB-0001"},"title":{"type":"string","example":"Full-stack Engineer (SvelteKit)"},"department":{"type":"string","nullable":true},"employment_type":{"type":"string","nullable":true,"example":"full_time"},"location":{"type":"string","nullable":true,"example":"Bangkok / Remote"},"category":{"$ref":"#/components/schemas/JobCategory"},"salary":{"$ref":"#/components/schemas/Salary"},"published_at":{"type":"string"},"apply_url":{"type":"string","format":"uri","description":"Hosted application form on Tonbab"}},"required":["id","number","title","department","employment_type","location","category","salary","published_at","apply_url"]},"JobCategory":{"type":"object","nullable":true,"properties":{"slug":{"type":"string"},"name_en":{"type":"string"},"name_th":{"type":"string"}},"required":["slug","name_en","name_th"]},"Salary":{"type":"object","nullable":true,"properties":{"min":{"type":"number","nullable":true},"max":{"type":"number","nullable":true},"currency":{"type":"string","nullable":true}},"required":["min","max","currency"],"description":"null unless the tenant opted in to showing the range"},"NotFound":{"type":"object","properties":{"error":{"type":"string","enum":["not_found"]}},"required":["error"]},"JobDetailResponse":{"type":"object","properties":{"company":{"type":"string"},"job":{"$ref":"#/components/schemas/JobDetail"}},"required":["company","job"]},"JobDetail":{"allOf":[{"$ref":"#/components/schemas/Job"},{"type":"object","properties":{"description":{"type":"string","nullable":true,"description":"Markdown, as authored"},"requirements":{"type":"string","nullable":true,"description":"Markdown, as authored"}},"required":["description","requirements"]}]},"Me":{"type":"object","properties":{"company":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"}},"required":["id","name","slug"]},"credential":{"type":"object","properties":{"kind":{"type":"string"},"label":{"type":"string"},"mode":{"type":"string"}},"required":["kind","label","mode"]},"scopes":{"type":"array","items":{"type":"string"}},"api_version":{"type":"string"}},"required":["company","credential","scopes","api_version"]},"Error":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string","example":"insufficient_scope"},"message":{"type":"string"},"request_id":{"type":"string"},"details":{"type":"object","additionalProperties":{"nullable":true}}},"required":["code","message","request_id"]}},"required":["error"]},"ProductList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Product"}},"has_more":{"type":"boolean"},"next_cursor":{"type":"string","nullable":true}},"required":["data","has_more","next_cursor"]},"Product":{"type":"object","properties":{"id":{"type":"string"},"sku_code":{"type":"string","nullable":true},"item_name":{"type":"string"},"description":{"type":"string","nullable":true},"item_type":{"type":"string","nullable":true},"unit_of_measure":{"type":"string","nullable":true},"base_uom":{"type":"string","nullable":true},"barcode":{"type":"string","nullable":true},"brand_id":{"type":"string","nullable":true},"is_stock_item":{"type":"boolean","nullable":true},"is_purchasable":{"type":"boolean","nullable":true},"is_sellable":{"type":"boolean","nullable":true},"is_manufacturable":{"type":"boolean","nullable":true},"is_active":{"type":"boolean","nullable":true},"selling_price_minor":{"type":"number","nullable":true,"description":"VAT-inclusive selling price in satang (1/100 THB)"},"pos_category":{"type":"string","nullable":true},"minimum_stock":{"type":"number","nullable":true},"reorder_point":{"type":"number","nullable":true},"lead_time_days":{"type":"number","nullable":true},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}},"required":["id","sku_code","item_name","description","item_type","unit_of_measure","base_uom","barcode","brand_id","is_stock_item","is_purchasable","is_sellable","is_manufacturable","is_active","selling_price_minor","pos_category","minimum_stock","reorder_point","lead_time_days","created_at","updated_at"]},"StockLevelList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/StockLevel"}},"has_more":{"type":"boolean"},"next_cursor":{"type":"string","nullable":true}},"required":["data","has_more","next_cursor"]},"StockLevel":{"type":"object","properties":{"id":{"type":"string"},"product_id":{"type":"string"},"warehouse_id":{"type":"string"},"quantity_on_hand":{"type":"number"},"quantity_reserved":{"type":"number","nullable":true},"quantity_available":{"type":"number","nullable":true},"avg_unit_cost":{"type":"number","nullable":true,"description":"Only with cost.view"},"total_value":{"type":"number","nullable":true,"description":"Only with cost.view"},"updated_at":{"type":"string","format":"date-time"},"product":{"type":"object","nullable":true,"properties":{"sku_code":{"type":"string","nullable":true},"item_name":{"type":"string"},"unit_of_measure":{"type":"string","nullable":true}},"required":["sku_code","item_name","unit_of_measure"]},"warehouse":{"type":"object","nullable":true,"properties":{"warehouse_code":{"type":"string","nullable":true},"warehouse_name":{"type":"string"}},"required":["warehouse_code","warehouse_name"]}},"required":["id","product_id","warehouse_id","quantity_on_hand","quantity_reserved","quantity_available","updated_at","product","warehouse"]},"WarehouseList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Warehouse"}},"has_more":{"type":"boolean"},"next_cursor":{"type":"string","nullable":true}},"required":["data","has_more","next_cursor"]},"Warehouse":{"type":"object","properties":{"id":{"type":"string"},"warehouse_code":{"type":"string","nullable":true},"warehouse_name":{"type":"string"},"kind":{"type":"string","nullable":true},"is_default":{"type":"boolean","nullable":true},"is_active":{"type":"boolean","nullable":true},"address":{"type":"string","nullable":true},"updated_at":{"type":"string","format":"date-time"}},"required":["id","warehouse_code","warehouse_name","kind","is_default","is_active","address","updated_at"]},"CompanyList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Company"}},"has_more":{"type":"boolean"},"next_cursor":{"type":"string","nullable":true}},"required":["data","has_more","next_cursor"]},"Company":{"type":"object","properties":{"id":{"type":"string"},"company_code":{"type":"string","nullable":true},"company_name":{"type":"string"},"local_name":{"type":"string","nullable":true},"is_vendor":{"type":"boolean","nullable":true},"is_customer":{"type":"boolean","nullable":true},"tax_id":{"type":"string","nullable":true},"branch_type":{"type":"string","nullable":true},"branch_code":{"type":"string","nullable":true},"email":{"type":"string","nullable":true},"phone":{"type":"string","nullable":true},"address":{"type":"string","nullable":true},"country":{"type":"string","nullable":true},"currency":{"type":"string","nullable":true},"payment_terms":{"type":"string","nullable":true},"is_active":{"type":"boolean","nullable":true},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}},"required":["id","company_code","company_name","local_name","is_vendor","is_customer","tax_id","branch_type","branch_code","email","phone","address","country","currency","payment_terms","is_active","created_at","updated_at"]},"CompanyDetail":{"allOf":[{"$ref":"#/components/schemas/Company"},{"type":"object","properties":{"contacts":{"type":"array","items":{"$ref":"#/components/schemas/CompanyContact"}}},"required":["contacts"]}]},"CompanyContact":{"allOf":[{"$ref":"#/components/schemas/Contact"},{"type":"object","properties":{"job_title":{"type":"string","nullable":true},"is_primary":{"type":"boolean","nullable":true},"role_active":{"type":"boolean","nullable":true}},"required":["job_title","is_primary","role_active"]}]},"Contact":{"type":"object","properties":{"id":{"type":"string"},"display_name":{"type":"string"},"nickname":{"type":"string","nullable":true},"mobile":{"type":"string","nullable":true},"email":{"type":"string","nullable":true},"line_id":{"type":"string","nullable":true},"is_active":{"type":"boolean","nullable":true},"updated_at":{"type":"string","format":"date-time"}},"required":["id","display_name","nickname","mobile","email","line_id","is_active","updated_at"]},"ContactList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Contact"}},"has_more":{"type":"boolean"},"next_cursor":{"type":"string","nullable":true}},"required":["data","has_more","next_cursor"]},"PurchaseRequestList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/PurchaseRequest"}},"has_more":{"type":"boolean"},"next_cursor":{"type":"string","nullable":true}},"required":["data","has_more","next_cursor"]},"PurchaseRequest":{"type":"object","properties":{"id":{"type":"string"},"pr_number":{"type":"string"},"pr_type":{"type":"string","nullable":true},"status":{"type":"string"},"approval_status":{"type":"string","nullable":true},"priority":{"type":"string","nullable":true},"request_date":{"type":"string","nullable":true},"required_date":{"type":"string","nullable":true},"department":{"type":"string","nullable":true},"purpose":{"type":"string","nullable":true},"job_control_id":{"type":"string","nullable":true},"total_estimated_amount":{"type":"number","nullable":true},"is_foreign":{"type":"boolean","nullable":true},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"lines":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"line_number":{"type":"number","nullable":true},"product_id":{"type":"string","nullable":true},"item_name":{"type":"string"},"description":{"type":"string","nullable":true},"quantity":{"type":"number","nullable":true},"unit_of_measure":{"type":"string","nullable":true},"estimated_unit_cost":{"type":"number","nullable":true},"line_status":{"type":"string","nullable":true},"line_type":{"type":"string","nullable":true},"required_date":{"type":"string","nullable":true},"warehouse_id":{"type":"string","nullable":true}},"required":["id","line_number","product_id","item_name","description","quantity","unit_of_measure","estimated_unit_cost","line_status","line_type","required_date","warehouse_id"]}}},"required":["id","pr_number","pr_type","status","approval_status","priority","request_date","required_date","department","purpose","job_control_id","total_estimated_amount","is_foreign","created_at","updated_at"]},"PurchaseOrderList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/PurchaseOrder"}},"has_more":{"type":"boolean"},"next_cursor":{"type":"string","nullable":true}},"required":["data","has_more","next_cursor"]},"PurchaseOrder":{"type":"object","properties":{"id":{"type":"string"},"po_number":{"type":"string"},"status":{"type":"string"},"company_id":{"type":"string","nullable":true},"vendor":{"type":"object","nullable":true,"properties":{"company_code":{"type":"string","nullable":true},"company_name":{"type":"string","nullable":true}},"required":["company_code","company_name"]},"order_date":{"type":"string","nullable":true},"expected_delivery_date":{"type":"string","nullable":true},"currency":{"type":"string","nullable":true},"vat_type":{"type":"string","nullable":true},"subtotal":{"type":"number","nullable":true},"vat_amount":{"type":"number","nullable":true},"total_amount":{"type":"number","nullable":true},"source_pr_id":{"type":"string","nullable":true},"job_control_id":{"type":"string","nullable":true},"is_foreign":{"type":"boolean","nullable":true},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"lines":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"line_number":{"type":"number","nullable":true},"pr_line_id":{"type":"string","nullable":true},"product_id":{"type":"string","nullable":true},"item_name":{"type":"string"},"description":{"type":"string","nullable":true},"quantity":{"type":"number","nullable":true},"quantity_received":{"type":"number","nullable":true},"unit_of_measure":{"type":"string","nullable":true},"unit_price":{"type":"number","nullable":true},"total_price":{"type":"number","nullable":true},"required_date":{"type":"string","nullable":true},"warehouse_id":{"type":"string","nullable":true},"line_type":{"type":"string","nullable":true}},"required":["id","line_number","pr_line_id","product_id","item_name","description","quantity","quantity_received","unit_of_measure","unit_price","total_price","required_date","warehouse_id","line_type"]}},"doc_title":{"type":"object","properties":{"kind":{"type":"string","enum":["purchase","service"]},"th":{"type":"string"},"en":{"type":"string"}},"required":["kind","th","en"],"description":"Document title from the lines: every line a service → ใบสั่งจ้าง (service order, purchasing); otherwise ใบสั่งซื้อ (purchase order). Same document type either way."}},"required":["id","po_number","status","company_id","order_date","expected_delivery_date","currency","vat_type","subtotal","vat_amount","total_amount","source_pr_id","job_control_id","is_foreign","created_at","updated_at"]},"GoodsReceiptList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/GoodsReceipt"}},"has_more":{"type":"boolean"},"next_cursor":{"type":"string","nullable":true}},"required":["data","has_more","next_cursor"]},"GoodsReceipt":{"type":"object","properties":{"id":{"type":"string"},"gr_number":{"type":"string"},"status":{"type":"string"},"purchase_order_id":{"type":"string","nullable":true},"company_id":{"type":"string","nullable":true},"warehouse_id":{"type":"string","nullable":true},"received_date":{"type":"string","nullable":true},"notes":{"type":"string","nullable":true},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"lines":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"line_number":{"type":"number","nullable":true},"po_line_id":{"type":"string","nullable":true},"product_id":{"type":"string","nullable":true},"item_name":{"type":"string"},"quantity_received":{"type":"number","nullable":true},"quantity_accepted":{"type":"number","nullable":true},"quantity_rejected":{"type":"number","nullable":true},"unit_of_measure":{"type":"string","nullable":true},"unit_cost_thb":{"type":"number","nullable":true},"warehouse_id":{"type":"string","nullable":true}},"required":["id","line_number","po_line_id","product_id","item_name","quantity_received","quantity_accepted","quantity_rejected","unit_of_measure","unit_cost_thb","warehouse_id"]}}},"required":["id","gr_number","status","purchase_order_id","company_id","warehouse_id","received_date","notes","created_at","updated_at"]},"DeliveryNoteList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/DeliveryNote"}},"has_more":{"type":"boolean"},"next_cursor":{"type":"string","nullable":true}},"required":["data","has_more","next_cursor"]},"DeliveryNote":{"type":"object","properties":{"id":{"type":"string"},"dn_number":{"type":"string"},"status":{"type":"string"},"company_id":{"type":"string","nullable":true},"customer":{"type":"string","nullable":true},"destination":{"type":"string","nullable":true},"delivery_date":{"type":"string","nullable":true},"delivered_at":{"type":"string","nullable":true},"tracking_number":{"type":"string","nullable":true},"customer_po_number":{"type":"string","nullable":true},"job_control_id":{"type":"string","nullable":true},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"lines":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"line_number":{"type":"number","nullable":true},"product_id":{"type":"string","nullable":true},"item_name":{"type":"string"},"quantity":{"type":"number","nullable":true},"shipped_quantity":{"type":"number","nullable":true},"backordered_quantity":{"type":"number","nullable":true},"unit_of_measure":{"type":"string","nullable":true},"warehouse_id":{"type":"string","nullable":true}},"required":["id","line_number","product_id","item_name","quantity","shipped_quantity","backordered_quantity","unit_of_measure","warehouse_id"]}}},"required":["id","dn_number","status","company_id","customer","destination","delivery_date","delivered_at","tracking_number","customer_po_number","job_control_id","created_at","updated_at"]},"OrderList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Order"}},"has_more":{"type":"boolean"},"next_cursor":{"type":"string","nullable":true}},"required":["data","has_more","next_cursor"]},"Order":{"type":"object","properties":{"id":{"type":"string"},"order_number":{"type":"string"},"source":{"type":"string","nullable":true},"status":{"type":"string"},"payment_status":{"type":"string","nullable":true},"customer_id":{"type":"string","nullable":true},"customer_name":{"type":"string","nullable":true},"currency":{"type":"string","nullable":true},"subtotal_minor":{"type":"number","nullable":true},"discount_minor":{"type":"number","nullable":true},"tax_minor":{"type":"number","nullable":true},"shipping_minor":{"type":"number","nullable":true},"total_minor":{"type":"number","nullable":true},"paid_minor":{"type":"number","nullable":true},"refunded_minor":{"type":"number","nullable":true},"placed_at":{"type":"string","nullable":true},"business_date":{"type":"string","nullable":true},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"lines":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"line_no":{"type":"number","nullable":true},"product_id":{"type":"string","nullable":true},"sku_code":{"type":"string","nullable":true},"item_name":{"type":"string"},"quantity":{"type":"number","nullable":true},"unit_of_measure":{"type":"string","nullable":true},"unit_price_minor":{"type":"number","nullable":true},"discount_minor":{"type":"number","nullable":true},"tax_minor":{"type":"number","nullable":true},"line_total_minor":{"type":"number","nullable":true},"refunded_qty":{"type":"number","nullable":true}},"required":["id","line_no","product_id","sku_code","item_name","quantity","unit_of_measure","unit_price_minor","discount_minor","tax_minor","line_total_minor","refunded_qty"]}}},"required":["id","order_number","source","status","payment_status","customer_id","customer_name","currency","subtotal_minor","discount_minor","tax_minor","shipping_minor","total_minor","paid_minor","refunded_minor","placed_at","business_date","created_at","updated_at"],"description":"Amounts are in minor units (satang)."},"DealList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Deal"}},"has_more":{"type":"boolean"},"next_cursor":{"type":"string","nullable":true}},"required":["data","has_more","next_cursor"]},"Deal":{"type":"object","properties":{"id":{"type":"string"},"title":{"type":"string"},"company_id":{"type":"string","nullable":true},"contact_id":{"type":"string","nullable":true},"pipeline_id":{"type":"string","nullable":true},"stage_id":{"type":"string","nullable":true},"stage":{"type":"object","nullable":true,"properties":{"name_en":{"type":"string","nullable":true},"name_th":{"type":"string","nullable":true},"kind":{"type":"string","nullable":true}},"required":["name_en","name_th","kind"]},"value_minor":{"type":"number","nullable":true,"description":"Value in baht (satang) — what totals use, also for foreign-currency deals."},"currency":{"type":"string","nullable":true,"description":"The deal currency (THB unless set)."},"fx_rate":{"type":"number","nullable":true,"description":"Baht per 1 unit of currency; null for THB."},"value_foreign_minor":{"type":"number","nullable":true,"description":"Value in the deal currency (minor units); null for THB."},"expected_close":{"type":"string","nullable":true},"owner_id":{"type":"string","nullable":true},"status":{"type":"string","nullable":true},"probability":{"type":"number","nullable":true},"forecast_category":{"type":"string","nullable":true},"won_at":{"type":"string","nullable":true},"lost_at":{"type":"string","nullable":true},"lost_reason":{"type":"string","nullable":true},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}},"required":["id","title","company_id","contact_id","pipeline_id","stage_id","value_minor","expected_close","owner_id","status","probability","forecast_category","won_at","lost_at","lost_reason","created_at","updated_at"]},"CrmActivityList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/CrmActivity"}},"has_more":{"type":"boolean"},"next_cursor":{"type":"string","nullable":true}},"required":["data","has_more","next_cursor"]},"CrmActivity":{"type":"object","properties":{"id":{"type":"string"},"company_id":{"type":"string","nullable":true},"contact_id":{"type":"string","nullable":true},"deal_id":{"type":"string","nullable":true},"assigned_to":{"type":"string","nullable":true},"title":{"type":"string","nullable":true},"channel":{"type":"string","nullable":true},"status":{"type":"string","nullable":true},"due_date":{"type":"string","nullable":true},"occurred_at":{"type":"string","nullable":true},"done_at":{"type":"string","nullable":true},"outcome_code":{"type":"string","nullable":true},"note":{"type":"string","nullable":true},"next_step":{"type":"string","nullable":true},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}},"required":["id","company_id","contact_id","deal_id","assigned_to","title","channel","status","due_date","occurred_at","done_at","outcome_code","note","next_step","created_at","updated_at"]},"WorkOrderList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/WorkOrder"}},"has_more":{"type":"boolean"},"next_cursor":{"type":"string","nullable":true}},"required":["data","has_more","next_cursor"]},"WorkOrder":{"type":"object","properties":{"id":{"type":"string"},"wo_number":{"type":"string"},"status":{"type":"string"},"product_id":{"type":"string","nullable":true},"quantity_to_produce":{"type":"number","nullable":true},"quantity_produced":{"type":"number","nullable":true},"quantity_scrap":{"type":"number","nullable":true},"warehouse_id":{"type":"string","nullable":true},"job_control_id":{"type":"string","nullable":true},"planned_start_date":{"type":"string","nullable":true},"planned_end_date":{"type":"string","nullable":true},"actual_end_date":{"type":"string","nullable":true},"qc_hold":{"type":"boolean","nullable":true},"updated_at":{"type":"string","format":"date-time"}},"required":["id","wo_number","status","product_id","quantity_to_produce","quantity_produced","quantity_scrap","warehouse_id","job_control_id","planned_start_date","planned_end_date","actual_end_date","qc_hold","updated_at"]},"JobControlList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/JobControl"}},"has_more":{"type":"boolean"},"next_cursor":{"type":"string","nullable":true}},"required":["data","has_more","next_cursor"]},"JobControl":{"type":"object","properties":{"id":{"type":"string"},"job_number":{"type":"string"},"job_name":{"type":"string"},"job_type":{"type":"string","nullable":true},"status":{"type":"string"},"company_id":{"type":"string","nullable":true},"customer":{"type":"string","nullable":true},"department":{"type":"string","nullable":true},"approved_budget":{"type":"number","nullable":true,"description":"Only with cost.view"},"planned_start_date":{"type":"string","nullable":true},"planned_end_date":{"type":"string","nullable":true},"updated_at":{"type":"string","format":"date-time"},"status_label":{"type":"object","properties":{"en":{"type":"string"},"th":{"type":"string"}},"required":["en","th"],"description":"SAP-style label for status: draft → Created สร้างแล้ว, active → Released ปล่อยงาน, completed → Technically complete เสร็จงาน, closed → Closed ปิดงาน"}},"required":["id","job_number","job_name","job_type","status","company_id","customer","department","approved_budget","planned_start_date","planned_end_date","updated_at"]},"EmployeeList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Employee"}},"has_more":{"type":"boolean"},"next_cursor":{"type":"string","nullable":true}},"required":["data","has_more","next_cursor"]},"Employee":{"type":"object","properties":{"id":{"type":"string"},"user_id":{"type":"string","nullable":true,"description":"The Tonbab login this employee uses (list_users), if any."},"employee_code":{"type":"string","nullable":true},"display_name":{"type":"string","nullable":true},"first_name_th":{"type":"string","nullable":true},"last_name_th":{"type":"string","nullable":true},"first_name_en":{"type":"string","nullable":true},"last_name_en":{"type":"string","nullable":true},"nickname_th":{"type":"string","nullable":true},"nickname_en":{"type":"string","nullable":true},"email":{"type":"string","nullable":true},"phone":{"type":"string","nullable":true},"job_title":{"type":"string","nullable":true},"department":{"type":"string","nullable":true},"manager_id":{"type":"string","nullable":true},"employment_type":{"type":"string","nullable":true},"start_date":{"type":"string","nullable":true},"status":{"type":"string","nullable":true},"updated_at":{"type":"string","format":"date-time"}},"required":["id","user_id","employee_code","display_name","first_name_th","last_name_th","first_name_en","last_name_en","nickname_th","nickname_en","email","phone","job_title","department","manager_id","employment_type","start_date","status","updated_at"],"description":"Directory fields only. ID numbers, bank details, salary and personal data are never exposed over the API."},"DocSearch":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"title":{"type":"string"},"icon":{"type":"string","nullable":true},"kind":{"type":"string"},"updated_at":{"type":"string"},"url":{"type":"string"}},"required":["id","title","icon","kind","updated_at","url"]}}},"required":["data"]},"DocPage":{"type":"object","properties":{"id":{"type":"string"},"title":{"type":"string"},"icon":{"type":"string","nullable":true},"kind":{"type":"string"},"updated_at":{"type":"string"},"url":{"type":"string"},"text":{"type":"string"},"children":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"title":{"type":"string"},"kind":{"type":"string"},"url":{"type":"string"}},"required":["id","title","kind","url"]}}},"required":["id","title","icon","kind","updated_at","url","text","children"]},"DocRows":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","additionalProperties":{"nullable":true}}}},"required":["data"],"additionalProperties":{"nullable":true}},"EventList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Event"}},"has_more":{"type":"boolean"},"next_cursor":{"type":"string","nullable":true}},"required":["data","has_more","next_cursor"]},"Event":{"type":"object","properties":{"id":{"type":"string"},"type":{"type":"string"},"entity_type":{"type":"string"},"entity_id":{"type":"string","nullable":true},"data":{"type":"object","additionalProperties":{"nullable":true}},"created_at":{"type":"string","format":"date-time"}},"required":["id","type","entity_type","entity_id","data","created_at"]},"MyCompanies":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"slug":{"type":"string"},"name":{"type":"string"},"is_default":{"type":"boolean"},"status":{"type":"string","enum":["ok","unavailable"]},"reason":{"type":"string"},"roles":{"type":"array","items":{"type":"string"}},"modules":{"type":"array","items":{"type":"string"}},"scopes":{"type":"array","items":{"type":"string"},"description":"Effective scopes IN this company (consent ∩ your role there)"}},"required":["id","slug","name","is_default","status","roles","modules","scopes"]}}},"required":["data"]},"SalesSummary":{"type":"object","properties":{"companies":{"type":"array","items":{"type":"object","properties":{"period":{"type":"object","properties":{"from":{"type":"string"},"to":{"type":"string"}},"required":["from","to"]},"currency":{"type":"string"},"basis":{"type":"string"},"totals":{"type":"object","properties":{"net_sales":{"type":"number"},"vat":{"type":"number"},"gross":{"type":"number"},"doc_count":{"type":"number"}},"required":["net_sales","vat","gross","doc_count"]},"rows":{"type":"array","items":{"type":"object","properties":{"customer_id":{"type":"string","nullable":true},"customer_name":{"type":"string"},"month":{"type":"string","nullable":true},"net_sales":{"type":"number"},"vat":{"type":"number"},"gross":{"type":"number"},"doc_count":{"type":"number"}},"required":["customer_id","customer_name","month","net_sales","vat","gross","doc_count"]}},"truncated":{"type":"boolean"},"company":{"$ref":"#/components/schemas/CompanyRef"},"status":{"type":"string","enum":["ok","error"]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["company","status"]}}},"required":["companies"]},"CompanyRef":{"type":"object","properties":{"id":{"type":"string"},"slug":{"type":"string"},"name":{"type":"string"}},"required":["id","slug","name"]},"ArAging":{"type":"object","properties":{"companies":{"type":"array","items":{"type":"object","properties":{"as_of":{"type":"string"},"currency":{"type":"string"},"buckets":{"type":"object","properties":{"current":{"type":"number"},"d1_30":{"type":"number"},"d31_60":{"type":"number"},"d61_90":{"type":"number"},"over90":{"type":"number"}},"required":["current","d1_30","d31_60","d61_90","over90"]},"total":{"type":"number"},"outstanding":{"type":"number"},"credits":{"type":"number"},"doc_count":{"type":"number"},"parties":{"type":"array","items":{"type":"object","properties":{"company_id":{"type":"string","nullable":true},"name":{"type":"string"},"buckets":{"type":"object","properties":{"current":{"type":"number"},"d1_30":{"type":"number"},"d31_60":{"type":"number"},"d61_90":{"type":"number"},"over90":{"type":"number"}},"required":["current","d1_30","d31_60","d61_90","over90"]},"total":{"type":"number"},"doc_count":{"type":"number"}},"required":["company_id","name","buckets","total","doc_count"]}},"truncated":{"type":"boolean"},"company":{"$ref":"#/components/schemas/CompanyRef"},"status":{"type":"string","enum":["ok","error"]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["company","status"]}}},"required":["companies"]},"ApAging":{"type":"object","properties":{"companies":{"type":"array","items":{"type":"object","properties":{"as_of":{"type":"string"},"currency":{"type":"string"},"buckets":{"type":"object","properties":{"current":{"type":"number"},"d1_30":{"type":"number"},"d31_60":{"type":"number"},"d61_90":{"type":"number"},"over90":{"type":"number"}},"required":["current","d1_30","d31_60","d61_90","over90"]},"total":{"type":"number"},"outstanding":{"type":"number"},"credits":{"type":"number"},"doc_count":{"type":"number"},"parties":{"type":"array","items":{"type":"object","properties":{"company_id":{"type":"string","nullable":true},"name":{"type":"string"},"buckets":{"type":"object","properties":{"current":{"type":"number"},"d1_30":{"type":"number"},"d31_60":{"type":"number"},"d61_90":{"type":"number"},"over90":{"type":"number"}},"required":["current","d1_30","d31_60","d61_90","over90"]},"total":{"type":"number"},"doc_count":{"type":"number"}},"required":["company_id","name","buckets","total","doc_count"]}},"truncated":{"type":"boolean"},"company":{"$ref":"#/components/schemas/CompanyRef"},"status":{"type":"string","enum":["ok","error"]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["company","status"]}}},"required":["companies"]},"ProfitAndLoss":{"type":"object","properties":{"companies":{"type":"array","items":{"type":"object","properties":{"period":{"type":"object","properties":{"from":{"type":"string"},"to":{"type":"string"}},"required":["from","to"]},"currency":{"type":"string"},"revenue":{"type":"object","properties":{"total":{"type":"number"},"lines":{"type":"array","items":{"type":"object","properties":{"account_id":{"type":"string"},"code":{"type":"string","nullable":true},"name":{"type":"string","nullable":true},"amount":{"type":"number"}},"required":["account_id","code","name","amount"]}}},"required":["total","lines"]},"expenses":{"type":"object","properties":{"total":{"type":"number"},"lines":{"type":"array","items":{"type":"object","properties":{"account_id":{"type":"string"},"code":{"type":"string","nullable":true},"name":{"type":"string","nullable":true},"amount":{"type":"number"}},"required":["account_id","code","name","amount"]}}},"required":["total","lines"]},"net_profit":{"type":"number"},"company":{"$ref":"#/components/schemas/CompanyRef"},"status":{"type":"string","enum":["ok","error"]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["company","status"]}}},"required":["companies"]},"TrialBalance":{"type":"object","properties":{"period":{"type":"object","properties":{"from":{"type":"string"},"to":{"type":"string"}},"required":["from","to"]},"data":{"type":"array","items":{"type":"object","properties":{"account_id":{"type":"string"},"code":{"type":"string","nullable":true},"name":{"type":"string","nullable":true},"account_type":{"type":"string","nullable":true},"opening":{"type":"number"},"debit":{"type":"number"},"credit":{"type":"number"},"closing":{"type":"number"}},"required":["account_id","code","name","account_type","opening","debit","credit","closing"]}}},"required":["period","data"]},"InvoiceList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/AccountingDocument"}},"has_more":{"type":"boolean"},"next_cursor":{"type":"string","nullable":true}},"required":["data","has_more","next_cursor"]},"AccountingDocument":{"type":"object","properties":{"id":{"type":"string"},"doc_type":{"type":"string"},"doc_no":{"type":"string","nullable":true},"status":{"type":"string"},"doc_date":{"type":"string","nullable":true},"due_date":{"type":"string","nullable":true},"company_id":{"type":"string","nullable":true},"party_name":{"type":"string","nullable":true},"title":{"type":"string","nullable":true},"currency":{"type":"string","nullable":true},"subtotal":{"type":"number","nullable":true},"vat_amount":{"type":"number","nullable":true},"total":{"type":"number","nullable":true},"wht_amount":{"type":"number","nullable":true},"paid_amount":{"type":"number","nullable":true},"balance":{"type":"number","description":"total − paid (THB); negative for credit notes"},"days_overdue":{"type":"number","nullable":true,"description":"Whole days past due for an issued payable document with a balance; null otherwise"},"owner_id":{"type":"string","nullable":true},"crm_deal_id":{"type":"string","nullable":true},"ref_document_id":{"type":"string","nullable":true},"updated_at":{"type":"string","format":"date-time"}},"required":["id","doc_type","doc_no","status","doc_date","due_date","company_id","party_name","title","currency","subtotal","vat_amount","total","wht_amount","paid_amount","balance","days_overdue","owner_id","crm_deal_id","ref_document_id","updated_at"]},"BillList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/AccountingDocument"}},"has_more":{"type":"boolean"},"next_cursor":{"type":"string","nullable":true}},"required":["data","has_more","next_cursor"]},"QuotationList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/AccountingDocument"}},"has_more":{"type":"boolean"},"next_cursor":{"type":"string","nullable":true}},"required":["data","has_more","next_cursor"]},"AccountingDocumentDetail":{"allOf":[{"$ref":"#/components/schemas/AccountingDocument"},{"type":"object","properties":{"lines":{"type":"array","items":{"type":"object","properties":{"line_no":{"type":"number","nullable":true},"product_id":{"type":"string","nullable":true},"description":{"type":"string","nullable":true},"quantity":{"type":"number","nullable":true},"unit":{"type":"string","nullable":true},"unit_price":{"type":"number","nullable":true},"discount_amount":{"type":"number","nullable":true},"amount":{"type":"number","nullable":true},"vat_code":{"type":"string","nullable":true},"vat_amount":{"type":"number","nullable":true}},"required":["line_no","product_id","description","quantity","unit","unit_price","discount_amount","amount","vat_code","vat_amount"]}}},"required":["lines"]}]},"PaymentList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Payment"}},"has_more":{"type":"boolean"},"next_cursor":{"type":"string","nullable":true}},"required":["data","has_more","next_cursor"]},"Payment":{"type":"object","properties":{"id":{"type":"string"},"pay_no":{"type":"string","nullable":true},"kind":{"type":"string"},"status":{"type":"string"},"pay_date":{"type":"string","nullable":true},"company_id":{"type":"string","nullable":true},"party_name":{"type":"string","nullable":true},"method":{"type":"string","nullable":true},"reference":{"type":"string","nullable":true},"amount":{"type":"number","nullable":true},"wht_amount":{"type":"number","nullable":true},"fee_amount":{"type":"number","nullable":true},"updated_at":{"type":"string","format":"date-time"}},"required":["id","pay_no","kind","status","pay_date","company_id","party_name","method","reference","amount","wht_amount","fee_amount","updated_at"]},"AccountList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Account"}},"has_more":{"type":"boolean"},"next_cursor":{"type":"string","nullable":true}},"required":["data","has_more","next_cursor"]},"Account":{"type":"object","properties":{"id":{"type":"string"},"code":{"type":"string","nullable":true},"name":{"type":"string","nullable":true},"account_type":{"type":"string","nullable":true},"parent_id":{"type":"string","nullable":true},"is_postable":{"type":"boolean","nullable":true},"is_active":{"type":"boolean","nullable":true},"updated_at":{"type":"string","format":"date-time"}},"required":["id","code","name","account_type","parent_id","is_postable","is_active","updated_at"]},"BankAccountList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/BankAccount"}},"has_more":{"type":"boolean"},"next_cursor":{"type":"string","nullable":true}},"required":["data","has_more","next_cursor"]},"BankAccount":{"type":"object","properties":{"id":{"type":"string"},"kind":{"type":"string","nullable":true},"name":{"type":"string","nullable":true},"bank_code":{"type":"string","nullable":true},"account_no_last4":{"type":"string","nullable":true},"currency":{"type":"string","nullable":true},"is_active":{"type":"boolean","nullable":true},"updated_at":{"type":"string","format":"date-time"}},"required":["id","kind","name","bank_code","account_no_last4","currency","is_active","updated_at"]},"FixedAssetList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/FixedAsset"}},"has_more":{"type":"boolean"},"next_cursor":{"type":"string","nullable":true}},"required":["data","has_more","next_cursor"]},"FixedAsset":{"type":"object","properties":{"id":{"type":"string"},"asset_no":{"type":"string","nullable":true},"name":{"type":"string"},"asset_class":{"type":"string","nullable":true},"cost":{"type":"number","nullable":true},"acquired_date":{"type":"string","nullable":true},"in_service_date":{"type":"string","nullable":true},"method":{"type":"string","nullable":true},"rate_percent":{"type":"number","nullable":true},"location":{"type":"string","nullable":true},"status":{"type":"string","nullable":true},"disposed_date":{"type":"string","nullable":true},"updated_at":{"type":"string","format":"date-time"}},"required":["id","asset_no","name","asset_class","cost","acquired_date","in_service_date","method","rate_percent","location","status","disposed_date","updated_at"]},"ExpenseClaimList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/ExpenseClaim"}},"has_more":{"type":"boolean"},"next_cursor":{"type":"string","nullable":true}},"required":["data","has_more","next_cursor"]},"ExpenseClaim":{"type":"object","properties":{"id":{"type":"string"},"claim_number":{"type":"string","nullable":true},"title":{"type":"string","nullable":true},"status":{"type":"string"},"claim_type":{"type":"string","nullable":true},"employee_id":{"type":"string","nullable":true},"employee_name":{"type":"string","nullable":true},"period_start":{"type":"string","nullable":true},"period_end":{"type":"string","nullable":true},"submitted_at":{"type":"string","nullable":true},"approved_at":{"type":"string","nullable":true},"reimbursed_at":{"type":"string","nullable":true},"payout_method":{"type":"string","nullable":true},"total_thb":{"type":"number"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}},"required":["id","claim_number","title","status","claim_type","employee_id","employee_name","period_start","period_end","submitted_at","approved_at","reimbursed_at","payout_method","total_thb","created_at","updated_at"]},"ExpenseClaimDetail":{"allOf":[{"$ref":"#/components/schemas/ExpenseClaim"},{"type":"object","properties":{"lines":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"category":{"type":"string","nullable":true},"expense_date":{"type":"string","nullable":true},"description":{"type":"string","nullable":true},"amount_thb":{"type":"number","nullable":true},"paid_by":{"type":"string","nullable":true},"job_control_id":{"type":"string","nullable":true},"billable":{"type":"boolean","nullable":true},"vat_amount":{"type":"number","nullable":true},"has_tax_invoice":{"type":"boolean","nullable":true},"distance_km":{"type":"number","nullable":true},"from_place":{"type":"string","nullable":true},"to_place":{"type":"string","nullable":true}},"required":["id","category","expense_date","description","amount_thb","paid_by","job_control_id","billable","vat_amount","has_tax_invoice","distance_km","from_place","to_place"]}}},"required":["lines"]}]},"MyLeaveBalance":{"type":"object","properties":{"year":{"type":"number"},"employee_id":{"type":"string","nullable":true},"data":{"type":"array","items":{"type":"object","properties":{"leave_type":{"type":"object","nullable":true,"properties":{"id":{"type":"string","nullable":true},"code":{"type":"string","nullable":true},"name_en":{"type":"string","nullable":true},"name_th":{"type":"string","nullable":true},"is_paid":{"type":"boolean","nullable":true}},"required":["id","code","name_en","name_th","is_paid"]},"entitled_days":{"type":"number"},"carried_in":{"type":"number"},"used_days":{"type":"number"},"remaining_days":{"type":"number"}},"required":["leave_type","entitled_days","carried_in","used_days","remaining_days"]}}},"required":["year","employee_id","data"]},"LeaveRequestList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/LeaveRequest"}},"has_more":{"type":"boolean"},"next_cursor":{"type":"string","nullable":true}},"required":["data","has_more","next_cursor"]},"LeaveRequest":{"type":"object","properties":{"id":{"type":"string"},"employee_id":{"type":"string"},"employee_name":{"type":"string","nullable":true},"leave_type":{"type":"object","nullable":true,"properties":{"code":{"type":"string","nullable":true},"name_en":{"type":"string","nullable":true},"name_th":{"type":"string","nullable":true}},"required":["code","name_en","name_th"]},"start_date":{"type":"string"},"end_date":{"type":"string"},"half_day":{"type":"boolean","nullable":true},"total_days":{"type":"number","nullable":true},"status":{"type":"string"},"reason":{"type":"string","nullable":true},"decided_at":{"type":"string","nullable":true},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}},"required":["id","employee_id","employee_name","leave_type","start_date","end_date","half_day","total_days","status","reason","decided_at","created_at","updated_at"]},"ServiceJobList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/ServiceJob"}},"has_more":{"type":"boolean"},"next_cursor":{"type":"string","nullable":true}},"required":["data","has_more","next_cursor"]},"ServiceJob":{"type":"object","properties":{"id":{"type":"string"},"order_number":{"type":"string","nullable":true},"type":{"type":"string","nullable":true},"status":{"type":"string"},"priority":{"type":"string","nullable":true},"reported_problem":{"type":"string","nullable":true},"company_id":{"type":"string","nullable":true},"customer":{"type":"object","nullable":true,"properties":{"company_name":{"type":"string","nullable":true}},"required":["company_name"]},"assigned_to":{"type":"string","nullable":true},"job_control_id":{"type":"string","nullable":true},"work_center_id":{"type":"string","nullable":true},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"completed_at":{"type":"string","nullable":true},"closed_at":{"type":"string","nullable":true}},"required":["id","order_number","type","status","priority","reported_problem","company_id","assigned_to","job_control_id","work_center_id","created_at","updated_at","completed_at","closed_at"]},"ServiceJobDetail":{"allOf":[{"$ref":"#/components/schemas/ServiceJob"},{"type":"object","properties":{"work_summary":{"type":"string","nullable":true},"visits":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"service_order_id":{"type":"string"},"assigned_to":{"type":"string","nullable":true},"scheduled_at":{"type":"string","nullable":true},"started_at":{"type":"string","nullable":true},"ended_at":{"type":"string","nullable":true},"outcome":{"type":"string","nullable":true},"note":{"type":"string","nullable":true},"job":{"type":"object","nullable":true,"properties":{"order_number":{"type":"string","nullable":true},"status":{"type":"string","nullable":true}},"required":["order_number","status"]}},"required":["id","service_order_id","assigned_to","scheduled_at","started_at","ended_at","outcome","note"]}}},"required":["work_summary","visits"]}]},"ServiceSchedule":{"type":"object","properties":{"period":{"type":"object","properties":{"from":{"type":"string"},"to":{"type":"string"}},"required":["from","to"]},"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"service_order_id":{"type":"string"},"assigned_to":{"type":"string","nullable":true},"scheduled_at":{"type":"string","nullable":true},"started_at":{"type":"string","nullable":true},"ended_at":{"type":"string","nullable":true},"outcome":{"type":"string","nullable":true},"note":{"type":"string","nullable":true},"job":{"type":"object","nullable":true,"properties":{"order_number":{"type":"string","nullable":true},"status":{"type":"string","nullable":true}},"required":["order_number","status"]}},"required":["id","service_order_id","assigned_to","scheduled_at","started_at","ended_at","outcome","note"]}}},"required":["period","data"]},"StockValuation":{"type":"object","properties":{"companies":{"type":"array","items":{"type":"object","properties":{"as_of":{"type":"string"},"currency":{"type":"string"},"total_value":{"type":"number"},"warehouses":{"type":"array","items":{"type":"object","properties":{"warehouse_id":{"type":"string"},"warehouse_code":{"type":"string","nullable":true},"warehouse_name":{"type":"string","nullable":true},"value":{"type":"number"},"product_lines":{"type":"number"}},"required":["warehouse_id","warehouse_code","warehouse_name","value","product_lines"]}},"company":{"$ref":"#/components/schemas/CompanyRef"},"status":{"type":"string","enum":["ok","error"]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["company","status"]}}},"required":["companies"]},"StockMovementList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/StockMovement"}},"has_more":{"type":"boolean"},"next_cursor":{"type":"string","nullable":true}},"required":["data","has_more","next_cursor"]},"StockMovement":{"type":"object","properties":{"id":{"type":"string"},"movement_number":{"type":"string","nullable":true},"product_id":{"type":"string"},"warehouse_id":{"type":"string","nullable":true},"movement_type":{"type":"string"},"source_type":{"type":"string","nullable":true},"source_id":{"type":"string","nullable":true},"qty_in":{"type":"number","nullable":true},"qty_out":{"type":"number","nullable":true},"quantity":{"type":"number","nullable":true},"unit_of_measure":{"type":"string","nullable":true},"reference_number":{"type":"string","nullable":true},"job_control_id":{"type":"string","nullable":true},"inventory_lot_id":{"type":"string","nullable":true},"unit_cost":{"type":"number","nullable":true,"description":"Only with cost.view"},"total_value":{"type":"number","nullable":true,"description":"Only with cost.view"},"created_at":{"type":"string","format":"date-time"}},"required":["id","movement_number","product_id","warehouse_id","movement_type","source_type","source_id","qty_in","qty_out","quantity","unit_of_measure","reference_number","job_control_id","inventory_lot_id","created_at"]},"LotList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/InventoryLot"}},"has_more":{"type":"boolean"},"next_cursor":{"type":"string","nullable":true}},"required":["data","has_more","next_cursor"]},"InventoryLot":{"type":"object","properties":{"id":{"type":"string"},"product_id":{"type":"string"},"warehouse_id":{"type":"string","nullable":true},"lot_number":{"type":"string"},"manufacture_date":{"type":"string","nullable":true},"expiry_date":{"type":"string","nullable":true},"quantity_received":{"type":"number","nullable":true},"quantity_on_hand":{"type":"number","nullable":true},"quantity_reserved":{"type":"number","nullable":true},"status":{"type":"string","nullable":true},"received_date":{"type":"string","nullable":true},"source_document_number":{"type":"string","nullable":true},"unit_cost":{"type":"number","nullable":true,"description":"Only with cost.view"},"updated_at":{"type":"string","format":"date-time"}},"required":["id","product_id","warehouse_id","lot_number","manufacture_date","expiry_date","quantity_received","quantity_on_hand","quantity_reserved","status","received_date","source_document_number","updated_at"]},"SerialList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/SerialNumber"}},"has_more":{"type":"boolean"},"next_cursor":{"type":"string","nullable":true}},"required":["data","has_more","next_cursor"]},"SerialNumber":{"type":"object","properties":{"id":{"type":"string"},"product_id":{"type":"string"},"serial_number":{"type":"string"},"status":{"type":"string","nullable":true},"warehouse_id":{"type":"string","nullable":true},"received_date":{"type":"string","nullable":true},"source_document_number":{"type":"string","nullable":true},"current_job_control_id":{"type":"string","nullable":true},"current_work_order_id":{"type":"string","nullable":true},"current_delivery_note_id":{"type":"string","nullable":true},"updated_at":{"type":"string","format":"date-time"}},"required":["id","product_id","serial_number","status","warehouse_id","received_date","source_document_number","current_job_control_id","current_work_order_id","current_delivery_note_id","updated_at"]},"BomList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Bom"}},"has_more":{"type":"boolean"},"next_cursor":{"type":"string","nullable":true}},"required":["data","has_more","next_cursor"]},"Bom":{"type":"object","properties":{"id":{"type":"string"},"product_id":{"type":"string","nullable":true},"bom_code":{"type":"string","nullable":true},"version":{"type":"string","nullable":true},"kind":{"type":"string","nullable":true},"is_active":{"type":"boolean","nullable":true},"brand":{"type":"string","nullable":true},"model_no":{"type":"string","nullable":true},"model_name":{"type":"string","nullable":true},"revision":{"type":"string","nullable":true},"updated_at":{"type":"string","format":"date-time"}},"required":["id","product_id","bom_code","version","kind","is_active","brand","model_no","model_name","revision","updated_at"]},"Created":{"type":"object","properties":{"id":{"type":"string","nullable":true},"number":{"type":"string","nullable":true},"status":{"type":"string"},"dry_run":{"type":"boolean"},"url":{"type":"string","nullable":true}},"required":["id","number","status","dry_run","url"],"description":"dry_run=true (test keys): validated, nothing saved, id/number are null."},"StockCountCreated":{"allOf":[{"$ref":"#/components/schemas/Created"},{"type":"object","properties":{"differences":{"type":"integer"}},"required":["differences"]}],"description":"dry_run=true (test keys): validated, nothing saved, id/number are null."},"CrmPipelineList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/CrmPipeline"}}},"required":["data"]},"CrmPipeline":{"type":"object","properties":{"id":{"type":"string"},"name_en":{"type":"string","nullable":true},"name_th":{"type":"string","nullable":true},"is_default":{"type":"boolean","nullable":true},"is_active":{"type":"boolean","nullable":true},"sort_order":{"type":"number","nullable":true},"stages":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name_en":{"type":"string","nullable":true},"name_th":{"type":"string","nullable":true},"kind":{"type":"string","description":"open · won · lost"},"sort_order":{"type":"number","nullable":true},"probability":{"type":"number","nullable":true},"is_active":{"type":"boolean","nullable":true}},"required":["id","name_en","name_th","kind","sort_order","probability","is_active"]}}},"required":["id","name_en","name_th","is_default","is_active","sort_order","stages"]},"UnitList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Unit"}},"product":{"type":"object","nullable":true,"properties":{"id":{"type":"string"},"stock_unit":{"type":"string","nullable":true},"purchase_unit":{"type":"string","nullable":true},"unit_of_measure":{"type":"string","nullable":true},"uom_strict":{"type":"boolean","nullable":true},"conversions":{"type":"array","items":{"$ref":"#/components/schemas/UnitConversion"}}},"required":["id","stock_unit","purchase_unit","unit_of_measure","uom_strict","conversions"],"description":"Only with product_id"}},"required":["data","product"]},"Unit":{"type":"object","properties":{"code":{"type":"string"},"dimension":{"type":"string","nullable":true},"name_en":{"type":"string","nullable":true},"name_th":{"type":"string","nullable":true},"symbol":{"type":"string","nullable":true},"decimals":{"type":"number","nullable":true},"is_packaging":{"type":"boolean","nullable":true},"company_unit":{"type":"boolean","description":"true = this company added it; false = the built-in catalogue"}},"required":["code","dimension","name_en","name_th","symbol","decimals","is_packaging","company_unit"]},"UnitConversion":{"type":"object","properties":{"from_uom":{"type":"string"},"to_uom":{"type":"string"},"factor":{"type":"number"},"is_active":{"type":"boolean","nullable":true},"notes":{"type":"string","nullable":true}},"required":["from_uom","to_uom","factor","is_active","notes"]},"TaxRates":{"type":"object","properties":{"vat":{"type":"object","properties":{"standard_rate":{"type":"number"},"company_vat_registered":{"type":"boolean"},"codes":{"type":"array","items":{"type":"object","properties":{"code":{"type":"string"},"description":{"type":"string"}},"required":["code","description"]}}},"required":["standard_rate","company_vat_registered","codes"]},"wht":{"type":"object","properties":{"forms":{"type":"array","items":{"type":"string"}},"income_types":{"type":"array","items":{"type":"object","properties":{"key":{"type":"string"},"rate":{"type":"number"}},"required":["key","rate"]}}},"required":["forms","income_types"]}},"required":["vat","wht"]},"ExpenseTypeList":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"key":{"type":"string"},"name_th":{"type":"string","nullable":true},"name_en":{"type":"string","nullable":true},"kind":{"type":"string","enum":["receipt","system"]},"is_active":{"type":"boolean"},"sort_order":{"type":"number"},"requires_receipt":{"type":"boolean"},"requires_attendees":{"type":"boolean"},"allow_vat_claim":{"type":"boolean"},"pickable":{"type":"boolean","description":"Active receipt type: valid as create_expense_claim_draft line category"},"account":{"type":"object","nullable":true,"properties":{"code":{"type":"string"},"name":{"type":"string"}},"required":["code","name"],"description":"Only with accounting.view; null = not linked yet"}},"required":["key","name_th","name_en","kind","is_active","sort_order","requires_receipt","requires_attendees","allow_vat_claim","pickable"]}}},"required":["data"]},"UserList":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"user_id":{"type":"string"},"display_name":{"type":"string","nullable":true},"roles":{"type":"array","items":{"type":"string"}},"email":{"type":"string","nullable":true,"description":"Only with user.manage"},"employee_id":{"type":"string","nullable":true,"description":"Their People employee record (list_employees), when the People module is on and one is linked."}},"required":["user_id","display_name","roles","email","employee_id"]}}},"required":["data"]},"MyApprovals":{"type":"object","properties":{"total":{"type":"number"},"groups":{"type":"array","items":{"type":"object","properties":{"key":{"type":"string"},"label":{"type":"string"},"count":{"type":"number"},"oldest_days":{"type":"number","nullable":true},"url":{"type":"string"}},"required":["key","label","count","oldest_days","url"]}},"unread_notifications":{"type":"number"}},"required":["total","groups","unread_notifications"]},"CrmLeadList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/CrmLead"}},"has_more":{"type":"boolean"},"next_cursor":{"type":"string","nullable":true}},"required":["data","has_more","next_cursor"]},"CrmLead":{"type":"object","properties":{"id":{"type":"string"},"channel":{"type":"string"},"status":{"type":"string","description":"new · assigned · contacted · qualified · disqualified"},"need":{"type":"string","nullable":true},"company_id":{"type":"string","nullable":true},"contact_id":{"type":"string","nullable":true},"contact_hint":{"type":"string","nullable":true},"value_minor":{"type":"number","nullable":true,"description":"Satang; null without prices.sell"},"owner_id":{"type":"string","nullable":true},"assigned_at":{"type":"string","nullable":true},"first_contact_at":{"type":"string","nullable":true},"disqualify_reason":{"type":"string","nullable":true},"deal_id":{"type":"string","nullable":true},"created_by":{"type":"string","nullable":true},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}},"required":["id","channel","status","need","company_id","contact_id","contact_hint","value_minor","owner_id","assigned_at","first_contact_at","disqualify_reason","deal_id","created_by","created_at","updated_at"]},"LeadCreated":{"allOf":[{"$ref":"#/components/schemas/Created"},{"type":"object","properties":{"assigned_to":{"type":"string","nullable":true}},"required":["assigned_to"]}],"description":"dry_run=true (test keys): validated, nothing saved, id/number are null."},"CrmPipelineReport":{"type":"object","properties":{"scope":{"type":"string","enum":["self","team","all"]},"can_see_values":{"type":"boolean"},"kpi":{"type":"object","properties":{"open_count":{"type":"number"},"open_value_minor":{"type":"number","nullable":true},"weighted_minor":{"type":"number","nullable":true},"won_mtd_value_minor":{"type":"number","nullable":true},"won_mtd_count":{"type":"number"},"win_rate_pct":{"type":"number","nullable":true},"overdue_activities":{"type":"number"},"due_today_activities":{"type":"number"}},"required":["open_count","open_value_minor","weighted_minor","won_mtd_value_minor","won_mtd_count","win_rate_pct","overdue_activities","due_today_activities"]},"funnel":{"type":"array","items":{"type":"object","properties":{"stage_id":{"type":"string"},"pipeline_id":{"type":"string","nullable":true},"name_en":{"type":"string","nullable":true},"name_th":{"type":"string","nullable":true},"count":{"type":"number"},"value_minor":{"type":"number","nullable":true},"weighted_minor":{"type":"number","nullable":true}},"required":["stage_id","pipeline_id","name_en","name_th","count","value_minor","weighted_minor"]}},"pipelines":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name_en":{"type":"string","nullable":true},"name_th":{"type":"string","nullable":true},"count":{"type":"number"},"value_minor":{"type":"number","nullable":true}},"required":["id","name_en","name_th","count","value_minor"]}},"months":{"type":"array","items":{"type":"object","properties":{"month":{"type":"string"},"won_count":{"type":"number"},"won_value_minor":{"type":"number","nullable":true},"lost_count":{"type":"number"},"lost_value_minor":{"type":"number","nullable":true}},"required":["month","won_count","won_value_minor","lost_count","lost_value_minor"]}},"lost_reasons":{"type":"array","items":{"type":"object","properties":{"reason":{"type":"string"},"count":{"type":"number"}},"required":["reason","count"]}},"my_goal":{"type":"object","nullable":true,"properties":{"won_target_minor":{"type":"number","nullable":true},"activity_target":{"type":"number","nullable":true},"won_mtd_minor":{"type":"number","nullable":true}},"required":["won_target_minor","activity_target","won_mtd_minor"]}},"required":["scope","can_see_values","kpi","funnel","pipelines","months","lost_reasons","my_goal"]},"LeaveRequested":{"allOf":[{"$ref":"#/components/schemas/Created"},{"type":"object","properties":{"total_days":{"type":"number","nullable":true}},"required":["total_days"]}],"description":"dry_run=true (test keys): validated, nothing saved, id/number are null."},"ExpenseClaimDraftCreated":{"allOf":[{"$ref":"#/components/schemas/Created"},{"type":"object","properties":{"existing":{"type":"boolean"}},"required":["existing"]}],"description":"dry_run=true (test keys): validated, nothing saved, id/number are null."},"JobControlDetail":{"type":"object","properties":{"id":{"type":"string"},"job_number":{"type":"string"},"job_name":{"type":"string","nullable":true},"job_type":{"type":"string","nullable":true},"status":{"type":"string"},"company_id":{"type":"string","nullable":true},"company_name":{"type":"string","nullable":true},"customer":{"type":"string","nullable":true},"department":{"type":"string","nullable":true},"owner_id":{"type":"string","nullable":true},"sales_owner_id":{"type":"string","nullable":true},"planned_start_date":{"type":"string","nullable":true},"planned_end_date":{"type":"string","nullable":true},"actual_start_date":{"type":"string","nullable":true},"actual_end_date":{"type":"string","nullable":true},"notes":{"type":"string","nullable":true},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"cancel_reason":{"type":"string","nullable":true,"description":"Why the job was cancelled (status cancelled)"},"cancelled_at":{"type":"string","nullable":true},"cancelled_by":{"type":"string","nullable":true},"status_label":{"type":"object","properties":{"en":{"type":"string"},"th":{"type":"string"}},"required":["en","th"],"description":"SAP-style label for status (labels only; status values are unchanged)"},"responsible":{"type":"object","nullable":true,"properties":{"id":{"type":"string"},"name":{"type":"string","nullable":true}},"required":["id","name"],"description":"Person responsible (ผู้รับผิดชอบหลัก): one person accountable for the job"},"team":{"type":"array","items":{"type":"object","properties":{"user":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string","nullable":true}},"required":["id","name"]},"role":{"type":"string","enum":["project_manager","sales","engineer","site_supervisor","technician","purchaser","accountant","other"]},"is_primary":{"type":"boolean"}},"required":["user","role","is_primary"]},"description":"Job team: people with a role on this job. is_primary = the primary person for that role (primary sales = sales_owner_id, primary technician = the service person)"},"cost":{"type":"object","nullable":true,"properties":{"approved_budget":{"type":"number","nullable":true},"material_actual":{"type":"number"},"services_actual":{"type":"number"},"actual_total":{"type":"number"},"committed":{"type":"number"},"variance":{"type":"number","nullable":true,"description":"approved_budget − (actual_total + committed); null without a budget"},"budget_used_pct":{"type":"number","nullable":true},"excludes":{"type":"array","items":{"type":"string"}}},"required":["approved_budget","material_actual","services_actual","actual_total","committed","variance","budget_used_pct","excludes"],"description":"Only with cost.view; null otherwise"}},"required":["id","job_number","job_name","job_type","status","company_id","company_name","customer","department","owner_id","sales_owner_id","planned_start_date","planned_end_date","actual_start_date","actual_end_date","notes","created_at","updated_at","cost"]},"QuotationDraftCreated":{"allOf":[{"$ref":"#/components/schemas/Created"},{"type":"object","properties":{"prices_omitted":{"type":"boolean","description":"true = no prices.sell: lines saved without a price"}},"required":["prices_omitted"]}],"description":"dry_run=true (test keys): validated, nothing saved, id/number are null."},"ProductSaved":{"allOf":[{"$ref":"#/components/schemas/Created"},{"type":"object","properties":{"sku_code":{"type":"string","nullable":true}},"required":["sku_code"]}],"description":"dry_run=true (test keys): validated, nothing saved, id/number are null."},"ProductImageSet":{"allOf":[{"$ref":"#/components/schemas/Created"},{"type":"object","properties":{"content_type":{"type":"string"}},"required":["content_type"]}],"description":"dry_run=true (test keys): validated, nothing saved, id/number are null."},"StockAdjustmentCreated":{"allOf":[{"$ref":"#/components/schemas/Created"},{"type":"object","properties":{"lines":{"type":"integer"}},"required":["lines"]}],"description":"dry_run=true (test keys): validated, nothing saved, id/number are null."},"StockTransferCreated":{"allOf":[{"$ref":"#/components/schemas/Created"},{"type":"object","properties":{"lines":{"type":"integer"}},"required":["lines"]}],"description":"dry_run=true (test keys): validated, nothing saved, id/number are null."},"StockTransferList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/StockTransfer"}},"has_more":{"type":"boolean"},"next_cursor":{"type":"string","nullable":true}},"required":["data","has_more","next_cursor"]},"StockTransfer":{"type":"object","properties":{"id":{"type":"string"},"transfer_number":{"type":"string"},"status":{"type":"string"},"transfer_date":{"type":"string","nullable":true},"from_warehouse_id":{"type":"string","nullable":true},"to_warehouse_id":{"type":"string","nullable":true},"reason":{"type":"string","nullable":true},"notes":{"type":"string","nullable":true},"posted_at":{"type":"string","nullable":true},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"lines":{"type":"array","items":{"type":"object","properties":{"line_number":{"type":"number"},"product_id":{"type":"string","nullable":true},"item_name":{"type":"string","nullable":true},"unit_of_measure":{"type":"string","nullable":true},"quantity":{"type":"number"},"notes":{"type":"string","nullable":true}},"required":["line_number","product_id","item_name","unit_of_measure","quantity","notes"]}}},"required":["id","transfer_number","status","transfer_date","from_warehouse_id","to_warehouse_id","reason","notes","posted_at","created_at","updated_at","lines"]},"StockAdjustmentList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/StockAdjustment"}},"has_more":{"type":"boolean"},"next_cursor":{"type":"string","nullable":true}},"required":["data","has_more","next_cursor"]},"StockAdjustment":{"type":"object","properties":{"id":{"type":"string"},"adjustment_number":{"type":"string"},"adjustment_type":{"type":"string"},"status":{"type":"string"},"warehouse_id":{"type":"string","nullable":true},"adjustment_date":{"type":"string","nullable":true},"reason":{"type":"string","nullable":true},"notes":{"type":"string","nullable":true},"posted_at":{"type":"string","nullable":true},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"lines":{"type":"array","items":{"type":"object","properties":{"line_number":{"type":"number"},"product_id":{"type":"string","nullable":true},"item_name":{"type":"string","nullable":true},"unit_of_measure":{"type":"string","nullable":true},"system_qty":{"type":"number","nullable":true},"counted_qty":{"type":"number","nullable":true},"adjust_qty":{"type":"number"},"notes":{"type":"string","nullable":true},"unit_cost":{"type":"number","nullable":true,"description":"Only with cost.view"}},"required":["line_number","product_id","item_name","unit_of_measure","system_qty","counted_qty","adjust_qty","notes","unit_cost"]}}},"required":["id","adjustment_number","adjustment_type","status","warehouse_id","adjustment_date","reason","notes","posted_at","created_at","updated_at","lines"]},"WorkOrderDetail":{"type":"object","properties":{"id":{"type":"string"},"wo_number":{"type":"string"},"status":{"type":"string"},"product_id":{"type":"string","nullable":true},"bom_id":{"type":"string","nullable":true},"warehouse_id":{"type":"string","nullable":true},"job_control_id":{"type":"string","nullable":true},"execution_type":{"type":"string","nullable":true},"priority":{"type":"string","nullable":true},"assigned_to":{"type":"string","nullable":true},"quantity_to_produce":{"type":"number","nullable":true},"quantity_produced":{"type":"number","nullable":true},"quantity_scrap":{"type":"number","nullable":true},"planned_start_date":{"type":"string","nullable":true},"planned_end_date":{"type":"string","nullable":true},"actual_start_date":{"type":"string","nullable":true},"actual_end_date":{"type":"string","nullable":true},"qc_hold":{"type":"boolean","nullable":true},"notes":{"type":"string","nullable":true},"updated_at":{"type":"string","format":"date-time"},"planned_material_cost":{"type":"number","nullable":true,"description":"Only with cost.view"},"materials":{"type":"array","items":{"type":"object","properties":{"line_number":{"type":"number","nullable":true},"product_id":{"type":"string","nullable":true},"item_name":{"type":"string","nullable":true},"unit_of_measure":{"type":"string","nullable":true},"quantity_required":{"type":"number"},"quantity_issued":{"type":"number"},"stock_unit":{"type":"string","nullable":true},"remaining_base":{"type":"number"},"warehouse_id":{"type":"string","nullable":true}},"required":["line_number","product_id","item_name","unit_of_measure","quantity_required","quantity_issued","stock_unit","remaining_base","warehouse_id"]}},"shortages":{"type":"array","items":{"type":"object","properties":{"product_id":{"type":"string"},"warehouse_id":{"type":"string"},"needed":{"type":"number"},"on_hand":{"type":"number"},"short_by":{"type":"number"}},"required":["product_id","warehouse_id","needed","on_hand","short_by"]}}},"required":["id","wo_number","status","product_id","bom_id","warehouse_id","job_control_id","execution_type","priority","assigned_to","quantity_to_produce","quantity_produced","quantity_scrap","planned_start_date","planned_end_date","actual_start_date","actual_end_date","qc_hold","notes","updated_at","planned_material_cost","materials","shortages"]},"BomDetail":{"type":"object","properties":{"id":{"type":"string"},"product_id":{"type":"string","nullable":true},"bom_code":{"type":"string","nullable":true},"version":{"type":"string","nullable":true},"kind":{"type":"string","nullable":true},"is_active":{"type":"boolean","nullable":true},"brand":{"type":"string","nullable":true},"model_no":{"type":"string","nullable":true},"model_name":{"type":"string","nullable":true},"revision":{"type":"string","nullable":true},"notes":{"type":"string","nullable":true},"updated_at":{"type":"string","format":"date-time"},"lines":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"line_number":{"type":"number","nullable":true},"component_product_id":{"type":"string","nullable":true},"quantity_per":{"type":"number"},"unit_of_measure":{"type":"string","nullable":true},"notes":{"type":"string","nullable":true},"ref_no":{"type":"string","nullable":true},"is_wear_part":{"type":"boolean","nullable":true},"alternates":{"type":"array","items":{"type":"object","properties":{"alt_product_id":{"type":"string","nullable":true},"scope":{"type":"string","enum":["line","global"]},"grade":{"type":"string","nullable":true},"priority":{"type":"number","nullable":true},"notes":{"type":"string","nullable":true}},"required":["alt_product_id","scope","grade","priority","notes"]}},"unit_cost":{"type":"number","nullable":true},"line_cost":{"type":"number","nullable":true},"cost_source":{"type":"string","nullable":true}},"required":["id","line_number","component_product_id","quantity_per","unit_of_measure","notes","ref_no","is_wear_part","alternates","unit_cost","line_cost","cost_source"]}},"cost":{"type":"object","nullable":true,"properties":{"total":{"type":"number"},"complete":{"type":"boolean"},"missing":{"type":"number"},"estimated":{"type":"number"}},"required":["total","complete","missing","estimated"],"description":"Only with cost.view"}},"required":["id","product_id","bom_code","version","kind","is_active","brand","model_no","model_name","revision","notes","updated_at","lines","cost"]},"VatReport":{"type":"object","properties":{"companies":{"type":"array","items":{"type":"object","properties":{"period":{"type":"string"},"vat_registered":{"type":"boolean","description":"false = the company files no ภ.พ.30; the totals are 0"},"pos_included":{"type":"boolean","description":"false = POS / Commerce sales could not be read; the output side may miss them"},"currency":{"type":"string"},"summary":{"type":"object","properties":{"sales_base":{"type":"number"},"output_vat":{"type":"number"},"zero_rated_sales":{"type":"number"},"exempt_sales":{"type":"number"},"purchase_base":{"type":"number"},"input_vat":{"type":"number"},"pp36_claim":{"type":"number","description":"ภ.พ.36 VAT paid this month, claimed as input VAT"},"pp36_pending":{"type":"number","description":"Last month's ภ.พ.36 not yet marked paid (not claimable until it is)"},"net_payable":{"type":"number","description":"output − input − ภ.พ.36 claim; negative = credit carried forward"}},"required":["sales_base","output_vat","zero_rated_sales","exempt_sales","purchase_base","input_vat","pp36_claim","pp36_pending","net_payable"]},"output":{"type":"array","items":{"type":"object","properties":{"doc_type":{"type":"string"},"doc_no":{"type":"string"},"date":{"type":"string"},"tax_doc_no":{"type":"string"},"party_name":{"type":"string","nullable":true},"party_tax_id":{"type":"string","nullable":true},"party_branch":{"type":"string","nullable":true},"base":{"type":"number"},"vat":{"type":"number"},"note":{"type":"string","nullable":true}},"required":["doc_type","doc_no","date","tax_doc_no","party_name","party_tax_id","party_branch","base","vat"]},"description":"รายงานภาษีขาย rows (with include_rows)"},"input":{"type":"array","items":{"type":"object","properties":{"doc_type":{"type":"string"},"doc_no":{"type":"string"},"date":{"type":"string"},"tax_doc_no":{"type":"string"},"party_name":{"type":"string","nullable":true},"party_tax_id":{"type":"string","nullable":true},"party_branch":{"type":"string","nullable":true},"base":{"type":"number"},"vat":{"type":"number"},"note":{"type":"string","nullable":true}},"required":["doc_type","doc_no","date","tax_doc_no","party_name","party_tax_id","party_branch","base","vat"]},"description":"รายงานภาษีซื้อ rows, listed in their claim month (with include_rows)"},"filed":{"type":"array","items":{"type":"object","properties":{"form":{"type":"string"},"amount":{"type":"number","nullable":true},"reference":{"type":"string","nullable":true},"filed_on":{"type":"string","nullable":true}},"required":["form","amount","reference","filed_on"]},"description":"Forms marked filed for this month"},"company":{"$ref":"#/components/schemas/CompanyRef"},"status":{"type":"string","enum":["ok","error"]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["company","status"]}}},"required":["companies"]},"BalanceSheet":{"type":"object","properties":{"companies":{"type":"array","items":{"type":"object","properties":{"as_of":{"type":"string"},"compare_as_of":{"type":"string","description":"End of the previous fiscal year"},"currency":{"type":"string"},"total_equity":{"type":"number"},"difference":{"type":"number","description":"assets − (liabilities + equity); 0 when the books balance"},"lines":{"type":"array","items":{"type":"object","properties":{"kind":{"type":"string","enum":["heading","account","computed","subtotal","total"]},"label":{"type":"string","description":"Heading / total text, or the account name"},"code":{"type":"string","nullable":true},"name_th":{"type":"string","nullable":true},"depth":{"type":"number"},"amount":{"type":"number"},"compare":{"type":"number"}},"required":["kind","label","code","name_th","depth","amount","compare"]}},"company":{"$ref":"#/components/schemas/CompanyRef"},"status":{"type":"string","enum":["ok","error"]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["company","status"]}}},"required":["companies"]},"CommerceDayReport":{"type":"object","properties":{"date":{"type":"string"},"cutoff_hour":{"type":"number"},"window":{"type":"object","properties":{"start":{"type":"string","format":"date-time"},"end":{"type":"string","format":"date-time"}},"required":["start","end"]},"currency":{"type":"string"},"totals":{"type":"object","properties":{"orders":{"type":"number"},"gross":{"type":"number"},"discount":{"type":"number"},"charges":{"type":"number"},"tax":{"type":"number"},"sales":{"type":"number"},"refunds":{"type":"number"},"net":{"type":"number"},"avg_ticket":{"type":"number"},"cancelled":{"type":"number"},"unpaid":{"type":"number"}},"required":["orders","gross","discount","charges","tax","sales","refunds","net","avg_ticket","cancelled","unpaid"]},"by_tender":{"type":"array","items":{"type":"object","properties":{"key":{"type":"string"},"count":{"type":"number"},"amount":{"type":"number"}},"required":["key","count","amount"]}},"by_source":{"type":"array","items":{"type":"object","properties":{"key":{"type":"string"},"count":{"type":"number"},"amount":{"type":"number"}},"required":["key","count","amount"]}},"by_dining":{"type":"array","items":{"type":"object","properties":{"key":{"type":"string"},"count":{"type":"number"},"amount":{"type":"number"}},"required":["key","count","amount"]}},"by_hour":{"type":"array","items":{"type":"object","properties":{"hour":{"type":"number"},"count":{"type":"number"},"amount":{"type":"number"}},"required":["hour","count","amount"]}},"top_items":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"qty":{"type":"number"},"amount":{"type":"number"}},"required":["name","qty","amount"]}},"refunds":{"type":"array","items":{"type":"object","properties":{"number":{"type":"string","nullable":true},"order_number":{"type":"string"},"amount":{"type":"number"},"method":{"type":"string","nullable":true},"reason":{"type":"string","nullable":true},"created_at":{"type":"string"}},"required":["number","order_number","amount","method","reason","created_at"]}},"pp06_ready":{"type":"boolean","description":"ภ.พ.06 per-register summary available"}},"required":["date","cutoff_hour","window","currency","totals","by_tender","by_source","by_dining","by_hour","top_items","refunds","pp06_ready"]},"EgpTenderList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/EgpTender"}},"has_more":{"type":"boolean"},"next_cursor":{"type":"string","nullable":true}},"required":["data","has_more","next_cursor"]},"EgpTender":{"type":"object","properties":{"id":{"type":"string"},"status":{"type":"string","description":"new (undecided) | added (in the pipeline) | passed"},"matched_terms":{"type":"array","items":{"type":"string"}},"deal_id":{"type":"string","nullable":true},"passed_reason":{"type":"string","nullable":true},"decided_at":{"type":"string","nullable":true},"created_at":{"type":"string","format":"date-time"},"outcome":{"type":"string","nullable":true},"outcome_winner":{"type":"string","nullable":true},"outcome_price":{"type":"number","nullable":true},"outcome_at":{"type":"string","nullable":true},"notice":{"type":"object","properties":{"title":{"type":"string","nullable":true},"project_no":{"type":"string","nullable":true},"link":{"type":"string","nullable":true},"dept_code":{"type":"string","nullable":true},"dept_name":{"type":"string","nullable":true},"announce_type":{"type":"string","nullable":true},"method":{"type":"string","nullable":true},"type_label":{"type":"string","nullable":true},"pub_date":{"type":"string","nullable":true}},"required":["title","project_no","link","dept_code","dept_name","announce_type","method","type_label","pub_date"]}},"required":["id","status","matched_terms","deal_id","passed_reason","decided_at","created_at","outcome","outcome_winner","outcome_price","outcome_at","notice"]},"VoucherList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Voucher"}},"has_more":{"type":"boolean"},"next_cursor":{"type":"string","nullable":true}},"required":["data","has_more","next_cursor"]},"Voucher":{"type":"object","properties":{"id":{"type":"string"},"book":{"type":"string","description":"JV general, SJ sales, PJ purchase, RV receipt, PV payment"},"entry_no":{"type":"string","nullable":true,"description":"Set when posted; drafts have none"},"entry_date":{"type":"string"},"description":{"type":"string","nullable":true},"reference":{"type":"string","nullable":true},"status":{"type":"string"},"total_amount":{"type":"number","nullable":true},"source_type":{"type":"string","nullable":true,"description":"What made it (invoice, bill, payment, payroll…); null = typed in"},"reverses_id":{"type":"string","nullable":true},"reversed_by_id":{"type":"string","nullable":true},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"posted_at":{"type":"string","nullable":true}},"required":["id","book","entry_no","entry_date","description","reference","status","total_amount","source_type","reverses_id","reversed_by_id","created_at","updated_at","posted_at"]},"VoucherDetail":{"allOf":[{"$ref":"#/components/schemas/Voucher"},{"type":"object","properties":{"lines":{"type":"array","items":{"type":"object","properties":{"line_no":{"type":"number"},"account_id":{"type":"string","nullable":true},"account_code":{"type":"string","nullable":true},"account_name":{"type":"string","nullable":true},"description":{"type":"string","nullable":true},"debit":{"type":"number"},"credit":{"type":"number"}},"required":["line_no","account_id","account_code","account_name","description","debit","credit"]}},"reverses_no":{"type":"string","nullable":true},"reversed_by_no":{"type":"string","nullable":true}},"required":["lines","reverses_no","reversed_by_no"]}]},"MyAttendance":{"type":"object","properties":{"employee_id":{"type":"string"},"from":{"type":"string"},"to":{"type":"string"},"work_hours":{"type":"object","properties":{"start_minute":{"type":"number"},"end_minute":{"type":"number"},"late_grace_minutes":{"type":"number"}},"required":["start_minute","end_minute","late_grace_minutes"]},"days":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"employee_id":{"type":"string"},"work_date":{"type":"string"},"clock_in":{"type":"string","nullable":true},"clock_out":{"type":"string","nullable":true},"break_minutes":{"type":"number","nullable":true},"worked_minutes":{"type":"number","nullable":true},"source":{"type":"string","nullable":true},"status":{"type":"string","nullable":true},"class":{"type":"string","description":"ok | late | ot | missing_in | missing_out | empty (company work hours, late grace)"},"late_minutes":{"type":"number"},"ot_minutes":{"type":"number"}},"required":["id","employee_id","work_date","clock_in","clock_out","break_minutes","worked_minutes","source","status","class","late_minutes","ot_minutes"]}},"overtime":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"employee_id":{"type":"string"},"work_date":{"type":"string"},"hours":{"type":"number","nullable":true},"multiplier":{"type":"number","nullable":true},"compensation_type":{"type":"string","nullable":true},"status":{"type":"string","nullable":true},"reason":{"type":"string","nullable":true}},"required":["id","employee_id","work_date","hours","multiplier","compensation_type","status","reason"]}},"totals":{"type":"object","properties":{"days":{"type":"number"},"approved_worked_minutes":{"type":"number"},"late_days":{"type":"number"},"late_minutes":{"type":"number"},"missing_punch_days":{"type":"number"},"approved_ot_hours":{"type":"number"},"pending_days":{"type":"number"}},"required":["days","approved_worked_minutes","late_days","late_minutes","missing_punch_days","approved_ot_hours","pending_days"]}},"required":["employee_id","from","to","work_hours","days","overtime","totals"]},"TeamAttendance":{"type":"object","properties":{"from":{"type":"string"},"to":{"type":"string"},"scope":{"type":"string","enum":["company","reporting_line"]},"employees":{"type":"array","items":{"type":"object","properties":{"employee_id":{"type":"string"},"display_name":{"type":"string","nullable":true},"employee_code":{"type":"string","nullable":true},"totals":{"type":"object","properties":{"days":{"type":"number"},"approved_worked_minutes":{"type":"number"},"late_days":{"type":"number"},"late_minutes":{"type":"number"},"missing_punch_days":{"type":"number"},"approved_ot_hours":{"type":"number"},"pending_days":{"type":"number"}},"required":["days","approved_worked_minutes","late_days","late_minutes","missing_punch_days","approved_ot_hours","pending_days"]},"days":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"employee_id":{"type":"string"},"work_date":{"type":"string"},"clock_in":{"type":"string","nullable":true},"clock_out":{"type":"string","nullable":true},"break_minutes":{"type":"number","nullable":true},"worked_minutes":{"type":"number","nullable":true},"source":{"type":"string","nullable":true},"status":{"type":"string","nullable":true},"class":{"type":"string","description":"ok | late | ot | missing_in | missing_out | empty (company work hours, late grace)"},"late_minutes":{"type":"number"},"ot_minutes":{"type":"number"}},"required":["id","employee_id","work_date","clock_in","clock_out","break_minutes","worked_minutes","source","status","class","late_minutes","ot_minutes"]}},"overtime":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"employee_id":{"type":"string"},"work_date":{"type":"string"},"hours":{"type":"number","nullable":true},"multiplier":{"type":"number","nullable":true},"compensation_type":{"type":"string","nullable":true},"status":{"type":"string","nullable":true},"reason":{"type":"string","nullable":true}},"required":["id","employee_id","work_date","hours","multiplier","compensation_type","status","reason"]}}},"required":["employee_id","display_name","employee_code","totals"]}}},"required":["from","to","scope","employees"]},"LeaveCancelled":{"type":"object","properties":{"id":{"type":"string"},"status":{"type":"string"},"previous_status":{"type":"string"},"days_refunded":{"type":"boolean"},"dry_run":{"type":"boolean"}},"required":["id","status","previous_status","days_refunded","dry_run"]},"ExpenseReceiptAttached":{"type":"object","properties":{"id":{"type":"string","nullable":true},"claim_id":{"type":"string"},"line_id":{"type":"string"},"content_type":{"type":"string"},"dry_run":{"type":"boolean"},"url":{"type":"string","nullable":true}},"required":["id","claim_id","line_id","content_type","dry_run","url"]},"PeopleFound":{"type":"object","properties":{"results":{"type":"array","items":{"type":"object","properties":{"query":{"type":"string"},"resolved":{"type":"object","nullable":true,"properties":{"user_id":{"type":"string","nullable":true,"description":"Their Tonbab login (use for owner_id / assignment); null = an employee without a login"},"employee_id":{"type":"string","nullable":true},"display_name":{"type":"string","nullable":true},"name_th":{"type":"string","nullable":true},"name_en":{"type":"string","nullable":true},"nickname_th":{"type":"string","nullable":true},"nickname_en":{"type":"string","nullable":true},"employee_code":{"type":"string","nullable":true},"email":{"type":"string","nullable":true,"description":"Work / login email — only with people.employee.view or user.manage, or when you searched by that email"},"job_title":{"type":"string","nullable":true},"department":{"type":"string","nullable":true},"employee_status":{"type":"string","nullable":true},"is_member":{"type":"boolean"}},"required":["user_id","employee_id","display_name","name_th","name_en","nickname_th","nickname_en","employee_code","email","job_title","department","employee_status","is_member"]},"match":{"type":"string","nullable":true,"description":"email | employee_code | name_en | name_th | nickname | display_name | fuzzy"},"ambiguous":{"type":"boolean"},"candidates":{"type":"array","items":{"type":"object","properties":{"user_id":{"type":"string","nullable":true,"description":"Their Tonbab login (use for owner_id / assignment); null = an employee without a login"},"employee_id":{"type":"string","nullable":true},"display_name":{"type":"string","nullable":true},"name_th":{"type":"string","nullable":true},"name_en":{"type":"string","nullable":true},"nickname_th":{"type":"string","nullable":true},"nickname_en":{"type":"string","nullable":true},"employee_code":{"type":"string","nullable":true},"email":{"type":"string","nullable":true,"description":"Work / login email — only with people.employee.view or user.manage, or when you searched by that email"},"job_title":{"type":"string","nullable":true},"department":{"type":"string","nullable":true},"employee_status":{"type":"string","nullable":true},"is_member":{"type":"boolean"},"match":{"type":"string"},"confidence":{"type":"string","enum":["exact","suggestion"]}},"required":["user_id","employee_id","display_name","name_th","name_en","nickname_th","nickname_en","employee_code","email","job_title","department","employee_status","is_member","match","confidence"]}}},"required":["query","resolved","match","ambiguous","candidates"]}}},"required":["results"]},"MigrationStart":{"type":"object","properties":{"job":{"$ref":"#/components/schemas/MigrationJob"},"ready":{"type":"boolean"},"next_step":{"type":"string"},"limits":{"type":"object","additionalProperties":{"type":"number"}},"playbook":{"type":"string"},"settings_url":{"type":"string"}},"required":["job","ready","next_step","limits","playbook","settings_url"]},"MigrationJob":{"type":"object","nullable":true,"properties":{"id":{"type":"string"},"status":{"type":"string"},"mode":{"type":"string"},"source_system":{"type":"string"},"cutover_date":{"type":"string"},"expires_at":{"type":"string"},"granted_to_you":{"type":"boolean"},"granted_to":{"type":"string","nullable":true},"stats":{"type":"object","additionalProperties":{"nullable":true}},"reconciliation":{"nullable":true},"open_items":{"nullable":true},"review_summary":{"type":"string","nullable":true}},"required":["id","status","mode","source_system","cutover_date","expires_at","granted_to_you","granted_to","stats","review_summary"]},"MigrationStatus":{"type":"object","properties":{"job":{"$ref":"#/components/schemas/MigrationJob"},"account_mappings":{"type":"number"}},"required":["job","account_mappings"]},"MigrationRollbackPreview":{"type":"object","properties":{"job_id":{"type":"string"},"can_rollback":{"type":"boolean"},"created":{"type":"object","additionalProperties":{"type":"number"}},"blockers":{"type":"array","items":{"type":"object","additionalProperties":{"nullable":true}}}},"required":["job_id","can_rollback","created","blockers"]},"MigrationBatchResult":{"type":"object","properties":{"job_id":{"type":"string"},"dry_run":{"type":"boolean"},"created":{"type":"number"},"updated":{"type":"number"},"linked":{"type":"number"},"skipped":{"type":"number"},"errors":{"type":"number"},"results":{"type":"array","items":{"$ref":"#/components/schemas/MigrationItemResult"}}},"required":["job_id","dry_run","created","skipped","errors","results"],"description":"One result per item, in order. created = new in Tonbab; skipped = its number is already there (re-run is safe); error = not imported (code + message). dry_run=true: nothing was saved."},"MigrationItemResult":{"type":"object","properties":{"index":{"type":"number"},"source_id":{"type":"string"},"status":{"type":"string","enum":["created","updated","linked","skipped","error"]},"number":{"type":"string","nullable":true},"id":{"type":"string","nullable":true},"code":{"type":"string","nullable":true},"message":{"type":"string","nullable":true}},"required":["index","source_id","status"]},"MigrationTrialBalanceReconciliation":{"type":"object","properties":{"job_id":{"type":"string"},"as_of":{"type":"string"},"balanced":{"type":"boolean"},"matched":{"type":"number"},"difference_count":{"type":"number"},"differences":{"type":"array","items":{"type":"object","properties":{"code":{"type":"string"},"name":{"type":"string","nullable":true},"source":{"type":"number"},"tonbab":{"type":"number"},"difference":{"type":"number"}},"required":["code","name","source","tonbab","difference"]}},"source_total":{"type":"number"},"tonbab_total":{"type":"number"},"unclosed_prior_years_pl":{"type":"number"}},"required":["job_id","as_of","balanced","matched","difference_count","differences","source_total","tonbab_total","unclosed_prior_years_pl"]},"MigrationOpenItems":{"type":"object","properties":{"job_id":{"type":"string"},"as_of":{"type":"string"},"matched":{"type":"number"},"difference_count":{"type":"number"},"differences":{"type":"array","items":{"type":"object","properties":{"kind":{"type":"string"},"party":{"type":"string"},"source":{"type":"number"},"tonbab":{"type":"number"},"difference":{"type":"number"}},"required":["kind","party","source","tonbab","difference"]}},"totals":{"type":"object","properties":{"ar":{"type":"object","properties":{"source":{"type":"number"},"tonbab":{"type":"number"}},"required":["source","tonbab"]},"ap":{"type":"object","properties":{"source":{"type":"number"},"tonbab":{"type":"number"}},"required":["source","tonbab"]}},"required":["ar","ap"]}},"required":["job_id","as_of","matched","difference_count","differences","totals"]},"MigrationReviewRequested":{"type":"object","properties":{"job_id":{"type":"string"},"status":{"type":"string"},"settings_url":{"type":"string"}},"required":["job_id","status","settings_url"]},"GeneralLedger":{"type":"object","properties":{"account":{"type":"object","properties":{"code":{"type":"string"},"name":{"type":"string"},"account_type":{"type":"string"}},"required":["code","name","account_type"]},"period":{"type":"object","properties":{"from":{"type":"string"},"to":{"type":"string"}},"required":["from","to"]},"opening":{"type":"number"},"debit":{"type":"number"},"credit":{"type":"number"},"closing":{"type":"number"},"lines":{"type":"array","items":{"type":"object","properties":{"date":{"type":"string"},"entry_no":{"type":"string","nullable":true},"book":{"type":"string"},"description":{"type":"string","nullable":true},"line_description":{"type":"string","nullable":true},"debit":{"type":"number"},"credit":{"type":"number"},"balance":{"type":"number"}},"required":["date","entry_no","book","description","line_description","debit","credit","balance"]}},"has_more":{"type":"boolean"},"next_offset":{"type":"number","nullable":true}},"required":["account","period","opening","debit","credit","closing","lines","has_more","next_offset"]},"CrmMigrationStart":{"type":"object","properties":{"job":{"$ref":"#/components/schemas/CrmMigrationJob"},"ready":{"type":"boolean"},"next_step":{"type":"string"},"limits":{"type":"object","additionalProperties":{"type":"number"}},"playbook":{"type":"string"},"settings_url":{"type":"string"},"pipelines":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name_en":{"type":"string"},"name_th":{"type":"string"},"stages":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name_en":{"type":"string"},"name_th":{"type":"string"},"kind":{"type":"string"},"probability":{"type":"number","nullable":true}},"required":["id","name_en","name_th","kind","probability"]}}},"required":["id","name_en","name_th","stages"]}},"team":{"type":"object","properties":{"members":{"type":"number"},"employees":{"type":"number","nullable":true},"people_module":{"type":"boolean"}},"required":["members","employees","people_module"]}},"required":["job","ready","next_step","limits","playbook","settings_url","pipelines","team"]},"CrmMigrationJob":{"type":"object","nullable":true,"properties":{"id":{"type":"string"},"status":{"type":"string"},"source_system":{"type":"string"},"expires_at":{"type":"string"},"granted_to_you":{"type":"boolean"},"granted_to":{"type":"string","nullable":true},"owner_decisions":{"type":"array","items":{"type":"object","additionalProperties":{"nullable":true}},"description":"Decisions a person made for owners without a login: { source_id, name, decision transfer|invite|keep, user_id, at, moved }."},"stats":{"type":"object","additionalProperties":{"nullable":true}},"reconciliation":{"nullable":true},"issues":{"type":"array","items":{"type":"object","additionalProperties":{"nullable":true}},"description":"Findings to follow up: { kind, severity, issue_key, title_th, title_en, detail, action?, dismissed? }."},"review_summary":{"type":"string","nullable":true}},"required":["id","status","source_system","expires_at","granted_to_you","granted_to","owner_decisions","stats","issues","review_summary"]},"CrmMigrationStatus":{"type":"object","properties":{"job":{"$ref":"#/components/schemas/CrmMigrationJob"},"owners":{"type":"array","items":{"type":"object","properties":{"source_id":{"type":"string"},"name":{"type":"string","nullable":true},"email":{"type":"string","nullable":true},"match":{"type":"string"},"user_id":{"type":"string","nullable":true},"employee_id":{"type":"string","nullable":true},"decision":{"type":"string","nullable":true},"counts":{"type":"object","nullable":true,"additionalProperties":{"nullable":true}},"candidates":{"type":"array","items":{"type":"object","additionalProperties":{"nullable":true}}}},"required":["source_id","name","email","match","user_id","employee_id","decision","counts","candidates"]}},"owners_awaiting_decision":{"type":"array","items":{"type":"string"}}},"required":["job","owners","owners_awaiting_decision"]},"CrmMigrationRollbackPreview":{"type":"object","properties":{"job_id":{"type":"string"},"can_rollback":{"type":"boolean"},"window_ends":{"type":"string","nullable":true},"created":{"type":"object","additionalProperties":{"type":"number"}},"will_delete":{"type":"object","additionalProperties":{"type":"number"}},"will_keep":{"type":"object","additionalProperties":{"type":"number"}},"kept_counts":{"type":"object","additionalProperties":{"type":"number"}},"kept":{"type":"array","items":{"type":"object","properties":{"table":{"type":"string"},"id":{"type":"string"},"source_id":{"type":"string"},"reason":{"type":"string"}},"required":["table","id","source_id","reason"]}},"filled":{"type":"number"},"blockers":{"type":"array","items":{"type":"object","additionalProperties":{"nullable":true}}}},"required":["job_id","can_rollback","window_ends","created","will_delete","will_keep","kept_counts","kept","filled","blockers"]},"CrmMigrationItemResult":{"type":"object","properties":{"index":{"type":"number"},"source_id":{"type":"string"},"status":{"type":"string","enum":["created","updated","linked","skipped","error"]},"number":{"type":"string","nullable":true},"id":{"type":"string","nullable":true},"code":{"type":"string","nullable":true},"message":{"type":"string","nullable":true},"match":{"type":"string","description":"map_crm_users: matched_user | matched_employee_no_login | unmatched | confirmed"},"via":{"type":"string"},"candidates":{"type":"array","items":{"type":"object","additionalProperties":{"nullable":true}}},"owner_name":{"type":"string","nullable":true},"stages":{"type":"array","items":{"type":"object","additionalProperties":{"nullable":true}}},"filled":{"type":"array","items":{"type":"string"}},"duplicate_of":{"type":"string"},"placeholder_account":{"type":"boolean"}},"required":["index","source_id","status"]},"CrmMigrationBatchResult":{"type":"object","properties":{"job_id":{"type":"string"},"dry_run":{"type":"boolean"},"created":{"type":"number"},"updated":{"type":"number"},"linked":{"type":"number"},"skipped":{"type":"number"},"errors":{"type":"number"},"results":{"type":"array","items":{"$ref":"#/components/schemas/CrmMigrationItemResult"}}},"required":["job_id","dry_run","created","updated","linked","skipped","errors","results"],"description":"One result per item, in order. created = new in Tonbab; linked = matched an existing record (updated = and filled its blank fields); skipped = this source_id is already imported (re-run is safe); error = not imported (code + message). dry_run=true: nothing was saved."},"CrmMigrationReconciliation":{"type":"object","properties":{"job_id":{"type":"string"},"balanced":{"type":"boolean"},"pipelines_matched":{"type":"number"},"pipeline_differences":{"type":"array","items":{"type":"object","additionalProperties":{"nullable":true}}},"count_differences":{"type":"array","items":{"type":"object","additionalProperties":{"nullable":true}}},"totals":{"type":"object","additionalProperties":{"nullable":true}},"as_of":{"type":"string"}},"required":["job_id","balanced","pipelines_matched","pipeline_differences","count_differences","totals","as_of"]},"CrmMigrationReviewRequested":{"type":"object","properties":{"job_id":{"type":"string"},"status":{"type":"string"},"settings_url":{"type":"string"}},"required":["job_id","status","settings_url"]},"ImportIssueReport":{"type":"object","properties":{"dry_run":{"type":"boolean"},"domain":{"type":"string"},"context":{"type":"string"},"check_date":{"type":"string"},"recurring":{"type":"boolean"},"reported":{"type":"number"},"new":{"type":"number"},"still_open":{"type":"number"},"reopened":{"type":"number"},"still_dismissed":{"type":"number"},"resolved":{"type":"number"},"repeated":{"type":"array","items":{"type":"object","properties":{"issue_key":{"type":"string"},"seen_days":{"type":"number"}},"required":["issue_key","seen_days"]}},"notified":{"type":"number"}},"required":["dry_run","domain","context","check_date","recurring","reported","new","still_open","reopened","still_dismissed","resolved","repeated","notified"]},"ImportIssueInput":{"type":"object","properties":{"kind":{"type":"string","pattern":"^[a-z0-9_]{2,50}$","description":"A catalogue kind (see docs/IMPORT-ISSUES.md), e.g. payments_voided_at_source, trial_balance_mismatch, unmatched_owner. An unknown kind still shows, with a generic title."},"issue_key":{"type":"string","minLength":3,"maxLength":200,"description":"Stable per problem: <kind>:<natural ref>, e.g. payments_voided_at_source:PV2026100013. The same key on the next report = the same issue."},"severity":{"type":"string","enum":["high","medium","low"]},"title_th":{"type":"string","maxLength":300},"title_en":{"type":"string","maxLength":300},"detail":{"type":"object","additionalProperties":{"nullable":true},"description":"Numbers, codes and document numbers (doc_no, amount, date, account_code, source_balance, tonbab_balance, difference, as_of, record_type, record_id, …). No tax IDs or personal data."},"action":{"type":"object","nullable":true,"additionalProperties":{"nullable":true}},"fingerprint":{"type":"string","maxLength":200,"description":"What makes the issue \"the same\". Default: the detail minus as_of / checked_at / check_date. A dismissed issue reopens only when this changes."}},"required":["kind","issue_key"]},"ImportIssueList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/ImportIssue"}}},"required":["data"]},"ImportIssue":{"type":"object","properties":{"id":{"type":"string"},"domain":{"type":"string"},"context":{"type":"string"},"kind":{"type":"string"},"severity":{"type":"string"},"issue_key":{"type":"string"},"title_th":{"type":"string","nullable":true},"title_en":{"type":"string","nullable":true},"detail":{"type":"object","additionalProperties":{"nullable":true}},"status":{"type":"string"},"resolution":{"type":"string","nullable":true},"first_seen_date":{"type":"string"},"last_seen_date":{"type":"string"},"seen_days":{"type":"number"},"reopened_after_fix":{"type":"boolean"},"dismiss_reason":{"type":"string","nullable":true},"source_label":{"type":"string","nullable":true}},"required":["id","domain","context","kind","severity","issue_key","title_th","title_en","detail","status","resolution","first_seen_date","last_seen_date","seen_days","reopened_after_fix","dismiss_reason"]},"AccountingDraftCreated":{"allOf":[{"$ref":"#/components/schemas/Created"},{"type":"object","properties":{"doc_type":{"type":"string"}},"required":["doc_type"]}],"description":"dry_run=true (test keys): validated, nothing saved, id/number are null."},"JournalDraftCreated":{"allOf":[{"$ref":"#/components/schemas/Created"},{"type":"object","properties":{"total":{"type":"number","description":"Total debits (= credits), THB"}},"required":["total"]}],"description":"dry_run=true (test keys): validated, nothing saved, id/number are null."},"ServiceJobSaved":{"allOf":[{"$ref":"#/components/schemas/Created"},{"type":"object","properties":{"order_number":{"type":"string","nullable":true}},"required":["order_number"]}],"description":"dry_run=true (test keys): validated, nothing saved, id/number are null."},"ServiceJobPhotosAdded":{"type":"object","properties":{"id":{"type":"string"},"saved":{"type":"number"},"failed":{"type":"number"},"dry_run":{"type":"boolean"},"url":{"type":"string","nullable":true}},"required":["id","saved","failed","dry_run","url"]},"DocPageSaved":{"allOf":[{"$ref":"#/components/schemas/Created"},{"type":"object","properties":{"version":{"type":"number","nullable":true,"description":"Page version after the save (pass as expected_version next time)"}},"required":["version"]}],"description":"dry_run=true (test keys): validated, nothing saved, id/number are null."},"DocRowAdded":{"allOf":[{"$ref":"#/components/schemas/Created"},{"type":"object","properties":{"props":{"type":"object","additionalProperties":{"nullable":true}}},"required":["props"]}],"description":"dry_run=true (test keys): validated, nothing saved, id/number are null."},"FileAttached":{"allOf":[{"$ref":"#/components/schemas/Created"},{"type":"object","properties":{"file_name":{"type":"string","nullable":true},"content_type":{"type":"string","nullable":true},"bytes":{"type":"number"}},"required":["file_name","content_type","bytes"]}],"description":"dry_run=true (test keys): validated, nothing saved, id/number are null."},"MigrationSyncBatchResult":{"type":"object","properties":{"job_id":{"type":"string"},"dry_run":{"type":"boolean"},"done":{"type":"number"},"skipped":{"type":"number"},"errors":{"type":"number"},"results":{"type":"array","items":{"$ref":"#/components/schemas/MigrationSyncItemResult"}}},"required":["job_id","dry_run","done","skipped","errors","results"],"description":"One result per item, in order. skipped = already so in Tonbab (re-run is safe). dry_run=true: nothing was saved."},"MigrationSyncItemResult":{"type":"object","properties":{"index":{"type":"number"},"source_id":{"type":"string"},"status":{"type":"string","enum":["voided","replaced","skipped","error"]},"number":{"type":"string","nullable":true},"id":{"type":"string","nullable":true},"code":{"type":"string","nullable":true},"message":{"type":"string","nullable":true}},"required":["index","source_id","status"]},"MigrationAmendResult":{"type":"object","properties":{"job_id":{"type":"string"},"dry_run":{"type":"boolean"},"status":{"type":"string"},"number":{"type":"string"},"id":{"type":"string","nullable":true},"voided_id":{"type":"string","nullable":true},"voided_number":{"type":"string","nullable":true}},"required":["job_id","dry_run","status","number","id","voided_id","voided_number"],"description":"id = the corrected document; voided_id / voided_number = the imported copy now void. dry_run: nothing saved (ids are what would have been)."},"MigrationRelinkResult":{"type":"object","properties":{"job_id":{"type":"string"},"dry_run":{"type":"boolean"},"company_id":{"type":"string"},"documents_moved":{"type":"number"},"payments_moved":{"type":"number"}},"required":["job_id","dry_run","company_id","documents_moved","payments_moved"]},"PossibleDuplicates":{"type":"object","properties":{"results":{"type":"array","items":{"type":"object","properties":{"ref":{"type":"string"},"number_exists":{"type":"boolean","description":"A document of this type with this number is already in Tonbab."},"matches":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"kind":{"type":"string"},"number":{"type":"string","nullable":true},"date":{"type":"string"},"total":{"type":"number"},"party_name":{"type":"string","nullable":true},"imported":{"type":"boolean"},"score":{"type":"number"},"strong":{"type":"boolean"},"signals":{"type":"array","items":{"type":"string"}},"url":{"type":"string"}},"required":["id","kind","number","date","total","party_name","imported","score","strong","signals","url"]}}},"required":["ref","number_exists","matches"]}}},"required":["results"]},"MigrationExtensionRequest":{"type":"object","properties":{"job_id":{"type":"string"},"requested":{"type":"boolean"},"already_requested":{"type":"boolean"},"notified":{"type":"string","nullable":true},"expires_at":{"type":"string"}},"required":["job_id","requested","already_requested","notified","expires_at"]},"AnnouncementList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Announcement"}}},"required":["data"]},"Announcement":{"type":"object","properties":{"id":{"type":"string"},"kind":{"type":"string","description":"news · update · action_required · maintenance"},"severity":{"type":"string","description":"info · warning · critical"},"title":{"type":"object","properties":{"en":{"type":"string","nullable":true},"th":{"type":"string","nullable":true}}},"body":{"type":"object","properties":{"en":{"type":"string","nullable":true},"th":{"type":"string","nullable":true}},"description":"Plain text or minimal markdown (paragraphs, \"- \" bullets, **bold**)."},"link_url":{"type":"string","nullable":true},"link_label":{"type":"object","nullable":true,"properties":{"en":{"type":"string","nullable":true},"th":{"type":"string","nullable":true}}},"cta_url":{"type":"string","nullable":true,"description":"Where in Tonbab to act on it (absolute URL), or null."},"starts_at":{"type":"string"},"ends_at":{"type":"string","nullable":true}},"required":["id","kind","severity","title","body","link_url","link_label","cta_url","starts_at","ends_at"]},"DocumentFlow":{"type":"object","properties":{"root":{"type":"object","properties":{"type":{"type":"string"},"id":{"type":"string"}},"required":["type","id"]},"nodes":{"type":"array","items":{"$ref":"#/components/schemas/DocumentFlowNode"}},"edges":{"type":"array","items":{"type":"object","properties":{"from":{"type":"string"},"to":{"type":"string"}},"required":["from","to"]},"description":"\"type:id\" pairs; links are undirected"},"truncated":{"type":"boolean"}},"required":["root","nodes","edges","truncated"]},"DocumentFlowNode":{"type":"object","properties":{"type":{"type":"string","description":"purchase_request · purchase_order · goods_receipt · delivery_note · work_order · job_control · service_order · crm_deal · acc_document · acc_payment · expense_claim · payroll_run"},"id":{"type":"string"},"number":{"type":"string","nullable":true,"description":"Document number (a deal: its title); null on a draft that has none yet"},"status":{"type":"string","nullable":true},"subtype":{"type":"string","nullable":true,"description":"acc_document: quotation · invoice · billing_note · credit_note · debit_note · bill · bill_credit; acc_payment: receipt · payment"},"date":{"type":"string","nullable":true},"url":{"type":"string","nullable":true,"description":"Link to the document in Tonbab, or null when this connection may not open it"},"root":{"type":"boolean","description":"The document you asked about"}},"required":["type","id","number","status","subtype","date","url","root"]},"EventTypes":{"type":"object","properties":{"data":{"type":"array","items":{"type":"string"}}},"required":["data"]}},"parameters":{}},"paths":{"/v1/public/careers/{slug}/jobs":{"get":{"tags":["Careers"],"summary":"List published job openings","description":"Public job board feed for one company. Keyless; cache for 5 minutes. Returns only published postings of a company whose careers page is switched on.","parameters":[{"schema":{"type":"string","example":"codustry","description":"The tenant's careers slug"},"required":true,"description":"The tenant's careers slug","name":"slug","in":"path"},{"schema":{"type":"string","description":"Filter by category slug"},"required":false,"description":"Filter by category slug","name":"category","in":"query"}],"responses":{"200":{"description":"Job list","content":{"application/json":{"schema":{"$ref":"#/components/schemas/JobListResponse"}}}},"404":{"description":"Unknown slug or careers page switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NotFound"}}}}}}},"/v1/public/careers/{slug}/jobs/{id}":{"get":{"tags":["Careers"],"summary":"Get one job opening","description":"Full posting incl. description and requirements (markdown). Keyless; cache for 5 minutes.","parameters":[{"schema":{"type":"string","example":"codustry","description":"The tenant's careers slug"},"required":true,"description":"The tenant's careers slug","name":"slug","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Job detail","content":{"application/json":{"schema":{"$ref":"#/components/schemas/JobDetailResponse"}}}},"404":{"description":"Unknown/unpublished posting, unknown slug, or careers page switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NotFound"}}}}}}},"/v1/me":{"get":{"operationId":"me.get","tags":["Account"],"summary":"Who am I","description":"The company this credential belongs to, its granted scopes and mode (live/test). Call this first to see what you can do.","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Me"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/products":{"get":{"operationId":"products.list","tags":["Products"],"summary":"List products","description":"Search the product catalogue by SKU, name or barcode. Supports incremental sync with updated_since.\n\n**Scopes:** `product.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":200,"default":50,"description":"Page size (1–200, default 50)"},"required":false,"description":"Page size (1–200, default 50)","name":"limit","in":"query"},{"schema":{"type":"string","maxLength":200,"description":"Opaque cursor from `next_cursor` of the previous page"},"required":false,"description":"Opaque cursor from `next_cursor` of the previous page","name":"cursor","in":"query"},{"schema":{"type":"string","format":"date-time","description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally."},"required":false,"description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally.","name":"updated_since","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Text search"},"required":false,"description":"Text search","name":"q","in":"query"},{"schema":{"type":"string","enum":["true","false"],"description":"Filter by active flag"},"required":false,"description":"Filter by active flag","name":"active","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProductList"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"products.create","tags":["Products"],"summary":"Create a product","description":"Add a product exactly as the product form does: a blank SKU takes the next system SKU, a service is never stocked, alternate units in the stock unit. selling_price (THB, VAT-inclusive) needs prices.sell; main_vendor / alt_vendors (and their prices) need cost.view + supplier.view — giving them without that is refused. The plan's product limit applies.\n\n**Scopes:** `product.create`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"sku_code":{"type":"string","maxLength":60,"description":"Blank / omitted = the next system SKU"},"item_name":{"type":"string","minLength":1,"maxLength":300},"item_type":{"type":"string","enum":["raw_material","component","semi_finished","finished_good","service","consumable"]},"unit_of_measure":{"type":"string","minLength":1,"maxLength":40},"description":{"type":"string","maxLength":4000},"barcode":{"type":"string","maxLength":100},"brand_id":{"type":"string","format":"uuid"},"is_stock_item":{"type":"boolean"},"is_purchasable":{"type":"boolean"},"is_sellable":{"type":"boolean"},"is_manufacturable":{"type":"boolean"},"selling_price":{"type":"number","nullable":true,"minimum":0,"maximum":10000000000,"description":"THB, VAT-inclusive; null = no price. Needs prices.sell"},"default_warehouse_id":{"type":"string","nullable":true,"format":"uuid"},"lead_time_days":{"type":"integer","nullable":true,"minimum":0,"maximum":3650},"minimum_stock":{"type":"number","minimum":0,"maximum":1000000000},"reorder_point":{"type":"number","minimum":0,"maximum":1000000000},"base_uom":{"type":"string","maxLength":40,"description":"Stock unit (default unit_of_measure). Fixed once stock has moved"},"purchase_uom":{"type":"string","nullable":true,"maxLength":40},"production_uom":{"type":"string","nullable":true,"maxLength":40},"uom_strict":{"type":"boolean"},"serial_tracking_enabled":{"type":"boolean"},"batch_tracking_enabled":{"type":"boolean"},"costing_method":{"type":"string","nullable":true,"enum":["avco","fifo",null],"description":"null = company default; fifo needs batch tracking"},"unit_weight_kg":{"type":"number","nullable":true,"minimum":0,"exclusiveMinimum":true,"maximum":1000000},"notes":{"type":"string","nullable":true,"maxLength":4000},"main_vendor":{"type":"object","nullable":true,"properties":{"company_id":{"type":"string","format":"uuid"},"vendor_part_number":{"type":"string","maxLength":100},"unit_price":{"type":"number","minimum":0,"maximum":1000000000000,"description":"Vendor price per purchase unit"},"currency":{"type":"string","minLength":3,"maxLength":3,"default":"THB"},"lead_time_days":{"type":"integer","minimum":0,"maximum":3650},"purchase_uom":{"type":"string","maxLength":40},"notes":{"type":"string","maxLength":500,"description":"Alternate vendors only"}},"required":["company_id"],"description":"Needs cost.view + supplier.view; null removes it"},"alt_vendors":{"type":"array","items":{"type":"object","properties":{"company_id":{"type":"string","format":"uuid"},"vendor_part_number":{"type":"string","maxLength":100},"unit_price":{"type":"number","minimum":0,"maximum":1000000000000,"description":"Vendor price per purchase unit"},"currency":{"type":"string","minLength":3,"maxLength":3,"default":"THB"},"lead_time_days":{"type":"integer","minimum":0,"maximum":3650},"purchase_uom":{"type":"string","maxLength":40},"notes":{"type":"string","maxLength":500,"description":"Alternate vendors only"}},"required":["company_id"]},"maxItems":5,"description":"Replaces the alternates. Needs cost.view + supplier.view"},"alt_units":{"type":"array","items":{"type":"object","properties":{"from_uom":{"type":"string","minLength":1,"maxLength":40},"factor":{"type":"number","minimum":0,"exclusiveMinimum":true,"maximum":1000000000,"description":"1 from_uom = factor × stock unit"},"notes":{"type":"string","maxLength":200}},"required":["from_uom","factor"]},"maxItems":20},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["item_name","item_type","unit_of_measure"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProductSaved"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/products/{id}":{"get":{"operationId":"products.get","tags":["Products"],"summary":"Get a product","description":"One product by id.\n\n**Scopes:** `product.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","description":"Record id (uuid)"},"required":true,"description":"Record id (uuid)","name":"id","in":"path"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Product"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"products.update","tags":["Products"],"summary":"Update a product","description":"Change a product: only the fields you give change; the rest stay as they are. Same rules as the edit form: tracking mode, costing method and the stock unit are fixed once stock has moved; renaming a system SKU frees it. selling_price needs prices.sell; vendors need cost.view + supplier.view (vendors you can't see are never touched). Pass expected_updated_at (from get_product) to refuse the change if someone else saved first.\n\n**Scopes:** `product.edit`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","description":"Record id (uuid)"},"required":true,"description":"Record id (uuid)","name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"sku_code":{"type":"string","maxLength":60,"description":"Blank / omitted = the next system SKU"},"item_name":{"type":"string","minLength":1,"maxLength":300},"item_type":{"type":"string","enum":["raw_material","component","semi_finished","finished_good","service","consumable"]},"unit_of_measure":{"type":"string","minLength":1,"maxLength":40},"description":{"type":"string","maxLength":4000},"barcode":{"type":"string","maxLength":100},"brand_id":{"type":"string","format":"uuid"},"is_stock_item":{"type":"boolean"},"is_purchasable":{"type":"boolean"},"is_sellable":{"type":"boolean"},"is_manufacturable":{"type":"boolean"},"selling_price":{"type":"number","nullable":true,"minimum":0,"maximum":10000000000,"description":"THB, VAT-inclusive; null = no price. Needs prices.sell"},"default_warehouse_id":{"type":"string","nullable":true,"format":"uuid"},"lead_time_days":{"type":"integer","nullable":true,"minimum":0,"maximum":3650},"minimum_stock":{"type":"number","minimum":0,"maximum":1000000000},"reorder_point":{"type":"number","minimum":0,"maximum":1000000000},"base_uom":{"type":"string","maxLength":40,"description":"Stock unit (default unit_of_measure). Fixed once stock has moved"},"purchase_uom":{"type":"string","nullable":true,"maxLength":40},"production_uom":{"type":"string","nullable":true,"maxLength":40},"uom_strict":{"type":"boolean"},"serial_tracking_enabled":{"type":"boolean"},"batch_tracking_enabled":{"type":"boolean"},"costing_method":{"type":"string","nullable":true,"enum":["avco","fifo",null],"description":"null = company default; fifo needs batch tracking"},"unit_weight_kg":{"type":"number","nullable":true,"minimum":0,"exclusiveMinimum":true,"maximum":1000000},"notes":{"type":"string","nullable":true,"maxLength":4000},"main_vendor":{"type":"object","nullable":true,"properties":{"company_id":{"type":"string","format":"uuid"},"vendor_part_number":{"type":"string","maxLength":100},"unit_price":{"type":"number","minimum":0,"maximum":1000000000000,"description":"Vendor price per purchase unit"},"currency":{"type":"string","minLength":3,"maxLength":3,"default":"THB"},"lead_time_days":{"type":"integer","minimum":0,"maximum":3650},"purchase_uom":{"type":"string","maxLength":40},"notes":{"type":"string","maxLength":500,"description":"Alternate vendors only"}},"required":["company_id"],"description":"Needs cost.view + supplier.view; null removes it"},"alt_vendors":{"type":"array","items":{"type":"object","properties":{"company_id":{"type":"string","format":"uuid"},"vendor_part_number":{"type":"string","maxLength":100},"unit_price":{"type":"number","minimum":0,"maximum":1000000000000,"description":"Vendor price per purchase unit"},"currency":{"type":"string","minLength":3,"maxLength":3,"default":"THB"},"lead_time_days":{"type":"integer","minimum":0,"maximum":3650},"purchase_uom":{"type":"string","maxLength":40},"notes":{"type":"string","maxLength":500,"description":"Alternate vendors only"}},"required":["company_id"]},"maxItems":5,"description":"Replaces the alternates. Needs cost.view + supplier.view"},"expected_updated_at":{"type":"string","format":"date-time","description":"updated_at as you last read it; a newer save → 409"},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}}}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProductSaved"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/stock":{"get":{"operationId":"stock.list","tags":["Inventory"],"summary":"Stock levels","description":"On-hand, reserved and available quantity per product per warehouse. Filter by product_id, warehouse_id or SKU/name (q). Costs only with cost.view.\n\n**Scopes:** `inventory.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":200,"default":50,"description":"Page size (1–200, default 50)"},"required":false,"description":"Page size (1–200, default 50)","name":"limit","in":"query"},{"schema":{"type":"string","maxLength":200,"description":"Opaque cursor from `next_cursor` of the previous page"},"required":false,"description":"Opaque cursor from `next_cursor` of the previous page","name":"cursor","in":"query"},{"schema":{"type":"string","format":"date-time","description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally."},"required":false,"description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally.","name":"updated_since","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Text search"},"required":false,"description":"Text search","name":"q","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"product_id","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"warehouse_id","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StockLevelList"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/warehouses":{"get":{"operationId":"warehouses.list","tags":["Inventory"],"summary":"List warehouses","description":"Warehouses and stock locations.\n\n**Scopes:** `warehouse.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":200,"default":50,"description":"Page size (1–200, default 50)"},"required":false,"description":"Page size (1–200, default 50)","name":"limit","in":"query"},{"schema":{"type":"string","maxLength":200,"description":"Opaque cursor from `next_cursor` of the previous page"},"required":false,"description":"Opaque cursor from `next_cursor` of the previous page","name":"cursor","in":"query"},{"schema":{"type":"string","format":"date-time","description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally."},"required":false,"description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally.","name":"updated_since","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Text search"},"required":false,"description":"Text search","name":"q","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WarehouseList"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"warehouses.create","tags":["Inventory"],"summary":"Create a warehouse","description":"Add a warehouse: owned (your own stock), subcontractor (needs supplier_company_id — one per supplier), customer (consignment; needs customer_company_id) or transit. The plan's warehouse limit counts owned warehouses.\n\n**Scopes:** `warehouse.edit`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"warehouse_code":{"type":"string","minLength":1,"maxLength":40},"warehouse_name":{"type":"string","minLength":1,"maxLength":200},"kind":{"type":"string","enum":["owned","subcontractor","customer","transit"],"default":"owned"},"supplier_company_id":{"type":"string","format":"uuid"},"customer_company_id":{"type":"string","format":"uuid"},"address":{"type":"string","maxLength":1000},"notes":{"type":"string","maxLength":4000},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["warehouse_code","warehouse_name"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Created"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/companies":{"get":{"operationId":"companies.list","tags":["Parties"],"summary":"List companies","description":"Customers and vendors (legal entities). Filter role=customer|vendor; search by code, name or tax ID.\n\n**Scopes:** `company.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":200,"default":50,"description":"Page size (1–200, default 50)"},"required":false,"description":"Page size (1–200, default 50)","name":"limit","in":"query"},{"schema":{"type":"string","maxLength":200,"description":"Opaque cursor from `next_cursor` of the previous page"},"required":false,"description":"Opaque cursor from `next_cursor` of the previous page","name":"cursor","in":"query"},{"schema":{"type":"string","format":"date-time","description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally."},"required":false,"description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally.","name":"updated_since","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Text search"},"required":false,"description":"Text search","name":"q","in":"query"},{"schema":{"type":"string","enum":["customer","vendor"]},"required":false,"name":"role","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CompanyList"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"companies.create","tags":["Parties"],"summary":"Create a customer or vendor","description":"Add a customer and/or vendor. Refuses a duplicate code, or a duplicate tax ID + branch.\n\n**Scopes:** `company.create`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"company_code":{"type":"string","minLength":1,"maxLength":40},"company_name":{"type":"string","minLength":1,"maxLength":300},"local_name":{"type":"string","maxLength":300},"is_customer":{"type":"boolean","default":true},"is_vendor":{"type":"boolean","default":false},"tax_id":{"type":"string","pattern":"^\\d{13}$","description":"13-digit Thai tax ID"},"branch_type":{"type":"string","enum":["head_office","branch"]},"branch_code":{"type":"string","pattern":"^\\d{5}$"},"email":{"type":"string","maxLength":200,"format":"email"},"phone":{"type":"string","maxLength":40},"address":{"type":"string","maxLength":1000},"country":{"type":"string","minLength":2,"maxLength":2,"default":"TH"},"currency":{"type":"string","minLength":3,"maxLength":3,"default":"THB"},"payment_terms":{"type":"string","maxLength":100},"notes":{"type":"string","maxLength":4000},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["company_code","company_name"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Created"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/companies/{id}":{"get":{"operationId":"companies.get","tags":["Parties"],"summary":"Get a company","description":"One customer/vendor by id, with the people who work there (contacts: name, job title, primary, mobile, email, LINE — the same fields list_contacts returns).\n\n**Scopes:** `company.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","description":"Record id (uuid)"},"required":true,"description":"Record id (uuid)","name":"id","in":"path"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CompanyDetail"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/contacts":{"get":{"operationId":"contacts.list","tags":["Parties"],"summary":"List contacts","description":"People at customers/vendors (name, mobile, email, LINE). company_id lists only the people who work at that company.\n\n**Scopes:** `company.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":200,"default":50,"description":"Page size (1–200, default 50)"},"required":false,"description":"Page size (1–200, default 50)","name":"limit","in":"query"},{"schema":{"type":"string","maxLength":200,"description":"Opaque cursor from `next_cursor` of the previous page"},"required":false,"description":"Opaque cursor from `next_cursor` of the previous page","name":"cursor","in":"query"},{"schema":{"type":"string","format":"date-time","description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally."},"required":false,"description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally.","name":"updated_since","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Text search"},"required":false,"description":"Text search","name":"q","in":"query"},{"schema":{"type":"string","format":"uuid","description":"Only contacts who work at this company"},"required":false,"description":"Only contacts who work at this company","name":"company_id","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContactList"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/purchase-requests":{"get":{"operationId":"purchase_requests.list","tags":["Procurement"],"summary":"List purchase requests","description":"Purchase requests (PR) with status. Filter by status; search by PR number or purpose.\n\n**Scopes:** `pr.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":200,"default":50,"description":"Page size (1–200, default 50)"},"required":false,"description":"Page size (1–200, default 50)","name":"limit","in":"query"},{"schema":{"type":"string","maxLength":200,"description":"Opaque cursor from `next_cursor` of the previous page"},"required":false,"description":"Opaque cursor from `next_cursor` of the previous page","name":"cursor","in":"query"},{"schema":{"type":"string","format":"date-time","description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally."},"required":false,"description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally.","name":"updated_since","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Text search"},"required":false,"description":"Text search","name":"q","in":"query"},{"schema":{"type":"string","maxLength":40},"required":false,"name":"status","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PurchaseRequestList"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"purchase_requests.create","tags":["Procurement"],"summary":"Create a PR draft","description":"Create a purchase request as a DRAFT. A person reviews and submits it in Tonbab — this never submits or approves. pr_type \"job\" needs job_control_id; \"stock\" may set destination_warehouse_id.\n\n**Scopes:** `pr.create`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"pr_type":{"type":"string","enum":["stock","job"],"default":"stock"},"job_control_id":{"type":"string","format":"uuid"},"destination_warehouse_id":{"type":"string","format":"uuid"},"required_date":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-12-01"},"priority":{"type":"string","enum":["low","normal","high","urgent"],"default":"normal"},"department":{"type":"string","maxLength":100},"purpose":{"type":"string","maxLength":1000},"notes":{"type":"string","maxLength":4000},"lines":{"type":"array","items":{"type":"object","properties":{"product_id":{"type":"string","format":"uuid","description":"Catalogue product; omit for a free-text item"},"item_name":{"type":"string","minLength":1,"maxLength":300},"description":{"type":"string","maxLength":2000},"quantity":{"type":"number","minimum":0,"exclusiveMinimum":true,"maximum":1000000000},"unit_of_measure":{"type":"string","maxLength":20},"estimated_unit_cost":{"type":"number","minimum":0,"maximum":1000000000000},"line_type":{"type":"string","enum":["goods","service"],"default":"goods"},"preferred_company_id":{"type":"string","format":"uuid","description":"Suggested vendor"},"warehouse_id":{"type":"string","format":"uuid"},"required_date":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-12-01"}},"required":["item_name","quantity"]},"minItems":1,"maxItems":200},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["lines"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Created"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/purchase-requests/{id}":{"get":{"operationId":"purchase_requests.get","tags":["Procurement"],"summary":"Get a purchase request","description":"One PR with its lines.\n\n**Scopes:** `pr.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","description":"Record id (uuid)"},"required":true,"description":"Record id (uuid)","name":"id","in":"path"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PurchaseRequest"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"purchase_requests.update","tags":["Procurement"],"summary":"Update a draft purchase request (แก้ไขใบขอซื้อฉบับร่าง)","description":"Change a purchase request (ใบขอซื้อ, PR) that is still a DRAFT, as the PR edit form does: only the fields you give change; `lines` replaces all lines (a service line stays a service line). The PR type is fixed; a job PR keeps a Job Control and a changed one must be active (and trace to a CRM deal for a customer job). Once submitted, a PR is changed in Tonbab (procurement mid-sourcing, re-approval) — this refuses. Pass expected_updated_at to refuse the change if someone else saved first. It never submits or approves.\n\n**Scopes:** `pr.edit`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","description":"Record id (uuid)"},"required":true,"description":"Record id (uuid)","name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"expected_updated_at":{"type":"string","format":"date-time","description":"updated_at as you last read it (get_purchase_request); a newer save → 409"},"job_control_id":{"type":"string","format":"uuid","description":"Job PRs only. A changed job (formerly Job Control) must be released (active)"},"destination_warehouse_id":{"type":"string","nullable":true,"format":"uuid","description":"Stock PRs only: default warehouse for the lines"},"required_date":{"type":"string","nullable":true,"format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-12-01"},"priority":{"type":"string","enum":["low","normal","high","urgent"]},"department":{"type":"string","nullable":true,"maxLength":100},"cost_center":{"type":"string","nullable":true,"maxLength":100},"purpose":{"type":"string","nullable":true,"maxLength":1000},"notes":{"type":"string","nullable":true,"maxLength":4000},"lines":{"type":"array","items":{"type":"object","properties":{"product_id":{"type":"string","format":"uuid","description":"Catalogue product; omit for a free-text item"},"item_name":{"type":"string","minLength":1,"maxLength":300},"description":{"type":"string","maxLength":2000},"quantity":{"type":"number","minimum":0,"exclusiveMinimum":true,"maximum":1000000000},"unit_of_measure":{"type":"string","maxLength":20},"estimated_unit_cost":{"type":"number","minimum":0,"maximum":1000000000000},"line_type":{"type":"string","enum":["goods","service"],"default":"goods"},"preferred_company_id":{"type":"string","format":"uuid","description":"Suggested vendor"},"warehouse_id":{"type":"string","format":"uuid"},"required_date":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-12-01"}},"required":["item_name","quantity"]},"minItems":1,"maxItems":200,"description":"The PR's lines after the change — replaces them all. Omit to keep the lines"},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}}}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Created"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/purchase-orders":{"get":{"operationId":"purchase_orders.list","tags":["Procurement"],"summary":"List purchase orders","description":"Purchase orders (PO): ใบสั่งซื้อ, or ใบสั่งจ้าง (service order) when every line is a service — doc_title says which. Filter by status or vendor (company_id); search by PO number.\n\n**Scopes:** `po.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":200,"default":50,"description":"Page size (1–200, default 50)"},"required":false,"description":"Page size (1–200, default 50)","name":"limit","in":"query"},{"schema":{"type":"string","maxLength":200,"description":"Opaque cursor from `next_cursor` of the previous page"},"required":false,"description":"Opaque cursor from `next_cursor` of the previous page","name":"cursor","in":"query"},{"schema":{"type":"string","format":"date-time","description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally."},"required":false,"description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally.","name":"updated_since","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Text search"},"required":false,"description":"Text search","name":"q","in":"query"},{"schema":{"type":"string","maxLength":40},"required":false,"name":"status","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"company_id","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PurchaseOrderList"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"purchase_orders.create","tags":["Procurement"],"summary":"Create a purchase order draft (ใบสั่งซื้อฉบับร่าง)","description":"Prepare a purchase order (ใบสั่งซื้อ, PO; titled ใบสั่งจ้าง / service order when every line is a service) to a vendor as a DRAFT, exactly as the PO form does: from an approved purchase request (source_pr_id + pr_line_id per line — those PR lines are claimed so they cannot be ordered twice) or from scratch. Goods lines need a product or a name; service lines (labour, transport) carry no product and never enter stock. VAT 7% is added on top with vat_type=vat_7. A customer job (งาน, formerly Job Control) must trace to a CRM deal. Typing unit_price needs cost.view (prices copied from the PR are carried as the form does). The PO gets its number now but stays a draft: a person reviews, issues and sends it in Tonbab. Domestic POs only (an import PO with a landed-cost card is made in Tonbab).\n\n**Scopes:** `po.create`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"company_id":{"type":"string","format":"uuid","description":"The vendor (a company in Tonbab)"},"source_pr_id":{"type":"string","format":"uuid","description":"Convert an approved purchase request: its lines are claimed for this PO (pr_line_id on each line)"},"job_control_id":{"type":"string","format":"uuid","description":"Charge to a job (งาน, formerly Job Control): a released one, or the source PR's own. Default: the source PR's"},"vat_type":{"type":"string","enum":["vat_7","non_vat"],"description":"vat_7 = 7% VAT on top; omit for none"},"currency":{"type":"string","enum":["THB","USD","EUR"],"default":"THB"},"payment_terms":{"type":"string","maxLength":200},"expected_delivery_date":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-12-01"},"remarks":{"type":"string","maxLength":4000},"lines":{"type":"array","items":{"type":"object","properties":{"line_type":{"type":"string","enum":["goods","service"],"description":"service = a service / labour line: no product, never enters stock (default goods, or the PR line's type)"},"pr_line_id":{"type":"string","format":"uuid","description":"An approved / awarded line of source_pr_id. Product, name, quantity, unit, warehouse and the sourced price are copied from it unless given here"},"product_id":{"type":"string","format":"uuid"},"item_name":{"type":"string","minLength":1,"maxLength":300,"description":"Default: the product's or PR line's name"},"description":{"type":"string","maxLength":2000},"quantity":{"type":"number","minimum":0,"exclusiveMinimum":true,"maximum":1000000000,"description":"Required unless pr_line_id gives it"},"unit":{"type":"string","maxLength":40,"description":"Default: the PR line's unit, else the product's purchase / stock unit. A strict product's unit must convert"},"unit_price":{"type":"number","minimum":0,"maximum":1000000000000,"description":"THB per unit, excluding VAT. Needs cost.view"},"warehouse_id":{"type":"string","format":"uuid","description":"Receiving warehouse (one of your internal warehouses)"},"required_date":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-12-01"}}},"minItems":1,"maxItems":200},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["company_id","lines"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Created"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/purchase-orders/{id}":{"get":{"operationId":"purchase_orders.get","tags":["Procurement"],"summary":"Get a purchase order","description":"One PO with its lines and received quantities, and doc_title: ใบสั่งจ้าง (service order, purchasing) when every line is a service, else ใบสั่งซื้อ (purchase order).\n\n**Scopes:** `po.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","description":"Record id (uuid)"},"required":true,"description":"Record id (uuid)","name":"id","in":"path"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PurchaseOrder"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/goods-receipts":{"get":{"operationId":"goods_receipts.list","tags":["Procurement"],"summary":"List goods receipts","description":"Goods receipts (GR). Filter by status or purchase_order_id.\n\n**Scopes:** `gr.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":200,"default":50,"description":"Page size (1–200, default 50)"},"required":false,"description":"Page size (1–200, default 50)","name":"limit","in":"query"},{"schema":{"type":"string","maxLength":200,"description":"Opaque cursor from `next_cursor` of the previous page"},"required":false,"description":"Opaque cursor from `next_cursor` of the previous page","name":"cursor","in":"query"},{"schema":{"type":"string","format":"date-time","description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally."},"required":false,"description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally.","name":"updated_since","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Text search"},"required":false,"description":"Text search","name":"q","in":"query"},{"schema":{"type":"string","maxLength":40},"required":false,"name":"status","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"purchase_order_id","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GoodsReceiptList"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"goods_receipts.create","tags":["Procurement"],"summary":"Create a goods receipt draft (ใบรับสินค้าฉบับร่าง)","description":"Record goods that arrived against a purchase order as a DRAFT goods receipt (ใบรับสินค้า, GR), exactly as the GR form does. The PO must be issued or partially received (not a subcontract PO — those are received by completing the Work Order). Each line names a PO line and the quantity received (at most what is still open; bonus pieces go in quantity_free), accepted (default all) and optionally its warehouse. Product, unit and cost come from the PO line. Stock does NOT move and the GR has no number yet: a person checks and POSTS it in Tonbab.\n\n**Scopes:** `gr.create`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"purchase_order_id":{"type":"string","format":"uuid"},"warehouse_id":{"type":"string","format":"uuid","description":"Receiving warehouse (one of your internal warehouses)"},"received_date":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-12-01","description":"Default: today (Bangkok)"},"notes":{"type":"string","maxLength":4000},"lines":{"type":"array","items":{"type":"object","properties":{"po_line_id":{"type":"string","format":"uuid","description":"A line of the purchase order"},"quantity_received":{"type":"number","minimum":0,"exclusiveMinimum":true,"maximum":1000000000,"description":"In the PO line's unit; at most what the line still has open"},"quantity_accepted":{"type":"number","minimum":0,"maximum":1000000000,"description":"Default: all received. The rest is recorded as rejected"},"quantity_free":{"type":"number","minimum":0,"maximum":1000000000,"description":"Bonus pieces beyond the paid quantity (enter stock at no extra cost)"},"warehouse_id":{"type":"string","format":"uuid","description":"Default: the PO line's warehouse, else the receipt's"}},"required":["po_line_id","quantity_received"]},"minItems":1,"maxItems":500},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["purchase_order_id","warehouse_id","lines"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Created"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/goods-receipts/{id}":{"get":{"operationId":"goods_receipts.get","tags":["Procurement"],"summary":"Get a goods receipt","description":"One GR with its lines.\n\n**Scopes:** `gr.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","description":"Record id (uuid)"},"required":true,"description":"Record id (uuid)","name":"id","in":"path"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GoodsReceipt"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/delivery-notes":{"get":{"operationId":"delivery_notes.list","tags":["Sales"],"summary":"List delivery notes","description":"Delivery notes (DN) to customers. Filter by status or customer company_id.\n\n**Scopes:** `dn.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":200,"default":50,"description":"Page size (1–200, default 50)"},"required":false,"description":"Page size (1–200, default 50)","name":"limit","in":"query"},{"schema":{"type":"string","maxLength":200,"description":"Opaque cursor from `next_cursor` of the previous page"},"required":false,"description":"Opaque cursor from `next_cursor` of the previous page","name":"cursor","in":"query"},{"schema":{"type":"string","format":"date-time","description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally."},"required":false,"description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally.","name":"updated_since","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Text search"},"required":false,"description":"Text search","name":"q","in":"query"},{"schema":{"type":"string","maxLength":40},"required":false,"name":"status","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"company_id","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeliveryNoteList"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"delivery_notes.create","tags":["Sales"],"summary":"Create a delivery note draft","description":"Prepare a delivery note as a DRAFT (temporary DN-DRAFT label; the DN number comes when packing starts or it is issued): customer, optional Job Control (active or completed), the customer's PO number, destination, receiver and lines (product, qty in its stock unit unless you give a unit that converts, optional source warehouse). It is never issued here and no stock moves.\n\n**Scopes:** `dn.create`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"company_id":{"type":"string","format":"uuid","description":"The customer"},"customer":{"type":"string","maxLength":300,"description":"Customer name as printed (default: the company name)"},"job_control_id":{"type":"string","format":"uuid","description":"A released (active) or technically complete (completed) job — formerly Job Control"},"customer_po_number":{"type":"string","maxLength":80},"delivery_date":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-12-01"},"destination":{"type":"string","maxLength":1000},"destination_warehouse_id":{"type":"string","format":"uuid","description":"A consignment (customer) warehouse of this customer"},"receiver_name":{"type":"string","maxLength":200},"receiver_phone":{"type":"string","maxLength":40},"remarks":{"type":"string","maxLength":4000},"lines":{"type":"array","items":{"type":"object","properties":{"product_id":{"type":"string","format":"uuid"},"quantity":{"type":"number","minimum":0,"exclusiveMinimum":true,"maximum":1000000000},"unit":{"type":"string","maxLength":40,"description":"Default: the product's stock unit. A strict product's unit must convert"},"warehouse_id":{"type":"string","format":"uuid","description":"Source warehouse (pre-fills the Issue dialog)"}},"required":["product_id","quantity"]},"minItems":1,"maxItems":300},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["lines"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Created"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/delivery-notes/{id}":{"get":{"operationId":"delivery_notes.get","tags":["Sales"],"summary":"Get a delivery note","description":"One DN with its lines (shipped and back-ordered quantities).\n\n**Scopes:** `dn.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","description":"Record id (uuid)"},"required":true,"description":"Record id (uuid)","name":"id","in":"path"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeliveryNote"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"delivery_notes.update","tags":["Sales"],"summary":"Update a delivery note draft","description":"Change a DRAFT delivery note: only the header fields you give change; `lines`, when given, replace all lines. Refused once the DN is past draft. expected_updated_at refuses the change if someone saved first.\n\n**Scopes:** `dn.edit`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","description":"Record id (uuid)"},"required":true,"description":"Record id (uuid)","name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"expected_updated_at":{"type":"string","format":"date-time"},"company_id":{"type":"string","format":"uuid","description":"The customer"},"customer":{"type":"string","maxLength":300,"description":"Customer name as printed (default: the company name)"},"job_control_id":{"type":"string","format":"uuid","description":"A released (active) or technically complete (completed) job — formerly Job Control"},"customer_po_number":{"type":"string","maxLength":80},"delivery_date":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-12-01"},"destination":{"type":"string","maxLength":1000},"destination_warehouse_id":{"type":"string","format":"uuid","description":"A consignment (customer) warehouse of this customer"},"receiver_name":{"type":"string","maxLength":200},"receiver_phone":{"type":"string","maxLength":40},"remarks":{"type":"string","maxLength":4000},"lines":{"type":"array","items":{"type":"object","properties":{"product_id":{"type":"string","format":"uuid"},"quantity":{"type":"number","minimum":0,"exclusiveMinimum":true,"maximum":1000000000},"unit":{"type":"string","maxLength":40,"description":"Default: the product's stock unit. A strict product's unit must convert"},"warehouse_id":{"type":"string","format":"uuid","description":"Source warehouse (pre-fills the Issue dialog)"}},"required":["product_id","quantity"]},"minItems":1,"maxItems":300},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}}}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Created"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/orders":{"get":{"operationId":"orders.list","tags":["Sales"],"summary":"List sales orders","description":"Commerce orders from POS, chat, marketplaces and manual entry. Filter by status, payment_status or source.\n\n**Scopes:** `commerce.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":200,"default":50,"description":"Page size (1–200, default 50)"},"required":false,"description":"Page size (1–200, default 50)","name":"limit","in":"query"},{"schema":{"type":"string","maxLength":200,"description":"Opaque cursor from `next_cursor` of the previous page"},"required":false,"description":"Opaque cursor from `next_cursor` of the previous page","name":"cursor","in":"query"},{"schema":{"type":"string","format":"date-time","description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally."},"required":false,"description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally.","name":"updated_since","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Text search"},"required":false,"description":"Text search","name":"q","in":"query"},{"schema":{"type":"string","maxLength":40},"required":false,"name":"status","in":"query"},{"schema":{"type":"string","maxLength":40},"required":false,"name":"payment_status","in":"query"},{"schema":{"type":"string","maxLength":40},"required":false,"name":"source","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrderList"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/orders/{id}":{"get":{"operationId":"orders.get","tags":["Sales"],"summary":"Get a sales order","description":"One order with its lines.\n\n**Scopes:** `commerce.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","description":"Record id (uuid)"},"required":true,"description":"Record id (uuid)","name":"id","in":"path"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Order"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/crm/deals":{"get":{"operationId":"deals.list","tags":["CRM"],"summary":"List CRM deals","description":"Sales pipeline deals with stage. Filter by status (open/won/lost), owner_id or company_id.\n\n**Scopes:** `crm.deal.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":200,"default":50,"description":"Page size (1–200, default 50)"},"required":false,"description":"Page size (1–200, default 50)","name":"limit","in":"query"},{"schema":{"type":"string","maxLength":200,"description":"Opaque cursor from `next_cursor` of the previous page"},"required":false,"description":"Opaque cursor from `next_cursor` of the previous page","name":"cursor","in":"query"},{"schema":{"type":"string","format":"date-time","description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally."},"required":false,"description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally.","name":"updated_since","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Text search"},"required":false,"description":"Text search","name":"q","in":"query"},{"schema":{"type":"string","maxLength":20},"required":false,"name":"status","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"owner_id","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"company_id","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DealList"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"deals.create","tags":["CRM"],"summary":"Create a CRM deal","description":"Open a deal in a pipeline (default pipeline + its first open stage when omitted). Owner = the connected user / key creator unless owner_id names someone in your CRM scope. The company's CRM rules apply exactly as in the app: with \"require next step\" on, next_step + next_step_date are required (a planned activity is created); with \"minimal deal fields\" on, title may be omitted (generated).\n\n**Scopes:** `crm.deal.edit`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"company_id":{"type":"string","format":"uuid"},"title":{"type":"string","minLength":1,"maxLength":200,"description":"Required unless the company has \"minimal deal fields\" on"},"pipeline_id":{"type":"string","format":"uuid"},"stage_id":{"type":"string","format":"uuid","description":"An OPEN stage of the pipeline (default: its first)"},"contact_id":{"type":"string","format":"uuid"},"owner_id":{"type":"string","format":"uuid","description":"Assign to someone in your CRM scope (crm.plan.manage: anyone); otherwise you"},"value":{"type":"number","minimum":0,"maximum":1000000000000,"description":"Deal value in the deal currency (default THB). Totals and reports use baht."},"currency":{"type":"string","pattern":"^[A-Za-z]{3}$","description":"ISO currency of the deal (default THB). Not THB: send fx_rate."},"fx_rate":{"type":"number","minimum":0,"exclusiveMinimum":true,"maximum":1000000,"description":"Baht per 1 unit of currency (required when currency is not THB)."},"expected_close":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-12-01"},"source_channel":{"type":"string","enum":["referral","repeat","line","facebook","website","phone","walkin","tender","event","other"]},"note":{"type":"string","maxLength":4000},"next_step":{"type":"string","minLength":1,"maxLength":200},"next_step_date":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-12-01"},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["company_id"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Created"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/crm/deals/{id}":{"get":{"operationId":"deals.get","tags":["CRM"],"summary":"Get a CRM deal","description":"One deal.\n\n**Scopes:** `crm.deal.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","description":"Record id (uuid)"},"required":true,"description":"Record id (uuid)","name":"id","in":"path"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Deal"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/crm/activities":{"get":{"operationId":"activities.list","tags":["CRM"],"summary":"List CRM activities","description":"Calls, visits, meetings and tasks. Filter by company_id, deal_id, assigned_to or status.\n\n**Scopes:** `crm.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":200,"default":50,"description":"Page size (1–200, default 50)"},"required":false,"description":"Page size (1–200, default 50)","name":"limit","in":"query"},{"schema":{"type":"string","maxLength":200,"description":"Opaque cursor from `next_cursor` of the previous page"},"required":false,"description":"Opaque cursor from `next_cursor` of the previous page","name":"cursor","in":"query"},{"schema":{"type":"string","format":"date-time","description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally."},"required":false,"description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally.","name":"updated_since","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Text search"},"required":false,"description":"Text search","name":"q","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"company_id","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"deal_id","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"assigned_to","in":"query"},{"schema":{"type":"string","maxLength":20},"required":false,"name":"status","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CrmActivityList"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"activities.create","tags":["CRM"],"summary":"Log or plan a CRM activity","description":"Log a call/visit/LINE/email that happened (status done, occurred_at) or plan one (status planned, due_date). Assigned to the connected user / key creator.\n\n**Scopes:** `crm.plan.self`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"company_id":{"type":"string","format":"uuid"},"contact_id":{"type":"string","format":"uuid"},"deal_id":{"type":"string","format":"uuid"},"channel":{"type":"string","enum":["call","visit","line","email","meeting","other"],"default":"call"},"title":{"type":"string","maxLength":300},"note":{"type":"string","maxLength":4000},"status":{"type":"string","enum":["planned","done"],"default":"done"},"due_date":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-12-01"},"occurred_at":{"type":"string","format":"date-time"},"next_step":{"type":"string","maxLength":1000},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["company_id"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Created"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/work-orders":{"get":{"operationId":"work_orders.list","tags":["Manufacturing"],"summary":"List production orders (work orders)","description":"Production orders (ใบสั่งผลิต; formerly \"work orders\") with planned vs produced quantity.\n\n**Scopes:** `wo.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":200,"default":50,"description":"Page size (1–200, default 50)"},"required":false,"description":"Page size (1–200, default 50)","name":"limit","in":"query"},{"schema":{"type":"string","maxLength":200,"description":"Opaque cursor from `next_cursor` of the previous page"},"required":false,"description":"Opaque cursor from `next_cursor` of the previous page","name":"cursor","in":"query"},{"schema":{"type":"string","format":"date-time","description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally."},"required":false,"description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally.","name":"updated_since","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Text search"},"required":false,"description":"Text search","name":"q","in":"query"},{"schema":{"type":"string","maxLength":40},"required":false,"name":"status","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WorkOrderList"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/jobs":{"get":{"operationId":"job_controls.list","tags":["Manufacturing"],"summary":"List jobs","description":"Jobs (งาน; formerly \"Job Control\"): projects, internal orders, maintenance and production runs that demand, purchasing and cost roll up to. status_label gives the SAP-style label (Created / Released / Technically complete / Closed) next to the stored status.\n\n**Scopes:** `jc.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":200,"default":50,"description":"Page size (1–200, default 50)"},"required":false,"description":"Page size (1–200, default 50)","name":"limit","in":"query"},{"schema":{"type":"string","maxLength":200,"description":"Opaque cursor from `next_cursor` of the previous page"},"required":false,"description":"Opaque cursor from `next_cursor` of the previous page","name":"cursor","in":"query"},{"schema":{"type":"string","format":"date-time","description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally."},"required":false,"description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally.","name":"updated_since","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Text search"},"required":false,"description":"Text search","name":"q","in":"query"},{"schema":{"type":"string","maxLength":40},"required":false,"name":"status","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/JobControlList"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/employees":{"get":{"operationId":"employees.list","tags":["People"],"summary":"Employee directory","description":"Employee directory (Thai / English names and nicknames, title, department, work email / phone, and the linked login user_id). Never includes ID numbers, bank, salary or personal data.\n\n**Scopes:** `people.employee.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":200,"default":50,"description":"Page size (1–200, default 50)"},"required":false,"description":"Page size (1–200, default 50)","name":"limit","in":"query"},{"schema":{"type":"string","maxLength":200,"description":"Opaque cursor from `next_cursor` of the previous page"},"required":false,"description":"Opaque cursor from `next_cursor` of the previous page","name":"cursor","in":"query"},{"schema":{"type":"string","format":"date-time","description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally."},"required":false,"description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally.","name":"updated_since","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Text search"},"required":false,"description":"Text search","name":"q","in":"query"},{"schema":{"type":"string","maxLength":20},"required":false,"name":"status","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EmployeeList"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/docs/pages":{"get":{"operationId":"docs.search","tags":["Docs"],"summary":"Search company docs","description":"Search pages in company-wide Docs spaces (never private spaces or restricted pages).\n\n**Scopes:** `docs.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","maxLength":200},"required":false,"name":"q","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":100,"default":20},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DocSearch"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"docs.pages.create","tags":["Docs"],"summary":"Create a Docs page","description":"Write a new page in Docs (คู่มือ / SOP / บันทึก), at the top of a space (space_id) or under a page (parent_id). The body is simple Markdown (or the editor's JSON). You can only write where you can edit in the app: your space membership, private spaces and page sharing decide, exactly as in Docs. The plan's page limit applies. Mentioned people are linked but not notified.\n\n**Scopes:** `docs.edit`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"space_id":{"type":"string","format":"uuid","description":"The space (needed without parent_id)"},"parent_id":{"type":"string","format":"uuid","description":"Put the page under this page"},"title":{"type":"string","maxLength":300,"default":""},"icon":{"type":"string","maxLength":16,"description":"An emoji"},"markdown":{"type":"string","maxLength":500000,"description":"Page body as simple Markdown (headings, lists, quotes, code blocks, **bold**). Thai and English text as written."},"content":{"type":"object","additionalProperties":{"nullable":true},"description":"Advanced: the Docs editor's document JSON ({ type: 'doc', content: [...] }). Give markdown OR content."},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}}}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DocPageSaved"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/docs/pages/{id}":{"get":{"operationId":"docs.get","tags":["Docs"],"summary":"Read a doc page","description":"Full text of one Docs page and its sub-pages.\n\n**Scopes:** `docs.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","description":"Record id (uuid)"},"required":true,"description":"Record id (uuid)","name":"id","in":"path"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DocPage"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"docs.pages.update","tags":["Docs"],"summary":"Update a Docs page","description":"Change a Docs page: title, icon and/or the body (Markdown or the editor's JSON). mode \"replace\" (default) replaces the body; \"append\" adds the Markdown at the end. Only what you give changes. Same rules as editing in Docs: edit access on the page, a locked page only with full access, never a page in the trash. Pass expected_version (from a previous save) to refuse the change if someone else saved first. The page history keeps the previous version.\n\n**Scopes:** `docs.edit`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","description":"Record id (uuid)"},"required":true,"description":"Record id (uuid)","name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"title":{"type":"string","maxLength":300},"icon":{"type":"string","nullable":true,"maxLength":16},"markdown":{"type":"string","maxLength":500000,"description":"Page body as simple Markdown (headings, lists, quotes, code blocks, **bold**). Thai and English text as written."},"content":{"type":"object","additionalProperties":{"nullable":true},"description":"Advanced: the Docs editor's document JSON ({ type: 'doc', content: [...] }). Give markdown OR content."},"mode":{"type":"string","enum":["replace","append"],"default":"replace"},"expected_version":{"type":"integer","minimum":0},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}}}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DocPageSaved"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/docs/databases/{id}/rows":{"get":{"operationId":"docs.rows","tags":["Docs"],"summary":"Docs database rows","description":"Rows of a Docs database (title + column values).\n\n**Scopes:** `docs.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","description":"Record id (uuid)"},"required":true,"description":"Record id (uuid)","name":"id","in":"path"},{"schema":{"type":"integer","minimum":1,"maximum":500,"default":200},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DocRows"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"docs.rows.create","tags":["Docs"],"summary":"Add a row to a Docs database","description":"Add one row to a Docs database (ตาราง): a title and column values keyed by column id or column name (see list_doc_database_rows). Values must fit the column — text, number, date (YYYY-MM-DD), checkbox, url, email, phone, select / multi-select (an existing choice), person (member user ids), relation (row ids of the linked database you can read). A value that does not fit, or an unknown column, is refused (nothing is saved). Record links, files and computed columns are not set here. Same rule as \"+ New\" in Docs: edit access, a locked database only with full access. The plan's page limit applies.\n\n**Scopes:** `docs.edit`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","description":"Record id (uuid)"},"required":true,"description":"Record id (uuid)","name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"title":{"type":"string","maxLength":300,"default":""},"props":{"type":"object","additionalProperties":{"nullable":true},"default":{},"description":"{ \"<column id or name>\": value }"},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}}}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DocRowAdded"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/events":{"get":{"operationId":"events.list","tags":["Events"],"summary":"List events","description":"Recent business events (same as webhooks, 30-day history) you are allowed to see — poll this instead of, or as a backstop to, webhooks. Filter by type (e.g. po.status_changed or po.*).","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":200,"default":50,"description":"Page size (1–200, default 50)"},"required":false,"description":"Page size (1–200, default 50)","name":"limit","in":"query"},{"schema":{"type":"string","maxLength":200,"description":"Opaque cursor from `next_cursor` of the previous page"},"required":false,"description":"Opaque cursor from `next_cursor` of the previous page","name":"cursor","in":"query"},{"schema":{"type":"string","format":"date-time","description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally."},"required":false,"description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally.","name":"updated_since","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Text search"},"required":false,"description":"Text search","name":"q","in":"query"},{"schema":{"type":"string","maxLength":60},"required":false,"name":"type","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EventList"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/me/companies":{"get":{"operationId":"me.companies","tags":["Account"],"summary":"My companies","description":"Companies this connection covers, with your role, enabled modules and effective scopes IN EACH company (permissions are per company). Pass a slug as `company` to any tool; summary tools also take `company: \"all\"`.","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MyCompanies"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/accounting/sales-summary":{"get":{"operationId":"accounting.sales_summary","tags":["Accounting"],"summary":"Sales summary","description":"Sales by customer and/or month from ISSUED invoices and debit notes minus credit notes (THB, ex-VAT net + VAT + gross). Default: this month to date (Bangkok). Answers \"สรุปยอดขายเดือนนี้ตามลูกค้า\". POS/marketplace orders that never became an invoice are not included — use list_orders for those.\n\n**Scopes:** `accounting.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-11-01"},"required":false,"name":"from","in":"query"},{"schema":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-11-01"},"required":false,"name":"to","in":"query"},{"schema":{"type":"string","enum":["customer","month","customer_month"],"default":"customer"},"required":false,"name":"group_by","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":500,"default":50,"description":"Rows returned (largest first)"},"required":false,"description":"Rows returned (largest first)","name":"top","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SalesSummary"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/accounting/ar-aging":{"get":{"operationId":"accounting.ar_aging","tags":["Accounting"],"summary":"Receivables aging","description":"Who owes the company money and how late (current, 1–30, 31–60, 61–90, 90+ days), per customer — the same figures as Accounting → Ageing.\n\n**Scopes:** `accounting.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-11-01"},"required":false,"name":"as_of","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":500,"default":50},"required":false,"name":"top","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ArAging"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/accounting/ap-aging":{"get":{"operationId":"accounting.ap_aging","tags":["Accounting"],"summary":"Payables aging","description":"What the company owes vendors and how late, per vendor (bills minus vendor credits).\n\n**Scopes:** `accounting.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-11-01"},"required":false,"name":"as_of","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":500,"default":50},"required":false,"name":"top","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApAging"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/accounting/profit-and-loss":{"get":{"operationId":"accounting.profit_and_loss","tags":["Accounting"],"summary":"Profit and loss","description":"Revenue, expenses and net profit from POSTED journal entries for a period (default: this month to date). Year-close entries are excluded, like the app.\n\n**Scopes:** `accounting.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-11-01"},"required":false,"name":"from","in":"query"},{"schema":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-11-01"},"required":false,"name":"to","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProfitAndLoss"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/accounting/trial-balance":{"get":{"operationId":"accounting.trial_balance","tags":["Accounting"],"summary":"Trial balance","description":"Opening, period debit/credit and closing balance per account (posted entries). Default period: this month to date.\n\n**Scopes:** `accounting.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-11-01"},"required":false,"name":"from","in":"query"},{"schema":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-11-01"},"required":false,"name":"to","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TrialBalance"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/accounting/invoices":{"get":{"operationId":"accounting.invoices.list","tags":["Accounting"],"summary":"List invoices","description":"Sales invoices, debit notes and credit notes with balance and days overdue. overdue=true lists unpaid issued invoices past due.\n\n**Scopes:** `accounting.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":200,"default":50,"description":"Page size (1–200, default 50)"},"required":false,"description":"Page size (1–200, default 50)","name":"limit","in":"query"},{"schema":{"type":"string","maxLength":200,"description":"Opaque cursor from `next_cursor` of the previous page"},"required":false,"description":"Opaque cursor from `next_cursor` of the previous page","name":"cursor","in":"query"},{"schema":{"type":"string","format":"date-time","description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally."},"required":false,"description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally.","name":"updated_since","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Text search"},"required":false,"description":"Text search","name":"q","in":"query"},{"schema":{"type":"string","enum":["invoice","debit_note","credit_note"],"description":"Document type (default: all of invoice, debit_note, credit_note)"},"required":false,"description":"Document type (default: all of invoice, debit_note, credit_note)","name":"type","in":"query"},{"schema":{"type":"string","maxLength":20,"description":"draft · issued · void · accepted · rejected"},"required":false,"description":"draft · issued · void · accepted · rejected","name":"status","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"company_id","in":"query"},{"schema":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-11-01","description":"Document date on/after"},"required":false,"description":"Document date on/after","name":"from","in":"query"},{"schema":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-11-01","description":"Document date on/before"},"required":false,"description":"Document date on/before","name":"to","in":"query"},{"schema":{"type":"string","enum":["true"],"description":"Only issued documents past their due date with money still owed"},"required":false,"description":"Only issued documents past their due date with money still owed","name":"overdue","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InvoiceList"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"accounting.invoices.create","tags":["Accounting"],"summary":"Create a sales invoice draft","description":"Start a sales invoice / tax invoice (ใบแจ้งหนี้ / ใบกำกับภาษี) as a DRAFT for a customer (company_id; name, tax ID, branch and address come from the company record). VAT 7% is on by default when the company is VAT-registered; wht_rate sets withholding tax (หัก ณ ที่จ่าย) the customer will deduct. Needs accounting.post (the Accounting form's permission) and prices.sell (it carries selling prices). Never issued: no number is given, nothing is posted to the ledger — a person reviews and issues it in Tonbab. A date in a closed year or locked period is refused.\n\n**Scopes:** `accounting.post`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"company_id":{"type":"string","format":"uuid"},"doc_date":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-12-01","description":"Default: today (Bangkok)"},"due_date":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-12-01"},"credit_days":{"type":"integer","minimum":0,"maximum":365},"is_vat":{"type":"boolean","description":"Default: true when the company is VAT-registered (ignored when it is not)"},"price_includes_vat":{"type":"boolean","default":false},"vat_rate":{"type":"number","minimum":0,"maximum":30,"default":7},"wht_rate":{"type":"number","minimum":0,"maximum":15,"default":0,"description":"Withholding tax % (หัก ณ ที่จ่าย), e.g. 3 for services"},"contact_name":{"type":"string","maxLength":200},"notes":{"type":"string","maxLength":2000,"description":"Printed on the document"},"internal_note":{"type":"string","maxLength":2000,"description":"For the team, never printed"},"lines":{"type":"array","items":{"type":"object","properties":{"description":{"type":"string","minLength":1,"maxLength":1000,"description":"Line text. Default: the product's name (with product_id)"},"product_id":{"type":"string","format":"uuid"},"qty":{"type":"number","minimum":0,"exclusiveMinimum":true,"maximum":1000000000,"default":1},"unit":{"type":"string","maxLength":20},"unit_price":{"type":"number","minimum":0,"maximum":1000000000000,"description":"THB per unit (VAT-exclusive unless price_includes_vat)"},"discount":{"anyOf":[{"type":"number","minimum":0,"maximum":1000000000000},{"type":"string","pattern":"^\\d{1,12}(\\.\\d{1,2})?%?$"}],"description":"Line discount: an amount (100) or a percentage (\"10%\")"},"vat_code":{"type":"string","enum":["vat","zero","exempt","none"],"description":"Default vat (7%) on a VAT document; none otherwise"},"account_code":{"type":"string","maxLength":20,"description":"Revenue (invoice) / expense or asset (bill) account code. Default: the form default (sales of services/goods; general expense / inventory)"}},"required":["unit_price"]},"minItems":1,"maxItems":200},"title":{"type":"string","maxLength":300,"description":"The job / subject on the invoice"},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["company_id","lines"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccountingDraftCreated"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/accounting/bills":{"get":{"operationId":"accounting.bills.list","tags":["Accounting"],"summary":"List supplier invoices (bills)","description":"Supplier invoices (ใบตั้งหนี้; formerly \"bills\" / expenses) and vendor credits with balance and days overdue.\n\n**Scopes:** `accounting.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":200,"default":50,"description":"Page size (1–200, default 50)"},"required":false,"description":"Page size (1–200, default 50)","name":"limit","in":"query"},{"schema":{"type":"string","maxLength":200,"description":"Opaque cursor from `next_cursor` of the previous page"},"required":false,"description":"Opaque cursor from `next_cursor` of the previous page","name":"cursor","in":"query"},{"schema":{"type":"string","format":"date-time","description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally."},"required":false,"description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally.","name":"updated_since","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Text search"},"required":false,"description":"Text search","name":"q","in":"query"},{"schema":{"type":"string","enum":["bill","bill_credit"],"description":"Document type (default: all of bill, bill_credit)"},"required":false,"description":"Document type (default: all of bill, bill_credit)","name":"type","in":"query"},{"schema":{"type":"string","maxLength":20,"description":"draft · issued · void · accepted · rejected"},"required":false,"description":"draft · issued · void · accepted · rejected","name":"status","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"company_id","in":"query"},{"schema":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-11-01","description":"Document date on/after"},"required":false,"description":"Document date on/after","name":"from","in":"query"},{"schema":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-11-01","description":"Document date on/before"},"required":false,"description":"Document date on/before","name":"to","in":"query"},{"schema":{"type":"string","enum":["true"],"description":"Only issued documents past their due date with money still owed"},"required":false,"description":"Only issued documents past their due date with money still owed","name":"overdue","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BillList"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"accounting.bills.create","tags":["Accounting"],"summary":"Create a supplier invoice draft (bill)","description":"Record a supplier invoice (ใบตั้งหนี้; formerly \"vendor bill\" / expense — ค่าใช้จ่าย, ใบกำกับภาษีซื้อ) as a DRAFT for a supplier (company_id). vendor_invoice_no is the supplier's tax-invoice number (required; the same number from the same supplier is refused — ป้องกันใบกำกับภาษีซ้ำ). Input VAT is claimed in the month of vendor_invoice_date by default (ม.82/3). Each line posts to account_code (an expense or asset account; default: general expense, or inventory for a stock item). Needs accounting.post. Never issued or paid: a person reviews, issues and pays it in Tonbab. A date in a closed year or locked period is refused.\n\n**Scopes:** `accounting.post`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"company_id":{"type":"string","format":"uuid"},"doc_date":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-12-01","description":"Default: today (Bangkok)"},"due_date":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-12-01"},"credit_days":{"type":"integer","minimum":0,"maximum":365},"is_vat":{"type":"boolean","description":"Default: true when the company is VAT-registered (ignored when it is not)"},"price_includes_vat":{"type":"boolean","default":false},"vat_rate":{"type":"number","minimum":0,"maximum":30,"default":7},"wht_rate":{"type":"number","minimum":0,"maximum":15,"default":0,"description":"Withholding tax % (หัก ณ ที่จ่าย), e.g. 3 for services"},"contact_name":{"type":"string","maxLength":200},"notes":{"type":"string","maxLength":2000,"description":"Printed on the document"},"internal_note":{"type":"string","maxLength":2000,"description":"For the team, never printed"},"vendor_invoice_no":{"type":"string","minLength":1,"maxLength":60},"vendor_invoice_date":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-12-01","description":"The supplier's tax-invoice date (default: doc_date)"},"vat_period":{"type":"string","pattern":"^\\d{4}-\\d{2}$","description":"Input-VAT claim month YYYY-MM (default: the vendor invoice month)"},"lines":{"type":"array","items":{"type":"object","properties":{"description":{"type":"string","minLength":1,"maxLength":1000,"description":"Line text. Default: the product's name (with product_id)"},"product_id":{"type":"string","format":"uuid"},"qty":{"type":"number","minimum":0,"exclusiveMinimum":true,"maximum":1000000000,"default":1},"unit":{"type":"string","maxLength":20},"unit_price":{"type":"number","minimum":0,"maximum":1000000000000,"description":"THB per unit (VAT-exclusive unless price_includes_vat)"},"discount":{"anyOf":[{"type":"number","minimum":0,"maximum":1000000000000},{"type":"string","pattern":"^\\d{1,12}(\\.\\d{1,2})?%?$"}],"description":"Line discount: an amount (100) or a percentage (\"10%\")"},"vat_code":{"type":"string","enum":["vat","zero","exempt","none"],"description":"Default vat (7%) on a VAT document; none otherwise"},"account_code":{"type":"string","maxLength":20,"description":"Revenue (invoice) / expense or asset (bill) account code. Default: the form default (sales of services/goods; general expense / inventory)"}},"required":["unit_price"]},"minItems":1,"maxItems":200},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["company_id","vendor_invoice_no","lines"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccountingDraftCreated"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/accounting/quotations":{"get":{"operationId":"accounting.quotations.list","tags":["Accounting"],"summary":"List quotations","description":"Quotations. accounting.view sees every quotation; a salesperson with accounting.quote_own (no accounting role) sees their own and their team's (people below them in the sales reporting line) — the same rule as the app.","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":200,"default":50,"description":"Page size (1–200, default 50)"},"required":false,"description":"Page size (1–200, default 50)","name":"limit","in":"query"},{"schema":{"type":"string","maxLength":200,"description":"Opaque cursor from `next_cursor` of the previous page"},"required":false,"description":"Opaque cursor from `next_cursor` of the previous page","name":"cursor","in":"query"},{"schema":{"type":"string","format":"date-time","description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally."},"required":false,"description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally.","name":"updated_since","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Text search"},"required":false,"description":"Text search","name":"q","in":"query"},{"schema":{"type":"string","enum":["quotation"],"description":"Document type (default: all of quotation)"},"required":false,"description":"Document type (default: all of quotation)","name":"type","in":"query"},{"schema":{"type":"string","maxLength":20,"description":"draft · issued · void · accepted · rejected"},"required":false,"description":"draft · issued · void · accepted · rejected","name":"status","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"company_id","in":"query"},{"schema":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-11-01","description":"Document date on/after"},"required":false,"description":"Document date on/after","name":"from","in":"query"},{"schema":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-11-01","description":"Document date on/before"},"required":false,"description":"Document date on/before","name":"to","in":"query"},{"schema":{"type":"string","enum":["true"],"description":"Only issued documents past their due date with money still owed"},"required":false,"description":"Only issued documents past their due date with money still owed","name":"overdue","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/QuotationList"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"accounting.quotations.create","tags":["Accounting"],"summary":"Create a quotation draft","description":"Start a quotation as a DRAFT, for a CRM deal (crm_deal_id: the deal's customer, lines, discounts and contact are filled in, and the draft is linked to the deal — needs crm.deal.view and the deal in your CRM scope) or for a customer (company_id). `lines` replace the deal's lines. You are the salesperson. A salesperson with accounting.quote_own makes their own quotation, exactly as in the app. Prices need prices.sell: without it the lines are saved with no price. It is never issued or sent for approval — a person reviews and issues it in Tonbab, which gives the number (drafts have none).\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"crm_deal_id":{"type":"string","format":"uuid"},"company_id":{"type":"string","format":"uuid","description":"The customer, when there is no deal (with a deal it must be the deal's customer)"},"lines":{"type":"array","items":{"type":"object","properties":{"description":{"type":"string","minLength":1,"maxLength":1000,"description":"What is sold. Default: the product's name (with product_id)"},"product_id":{"type":"string","format":"uuid"},"qty":{"type":"number","minimum":0,"exclusiveMinimum":true,"maximum":1000000000,"default":1},"unit":{"type":"string","maxLength":20},"unit_price":{"type":"number","minimum":0,"maximum":1000000000000,"description":"THB per unit. Needs prices.sell — without it the line is saved without a price for Accounting to fill in"}}},"minItems":1,"maxItems":200,"description":"Required without a deal"},"title":{"type":"string","maxLength":300,"description":"The job / subject on the quotation (default: the deal title)"},"valid_until":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-12-01"},"internal_note":{"type":"string","maxLength":2000,"description":"For the team, never printed"},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}}}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/QuotationDraftCreated"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/accounting/documents/{id}":{"get":{"operationId":"accounting.documents.get","tags":["Accounting"],"summary":"Get an accounting document","description":"One invoice / bill / quotation / note with its lines. With accounting.quote_own only (no accounting.view): your own / your team's quotations only.","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","description":"Record id (uuid)"},"required":true,"description":"Record id (uuid)","name":"id","in":"path"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccountingDocumentDetail"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/accounting/payments":{"get":{"operationId":"accounting.payments.list","tags":["Accounting"],"summary":"List receipts and payments","description":"Money received from customers (kind=receipt) and paid to vendors (kind=payment).\n\n**Scopes:** `accounting.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":200,"default":50,"description":"Page size (1–200, default 50)"},"required":false,"description":"Page size (1–200, default 50)","name":"limit","in":"query"},{"schema":{"type":"string","maxLength":200,"description":"Opaque cursor from `next_cursor` of the previous page"},"required":false,"description":"Opaque cursor from `next_cursor` of the previous page","name":"cursor","in":"query"},{"schema":{"type":"string","format":"date-time","description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally."},"required":false,"description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally.","name":"updated_since","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Text search"},"required":false,"description":"Text search","name":"q","in":"query"},{"schema":{"type":"string","enum":["receipt","payment"]},"required":false,"name":"kind","in":"query"},{"schema":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-11-01"},"required":false,"name":"from","in":"query"},{"schema":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-11-01"},"required":false,"name":"to","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"company_id","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PaymentList"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/accounting/accounts":{"get":{"operationId":"accounting.accounts.list","tags":["Accounting"],"summary":"Chart of accounts","description":"The chart of accounts (code, name, type, postable).\n\n**Scopes:** `accounting.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":500,"default":500},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","maxLength":200,"description":"Opaque cursor from `next_cursor` of the previous page"},"required":false,"description":"Opaque cursor from `next_cursor` of the previous page","name":"cursor","in":"query"},{"schema":{"type":"string","format":"date-time","description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally."},"required":false,"description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally.","name":"updated_since","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Text search"},"required":false,"description":"Text search","name":"q","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccountList"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/accounting/bank-accounts":{"get":{"operationId":"accounting.bank_accounts.list","tags":["Accounting"],"summary":"Bank and cash accounts","description":"Bank / cash accounts. Account numbers are masked to the last 4 digits.\n\n**Scopes:** `accounting.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":200,"default":50,"description":"Page size (1–200, default 50)"},"required":false,"description":"Page size (1–200, default 50)","name":"limit","in":"query"},{"schema":{"type":"string","maxLength":200,"description":"Opaque cursor from `next_cursor` of the previous page"},"required":false,"description":"Opaque cursor from `next_cursor` of the previous page","name":"cursor","in":"query"},{"schema":{"type":"string","format":"date-time","description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally."},"required":false,"description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally.","name":"updated_since","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Text search"},"required":false,"description":"Text search","name":"q","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BankAccountList"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/accounting/fixed-assets":{"get":{"operationId":"accounting.assets.list","tags":["Accounting"],"summary":"Fixed assets","description":"Fixed-asset register (cost, dates, depreciation method, status).\n\n**Scopes:** `accounting.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":200,"default":50,"description":"Page size (1–200, default 50)"},"required":false,"description":"Page size (1–200, default 50)","name":"limit","in":"query"},{"schema":{"type":"string","maxLength":200,"description":"Opaque cursor from `next_cursor` of the previous page"},"required":false,"description":"Opaque cursor from `next_cursor` of the previous page","name":"cursor","in":"query"},{"schema":{"type":"string","format":"date-time","description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally."},"required":false,"description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally.","name":"updated_since","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Text search"},"required":false,"description":"Text search","name":"q","in":"query"},{"schema":{"type":"string","maxLength":20},"required":false,"name":"status","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FixedAssetList"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/expense-claims":{"get":{"operationId":"expense_claims.list","tags":["People"],"summary":"List expense claims","description":"Expense and travel claims. Approvers (expense.approve / expense.manage) see the company's claims; everyone else sees only their own.","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":200,"default":50,"description":"Page size (1–200, default 50)"},"required":false,"description":"Page size (1–200, default 50)","name":"limit","in":"query"},{"schema":{"type":"string","maxLength":200,"description":"Opaque cursor from `next_cursor` of the previous page"},"required":false,"description":"Opaque cursor from `next_cursor` of the previous page","name":"cursor","in":"query"},{"schema":{"type":"string","format":"date-time","description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally."},"required":false,"description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally.","name":"updated_since","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Text search"},"required":false,"description":"Text search","name":"q","in":"query"},{"schema":{"type":"string","maxLength":20},"required":false,"name":"status","in":"query"},{"schema":{"type":"string","enum":["true"],"description":"Only my own claims"},"required":false,"description":"Only my own claims","name":"mine","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExpenseClaimList"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"expense_claims.create","tags":["People"],"summary":"Create an expense claim draft (for yourself)","description":"Start an expense claim for YOURSELF as a DRAFT: a receipt claim (optionally with a title and receipt lines — date, category (a key from list_expense_types), amount, who paid), a trip, or this period's field report (one per period; an existing one is returned). You add receipts / legs and submit it in Tonbab — nothing is submitted or approved here. Receipt photos are not accepted through the API.\n\n**Scopes:** `expense.self`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"claim_type":{"type":"string","enum":["receipt","trip","field_report"],"default":"receipt"},"title":{"type":"string","maxLength":200,"description":"Receipt claims only"},"lines":{"type":"array","items":{"type":"object","properties":{"date":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-12-01"},"category":{"type":"string","pattern":"^[a-z][a-z0-9_]{0,39}$","default":"other","description":"Expense type key: one of the company's active receipt types — call list_expense_types and use a key with pickable true (e.g. hotel, fuel, toll, taxi, parking, meal, flight, other). An unknown or inactive key is refused."},"description":{"type":"string","maxLength":300,"default":""},"amount":{"type":"number","minimum":0,"exclusiveMinimum":true,"maximum":1000000000,"description":"THB"},"paid_by":{"type":"string","enum":["employee","company","company_card","advance"],"default":"employee","description":"Only employee-paid lines are reimbursed"},"has_tax_invoice":{"type":"boolean","default":false},"vat_amount":{"type":"number","minimum":0,"maximum":1000000000},"supplier_tax_id":{"type":"string","pattern":"^\\d{13}$"}},"required":["date","amount"]},"maxItems":100,"description":"Receipt claims only"},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}}}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExpenseClaimDraftCreated"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/expense-claims/{id}":{"get":{"operationId":"expense_claims.get","tags":["People"],"summary":"Get an expense claim","description":"One claim with its lines (receipt files are not exposed). Someone else's claim reads as not found unless you approve claims.","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","description":"Record id (uuid)"},"required":true,"description":"Record id (uuid)","name":"id","in":"path"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExpenseClaimDetail"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/leave/my-balance":{"get":{"operationId":"leave.my_balance","tags":["People"],"summary":"My leave balance","description":"Your own leave entitlement, used and remaining days per leave type for a year (default this year).\n\n**Scopes:** `people.self`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"integer","minimum":2000,"maximum":2100},"required":false,"name":"year","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MyLeaveBalance"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/leave/requests":{"get":{"operationId":"leave.requests.list","tags":["People"],"summary":"List leave requests","description":"Leave requests. HR sees everyone, leave managers their reporting line, everyone else their own.","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":200,"default":50,"description":"Page size (1–200, default 50)"},"required":false,"description":"Page size (1–200, default 50)","name":"limit","in":"query"},{"schema":{"type":"string","maxLength":200,"description":"Opaque cursor from `next_cursor` of the previous page"},"required":false,"description":"Opaque cursor from `next_cursor` of the previous page","name":"cursor","in":"query"},{"schema":{"type":"string","format":"date-time","description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally."},"required":false,"description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally.","name":"updated_since","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Text search"},"required":false,"description":"Text search","name":"q","in":"query"},{"schema":{"type":"string","maxLength":20},"required":false,"name":"status","in":"query"},{"schema":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-11-01"},"required":false,"name":"from","in":"query"},{"schema":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-11-01"},"required":false,"name":"to","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LeaveRequestList"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"leave.request","tags":["People"],"summary":"Request leave (for yourself)","description":"File a leave request for YOURSELF (the connected person; never anyone else). The app's rules apply: the type must be active and allowed for you, no overlap with a pending / approved request, days = working days (weekends and public holidays excluded), work-away types need work_reason. It lands PENDING and your approvers are told — it is never approved through the API, even if you approve leave yourself.\n\n**Scopes:** `people.self`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"leave_type_id":{"type":"string","format":"uuid","description":"Leave type id (my_leave_balance lists them); or give leave_type_code"},"leave_type_code":{"type":"string","minLength":1,"maxLength":40,"description":"Leave type code, e.g. \"annual\", \"sick\""},"start_date":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-12-01"},"end_date":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-12-01","description":"Default: start_date (one day)"},"half_day":{"type":"string","enum":["am","pm"],"description":"One-day request only: morning or afternoon"},"start_half":{"type":"string","enum":["am","pm"],"description":"Multi-day only: the first day is a half day"},"end_half":{"type":"string","enum":["am","pm"],"description":"Multi-day only: the last day is a half day"},"reason":{"type":"string","maxLength":1000},"work_reason":{"type":"string","enum":["seminar","trade_show","conference","exhibition","training","installation","on_sales","other"],"description":"Required for work-away leave types"},"work_location":{"type":"string","maxLength":200},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["start_date"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LeaveRequested"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/service-jobs":{"get":{"operationId":"service_jobs.list","tags":["Workshop"],"summary":"List service orders","description":"Workshop service orders (ใบสั่งงานบริการ; formerly \"service jobs\"): repair and site work. open=true for jobs not closed or cancelled; mine=true for jobs assigned to you.\n\n**Scopes:** `service.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":200,"default":50,"description":"Page size (1–200, default 50)"},"required":false,"description":"Page size (1–200, default 50)","name":"limit","in":"query"},{"schema":{"type":"string","maxLength":200,"description":"Opaque cursor from `next_cursor` of the previous page"},"required":false,"description":"Opaque cursor from `next_cursor` of the previous page","name":"cursor","in":"query"},{"schema":{"type":"string","format":"date-time","description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally."},"required":false,"description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally.","name":"updated_since","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Text search"},"required":false,"description":"Text search","name":"q","in":"query"},{"schema":{"type":"string","maxLength":30},"required":false,"name":"status","in":"query"},{"schema":{"type":"string","enum":["true"]},"required":false,"name":"open","in":"query"},{"schema":{"type":"string","enum":["true"]},"required":false,"name":"mine","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"assigned_to","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"company_id","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ServiceJobList"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"service_jobs.create","tags":["Workshop"],"summary":"Open a service order","description":"Open a service order (ใบสั่งงานบริการ; formerly \"service job\") for a customer, exactly as the new-order form does: it gets the next number and its own job (งาน, formerly Job Control) — or is costed to an open project job you pass — the customer's contact and machine must be theirs, the technician must be someone who does service work, a template's checklist is copied, and a warranty claim is accepted only when a warranty really covers the machine today. type: on_site (a visit — give visit_at to schedule it) or in_house (brought to the workshop). If the company requires a sales deal for engineering support, give support_deal_id (an open or won deal of the same customer). The plan's monthly job limit applies. The job only starts: nothing is quoted, completed, closed or billed. Add photos with add_service_job_photos.\n\n**Scopes:** `service.create`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"company_id":{"type":"string","format":"uuid","description":"The customer (a company marked as customer)"},"reported_problem":{"type":"string","minLength":1,"maxLength":4000,"description":"What the customer reports (Thai or English)"},"type":{"type":"string","enum":["on_site","in_house"],"default":"on_site"},"priority":{"type":"string","enum":["normal","urgent"],"default":"normal"},"contact_id":{"type":"string","format":"uuid","description":"A contact of this customer (others are ignored, as on the form)"},"customer_asset_id":{"type":"string","format":"uuid","description":"The customer's machine on record"},"new_asset":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":200},"brand":{"type":"string","maxLength":100},"model":{"type":"string","maxLength":100},"serial":{"type":"string","maxLength":100},"warranty_end":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-12-01"}},"required":["name"],"description":"Record a new machine for this customer instead of customer_asset_id"},"site_address":{"type":"string","maxLength":1000,"description":"on_site only"},"visit_at":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}$","description":"on_site: first visit, Bangkok time YYYY-MM-DDTHH:mm (the job becomes scheduled)"},"assigned_to":{"type":"string","format":"uuid","description":"Technician (user id); see list_users"},"template_id":{"type":"string","format":"uuid"},"job_control_id":{"type":"string","format":"uuid","description":"Cost this service order to an open project job (formerly Job Control) of the same customer instead of a new one"},"support_deal_id":{"type":"string","format":"uuid","description":"The sales deal this engineering support is for"},"sales_owner_id":{"type":"string","format":"uuid","description":"Only for people who may assign sales owners; otherwise the owner is resolved (Job Control → account → latest open deal)"},"warranty_claim":{"type":"boolean","description":"Claim a warranty — accepted only if one covers the machine today"},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["company_id","reported_problem"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ServiceJobSaved"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/service-jobs/{id}":{"get":{"operationId":"service_jobs.get","tags":["Workshop"],"summary":"Get a service order","description":"One service order (ใบสั่งงานบริการ; formerly \"service job\") with its visits (schedule, outcome). Money (quotes/costs) is not included.\n\n**Scopes:** `service.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","description":"Record id (uuid)"},"required":true,"description":"Record id (uuid)","name":"id","in":"path"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ServiceJobDetail"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"service_jobs.update","tags":["Workshop"],"summary":"Update a service job","description":"Change who and where on a service job, with the job page's rules: assigned_to (a technician who does service work; null unassigns; the job's own Job Control follows), work_center_id (a work centre of this company; null clears), sales_owner_id (only for people who may assign sales owners; a person in the sales team), move_to_workshop (an on-site job becomes a workshop / bring-in job). Only the fields you give change. Closed and cancelled jobs are history and are refused. Status, quotes, parts, completion and billing are not changed here. Pass expected_updated_at (from get_service_job) to refuse the change if someone saved first.\n\n**Scopes:** `service.edit`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","description":"Record id (uuid)"},"required":true,"description":"Record id (uuid)","name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"assigned_to":{"type":"string","nullable":true,"format":"uuid"},"work_center_id":{"type":"string","nullable":true,"format":"uuid"},"sales_owner_id":{"type":"string","nullable":true,"format":"uuid"},"move_to_workshop":{"type":"boolean","enum":[true]},"expected_updated_at":{"type":"string","format":"date-time","description":"updated_at as you last read it; a newer save → 409"},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}}}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ServiceJobSaved"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/service-jobs/schedule":{"get":{"operationId":"service_jobs.schedule","tags":["Workshop"],"summary":"Service schedule","description":"Scheduled technician visits between two dates (default: today + 7 days). Filter by assigned_to or mine=true.\n\n**Scopes:** `service.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-11-01"},"required":false,"name":"from","in":"query"},{"schema":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-11-01"},"required":false,"name":"to","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"assigned_to","in":"query"},{"schema":{"type":"string","enum":["true"]},"required":false,"name":"mine","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ServiceSchedule"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/stock/valuation":{"get":{"operationId":"stock.valuation","tags":["Inventory"],"summary":"Stock valuation","description":"Inventory value (THB, at average cost) per warehouse right now. Needs cost.view — the price wall.\n\n**Scopes:** `inventory.view`, `cost.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":false,"name":"warehouse_id","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StockValuation"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/stock/movements":{"get":{"operationId":"stock.movements","tags":["Inventory"],"summary":"Stock movements","description":"Stock in/out history (receipts, issues, transfers, adjustments). Unit cost / value only with cost.view. updated_since filters on the movement time.\n\n**Scopes:** `inventory.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":200,"default":50,"description":"Page size (1–200, default 50)"},"required":false,"description":"Page size (1–200, default 50)","name":"limit","in":"query"},{"schema":{"type":"string","maxLength":200,"description":"Opaque cursor from `next_cursor` of the previous page"},"required":false,"description":"Opaque cursor from `next_cursor` of the previous page","name":"cursor","in":"query"},{"schema":{"type":"string","format":"date-time","description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally."},"required":false,"description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally.","name":"updated_since","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Text search"},"required":false,"description":"Text search","name":"q","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"product_id","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"warehouse_id","in":"query"},{"schema":{"type":"string","maxLength":40},"required":false,"name":"movement_type","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"job_control_id","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StockMovementList"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/stock/lots":{"get":{"operationId":"stock.lots","tags":["Inventory"],"summary":"Lots","description":"Inventory lots with expiry and remaining quantity (FIFO). Unit cost only with cost.view.\n\n**Scopes:** `inventory.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":200,"default":50,"description":"Page size (1–200, default 50)"},"required":false,"description":"Page size (1–200, default 50)","name":"limit","in":"query"},{"schema":{"type":"string","maxLength":200,"description":"Opaque cursor from `next_cursor` of the previous page"},"required":false,"description":"Opaque cursor from `next_cursor` of the previous page","name":"cursor","in":"query"},{"schema":{"type":"string","format":"date-time","description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally."},"required":false,"description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally.","name":"updated_since","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Text search"},"required":false,"description":"Text search","name":"q","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"product_id","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"warehouse_id","in":"query"},{"schema":{"type":"string","maxLength":20},"required":false,"name":"status","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LotList"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/stock/serials":{"get":{"operationId":"stock.serials","tags":["Inventory"],"summary":"Serial numbers","description":"Serial-tracked units: where each one is and what it is allocated to.\n\n**Scopes:** `inventory.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":200,"default":50,"description":"Page size (1–200, default 50)"},"required":false,"description":"Page size (1–200, default 50)","name":"limit","in":"query"},{"schema":{"type":"string","maxLength":200,"description":"Opaque cursor from `next_cursor` of the previous page"},"required":false,"description":"Opaque cursor from `next_cursor` of the previous page","name":"cursor","in":"query"},{"schema":{"type":"string","format":"date-time","description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally."},"required":false,"description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally.","name":"updated_since","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Text search"},"required":false,"description":"Text search","name":"q","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"product_id","in":"query"},{"schema":{"type":"string","maxLength":20},"required":false,"name":"status","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SerialList"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/boms":{"get":{"operationId":"boms.list","tags":["Manufacturing"],"summary":"Bills of materials","description":"BOM headers (product, code, version, kind). Component costs are not included.\n\n**Scopes:** `bom.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":200,"default":50,"description":"Page size (1–200, default 50)"},"required":false,"description":"Page size (1–200, default 50)","name":"limit","in":"query"},{"schema":{"type":"string","maxLength":200,"description":"Opaque cursor from `next_cursor` of the previous page"},"required":false,"description":"Opaque cursor from `next_cursor` of the previous page","name":"cursor","in":"query"},{"schema":{"type":"string","format":"date-time","description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally."},"required":false,"description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally.","name":"updated_since","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Text search"},"required":false,"description":"Text search","name":"q","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"product_id","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BomList"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/stock-counts":{"post":{"operationId":"stock_counts.create","tags":["Inventory"],"summary":"Create a stock count draft","description":"Record counted quantities for one warehouse as a DRAFT physical-count adjustment. The system quantity is read now; a person reviews the differences and posts it in Tonbab — stock does not change until then. The draft carries a temporary number (ADJ-DRAFT-…); its running ADJ number is given when it is posted.\n\n**Scopes:** `inventory.adjust`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"warehouse_id":{"type":"string","format":"uuid"},"count_date":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-12-01"},"reason":{"type":"string","minLength":1,"maxLength":300,"default":"Physical count (API)"},"notes":{"type":"string","maxLength":4000},"lines":{"type":"array","items":{"type":"object","properties":{"product_id":{"type":"string","format":"uuid"},"counted_qty":{"type":"number","minimum":0,"maximum":1000000000},"notes":{"type":"string","maxLength":500}},"required":["product_id","counted_qty"]},"minItems":1,"maxItems":500},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["warehouse_id","lines"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StockCountCreated"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/crm/pipelines":{"get":{"operationId":"crm_pipelines.list","tags":["CRM"],"summary":"CRM pipelines and stages","description":"Every CRM pipeline with its stages in board order (open stages, then won / lost). Use the ids with create_deal and move_deal_stage. include_inactive=true also lists switched-off ones.\n\n**Scopes:** `crm.deal.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","enum":["true","false"]},"required":false,"name":"include_inactive","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CrmPipelineList"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/units":{"get":{"operationId":"units.list","tags":["Products"],"summary":"Units of measure","description":"Units you can put on a line: the built-in catalogue plus units this company added, with their dimension (count, mass, volume…). With product_id: that product's stock unit, purchase unit and its own conversions too.\n\n**Scopes:** `product.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":false,"name":"product_id","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnitList"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/tax-rates":{"get":{"operationId":"tax_rates.list","tags":["Accounting"],"summary":"VAT and withholding-tax rates","description":"The VAT codes and the usual withholding-tax (WHT, 50 ทวิ) rates Tonbab offers on documents, and whether this company is VAT-registered. WHT rates are starting values a person may change; confirm with an accountant.","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TaxRates"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/expense-types":{"get":{"operationId":"expense_types.list","tags":["People"],"summary":"Expense types (claim categories)","description":"This company's expense types: the categories an expense-claim line may take. Use an active receipt type's key as `category` in create_expense_claim_draft. kind system (per_diem, mileage) is computed by the claim and cannot be picked. The linked chart-of-accounts account (code + name) is shown only with accounting.view. include_inactive=true also lists switched-off types (old lines may still carry their key).","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","enum":["true","false"]},"required":false,"name":"include_inactive","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExpenseTypeList"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/users":{"get":{"operationId":"users.list","tags":["Account"],"summary":"Company members","description":"People in this company (active members): user id, name and roles — use the ids for owner_id / assignment. Email only when the connection has user.manage (user admins); never phone, ID numbers or HR data (see list_employees for the directory).","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","maxLength":100,"description":"Name contains"},"required":false,"description":"Name contains","name":"q","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserList"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/me/approvals":{"get":{"operationId":"approvals.mine","tags":["Account"],"summary":"What is waiting for my approval","description":"Your own approval queues — the same counts as the bell in Tonbab: purchase requests, expense claims and cash advances, leave, overtime, revert requests… each with how many are waiting, how long the oldest has waited and a link. Only queues you can act on, and only areas this connection may read. Decide them in Tonbab; nothing is approved here.","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MyApprovals"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/crm/leads":{"get":{"operationId":"crm_leads.list","tags":["CRM"],"summary":"List CRM leads","description":"Leads (inquiries not yet deals) you can see in the app: yours and your team's, the unassigned queue, and leads you logged (crm.plan.manage: all). Filter by status. value_minor needs prices.sell.\n\n**Scopes:** `crm.deal.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":200,"default":50,"description":"Page size (1–200, default 50)"},"required":false,"description":"Page size (1–200, default 50)","name":"limit","in":"query"},{"schema":{"type":"string","maxLength":200,"description":"Opaque cursor from `next_cursor` of the previous page"},"required":false,"description":"Opaque cursor from `next_cursor` of the previous page","name":"cursor","in":"query"},{"schema":{"type":"string","format":"date-time","description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally."},"required":false,"description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally.","name":"updated_since","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Text search"},"required":false,"description":"Text search","name":"q","in":"query"},{"schema":{"type":"string","enum":["new","assigned","contacted","qualified","disqualified"]},"required":false,"name":"status","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CrmLeadList"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"crm_leads.create","tags":["CRM"],"summary":"Log a CRM lead","description":"Log an inquiry in the leads inbox (it is not a deal: it never counts on the board or forecast). Needs a company, a contact or a contact_hint. owner_id assigns it (yourself, or someone in your CRM scope — otherwise it lands unassigned) and tells them. A person qualifies it into a deal in Tonbab.\n\n**Scopes:** `crm.deal.edit`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"channel":{"type":"string","enum":["phone","line","meta","email","website","walkin","referral","other"]},"need":{"type":"string","minLength":1,"maxLength":2000,"description":"What the customer asked for"},"company_id":{"type":"string","format":"uuid"},"contact_id":{"type":"string","format":"uuid","description":"Kept only when the contact works at company_id"},"contact_hint":{"type":"string","maxLength":200,"description":"Name / phone / LINE when there is no contact record"},"value":{"type":"number","minimum":0,"maximum":1000000000000,"description":"Rough value in THB"},"owner_id":{"type":"string","format":"uuid"},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["channel","need"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LeadCreated"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/crm/deals/{id}/stage":{"post":{"operationId":"deals.move_stage","tags":["CRM"],"summary":"Move a deal to another stage","description":"Move an OPEN deal you own (or that is in your CRM scope) to another OPEN stage of its pipeline — exactly the board's rules: not while a discount approval is pending, not a deal managed by a service job, and won / lost go through close_deal. Records stage history and runs the stage's automatic task.\n\n**Scopes:** `crm.deal.edit`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","description":"Record id (uuid)"},"required":true,"description":"Record id (uuid)","name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"stage_id":{"type":"string","format":"uuid"},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["stage_id"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Created"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/crm/deals/{id}/close":{"post":{"operationId":"deals.close","tags":["CRM"],"summary":"Close a deal won or lost","description":"Mark an OPEN deal you own (or in your CRM scope) won or lost — the board's close rules: the company's \"require lost reason\" rule, no pending discount approval, not a service-job deal; it moves to the pipeline's won / lost stage. Optionally record the customer's PO (date / number) on a win. Quotations are not changed by this.\n\n**Scopes:** `crm.deal.edit`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","description":"Record id (uuid)"},"required":true,"description":"Record id (uuid)","name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"outcome":{"type":"string","enum":["won","lost"]},"lost_reason":{"type":"string","maxLength":500},"customer_po_date":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-12-01"},"customer_po_number":{"type":"string","maxLength":80},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["outcome"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Created"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/crm/report":{"get":{"operationId":"crm.pipeline_report","tags":["CRM"],"summary":"CRM pipeline report","description":"The CRM home dashboard for your scope (yourself; your team if people report to you; everyone with crm.plan.manage): open deals and weighted value, won this month, 90-day win rate, the open funnel per stage and pipeline, 12 months of won / lost, top lost reasons, overdue / today activities. Money is in baht (satang, *_minor / value; foreign-currency deals count at their own rate) and needs prices.sell.\n\n**Scopes:** `crm.deal.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CrmPipelineReport"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/crm/work-updates":{"post":{"operationId":"crm.work_updates.create","tags":["CRM"],"summary":"Log a work update","description":"Write today's work-update journal entry (\"อัปเดตงาน\") for yourself: who you called / met at a customer, what was discussed, what the customer said, the next step — and optionally a follow-up date that lands on your worklist. A linked deal must be that customer's and inside your CRM scope.\n\n**Scopes:** `crm.plan.self`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"company_id":{"type":"string","format":"uuid"},"discussed":{"type":"string","minLength":1,"maxLength":4000},"channel":{"type":"string","enum":["call","meeting","line","visit","email","other"],"default":"call"},"contact_id":{"type":"string","format":"uuid","description":"Must work at company_id"},"deal_id":{"type":"string","format":"uuid"},"feedback":{"type":"string","maxLength":2000,"description":"The customer's own words"},"next_step":{"type":"string","maxLength":200},"follow_up":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-12-01","description":"Today or later: plans a follow-up activity on your worklist"},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["company_id","discussed"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Created"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/jobs/{id}":{"get":{"operationId":"job_controls.get","tags":["Manufacturing"],"summary":"Get a job with its cost","description":"One job (งาน; formerly \"Job Control\"): status with its SAP-style status_label (Created / Released / Technically complete / Closed), customer, owners, dates, the person responsible and the team (each person with a role: project_manager, sales, engineer, site_supervisor, technician, purchaser, accountant, other; is_primary = primary for that role, and the primary sales person is sales_owner_id) — and, with cost.view, its money: approved budget, material actual (stock consumed by WO / DN / JC issues at issue cost), services actual (received service PO lines), open PO commitments, total actual and variance. Expenses, petty cash and service-job labour are NOT in these totals yet — the JC page in Tonbab shows them.\n\n**Scopes:** `jc.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","description":"Record id (uuid)"},"required":true,"description":"Record id (uuid)","name":"id","in":"path"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/JobControlDetail"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/products/{id}/image":{"post":{"operationId":"products.set_image","tags":["Products"],"summary":"Set a product's photo","description":"Replace the product's photo from a public https URL (fetched by Tonbab; redirects are followed only to other public https URLs) or from base64 data. PNG, JPEG or WebP, at most 5 MB — the type is read from the bytes themselves.\n\n**Scopes:** `product.edit`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","description":"Record id (uuid)"},"required":true,"description":"Record id (uuid)","name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"url":{"type":"string","maxLength":2000,"format":"uri"},"base64":{"type":"string","maxLength":7200000,"description":"The image bytes, base64 (a data: URL prefix is accepted)"},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}}}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProductImageSet"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/warehouses/{id}":{"post":{"operationId":"warehouses.update","tags":["Inventory"],"summary":"Update a warehouse","description":"Change a warehouse's code, name, kind, linked supplier / customer, address or notes — only the fields you give. Same rules as create. expected_updated_at refuses the change if someone saved first.\n\n**Scopes:** `warehouse.edit`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","description":"Record id (uuid)"},"required":true,"description":"Record id (uuid)","name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"expected_updated_at":{"type":"string","format":"date-time"},"warehouse_code":{"type":"string","minLength":1,"maxLength":40},"warehouse_name":{"type":"string","minLength":1,"maxLength":200},"kind":{"type":"string","enum":["owned","subcontractor","customer","transit"]},"supplier_company_id":{"type":"string","nullable":true,"format":"uuid"},"customer_company_id":{"type":"string","nullable":true,"format":"uuid"},"address":{"type":"string","nullable":true,"maxLength":1000},"notes":{"type":"string","nullable":true,"maxLength":4000},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}}}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Created"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/stock-adjustments":{"post":{"operationId":"stock_adjustments.create","tags":["Inventory"],"summary":"Create a stock adjustment draft","description":"Prepare an increase, decrease or scrap of stock in one of your own or consignment warehouses as a DRAFT, in each product's stock unit (quantities are positive; the type gives the direction). unit_cost (THB per stock unit) is for increases such as opening stock and needs cost.view. A person reviews and posts it in Tonbab — stock does not change until then; the ADJ number is given on posting. For a physical count use create_stock_count_draft.\n\n**Scopes:** `inventory.adjust`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"warehouse_id":{"type":"string","format":"uuid"},"adjustment_type":{"type":"string","enum":["increase","decrease","scrap"]},"reason":{"type":"string","minLength":1,"maxLength":300},"adjustment_date":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-12-01"},"notes":{"type":"string","maxLength":4000},"lines":{"type":"array","items":{"type":"object","properties":{"product_id":{"type":"string","format":"uuid"},"quantity":{"type":"number","minimum":0,"exclusiveMinimum":true,"maximum":1000000000},"unit_cost":{"type":"number","minimum":0,"maximum":10000000000},"notes":{"type":"string","maxLength":500}},"required":["product_id","quantity"]},"minItems":1,"maxItems":500},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["warehouse_id","adjustment_type","reason","lines"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StockAdjustmentCreated"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"get":{"operationId":"stock_adjustments.list","tags":["Inventory"],"summary":"List stock adjustments","description":"Stock adjustments and physical counts (draft / posted / cancelled) with their lines. A line's unit_cost needs cost.view.\n\n**Scopes:** `inventory.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":200,"default":50,"description":"Page size (1–200, default 50)"},"required":false,"description":"Page size (1–200, default 50)","name":"limit","in":"query"},{"schema":{"type":"string","maxLength":200,"description":"Opaque cursor from `next_cursor` of the previous page"},"required":false,"description":"Opaque cursor from `next_cursor` of the previous page","name":"cursor","in":"query"},{"schema":{"type":"string","format":"date-time","description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally."},"required":false,"description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally.","name":"updated_since","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Text search"},"required":false,"description":"Text search","name":"q","in":"query"},{"schema":{"type":"string","enum":["draft","posted","cancelled"]},"required":false,"name":"status","in":"query"},{"schema":{"type":"string","enum":["increase","decrease","count","scrap"]},"required":false,"name":"adjustment_type","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"warehouse_id","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StockAdjustmentList"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/stock-transfers":{"post":{"operationId":"stock_transfers.create","tags":["Inventory"],"summary":"Create a stock transfer draft","description":"Prepare a move of stock between two warehouses as a DRAFT with its XFR number, quantities in each product's stock unit. A person reviews and posts it in Tonbab — no stock moves until then.\n\n**Scopes:** `inventory.transfer`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"from_warehouse_id":{"type":"string","format":"uuid"},"to_warehouse_id":{"type":"string","format":"uuid"},"transfer_date":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-12-01"},"reason":{"type":"string","maxLength":300},"notes":{"type":"string","maxLength":4000},"lines":{"type":"array","items":{"type":"object","properties":{"product_id":{"type":"string","format":"uuid"},"quantity":{"type":"number","minimum":0,"exclusiveMinimum":true,"maximum":1000000000},"notes":{"type":"string","maxLength":500}},"required":["product_id","quantity"]},"minItems":1,"maxItems":500},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["from_warehouse_id","to_warehouse_id","lines"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StockTransferCreated"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"get":{"operationId":"stock_transfers.list","tags":["Inventory"],"summary":"List stock transfers","description":"Stock transfers between warehouses (draft / posted / cancelled) with their lines.\n\n**Scopes:** `inventory.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":200,"default":50,"description":"Page size (1–200, default 50)"},"required":false,"description":"Page size (1–200, default 50)","name":"limit","in":"query"},{"schema":{"type":"string","maxLength":200,"description":"Opaque cursor from `next_cursor` of the previous page"},"required":false,"description":"Opaque cursor from `next_cursor` of the previous page","name":"cursor","in":"query"},{"schema":{"type":"string","format":"date-time","description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally."},"required":false,"description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally.","name":"updated_since","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Text search"},"required":false,"description":"Text search","name":"q","in":"query"},{"schema":{"type":"string","enum":["draft","posted","cancelled"]},"required":false,"name":"status","in":"query"},{"schema":{"type":"string","format":"uuid","description":"From or to this warehouse"},"required":false,"description":"From or to this warehouse","name":"warehouse_id","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StockTransferList"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/work-orders/{id}":{"get":{"operationId":"work_orders.get","tags":["Manufacturing"],"summary":"Get a production order (work order)","description":"One production order (ใบสั่งผลิต; formerly \"work order\"): what it makes, quantities (target, produced, scrap), dates, status, its materials (required / issued in the stock unit, source warehouse) and the shortages still to issue against stock on hand now — the same all-or-nothing check the app runs before issuing. Planned material cost needs cost.view.\n\n**Scopes:** `wo.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","description":"Record id (uuid)"},"required":true,"description":"Record id (uuid)","name":"id","in":"path"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WorkOrderDetail"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/boms/{id}":{"get":{"operationId":"boms.get","tags":["Manufacturing"],"summary":"Get a bill of materials","description":"One BOM with its lines (component, quantity per unit made, unit) and each line's alternates (approved substitutes for that line, and \"wherever this part is used\" ones). With cost.view: each line's cost per stock unit and the rolled-up material cost, as the BOM page shows it (stock average, then manual cost, then the main vendor's price as an estimate).\n\n**Scopes:** `bom.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","description":"Record id (uuid)"},"required":true,"description":"Record id (uuid)","name":"id","in":"path"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BomDetail"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/accounting/vat-report":{"get":{"operationId":"accounting.vat_report","tags":["Accounting"],"summary":"VAT report (ภ.พ.30)","description":"The month's VAT position exactly as Accounting → ภาษี (ภ.พ.30) shows it: output VAT (รายงานภาษีขาย — issued tax invoices, debit / credit notes, POS and online sales summarised per register per day as ภ.พ.06) and input VAT (รายงานภาษีซื้อ — claimable VAT on bills, in their claim month under ม.82/3), ภ.พ.36 VAT paid this month as a claim, and the net payable (negative = credit carried forward). Default: last month — the one being filed now (due by the 15th, or the 23rd when filed online). include_rows=true adds the report lines. A company that is not VAT-registered returns vat_registered=false and zeros.\n\n**Scopes:** `accounting.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","pattern":"^\\d{4}-(0[1-9]|1[0-2])$","example":"2026-10","description":"Month, YYYY-MM"},"required":false,"description":"Month, YYYY-MM","name":"period","in":"query"},{"schema":{"anyOf":[{"type":"boolean"},{"type":"string","enum":["0","1","true","false"]}],"default":false},"required":false,"name":"include_rows","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VatReport"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/accounting/balance-sheet":{"get":{"operationId":"accounting.balance_sheet","tags":["Accounting"],"summary":"Balance sheet (งบแสดงฐานะการเงิน)","description":"Assets, liabilities and equity at a date from POSTED vouchers, with the end of the previous fiscal year as the comparison column — the same figures as Accounting → งบการเงิน → Balance sheet (current-year profit shown inside equity until the year is closed). Default: today. difference ≠ 0 means the books do not balance (check the trial balance).\n\n**Scopes:** `accounting.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-11-01"},"required":false,"name":"as_of","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BalanceSheet"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/commerce/day-report":{"get":{"operationId":"commerce.day_report","tags":["Commerce"],"summary":"Commerce day report (Z report)","description":"The end-of-day (Z) report for one business day, as Commerce → Day report shows it: orders, gross / discounts / service charges / VAT / sales, refunds made that day, net, average ticket, by tender (cash, PromptPay, card…), by channel (POS, LINE, Shopee…), by dining option, by hour and the top items. Amounts in baht. Restaurants with a day cut-off (e.g. 02:00) count sales until the cut-off in the previous day. Default: today's business day; warehouse_id = one store; channel=pos = POS only.\n\n**Scopes:** `commerce.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-11-01"},"required":false,"name":"date","in":"query"},{"schema":{"type":"string","format":"uuid","description":"One store (an owned warehouse); default all"},"required":false,"description":"One store (an owned warehouse); default all","name":"warehouse_id","in":"query"},{"schema":{"type":"string","enum":["all","pos"],"default":"all"},"required":false,"name":"channel","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CommerceDayReport"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/crm/tenders":{"get":{"operationId":"crm_tenders.list","tags":["CRM"],"summary":"List e-GP tenders","description":"Government tender notices (e-GP, ระบบจัดซื้อจัดจ้างภาครัฐ) from the agencies this company watches, as CRM → Tenders lists them, with the company's decision on each: new (undecided), added (a deal was created — deal_id) or passed (with the reason), and the award outcome once known. matched_only (default) = notices that hit the company's keywords. Adding a tender to the pipeline is done by a person in Tonbab.\n\n**Scopes:** `crm.deal.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":200,"default":50,"description":"Page size (1–200, default 50)"},"required":false,"description":"Page size (1–200, default 50)","name":"limit","in":"query"},{"schema":{"type":"string","maxLength":200,"description":"Opaque cursor from `next_cursor` of the previous page"},"required":false,"description":"Opaque cursor from `next_cursor` of the previous page","name":"cursor","in":"query"},{"schema":{"type":"string","format":"date-time","description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally."},"required":false,"description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally.","name":"updated_since","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Text search"},"required":false,"description":"Text search","name":"q","in":"query"},{"schema":{"type":"string","enum":["new","added","passed"]},"required":false,"name":"status","in":"query"},{"schema":{"anyOf":[{"type":"boolean"},{"type":"string","enum":["0","1","true","false"]}],"default":true,"description":"Only notices matching the keyword profile (default true)"},"required":false,"description":"Only notices matching the keyword profile (default true)","name":"matched_only","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EgpTenderList"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/accounting/vouchers":{"get":{"operationId":"accounting.vouchers.list","tags":["Accounting"],"summary":"List vouchers (สมุดรายวัน)","description":"Journal vouchers (ใบสำคัญ) as Accounting → Journals lists them: JV general, SJ sales, PJ purchase, RV receipt, PV payment; draft or posted; by date range. q matches the voucher number (any separators), description, reference, an amount or a date — every word must match. Use get_voucher for the lines.\n\n**Scopes:** `accounting.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":200,"default":50,"description":"Page size (1–200, default 50)"},"required":false,"description":"Page size (1–200, default 50)","name":"limit","in":"query"},{"schema":{"type":"string","maxLength":200,"description":"Opaque cursor from `next_cursor` of the previous page"},"required":false,"description":"Opaque cursor from `next_cursor` of the previous page","name":"cursor","in":"query"},{"schema":{"type":"string","format":"date-time","description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally."},"required":false,"description":"Only records changed at/after this ISO-8601 time. Results come oldest-first so you can sync incrementally.","name":"updated_since","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Text search"},"required":false,"description":"Text search","name":"q","in":"query"},{"schema":{"type":"string","enum":["JV","SJ","PJ","RV","PV"]},"required":false,"name":"book","in":"query"},{"schema":{"type":"string","enum":["draft","posted"]},"required":false,"name":"status","in":"query"},{"schema":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-11-01"},"required":false,"name":"from","in":"query"},{"schema":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-11-01"},"required":false,"name":"to","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VoucherList"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/accounting/vouchers/{id}":{"get":{"operationId":"accounting.vouchers.get","tags":["Accounting"],"summary":"Get a voucher","description":"One journal voucher with its debit / credit lines and account codes. id = the voucher id (uuid) or its number (e.g. JV-2611-0001, as printed).\n\n**Scopes:** `accounting.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":60,"description":"Voucher id (uuid) or voucher number"},"required":true,"description":"Voucher id (uuid) or voucher number","name":"id","in":"path"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VoucherDetail"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/attendance/me":{"get":{"operationId":"attendance.mine","tags":["People"],"summary":"My attendance","description":"YOUR own time records (ลงเวลา) for a date range (default this month, at most 93 days): clock-in / out per day, worked minutes, status (pending / approved), late and overtime minutes against the company's work hours and late grace — the same classification as My time & leave — your OT requests, and totals.","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-11-01"},"required":false,"name":"from","in":"query"},{"schema":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-11-01"},"required":false,"name":"to","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MyAttendance"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/attendance/team":{"get":{"operationId":"attendance.team","tags":["People"],"summary":"Team attendance","description":"Time records of the people you may see, as People → Time shows them: full HR sees the company; a people manager only their reporting line (themselves and everyone below them). Per employee: totals (approved worked minutes, late days / minutes, missing punches, approved OT hours, pending days), plus each day with include_days. Default this month, at most 93 days. employee_id narrows to one person (inside your scope).","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-11-01"},"required":false,"name":"from","in":"query"},{"schema":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-11-01"},"required":false,"name":"to","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"employee_id","in":"query"},{"schema":{"anyOf":[{"type":"boolean"},{"type":"string","enum":["0","1","true","false"]}],"default":false},"required":false,"name":"include_days","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TeamAttendance"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/leave/requests/{id}/cancel":{"post":{"operationId":"leave.cancel_mine","tags":["People"],"summary":"Cancel my leave request","description":"Withdraw YOUR OWN leave request (ใบลา), exactly as the Cancel button on My time & leave: a pending request any time; an approved one only before it starts (the days go back to your balance — comp-time days to their grant). Leave that has started or been taken is cancelled by HR, not here. Someone else's request is refused.\n\n**Scopes:** `people.self`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","description":"Leave request id (list_leave_requests)"},"required":true,"description":"Leave request id (list_leave_requests)","name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}}}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LeaveCancelled"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/expense-claims/{id}/receipts":{"post":{"operationId":"expense_claims.attach_receipt","tags":["People"],"summary":"Attach a receipt to my expense claim","description":"Attach a receipt (ใบเสร็จ / ใบกำกับภาษี) photo or PDF to a line of YOUR OWN expense claim while it is still a draft or was returned to you — the same storage and limits as the receipt upload on My expenses: PNG, JPEG, WebP or PDF (type read from the bytes), at most 8 MB, from base64 or a public https URL. line_id may be left out when the claim has one line. Nothing is submitted; you submit the claim in Tonbab.\n\n**Scopes:** `expense.self`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","description":"Expense claim id"},"required":true,"description":"Expense claim id","name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"line_id":{"type":"string","format":"uuid","description":"The claim line the receipt belongs to (get_expense_claim)"},"url":{"type":"string","maxLength":2000,"format":"uri"},"base64":{"type":"string","maxLength":11200000,"description":"The file bytes, base64 (a data: URL prefix is accepted)"},"file_name":{"type":"string","maxLength":200},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}}}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExpenseReceiptAttached"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/people/find":{"get":{"operationId":"people.find","tags":["People"],"summary":"Find people by name","description":"Who is \"คุณสมชาย\" / \"Nok\" / \"somchai@acme.co.th\"? Resolves names to your company's people — members (logins) and, with people.employee.view, People employees (Thai / English first + last names, nicknames ชื่อเล่น, employee codes, work email). Order: email → employee code → English full name → Thai full name → nickname → display name; an honorific (คุณ, นาย, Khun, Mr.) is ignored. The first step that hits decides: one person = resolved; several = ambiguous (all returned, none picked). No exact hit → suggestions only (every word inside the name) — never treat a suggestion as a match without asking. Use the user_id for owners / assignees. Several names: separate with | (at most 50). Directory fields only — never salary or personal data.","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":4000,"description":"A name, nickname, employee code or email — several separated by |"},"required":true,"description":"A name, nickname, employee code or email — several separated by |","name":"q","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PeopleFound"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/accounting/migration":{"get":{"operationId":"migration.start","tags":["Migration"],"summary":"Start accounting migration","description":"Call first when moving a company's books from its previous accounting system into Tonbab. Returns the migration job a person opened for this connection (mode, cut-over date, time limit), the batch limits, and the step-by-step playbook to follow. If no job is open (or it is granted to another connection), says how the person opens / grants one. Never writes.\n\n**Scopes:** `accounting.manage`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MigrationStart"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/accounting/migration/status":{"get":{"operationId":"migration.status","tags":["Migration"],"summary":"Accounting migration status","description":"The current (or latest) migration job for this company: status, counts per step (created / skipped / errors), the last reconciliation, and the number of account mappings. Never writes.\n\n**Scopes:** `accounting.manage`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MigrationStatus"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/accounting/migration/rollback-preview":{"get":{"operationId":"migration.rollback_preview","tags":["Migration"],"summary":"Preview migration rollback","description":"What rolling back the migration job would delete (records it CREATED, by table) and anything blocking it (locked periods, closed years, other records that now depend on them). Never writes: only a person can roll back, in Settings → Migration → Accounting.\n\n**Scopes:** `accounting.manage`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MigrationRollbackPreview"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/accounting/migration/accounts":{"post":{"operationId":"migration.map_accounts","tags":["Migration"],"summary":"Map chart of accounts","description":"Map the previous system's account codes to Tonbab account codes (default: the same code), creating missing postable accounts when \"create\" is given. Every later import translates codes through this map. Re-mapping a code replaces its mapping. Max 300 per call.\n\n**Scopes:** `accounting.manage`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"accounts":{"type":"array","items":{"type":"object","properties":{"source_code":{"type":"string","minLength":1,"maxLength":40},"source_name":{"type":"string","maxLength":200},"target_code":{"type":"string","pattern":"^[0-9A-Za-z.-]{1,20}$","description":"Tonbab account code. Default: the same code as the source."},"create":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":200},"account_type":{"type":"string","enum":["asset","liability","equity","revenue","expense"]},"parent_code":{"type":"string","maxLength":20}},"required":["name","account_type"],"description":"Create target_code as a postable account when it does not exist."}},"required":["source_code"]},"minItems":1,"maxItems":300},"dry_run":{"type":"boolean","default":false,"description":"Validate the whole batch in the database and roll it back. Always send a batch with dry_run=true first."},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["accounts"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MigrationBatchResult"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/accounting/migration/contacts":{"post":{"operationId":"migration.import_contacts","tags":["Migration"],"summary":"Import contacts","description":"Customers and vendors. Each is matched to an existing company by this job's earlier import, then a full tax id + branch, then the exact name; otherwise created. update_existing=true fills EMPTY fields (and the customer / vendor flags) of matched companies — it never overwrites. Max 200 per call.\n\n**Scopes:** `accounting.manage`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"contacts":{"type":"array","items":{"type":"object","properties":{"source_id":{"type":"string","minLength":1,"maxLength":120,"description":"The previous system's record id or number. Keys idempotency: the same source_id is never imported twice."},"name":{"type":"string","minLength":1,"maxLength":300},"code":{"type":"string","maxLength":40,"description":"Contact code to keep, if free in Tonbab."},"tax_id":{"type":"string","maxLength":40,"description":"13-digit Thai tax id. Masked or foreign ids are kept as foreign_tax_id and matching falls back to the name."},"branch":{"type":"string","maxLength":60,"description":"Branch number (00000 / สำนักงานใหญ่ = head office)."},"is_customer":{"type":"boolean","default":false},"is_vendor":{"type":"boolean","default":false},"address":{"type":"string","maxLength":1000},"email":{"type":"string","maxLength":200},"phone":{"type":"string","maxLength":60},"contact_person":{"type":"string","maxLength":200},"country":{"type":"string","maxLength":60},"credit_days":{"type":"integer","minimum":0,"maximum":365}},"required":["source_id","name"]},"minItems":1,"maxItems":200},"update_existing":{"type":"boolean","default":false},"dry_run":{"type":"boolean","default":false,"description":"Validate the whole batch in the database and roll it back. Always send a batch with dry_run=true first."},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["contacts"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MigrationBatchResult"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/accounting/migration/bank-accounts":{"post":{"operationId":"migration.import_bank_accounts","tags":["Migration"],"summary":"Import bank and cash accounts","description":"Bank, cash, petty-cash and e-wallet accounts that receipts and payments use, each on its GL account (asset, postable). An account already set up on that GL account is reused. Max 50 per call. Account numbers come back masked.\n\n**Scopes:** `accounting.manage`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"bank_accounts":{"type":"array","items":{"type":"object","properties":{"source_id":{"type":"string","minLength":1,"maxLength":120,"description":"The previous system's record id or number. Keys idempotency: the same source_id is never imported twice."},"account_code":{"type":"string","minLength":1,"maxLength":40,"description":"The GL account (asset, postable) this money account posts to; mapped through map_migration_accounts."},"kind":{"type":"string","enum":["bank","cash","petty_cash","ewallet"],"default":"bank"},"name":{"type":"string","minLength":1,"maxLength":120},"bank_code":{"type":"string","pattern":"^[A-Z0-9_]{2,20}$","description":"e.g. KBANK, SCB, BBL"},"branch":{"type":"string","maxLength":120},"account_no":{"type":"string","pattern":"^[0-9A-Za-z -]{1,40}$"},"account_holder":{"type":"string","maxLength":200},"deposit_type":{"type":"string","enum":["savings","current","fixed"]},"currency":{"type":"string","pattern":"^[A-Z]{3}$","default":"THB"}},"required":["source_id","account_code","name"]},"minItems":1,"maxItems":50},"dry_run":{"type":"boolean","default":false,"description":"Validate the whole batch in the database and roll it back. Always send a batch with dry_run=true first."},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["bank_accounts"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MigrationBatchResult"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/accounting/migration/opening-balances":{"post":{"operationId":"migration.import_opening_balances","tags":["Migration"],"summary":"Import opening balances","description":"One opening voucher (book JV) from the previous system's trial balance: one line per account, balance = debit − credit (credit balances negative), or debit / credit. Dated as_of (default: the day before cut-over; must be before it). Must balance to the satang. Its number (default OB-<as_of>) is kept, so sending it again is skipped.\n\n**Scopes:** `accounting.manage`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"as_of":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2025-12-31"},"no":{"type":"string","minLength":1,"maxLength":40},"description":{"type":"string","maxLength":500},"lines":{"type":"array","items":{"type":"object","properties":{"code":{"type":"string","minLength":1,"maxLength":40},"balance":{"type":"number","minimum":-10000000000000,"maximum":10000000000000},"debit":{"type":"number","minimum":0,"maximum":10000000000000},"credit":{"type":"number","minimum":0,"maximum":10000000000000}},"required":["code"]},"minItems":2,"maxItems":1000,"example":[{"code":"11121","balance":250000},{"code":"31100","balance":-250000}]},"dry_run":{"type":"boolean","default":false,"description":"Validate the whole batch in the database and roll it back. Always send a batch with dry_run=true first."},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["lines"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/MigrationBatchResult"},{"type":"object","properties":{"debit":{"type":"number"},"credit":{"type":"number"}},"required":["debit","credit"]}],"description":"One result per item, in order. created = new in Tonbab; skipped = its number is already there (re-run is safe); error = not imported (code + message). dry_run=true: nothing was saved."}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/accounting/migration/journal-entries":{"post":{"operationId":"migration.import_journal_entries","tags":["Migration"],"summary":"Import journal vouchers","description":"Full-history mode: the previous system's posted vouchers line for line (number, date, book, accounts, amounts kept), oldest year first. Books: JV general, SJ sales, PJ purchase, RV receipt, PV payment. Fiscal years the dates need are created. A number already in Tonbab is skipped. Each voucher must balance and use mapped, postable accounts; dates before cut-over only. Skip drafts, voided vouchers and year-end closing vouchers. Max 100 per call.\n\n**Scopes:** `accounting.manage`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"entries":{"type":"array","items":{"type":"object","properties":{"source_id":{"type":"string","minLength":1,"maxLength":120,"description":"The previous system's record id or number. Keys idempotency: the same source_id is never imported twice."},"no":{"type":"string","minLength":1,"maxLength":40,"description":"Voucher number as in the previous system (kept)."},"book":{"type":"string","enum":["JV","PV","RV","PJ","SJ"],"description":"JV general, SJ sales, PJ purchase, RV receipt, PV payment."},"date":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2025-12-31"},"description":{"type":"string","maxLength":500},"reference":{"type":"string","maxLength":120},"lines":{"type":"array","items":{"type":"object","properties":{"code":{"type":"string","minLength":1,"maxLength":40},"debit":{"type":"number","minimum":0,"maximum":10000000000000,"default":0},"credit":{"type":"number","minimum":0,"maximum":10000000000000,"default":0},"description":{"type":"string","maxLength":300}},"required":["code"]},"minItems":2,"maxItems":999,"example":[{"code":"11311","debit":1070,"credit":0},{"code":"41110","debit":0,"credit":1000},{"code":"21540","debit":0,"credit":70}]}},"required":["source_id","no","book","date","lines"]},"minItems":1,"maxItems":100},"dry_run":{"type":"boolean","default":false,"description":"Validate the whole batch in the database and roll it back. Always send a batch with dry_run=true first."},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["entries"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MigrationBatchResult"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/accounting/migration/documents":{"post":{"operationId":"migration.import_documents","tags":["Migration"],"summary":"Import sales and purchase documents","description":"Quotations, billing notes, invoices / tax invoices (cash sales: cash_sale=true + a receipt), credit / debit notes, bills (expenses, purchase tax invoices) and vendor credits, with their numbers and lines. Full history: entry_no links each to the voucher that posted it — nothing posts again. Opening balances: only documents still open at cut-over, with open_amount. Import a document before anything that references it. Max 100 per call.\n\n**Scopes:** `accounting.manage`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"documents":{"type":"array","items":{"type":"object","properties":{"source_id":{"type":"string","minLength":1,"maxLength":120,"description":"The previous system's record id or number. Keys idempotency: the same source_id is never imported twice."},"doc_type":{"type":"string","enum":["quotation","billing_note","invoice","credit_note","debit_note","bill","bill_credit"],"description":"invoice = invoice / tax invoice (also cash sales with cash_sale=true); bill = expense / purchase tax invoice; bill_credit = vendor credit."},"cash_sale":{"type":"boolean"},"doc_no":{"type":"string","minLength":1,"maxLength":40},"status":{"type":"string","enum":["issued","void","accepted","rejected"],"default":"issued","description":"issued | void (quotations also accepted | rejected)."},"doc_date":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2025-12-31"},"due_date":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2025-12-31"},"party_name":{"type":"string","minLength":1,"maxLength":300},"party_tax_id":{"type":"string","maxLength":40},"party_branch":{"type":"string","maxLength":60},"party_address":{"type":"string","maxLength":1000},"contact_name":{"type":"string","maxLength":200},"ref_type":{"type":"string","enum":["quotation","billing_note","invoice","credit_note","debit_note","bill","bill_credit"]},"ref_no":{"type":"string","maxLength":40,"description":"The document this came from / corrects (must be imported first)."},"entry_no":{"type":"string","maxLength":40,"description":"Full history: the voucher (already imported) that posted it. Nothing is posted again."},"is_vat":{"type":"boolean","default":false},"price_includes_vat":{"type":"boolean","default":false},"vat_rate":{"type":"number","minimum":0,"maximum":30,"default":7},"subtotal":{"type":"number","minimum":0,"maximum":10000000000000},"vat_amount":{"type":"number","minimum":0,"maximum":10000000000000,"default":0},"total":{"type":"number","minimum":0,"maximum":10000000000000},"wht_rate":{"type":"number","minimum":0,"maximum":30,"default":0},"wht_amount":{"type":"number","minimum":0,"maximum":10000000000000,"default":0},"discount_amount":{"type":"number","minimum":0,"maximum":10000000000000,"default":0},"external_no":{"type":"string","maxLength":60,"description":"Bills: the vendor's tax invoice number."},"external_date":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2025-12-31"},"vat_period":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2025-12-31","description":"VAT month (first day). Default: the document month."},"title":{"type":"string","maxLength":300},"notes":{"type":"string","maxLength":2000},"reason":{"type":"string","maxLength":500},"void_reason":{"type":"string","maxLength":500},"open_amount":{"type":"number","minimum":0,"maximum":10000000000000,"description":"Opening-balances mode: what is still unpaid at cut-over (default: the total)."},"sales_person":{"type":"string","maxLength":200,"description":"Salesperson name from the previous system (shown as the owner)."},"currency":{"type":"string","pattern":"^[A-Za-z]{3}$","description":"Foreign currency (ISO code). Amounts stay in baht; send fx_rate too."},"fx_rate":{"type":"number","minimum":0,"exclusiveMinimum":true,"maximum":1000000,"description":"Baht per 1 unit of currency."},"fc_total":{"type":"number","minimum":0,"maximum":10000000000000,"description":"Total in the foreign currency (default: total / fx_rate)."},"lines":{"type":"array","items":{"type":"object","properties":{"description":{"type":"string","maxLength":500},"quantity":{"type":"number","default":1},"unit":{"type":"string","maxLength":30},"unit_price":{"type":"number","minimum":-10000000000000,"maximum":10000000000000,"default":0},"discount_amount":{"type":"number","minimum":0,"maximum":10000000000000,"default":0},"amount":{"type":"number","minimum":0,"maximum":10000000000000},"vat_code":{"type":"string","enum":["vat","zero","exempt","none","non_claimable"],"default":"vat"},"vat_amount":{"type":"number","minimum":0,"maximum":10000000000000,"default":0},"account_code":{"type":"string","maxLength":40},"product_code":{"type":"string","maxLength":60,"description":"The previous system's product code; resolved through import_migration_products / the SKU. Unknown codes are an error."}},"required":["amount"]},"maxItems":500,"default":[]}},"required":["source_id","doc_type","doc_no","doc_date","party_name","subtotal","total"]},"minItems":1,"maxItems":100},"dry_run":{"type":"boolean","default":false,"description":"Validate the whole batch in the database and roll it back. Always send a batch with dry_run=true first."},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["documents"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MigrationBatchResult"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/accounting/migration/payments":{"post":{"operationId":"migration.import_payments","tags":["Migration"],"summary":"Import receipts and payments","description":"Full-history mode: customer receipts and supplier payments with the bank / cash account (bank_code), withholding tax (wht_amount, wht_base, wht_rate, wht_form pnd3 / pnd53 / pnd54, wht_cert_no), fees, the voucher that posted it (entry_no) and the documents each settled (allocations, imported first). A number already in Tonbab is skipped. Max 200 per call.\n\n**Scopes:** `accounting.manage`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"payments":{"type":"array","items":{"type":"object","properties":{"source_id":{"type":"string","minLength":1,"maxLength":120,"description":"The previous system's record id or number. Keys idempotency: the same source_id is never imported twice."},"kind":{"type":"string","enum":["receipt","payment"]},"pay_no":{"type":"string","minLength":1,"maxLength":40},"status":{"type":"string","enum":["posted","void"],"default":"posted"},"pay_date":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2025-12-31"},"party_name":{"type":"string","minLength":1,"maxLength":300},"party_tax_id":{"type":"string","maxLength":40},"party_branch":{"type":"string","maxLength":60},"party_address":{"type":"string","maxLength":1000},"bank_code":{"type":"string","minLength":1,"maxLength":40,"description":"GL code of the bank / cash account (set up with import_migration_bank_accounts)."},"method":{"type":"string","enum":["transfer","cash","cheque","promptpay","card","other"],"default":"transfer"},"reference":{"type":"string","maxLength":120},"amount":{"type":"number","minimum":0,"maximum":10000000000000,"description":"Money in / out of the bank account (after withholding and fees)."},"wht_amount":{"type":"number","minimum":0,"maximum":10000000000000,"default":0},"wht_base":{"type":"number","minimum":0,"maximum":10000000000000},"wht_rate":{"type":"number","minimum":0,"maximum":30},"wht_form":{"type":"string","enum":["pnd3","pnd53","pnd54"]},"wht_income_type":{"type":"string","maxLength":40},"wht_cert_no":{"type":"string","maxLength":40},"fee_amount":{"type":"number","minimum":0,"maximum":10000000000000,"default":0},"notes":{"type":"string","maxLength":2000},"entry_no":{"type":"string","maxLength":40,"description":"The RV / PV voucher (already imported) that posted it."},"currency":{"type":"string","pattern":"^[A-Za-z]{3}$","description":"Foreign currency (ISO code). Amounts stay in baht; send fx_rate too."},"fx_rate":{"type":"number","minimum":0,"exclusiveMinimum":true,"maximum":1000000,"description":"Baht per 1 unit of currency."},"allocations":{"type":"array","items":{"type":"object","properties":{"doc_type":{"type":"string","enum":["invoice","debit_note","billing_note","bill","credit_note","bill_credit"]},"doc_no":{"type":"string","minLength":1,"maxLength":40},"amount":{"type":"number","minimum":0,"maximum":10000000000000}},"required":["doc_type","doc_no","amount"]},"maxItems":200,"default":[]}},"required":["source_id","kind","pay_no","pay_date","party_name","bank_code","amount"]},"minItems":1,"maxItems":200},"dry_run":{"type":"boolean","default":false,"description":"Validate the whole batch in the database and roll it back. Always send a batch with dry_run=true first."},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["payments"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MigrationBatchResult"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/accounting/migration/withholding":{"post":{"operationId":"migration.import_wht","tags":["Migration"],"summary":"Import withholding certificates","description":"Withholding-tax certificate details (50 ทวิ: number, book, date; form pnd3 / pnd53 / pnd54; income type) for receipts / payments THIS job imported. Amounts never change — send them with import_accounting_payments. Max 200 per call.\n\n**Scopes:** `accounting.manage`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"certificates":{"type":"array","items":{"type":"object","properties":{"source_id":{"type":"string","minLength":1,"maxLength":120,"description":"The previous system's record id or number. Keys idempotency: the same source_id is never imported twice."},"kind":{"type":"string","enum":["receipt","payment"],"default":"payment"},"pay_no":{"type":"string","minLength":1,"maxLength":40},"wht_form":{"type":"string","enum":["pnd3","pnd53","pnd54"]},"wht_income_type":{"type":"string","maxLength":40},"wht_cert_no":{"type":"string","maxLength":40},"wht_cert_book":{"type":"string","maxLength":40},"wht_cert_date":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2025-12-31"}},"required":["source_id","pay_no"]},"minItems":1,"maxItems":200},"dry_run":{"type":"boolean","default":false,"description":"Validate the whole batch in the database and roll it back. Always send a batch with dry_run=true first."},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["certificates"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MigrationBatchResult"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/accounting/migration/reconcile":{"post":{"operationId":"migration.reconcile_trial_balance","tags":["Migration"],"summary":"Reconcile trial balance","description":"Compare the previous system's trial balance with Tonbab's, account by account, codes mapped through the account map. basis \"closing\" (default): closing balance per account (debit − credit; credit balances negative) as of as_of; profit of earlier years not yet closed in Tonbab is reported separately (or folded into retained_earnings_code); the result is saved on the job (replacing the previous one) and is what finalizing checks. basis \"movement\": net movement (debit − credit) per account from \"from\" to as_of — the general ledger's period totals — to find the month and account that differ; not saved. Max 1000 accounts.\n\n**Scopes:** `accounting.manage`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"as_of":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2025-12-31"},"basis":{"type":"string","enum":["closing","movement"],"default":"closing"},"from":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2025-12-31","description":"basis movement: first day of the period (default: the fiscal-year start)."},"accounts":{"type":"array","items":{"type":"object","properties":{"code":{"type":"string","minLength":1,"maxLength":40},"balance":{"type":"number","minimum":-10000000000000,"maximum":10000000000000}},"required":["code","balance"]},"minItems":1,"maxItems":1000},"scope":{"type":"string","enum":["all","balance_sheet"],"default":"all"},"retained_earnings_code":{"type":"string","maxLength":20},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["as_of","accounts"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MigrationTrialBalanceReconciliation"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/accounting/migration/open-items":{"post":{"operationId":"migration.compare_open_items","tags":["Migration"],"summary":"Compare open receivables and payables","description":"Compare the previous system's open receivables (ar) and payables (ap) per party with Tonbab's open documents (issued, unpaid part; credit notes / vendor credits reduce). Parties match by full tax id, else name. The result is saved on the job (replacing the previous one). Max 1000 rows.\n\n**Scopes:** `accounting.manage`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"as_of":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2025-12-31"},"items":{"type":"array","items":{"type":"object","properties":{"kind":{"type":"string","enum":["ar","ap"]},"party_name":{"type":"string","minLength":1,"maxLength":300},"party_tax_id":{"type":"string","maxLength":40},"open_amount":{"type":"number","minimum":-10000000000000,"maximum":10000000000000}},"required":["kind","party_name","open_amount"]},"minItems":1,"maxItems":1000},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["items"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MigrationOpenItems"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/accounting/migration/request-review":{"post":{"operationId":"migration.request_review","tags":["Migration"],"summary":"Hand migration over for review","description":"Finish your part: hand the migration job to the person for review, with a short summary (counts, differences left, anything skipped and why). The job stops accepting imports; the person then finalizes it, rolls it back, or reopens it in Settings → Migration → Accounting. This never finalizes by itself.\n\n**Scopes:** `accounting.manage`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"summary":{"type":"string","minLength":1,"maxLength":4000},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["summary"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MigrationReviewRequested"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/accounting/migration/general-ledger":{"post":{"operationId":"migration.import_general_ledger","tags":["Migration"],"summary":"Import general-ledger lines","description":"Full-history mode, for previous systems that only export a general-ledger listing (one row per account line: account_code, date, doc_no, debit, credit, description) instead of vouchers. Lines are grouped into vouchers by doc_no + date (a number on several dates becomes <no>-<MM>), the book comes from \"book\" or the number prefix (SV→SJ, UV→PJ, RV, PV, else JV), codes go through the account map. A group that does not balance is refused with its own error; the rest import. One result per voucher. Max 1000 lines per call — keep a voucher's lines in one call.\n\n**Scopes:** `accounting.manage`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"lines":{"type":"array","items":{"type":"object","properties":{"account_code":{"type":"string","minLength":1,"maxLength":40},"date":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2025-12-31"},"doc_no":{"type":"string","minLength":1,"maxLength":36},"debit":{"type":"number","minimum":0,"maximum":10000000000000,"default":0},"credit":{"type":"number","minimum":0,"maximum":10000000000000,"default":0},"description":{"type":"string","maxLength":300},"book":{"type":"string","maxLength":4},"reference":{"type":"string","maxLength":120}},"required":["account_code","date","doc_no"]},"minItems":2,"maxItems":1000,"example":[{"account_code":"11311","date":"2025-03-15","doc_no":"SV2025030001","debit":1070,"credit":0},{"account_code":"41110","date":"2025-03-15","doc_no":"SV2025030001","debit":0,"credit":1070}]},"dry_run":{"type":"boolean","default":false,"description":"Validate the whole batch in the database and roll it back. Always send a batch with dry_run=true first."},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["lines"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MigrationBatchResult"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/accounting/general-ledger":{"get":{"operationId":"accounting.general_ledger","tags":["Accounting"],"summary":"General ledger for an account","description":"Posted ledger lines of ONE account between two dates (oldest first): date, voucher number, book, descriptions, debit, credit and running balance, with the opening and closing balance. Use it to compare an account line by line with another system (e.g. during a migration). Pages with offset.\n\n**Scopes:** `accounting.view`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":20},"required":true,"name":"account_code","in":"query"},{"schema":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2025-12-31"},"required":true,"name":"from","in":"query"},{"schema":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2025-12-31"},"required":true,"name":"to","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":1000,"default":500},"required":false,"name":"limit","in":"query"},{"schema":{"type":"integer","nullable":true,"minimum":0,"maximum":1000000,"default":0},"required":false,"name":"offset","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GeneralLedger"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/accounting/migration/purchase-history":{"post":{"operationId":"migration.import_purchase_history","tags":["Migration"],"summary":"Import purchase orders and goods receipts (history)","description":"Purchase orders with their goods receipts as HISTORY ONLY: the PO is filed closed and each receipt posted, but no stock moves, no lots are made, costs (AVCO / FIFO) are untouched and nothing triggers purchase requests or auto-POs. bill_no links the PO to the bill this job imported from it. The vendor must already be a contact; line product_code resolves through import_migration_products. A PO number already in Tonbab is skipped. Max 50 POs per call.\n\n**Scopes:** `accounting.manage`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"purchase_orders":{"type":"array","items":{"type":"object","properties":{"source_id":{"type":"string","minLength":1,"maxLength":120,"description":"The previous system's record id or number. Keys idempotency: the same source_id is never imported twice."},"po_no":{"type":"string","minLength":1,"maxLength":40},"order_date":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2025-12-31"},"vendor_name":{"type":"string","minLength":1,"maxLength":300},"vendor_tax_id":{"type":"string","maxLength":40},"currency":{"type":"string","pattern":"^[A-Za-z]{3}$","description":"Foreign currency (ISO code). Amounts stay in baht; send fx_rate too."},"fx_rate":{"type":"number","minimum":0,"exclusiveMinimum":true,"maximum":1000000,"description":"Baht per 1 unit of currency."},"vat_type":{"type":"string","enum":["vat_7","non_vat"],"default":"vat_7"},"subtotal":{"type":"number","minimum":0,"maximum":10000000000000,"default":0},"vat_amount":{"type":"number","minimum":0,"maximum":10000000000000,"default":0},"total":{"type":"number","minimum":0,"maximum":10000000000000,"default":0},"remarks":{"type":"string","maxLength":2000},"bill_no":{"type":"string","maxLength":40,"description":"The bill (imported by this job) raised from this PO."},"lines":{"type":"array","items":{"type":"object","properties":{"item_name":{"type":"string","minLength":1,"maxLength":300},"description":{"type":"string","maxLength":2000},"product_code":{"type":"string","maxLength":60},"quantity":{"type":"number","minimum":0,"exclusiveMinimum":true,"maximum":1000000000},"unit":{"type":"string","maxLength":20},"unit_price":{"type":"number","minimum":-10000000000000,"maximum":10000000000000,"default":0},"total":{"type":"number","minimum":-10000000000000,"maximum":10000000000000},"line_type":{"type":"string","enum":["goods","service"],"default":"goods"}},"required":["item_name","quantity"]},"minItems":1,"maxItems":500},"receipts":{"type":"array","items":{"type":"object","properties":{"gr_no":{"type":"string","minLength":1,"maxLength":40},"received_date":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2025-12-31"},"warehouse_code":{"type":"string","maxLength":40},"lines":{"type":"array","items":{"type":"object","properties":{"line_no":{"type":"integer","minimum":1,"maximum":500},"quantity":{"type":"number","minimum":0,"exclusiveMinimum":true,"maximum":1000000000}},"required":["line_no"]},"minItems":1,"maxItems":500}},"required":["gr_no","received_date","lines"]},"maxItems":50,"default":[]}},"required":["source_id","po_no","order_date","vendor_name","lines"]},"minItems":1,"maxItems":50},"dry_run":{"type":"boolean","default":false,"description":"Validate the whole batch in the database and roll it back. Always send a batch with dry_run=true first."},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["purchase_orders"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MigrationBatchResult"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/accounting/migration/fixed-assets":{"post":{"operationId":"migration.import_fixed_assets","tags":["Migration"],"summary":"Import fixed assets","description":"The fixed-asset register at cut-over: number, name, class, cost, acquisition / in-service date, straight-line useful life (years) or rate, salvage value, accumulated depreciation as of opening_as_of (default: the day before cut-over), and the asset / accumulated-depreciation / expense account codes (mapped). Tonbab depreciates from the month after opening_as_of; nothing is posted now. An asset number already in Tonbab is skipped. Max 200 per call.\n\n**Scopes:** `accounting.manage`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"assets":{"type":"array","items":{"type":"object","properties":{"source_id":{"type":"string","minLength":1,"maxLength":120,"description":"The previous system's record id or number. Keys idempotency: the same source_id is never imported twice."},"asset_no":{"type":"string","pattern":"^[0-9A-Za-z./-]{1,30}$","description":"Kept when given (else FA-0001…)."},"name":{"type":"string","minLength":1,"maxLength":200},"asset_class":{"type":"string","enum":["land","building","temp_building","leasehold","intangible","computer","vehicle_passenger","machinery","furniture","office_equipment","other"]},"cost":{"type":"number","minimum":0,"exclusiveMinimum":true,"maximum":10000000000000},"salvage_value":{"type":"number","minimum":0,"maximum":10000000000000,"default":0},"acquired_date":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2025-12-31"},"in_service_date":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2025-12-31"},"useful_life_years":{"type":"number","minimum":0,"maximum":100},"rate_percent":{"type":"number","minimum":0,"maximum":100},"tax_rate_percent":{"type":"number","minimum":0,"maximum":100},"opening_accumulated":{"type":"number","minimum":0,"maximum":10000000000000,"default":0},"opening_tax_accumulated":{"type":"number","minimum":0,"maximum":10000000000000},"opening_as_of":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2025-12-31"},"asset_account_code":{"type":"string","minLength":1,"maxLength":40},"accdep_account_code":{"type":"string","maxLength":40},"expense_account_code":{"type":"string","maxLength":40},"location":{"type":"string","maxLength":200},"custodian":{"type":"string","maxLength":200},"serial_no":{"type":"string","maxLength":120},"vendor_name":{"type":"string","maxLength":300},"notes":{"type":"string","maxLength":1000}},"required":["source_id","name","asset_class","cost","acquired_date","asset_account_code"]},"minItems":1,"maxItems":200},"dry_run":{"type":"boolean","default":false,"description":"Validate the whole batch in the database and roll it back. Always send a batch with dry_run=true first."},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["assets"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MigrationBatchResult"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/accounting/migration/products":{"post":{"operationId":"migration.import_products","tags":["Migration"],"summary":"Link products","description":"Link the previous system's products to Tonbab products so document and PO lines can carry product_code. Each is matched by SKU / code, then exact name. Unmatched ones are created as minimal products ONLY when create_missing=true AND the person allowed product creation on the job (Settings → Migration → Accounting); otherwise they come back as not_found. Existing products are never changed. Use the previous system's product code as source_id. Max 300 per call.\n\n**Scopes:** `accounting.manage`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"products":{"type":"array","items":{"type":"object","properties":{"source_id":{"type":"string","minLength":1,"maxLength":120,"description":"The previous system's record id or number. Keys idempotency: the same source_id is never imported twice."},"code":{"type":"string","maxLength":60},"name":{"type":"string","minLength":1,"maxLength":300},"unit":{"type":"string","maxLength":20},"type":{"type":"string","enum":["goods","service"],"default":"goods"}},"required":["source_id","name"]},"minItems":1,"maxItems":300},"create_missing":{"type":"boolean","default":false},"dry_run":{"type":"boolean","default":false,"description":"Validate the whole batch in the database and roll it back. Always send a batch with dry_run=true first."},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["products"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MigrationBatchResult"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/accounting/migration/attachments":{"post":{"operationId":"migration.attach_file","tags":["Migration"],"summary":"Attach an original file","description":"Attach the original PDF / image of a document this job imported (by doc_type + doc_no), from an https URL or base64 content (max 10 MB; plan storage limits apply). Stored privately in the company's files and shown on the document. The same source_id is attached once.\n\n**Scopes:** `accounting.manage`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"source_id":{"type":"string","minLength":1,"maxLength":120,"description":"The previous system's record id or number. Keys idempotency: the same source_id is never imported twice."},"doc_type":{"type":"string","enum":["quotation","billing_note","invoice","credit_note","debit_note","bill","bill_credit"]},"doc_no":{"type":"string","minLength":1,"maxLength":40},"file_name":{"type":"string","minLength":1,"maxLength":200},"content_type":{"type":"string","maxLength":100},"url":{"type":"string","maxLength":2000,"format":"uri","description":"https only. The file is downloaded once."},"base64":{"type":"string","maxLength":13981022},"dry_run":{"type":"boolean","default":false,"description":"Validate the whole batch in the database and roll it back. Always send a batch with dry_run=true first."},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["source_id","doc_type","doc_no","file_name"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MigrationBatchResult"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/crm/migration":{"get":{"operationId":"crm_migration.start","tags":["Migration"],"summary":"Start CRM migration","description":"Call first when moving a company's CRM (leads, accounts, contacts, deals with value, activities, notes, owners) from its previous CRM into Tonbab. Returns the CRM migration job a person opened for this connection, the batch limits, the playbook to follow, and what to map to: Tonbab's pipelines with their stages, and how many members / People employees owners can match. If no job is open (or it is granted to another connection), says how the person opens / grants one. Never writes.\n\n**Scopes:** `crm.pipeline.manage`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CrmMigrationStart"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/crm/migration/status":{"get":{"operationId":"crm_migration.status","tags":["Migration"],"summary":"CRM migration status","description":"The current (or latest) CRM migration job: status, counts per step (created / updated / linked / skipped / errors), the last reconciliation, findings, the person's owner decisions, and every source owner's mapping (matched_user / matched_employee_no_login / unmatched / confirmed, the decision transfer / invite / keep, counts, candidates). owners_awaiting_decision lists the owners whose deals, leads and activities wait for a person. Never writes.\n\n**Scopes:** `crm.pipeline.manage`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CrmMigrationStatus"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/crm/migration/rollback-preview":{"get":{"operationId":"crm_migration.rollback_preview","tags":["Migration"],"summary":"Preview CRM migration rollback","description":"What undoing the CRM migration job would remove and keep. Undo is available until the job is finalized, for 30 days after its last import (window_ends). It removes only records the job CREATED that nobody changed or uses since; records changed after import (an imported deal moved / closed / re-valued, an edit), referenced since (a quotation on an imported deal, a person's activity / note / file, a contact role) or needed by those are KEPT and listed with the reason. Matched records get the blank fields the job filled cleared. Never writes: only a person can undo, in Settings → Migration → CRM.\n\n**Scopes:** `crm.pipeline.manage`","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CrmMigrationRollbackPreview"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/crm/migration/users":{"post":{"operationId":"crm_migration.map_users","tags":["Migration"],"summary":"Map CRM owners to your team","description":"Every user who owns a record in the previous CRM (name + email) → Tonbab. Matched against your team: members, and People employees when the People module is on (members only otherwise), in this order: login / work email, English full name, Thai full name, nickname — one person per step, else no match. Results per owner: matched_user (records get that owner); matched_employee_no_login (records go to the job's default owner and keep the original owner's name, to re-assign once they get a login); unmatched (default owner + the name, with fuzzy candidates as suggestions only — never applied). target_user_id / target_employee_id pick someone explicitly. Send counts (the source's deals open / won / lost + value in baht, leads, activities) so the person sees them. For each owner unmatched or without a login, a person decides in Settings → Migration → CRM: transfer to a member, invite as a new user, or keep with the default owner; until then that owner's deals, leads and activities are refused (owner_undecided). A person's decision is never replaced. Send dry_run=true first. Max 200 per call.\n\n**Scopes:** `crm.pipeline.manage`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"users":{"type":"array","items":{"type":"object","properties":{"source_id":{"type":"string","minLength":1,"maxLength":120,"description":"The previous CRM's record id. Keys idempotency: the same source_id is never imported twice."},"name":{"type":"string","maxLength":200,"example":"Somchai Thongdee"},"email":{"type":"string","maxLength":200,"example":"somchai@example.co.th"},"target_user_id":{"type":"string","format":"uuid","description":"A Tonbab member (list_users) to use for this owner, overriding the automatic match."},"target_employee_id":{"type":"string","format":"uuid","description":"A People employee (list_employees) to use for this owner. Without a login, a person decides (transfer / invite / keep)."},"counts":{"type":"object","properties":{"deals_open":{"type":"integer","minimum":0},"deals_won":{"type":"integer","minimum":0},"deals_lost":{"type":"integer","minimum":0},"deals_value":{"type":"number","minimum":0,"maximum":10000000000000,"description":"Total deal value in baht."},"leads":{"type":"integer","minimum":0},"activities":{"type":"integer","minimum":0}},"description":"This owner's records in the previous CRM, shown on the person's decision card."}},"required":["source_id"]},"minItems":1,"maxItems":200},"dry_run":{"type":"boolean","default":false,"description":"Run the whole batch in the database and roll it back. Always send a batch with dry_run=true first."},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["users"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/CrmMigrationBatchResult"},{"type":"object","properties":{"owners_awaiting_decision":{"type":"array","items":{"type":"string"}}},"required":["owners_awaiting_decision"]}],"description":"One result per item, in order. created = new in Tonbab; linked = matched an existing record (updated = and filled its blank fields); skipped = this source_id is already imported (re-run is safe); error = not imported (code + message). dry_run=true: nothing was saved."}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/crm/migration/pipelines":{"post":{"operationId":"crm_migration.map_pipelines","tags":["Migration"],"summary":"Map CRM pipelines and stages","description":"Each source pipeline with all its stages → a Tonbab pipeline. Matched by target_pipeline_id or exact name; create=true creates it when nothing matches. Stages match by target_stage_id or name within the pipeline; stages that match nothing are created (with probability and kind open / won / lost) when the pipeline was created by this job or create=true. Existing Tonbab stages keep their own kind and probability. A postponed / on-hold stage is open at 0%. Stage results come back per pipeline. Send dry_run=true first. Max 50 per call.\n\n**Scopes:** `crm.pipeline.manage`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"pipelines":{"type":"array","items":{"type":"object","properties":{"source_id":{"type":"string","minLength":1,"maxLength":120,"description":"The previous CRM's record id. Keys idempotency: the same source_id is never imported twice."},"name":{"type":"string","minLength":1,"maxLength":120},"name_th":{"type":"string","maxLength":120},"target_pipeline_id":{"type":"string","format":"uuid","description":"An existing Tonbab pipeline (start_crm_migration lists them). Default: match by name."},"create":{"type":"boolean","default":false,"description":"Create the pipeline (and stages that match nothing) when there is no match."},"stages":{"type":"array","items":{"type":"object","properties":{"source_id":{"type":"string","minLength":1,"maxLength":120,"description":"The previous CRM's record id. Keys idempotency: the same source_id is never imported twice."},"name":{"type":"string","minLength":1,"maxLength":120},"name_th":{"type":"string","maxLength":120},"probability":{"type":"number","minimum":0,"maximum":100},"kind":{"type":"string","enum":["open","won","lost"],"default":"open","description":"won / lost for closed stages; a postponed / on-hold stage is open at 0%."},"target_stage_id":{"type":"string","format":"uuid"}},"required":["source_id","name"]},"maxItems":50,"default":[]}},"required":["source_id","name"]},"minItems":1,"maxItems":50},"dry_run":{"type":"boolean","default":false,"description":"Run the whole batch in the database and roll it back. Always send a batch with dry_run=true first."},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["pipelines"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CrmMigrationBatchResult"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/crm/migration/accounts":{"post":{"operationId":"crm_migration.import_accounts","tags":["Migration"],"summary":"Import CRM accounts","description":"Accounts → companies (customers). Matched by full Thai tax id + branch, then exact normalised name (legal-form words ignored); masked or foreign tax ids are never used to match. A match only gets its EMPTY fields filled (phone, email, address, tax id, sales owner) and is flagged as a customer — nothing is overwritten, and a rollback clears exactly what was filled. Otherwise a company is created with the next company code. Duplicates in the previous CRM: send the canonical one first, the others with duplicate_of. Send dry_run=true first. Max 200 per call.\n\n**Scopes:** `crm.pipeline.manage`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"accounts":{"type":"array","items":{"type":"object","properties":{"source_id":{"type":"string","minLength":1,"maxLength":120,"description":"The previous CRM's record id. Keys idempotency: the same source_id is never imported twice."},"name":{"type":"string","minLength":1,"maxLength":300},"tax_id":{"type":"string","maxLength":40,"description":"13-digit Thai tax id. Masked or foreign ids are never used for matching (foreign ids are kept as foreign_tax_id on new companies)."},"branch":{"type":"string","maxLength":20,"description":"Branch number (00000 = head office, the default)."},"phone":{"type":"string","maxLength":60},"email":{"type":"string","maxLength":200},"address":{"type":"string","maxLength":1000},"country":{"type":"string","maxLength":60},"description":{"type":"string","maxLength":3000},"owner_source_id":{"type":"string","minLength":1,"maxLength":120,"description":"source_id of the owner (map_crm_users) (imported earlier in this job)."},"duplicate_of":{"type":"string","minLength":1,"maxLength":120,"description":"source_id of the canonical account this one duplicates (imported earlier in this job)."},"created_at":{"type":"string","maxLength":40,"pattern":"^\\d{4}-\\d{2}-\\d{2}([T ][0-9:.]+(Z|[+-]\\d{2}:?\\d{2})?)?$","description":"ISO date or date-time (kept as the record's original date).","example":"2026-03-05T10:30:00+07:00"}},"required":["source_id","name"]},"minItems":1,"maxItems":200},"dry_run":{"type":"boolean","default":false,"description":"Run the whole batch in the database and roll it back. Always send a batch with dry_run=true first."},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["accounts"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CrmMigrationBatchResult"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/crm/migration/contacts":{"post":{"operationId":"crm_migration.import_contacts","tags":["Migration"],"summary":"Import CRM contacts","description":"Contacts → one person each (company_contact), linked to their account with a role chosen by behaviour (decision_maker / purchasing). Deduplicated by email or mobile among the account's contacts (no account: by email); a match only gets its empty fields filled. Send dry_run=true first. Max 200 per call.\n\n**Scopes:** `crm.pipeline.manage`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"contacts":{"type":"array","items":{"type":"object","properties":{"source_id":{"type":"string","minLength":1,"maxLength":120,"description":"The previous CRM's record id. Keys idempotency: the same source_id is never imported twice."},"name":{"type":"string","maxLength":200},"first_name":{"type":"string","maxLength":100},"last_name":{"type":"string","maxLength":100},"email":{"type":"string","maxLength":200},"phone":{"type":"string","maxLength":60},"mobile":{"type":"string","maxLength":60},"line_id":{"type":"string","maxLength":100},"job_title":{"type":"string","maxLength":200},"account_source_id":{"type":"string","minLength":1,"maxLength":120,"description":"source_id of the account (imported earlier in this job)."},"decision_maker":{"type":"boolean","description":"Role on the account: the company's decision-maker role kind."},"purchasing":{"type":"boolean","description":"Role on the account: the company's purchasing role kind."},"is_primary":{"type":"boolean","description":"Primary contact, only when the account has none yet."},"note":{"type":"string","maxLength":2000},"created_at":{"type":"string","maxLength":40,"pattern":"^\\d{4}-\\d{2}-\\d{2}([T ][0-9:.]+(Z|[+-]\\d{2}:?\\d{2})?)?$","description":"ISO date or date-time (kept as the record's original date).","example":"2026-03-05T10:30:00+07:00"}},"required":["source_id"]},"minItems":1,"maxItems":200},"dry_run":{"type":"boolean","default":false,"description":"Run the whole batch in the database and roll it back. Always send a batch with dry_run=true first."},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["contacts"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CrmMigrationBatchResult"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/crm/migration/leads":{"post":{"operationId":"crm_migration.import_leads","tags":["Migration"],"summary":"Import CRM leads","description":"Leads with need, channel, status, value, owner, account / contact and the original created date. A converted lead links to its deal (deal_source_id here, or lead_source_id on the deal) and is marked qualified. Send dry_run=true first. Max 200 per call.\n\n**Scopes:** `crm.pipeline.manage`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"leads":{"type":"array","items":{"type":"object","properties":{"source_id":{"type":"string","minLength":1,"maxLength":120,"description":"The previous CRM's record id. Keys idempotency: the same source_id is never imported twice."},"need":{"type":"string","minLength":1,"maxLength":2000,"description":"What the lead asked for (the previous CRM's lead title / description)."},"channel":{"type":"string","enum":["email","phone","line","meta","website","walkin","referral","other"],"default":"other"},"status":{"type":"string","enum":["new","assigned","contacted","qualified","disqualified"],"default":"new"},"value":{"type":"number","minimum":0,"maximum":10000000000000},"currency":{"type":"string","pattern":"^[A-Za-z]{3}$","description":"ISO currency of the amount (default THB). Not THB: send fx_rate (baht per 1 unit). Deals keep their currency, rate and amount; totals use baht. Lead values are stored in baht."},"fx_rate":{"type":"number","minimum":0,"exclusiveMinimum":true,"maximum":1000000,"description":"Baht per 1 unit of currency."},"contact_hint":{"type":"string","maxLength":200,"description":"Name / company as typed on the lead when it has no contact."},"account_source_id":{"type":"string","minLength":1,"maxLength":120,"description":"source_id of the account (imported earlier in this job)."},"contact_source_id":{"type":"string","minLength":1,"maxLength":120,"description":"source_id of the contact (imported earlier in this job)."},"owner_source_id":{"type":"string","minLength":1,"maxLength":120,"description":"source_id of the owner (map_crm_users) (imported earlier in this job)."},"deal_source_id":{"type":"string","minLength":1,"maxLength":120,"description":"source_id of the deal it was converted to (imported earlier in this job)."},"first_contact_at":{"type":"string","maxLength":40,"pattern":"^\\d{4}-\\d{2}-\\d{2}([T ][0-9:.]+(Z|[+-]\\d{2}:?\\d{2})?)?$","description":"ISO date or date-time (kept as the record's original date).","example":"2026-03-05T10:30:00+07:00"},"contact_note":{"type":"string","maxLength":1500},"disqualify_reason":{"type":"string","maxLength":300},"created_at":{"type":"string","maxLength":40,"pattern":"^\\d{4}-\\d{2}-\\d{2}([T ][0-9:.]+(Z|[+-]\\d{2}:?\\d{2})?)?$","description":"ISO date or date-time (kept as the record's original date).","example":"2026-03-05T10:30:00+07:00"}},"required":["source_id","need"]},"minItems":1,"maxItems":200},"dry_run":{"type":"boolean","default":false,"description":"Run the whole batch in the database and roll it back. Always send a batch with dry_run=true first."},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["leads"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CrmMigrationBatchResult"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/crm/migration/deals":{"post":{"operationId":"crm_migration.import_deals","tags":["Migration"],"summary":"Import CRM deals","description":"Deals with pipeline + stage (through map_crm_pipelines), VALUE (amount; non-THB with currency + fx_rate, stored in baht with the original amount noted), expected close, open / won / lost with dates and lost reason, owner, account, contact, tags, source channel and the original created date. Products are not imported — send the deal amount. A deal without an account goes under one \"No account (imported)\" company. Send dry_run=true first. Max 200 per call.\n\n**Scopes:** `crm.pipeline.manage`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"deals":{"type":"array","items":{"type":"object","properties":{"source_id":{"type":"string","minLength":1,"maxLength":120,"description":"The previous CRM's record id. Keys idempotency: the same source_id is never imported twice."},"title":{"type":"string","minLength":1,"maxLength":300},"pipeline_source_id":{"type":"string","minLength":1,"maxLength":120},"stage_source_id":{"type":"string","minLength":1,"maxLength":120},"amount":{"type":"number","minimum":0,"maximum":10000000000000,"description":"Deal value in its own currency (default THB). Stored natively: currency, fx_rate and the amount; totals use baht (amount × fx_rate)."},"currency":{"type":"string","pattern":"^[A-Za-z]{3}$","description":"ISO currency of the amount (default THB). Not THB: send fx_rate (baht per 1 unit). Deals keep their currency, rate and amount; totals use baht. Lead values are stored in baht."},"fx_rate":{"type":"number","minimum":0,"exclusiveMinimum":true,"maximum":1000000,"description":"Baht per 1 unit of currency."},"expected_close":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-03-31"},"status":{"type":"string","enum":["open","won","lost"],"description":"Default: the stage's kind."},"won_at":{"type":"string","maxLength":40,"pattern":"^\\d{4}-\\d{2}-\\d{2}([T ][0-9:.]+(Z|[+-]\\d{2}:?\\d{2})?)?$","description":"ISO date or date-time (kept as the record's original date).","example":"2026-03-05T10:30:00+07:00"},"lost_at":{"type":"string","maxLength":40,"pattern":"^\\d{4}-\\d{2}-\\d{2}([T ][0-9:.]+(Z|[+-]\\d{2}:?\\d{2})?)?$","description":"ISO date or date-time (kept as the record's original date).","example":"2026-03-05T10:30:00+07:00"},"closed_at":{"type":"string","maxLength":40,"pattern":"^\\d{4}-\\d{2}-\\d{2}([T ][0-9:.]+(Z|[+-]\\d{2}:?\\d{2})?)?$","description":"Won / lost date when the source has one closing date.","example":"2026-03-05T10:30:00+07:00"},"lost_reason":{"type":"string","maxLength":500},"owner_source_id":{"type":"string","minLength":1,"maxLength":120,"description":"source_id of the owner (map_crm_users) (imported earlier in this job)."},"account_source_id":{"type":"string","minLength":1,"maxLength":120,"description":"source_id of the account (none: the \"No account (imported)\" company) (imported earlier in this job)."},"contact_source_id":{"type":"string","minLength":1,"maxLength":120,"description":"source_id of the contact (imported earlier in this job)."},"lead_source_id":{"type":"string","minLength":1,"maxLength":120,"description":"source_id of the lead it came from (imported earlier in this job)."},"tags":{"type":"array","items":{"type":"string","minLength":1,"maxLength":40},"maxItems":20},"source_channel":{"type":"string","enum":["referral","repeat","line","facebook","website","phone","walkin","tender","event","other"]},"probability":{"type":"number","minimum":0,"maximum":100,"description":"Default: the stage's probability."},"note":{"type":"string","maxLength":3500},"created_at":{"type":"string","maxLength":40,"pattern":"^\\d{4}-\\d{2}-\\d{2}([T ][0-9:.]+(Z|[+-]\\d{2}:?\\d{2})?)?$","description":"ISO date or date-time (kept as the record's original date).","example":"2026-03-05T10:30:00+07:00"}},"required":["source_id","title","pipeline_source_id","stage_source_id"]},"minItems":1,"maxItems":200},"dry_run":{"type":"boolean","default":false,"description":"Run the whole batch in the database and roll it back. Always send a batch with dry_run=true first."},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["deals"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CrmMigrationBatchResult"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/crm/migration/activities":{"post":{"operationId":"crm_migration.import_activities","tags":["Migration"],"summary":"Import CRM activities","description":"Calls, meetings, tasks, visits, emails and LINE messages as CRM activities (source: import), done or planned, with the original date, duration and owner, linked to their deal / account / contact (nothing linked: the \"No account (imported)\" company). Send dry_run=true first. Max 200 per call.\n\n**Scopes:** `crm.pipeline.manage`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"activities":{"type":"array","items":{"type":"object","properties":{"source_id":{"type":"string","minLength":1,"maxLength":120,"description":"The previous CRM's record id. Keys idempotency: the same source_id is never imported twice."},"type":{"type":"string","enum":["call","meeting","task","visit","email","line","other"]},"title":{"type":"string","maxLength":300},"note":{"type":"string","maxLength":3500},"due_date":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-03-31"},"occurred_at":{"type":"string","maxLength":40,"pattern":"^\\d{4}-\\d{2}-\\d{2}([T ][0-9:.]+(Z|[+-]\\d{2}:?\\d{2})?)?$","description":"ISO date or date-time (kept as the record's original date).","example":"2026-03-05T10:30:00+07:00"},"done_at":{"type":"string","maxLength":40,"pattern":"^\\d{4}-\\d{2}-\\d{2}([T ][0-9:.]+(Z|[+-]\\d{2}:?\\d{2})?)?$","description":"ISO date or date-time (kept as the record's original date).","example":"2026-03-05T10:30:00+07:00"},"duration_minutes":{"type":"integer","minimum":0,"maximum":1440},"status":{"type":"string","enum":["planned","done","skipped"],"description":"Default: done when its date is in the past, else planned."},"owner_source_id":{"type":"string","minLength":1,"maxLength":120,"description":"source_id of the owner (map_crm_users) (imported earlier in this job)."},"deal_source_id":{"type":"string","minLength":1,"maxLength":120,"description":"source_id of the deal (imported earlier in this job)."},"account_source_id":{"type":"string","minLength":1,"maxLength":120,"description":"source_id of the account (imported earlier in this job)."},"contact_source_id":{"type":"string","minLength":1,"maxLength":120,"description":"source_id of the contact (imported earlier in this job)."},"created_at":{"type":"string","maxLength":40,"pattern":"^\\d{4}-\\d{2}-\\d{2}([T ][0-9:.]+(Z|[+-]\\d{2}:?\\d{2})?)?$","description":"ISO date or date-time (kept as the record's original date).","example":"2026-03-05T10:30:00+07:00"}},"required":["source_id","type"]},"minItems":1,"maxItems":200},"dry_run":{"type":"boolean","default":false,"description":"Run the whole batch in the database and roll it back. Always send a batch with dry_run=true first."},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["activities"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CrmMigrationBatchResult"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/crm/migration/notes":{"post":{"operationId":"crm_migration.import_notes","tags":["Migration"],"summary":"Import CRM notes","description":"Notes on deals, accounts and contacts, with the original author and date. Send dry_run=true first. Max 200 per call.\n\n**Scopes:** `crm.pipeline.manage`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"notes":{"type":"array","items":{"type":"object","properties":{"source_id":{"type":"string","minLength":1,"maxLength":120,"description":"The previous CRM's record id. Keys idempotency: the same source_id is never imported twice."},"body":{"type":"string","minLength":1,"maxLength":19000},"title":{"type":"string","maxLength":300},"parent_type":{"type":"string","enum":["deal","account","contact"]},"parent_source_id":{"type":"string","maxLength":120,"description":"Not found / empty: filed on the \"No account (imported)\" company."},"owner_source_id":{"type":"string","minLength":1,"maxLength":120,"description":"source_id of the owner (map_crm_users) (imported earlier in this job)."},"created_at":{"type":"string","maxLength":40,"pattern":"^\\d{4}-\\d{2}-\\d{2}([T ][0-9:.]+(Z|[+-]\\d{2}:?\\d{2})?)?$","description":"ISO date or date-time (kept as the record's original date).","example":"2026-03-05T10:30:00+07:00"}},"required":["source_id","body","parent_type"]},"minItems":1,"maxItems":200},"dry_run":{"type":"boolean","default":false,"description":"Run the whole batch in the database and roll it back. Always send a batch with dry_run=true first."},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["notes"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CrmMigrationBatchResult"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/crm/migration/attachments":{"post":{"operationId":"crm_migration.attach_file","tags":["Migration"],"summary":"Attach a file to an imported deal or account","description":"Attach an original file (PDF, image, spreadsheet) to a deal or account this job brought in, from an https URL or base64 content (max 10 MB; plan storage limits apply). Stored privately and shown in the deal's / company's files. The same source_id is attached once.\n\n**Scopes:** `crm.pipeline.manage`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"source_id":{"type":"string","minLength":1,"maxLength":120,"description":"The previous CRM's record id. Keys idempotency: the same source_id is never imported twice."},"parent_type":{"type":"string","enum":["deal","account"]},"parent_source_id":{"type":"string","minLength":1,"maxLength":120},"file_name":{"type":"string","minLength":1,"maxLength":200},"content_type":{"type":"string","maxLength":100},"url":{"type":"string","maxLength":2000,"format":"uri","description":"https only. Downloaded once."},"base64":{"type":"string","maxLength":13981022},"dry_run":{"type":"boolean","default":false,"description":"Run the whole batch in the database and roll it back. Always send a batch with dry_run=true first."},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["source_id","parent_type","parent_source_id","file_name"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CrmMigrationBatchResult"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/crm/migration/reconcile":{"post":{"operationId":"crm_migration.reconcile","tags":["Migration"],"summary":"Reconcile CRM migration","description":"Compare the previous CRM's totals — per pipeline (its source_id): open / won / lost deal count and value in baht — and its record counts (accounts, contacts, leads, deals, activities, notes) with what this source has in Tonbab. Stores the result on the job (the person sees it in Settings; finalizing needs it balanced or a reason). Max 200 pipelines.\n\n**Scopes:** `crm.pipeline.manage`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"pipelines":{"type":"array","items":{"type":"object","properties":{"source_id":{"type":"string","minLength":1,"maxLength":120},"name":{"type":"string","maxLength":120},"open_count":{"type":"integer","minimum":0,"default":0},"open_value":{"type":"number","minimum":0,"maximum":10000000000000,"default":0},"won_count":{"type":"integer","minimum":0,"default":0},"won_value":{"type":"number","minimum":0,"maximum":10000000000000,"default":0},"lost_count":{"type":"integer","minimum":0,"default":0},"lost_value":{"type":"number","minimum":0,"maximum":10000000000000,"default":0}},"required":["source_id"]},"minItems":1,"maxItems":200},"counts":{"type":"object","properties":{"accounts":{"type":"integer","minimum":0},"contacts":{"type":"integer","minimum":0},"leads":{"type":"integer","minimum":0},"deals":{"type":"integer","minimum":0},"activities":{"type":"integer","minimum":0},"notes":{"type":"integer","minimum":0}}},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["pipelines"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CrmMigrationReconciliation"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/crm/migration/request-review":{"post":{"operationId":"crm_migration.request_review","tags":["Migration"],"summary":"Hand CRM migration over for review","description":"Finish your part: hand the CRM migration job to the person for review, with a short summary (counts, differences left, anything skipped and why, owners still on the default owner). The job stops accepting imports; the person then finalizes it, rolls it back, or reopens it in Settings → Migration → CRM. This never finalizes by itself.\n\n**Scopes:** `crm.pipeline.manage`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"summary":{"type":"string","minLength":1,"maxLength":4000},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["summary"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CrmMigrationReviewRequested"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/import-issues/report":{"post":{"operationId":"import_issues.report","tags":["Import issues"],"summary":"Report import issues","description":"File what an import found that a person must fix (accounting or CRM), so it shows on the module home card and its issue list. Send EVERY issue the check found each run: for a recurring context (daily_sync) any open issue you no longer send is marked resolved, and an issue sent on several days shows \"repeated for N days\". For a migration job use context \"migration_job:<job id>\" (one-time: nothing auto-resolves). Re-sending the same report is safe. Never posts, voids or edits records.\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"domain":{"type":"string","enum":["accounting","crm"]},"source_key":{"type":"string","pattern":"^[a-z0-9_]{2,30}$","description":"Your internal code for the previous system (a-z, 0-9, _). Stored, never shown."},"context":{"type":"string","pattern":"^[a-z_]{2,30}(:[0-9A-Za-z_-]{1,64})?$","default":"daily_sync","description":"\"daily_sync\" (default) or another recurring name, or \"migration_job:<id>\"."},"check_date":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-11-21","description":"The day of the check (Bangkok). Default: today. Repeat days count once per date."},"issues":{"type":"array","items":{"$ref":"#/components/schemas/ImportIssueInput"},"maxItems":500},"checked_kinds":{"type":"array","items":{"type":"string","pattern":"^[a-z0-9_]{2,50}$"},"maxItems":50,"description":"When the check looked at only some kinds: only open issues of these kinds can be auto-resolved."},"source_label":{"type":"string","maxLength":60,"description":"The previous system's name as the company calls it (shown to admins only). Migration jobs use the job's own name."},"dry_run":{"type":"boolean","default":false},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["domain","source_key","issues"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ImportIssueReport"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/import-issues":{"get":{"operationId":"import_issues.list","tags":["Import issues"],"summary":"List import issues","description":"The import issues of one module (accounting or CRM): open by default, or resolved / dismissed / closed_with_job / all; optionally one context (daily_sync, migration_job:<id>). Severity first, then how many days each has repeated. Read-only.","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","enum":["accounting","crm"]},"required":true,"name":"domain","in":"query"},{"schema":{"type":"string","enum":["open","resolved","dismissed","closed_with_job","all"],"default":"open"},"required":false,"name":"status","in":"query"},{"schema":{"type":"string","pattern":"^[a-z_]{2,30}(:[0-9A-Za-z_-]{1,64})?$"},"required":false,"name":"context","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":500,"default":100},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ImportIssueList"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/accounting/journal-vouchers":{"post":{"operationId":"accounting.journal_vouchers.create","tags":["Accounting"],"summary":"Create a journal voucher draft","description":"Prepare a journal voucher (ใบสำคัญ — JV general, PV payment, RV receipt, PJ purchase, SJ sales) as a DRAFT: 2–200 lines by account code (call list_accounts), each a debit or a credit. Debits must equal credits — an unbalanced voucher is refused (the app lets a person save one; an agent's draft must be postable as it stands). Needs accounting.post. Never posted: no voucher number, nothing in the ledger until a person posts it in Tonbab. A date in a closed year or locked period is refused.\n\n**Scopes:** `accounting.post`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"book":{"type":"string","enum":["JV","PV","RV","PJ","SJ"],"default":"JV"},"entry_date":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-12-01","description":"Default: today (Bangkok)"},"description":{"type":"string","minLength":1,"maxLength":500},"reference":{"type":"string","maxLength":120},"lines":{"type":"array","items":{"type":"object","properties":{"account_code":{"type":"string","minLength":1,"maxLength":20},"debit":{"type":"number","minimum":0,"maximum":9999999999.99,"default":0},"credit":{"type":"number","minimum":0,"maximum":9999999999.99,"default":0},"description":{"type":"string","maxLength":300}},"required":["account_code"]},"minItems":2,"maxItems":200,"example":[{"account_code":"53100","debit":1070,"credit":0},{"account_code":"11110","debit":0,"credit":1070}]},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["description","lines"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/JournalDraftCreated"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/service-jobs/{id}/photos":{"post":{"operationId":"service_jobs.add_photos","tags":["Workshop"],"summary":"Add photos to a service job","description":"Add up to 5 photos to a service job (the job page's \"Add photos\"): kind intake (machine arrived), finding, before, after (repair done) or return; an optional caption. Each photo from a public https URL or base64; PNG, JPEG or WebP, at most 10 MB each — the type is read from the bytes. Photos are never removed here.\n\n**Scopes:** `service.edit`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","description":"Record id (uuid)"},"required":true,"description":"Record id (uuid)","name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"kind":{"type":"string","enum":["intake","finding","before","after","return"]},"caption":{"type":"string","maxLength":500},"photos":{"type":"array","items":{"type":"object","properties":{"url":{"type":"string","maxLength":2000,"format":"uri","description":"A public https URL Tonbab fetches (redirects only to other public https URLs)"},"base64":{"type":"string","maxLength":14000000,"description":"The file bytes, base64 (a data: URL prefix is accepted)"},"name":{"type":"string","maxLength":200,"description":"File name to keep (default from the URL)"}}},"minItems":1,"maxItems":5},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["kind","photos"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ServiceJobPhotosAdded"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/attachments":{"post":{"operationId":"attachments.create","tags":["Procurement"],"summary":"Attach a file to a record","description":"Attach a file (e.g. a supplier quotation, tax invoice, packing list, drawing or spec sheet) to a record you can edit: a product (product.edit), a BOM (bom.edit), a purchase order (po.edit or po.attach; not when closed or cancelled; attachment_kind quotation / supplier_invoice / packing_list / bl_awb / customs_declaration / other) or a CRM deal (crm.deal.edit, a deal in your CRM scope). From a public https URL or base64, at most 10 MB. Accepted: PDF, PNG, JPEG, WebP, GIF, Word / Excel / PowerPoint (.docx .xlsx .pptx) and CSV / text — the type is read from the bytes. Files are stored privately; nothing is read by AI and nothing is removed.\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"entity_type":{"type":"string","enum":["product","bom","purchase_order","crm_deal"]},"entity_id":{"type":"string","format":"uuid"},"file":{"type":"object","properties":{"url":{"type":"string","maxLength":2000,"format":"uri","description":"A public https URL Tonbab fetches (redirects only to other public https URLs)"},"base64":{"type":"string","maxLength":14000000,"description":"The file bytes, base64 (a data: URL prefix is accepted)"},"name":{"type":"string","maxLength":200,"description":"File name to keep (default from the URL)"}}},"attachment_kind":{"type":"string","enum":["quotation","supplier_invoice","packing_list","bl_awb","customs_declaration","other"],"default":"other"},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["entity_type","entity_id","file"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FileAttached"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/accounting/migration/sync/void":{"post":{"operationId":"migration_sync.void","tags":["Migration"],"summary":"Void imported records voided at the source","description":"Daily sync from the previous accounting system: an imported document (ใบกำกับภาษี, ใบเสนอราคา, ใบแจ้งหนี้, ค่าใช้จ่าย …), receipt / payment, or journal voucher that was VOIDED at the source is voided in Tonbab the way the app voids it — the reversal voucher, the documents a payment settled reopen (the issues card's \"Void in Tonbab\" path). Only records this migration job's source imported; never anything created in Tonbab. reason + source_ref are required and kept on the record. The reversal is dated the record's own date (or date), before the cut-over, in an open period — closed periods and years are refused. A voucher owned by a document / payment is voided through that record; a payment must be voided before the invoice it settles. Already void = skipped. Needs the open migration job granted to this connection; send dry_run=true first. Max 100 per call.\n\n**Scopes:** `accounting.manage`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"records":{"type":"array","items":{"type":"object","properties":{"source_id":{"type":"string","minLength":1,"maxLength":120,"description":"The previous system's record id or number. Keys idempotency: the same source_id is never imported twice."},"kind":{"type":"string","enum":["document","payment","voucher"],"description":"document = an imported quotation / invoice / bill …; payment = an imported receipt or supplier payment; voucher = an imported journal voucher that no document or payment owns."},"doc_type":{"type":"string","enum":["quotation","billing_note","invoice","credit_note","debit_note","bill","bill_credit"],"description":"kind=document: its type."},"pay_kind":{"type":"string","enum":["receipt","payment"],"description":"kind=payment: receipt (from a customer) or payment (to a supplier). Default receipt."},"number":{"type":"string","minLength":1,"maxLength":40,"description":"The number in Tonbab (the same as in the previous system)."},"date":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-11-20","description":"Date of the reversal entry (default: the record's own date). Must be before the job's cut-over and in an open period."},"reason":{"type":"string","minLength":1,"maxLength":400,"description":"Why (as the previous system shows it), e.g. \"ยกเลิกเนื่องจากออกผิด\"."},"source_ref":{"type":"string","minLength":1,"maxLength":120,"description":"Where the change is in the previous system (its record id / log entry / void date), kept on the record's history."}},"required":["source_id","kind","number","reason","source_ref"]},"minItems":1,"maxItems":100,"example":[{"source_id":"inv-2026-0042","kind":"document","doc_type":"invoice","number":"INV2026110042","reason":"Voided at the source","source_ref":"void log 2026-11-21"}]},"dry_run":{"type":"boolean","default":false,"description":"Validate the whole batch in the database and roll it back. Always send a batch with dry_run=true first."},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["records"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MigrationSyncBatchResult"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/accounting/migration/sync/amend":{"post":{"operationId":"migration_sync.amend","tags":["Migration"],"summary":"Apply a source-side edit to an imported document","description":"Daily sync: a document imported from the previous system was EDITED there (date, customer / supplier, amounts, lines). Tonbab never edits an issued document, so this voids the imported copy (reversal as the app voids it), keeps it under \"<number>-R<n>\" with the reason, and imports the corrected document under the ORIGINAL number — all or nothing. Send the corrected document exactly as import_accounting_documents takes it (doc_no = the original number). Only documents this job imported, never ones issued in Tonbab; only when the source really shows the change (reason + source_ref required). If the source re-posted the document under a new voucher, import that voucher first and pass its entry_no; never the old voucher (it is reversed). A receipt / payment settling it must be voided first (void_imported_record). One document per call; dry_run=true first. Note: a job rollback removes the corrected copy but does not undo the void.\n\n**Scopes:** `accounting.manage`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"doc_type":{"type":"string","enum":["quotation","billing_note","invoice","credit_note","debit_note","bill","bill_credit"]},"doc_no":{"type":"string","minLength":1,"maxLength":40,"description":"The number in Tonbab (and at the source)."},"reason":{"type":"string","minLength":1,"maxLength":400,"description":"Why (as the previous system shows it), e.g. \"ยกเลิกเนื่องจากออกผิด\"."},"source_ref":{"type":"string","minLength":1,"maxLength":120,"description":"Where the change is in the previous system (its record id / log entry / void date), kept on the record's history."},"void_date":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-11-20","description":"Date of the reversal (default: the document's date)."},"document":{"type":"object","properties":{"source_id":{"type":"string","minLength":1,"maxLength":120,"description":"The previous system's record id or number. Keys idempotency: the same source_id is never imported twice."},"doc_type":{"type":"string","enum":["quotation","billing_note","invoice","credit_note","debit_note","bill","bill_credit"],"description":"invoice = invoice / tax invoice (also cash sales with cash_sale=true); bill = expense / purchase tax invoice; bill_credit = vendor credit."},"cash_sale":{"type":"boolean"},"doc_no":{"type":"string","minLength":1,"maxLength":40},"status":{"type":"string","enum":["issued","void","accepted","rejected"],"default":"issued","description":"issued | void (quotations also accepted | rejected)."},"doc_date":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2025-12-31"},"due_date":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2025-12-31"},"party_name":{"type":"string","minLength":1,"maxLength":300},"party_tax_id":{"type":"string","maxLength":40},"party_branch":{"type":"string","maxLength":60},"party_address":{"type":"string","maxLength":1000},"contact_name":{"type":"string","maxLength":200},"ref_type":{"type":"string","enum":["quotation","billing_note","invoice","credit_note","debit_note","bill","bill_credit"]},"ref_no":{"type":"string","maxLength":40,"description":"The document this came from / corrects (must be imported first)."},"entry_no":{"type":"string","maxLength":40,"description":"Full history: the voucher (already imported) that posted it. Nothing is posted again."},"is_vat":{"type":"boolean","default":false},"price_includes_vat":{"type":"boolean","default":false},"vat_rate":{"type":"number","minimum":0,"maximum":30,"default":7},"subtotal":{"type":"number","minimum":0,"maximum":10000000000000},"vat_amount":{"type":"number","minimum":0,"maximum":10000000000000,"default":0},"total":{"type":"number","minimum":0,"maximum":10000000000000},"wht_rate":{"type":"number","minimum":0,"maximum":30,"default":0},"wht_amount":{"type":"number","minimum":0,"maximum":10000000000000,"default":0},"discount_amount":{"type":"number","minimum":0,"maximum":10000000000000,"default":0},"external_no":{"type":"string","maxLength":60,"description":"Bills: the vendor's tax invoice number."},"external_date":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2025-12-31"},"vat_period":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2025-12-31","description":"VAT month (first day). Default: the document month."},"title":{"type":"string","maxLength":300},"notes":{"type":"string","maxLength":2000},"reason":{"type":"string","maxLength":500},"void_reason":{"type":"string","maxLength":500},"open_amount":{"type":"number","minimum":0,"maximum":10000000000000,"description":"Opening-balances mode: what is still unpaid at cut-over (default: the total)."},"sales_person":{"type":"string","maxLength":200,"description":"Salesperson name from the previous system (shown as the owner)."},"currency":{"type":"string","pattern":"^[A-Za-z]{3}$","description":"Foreign currency (ISO code). Amounts stay in baht; send fx_rate too."},"fx_rate":{"type":"number","minimum":0,"exclusiveMinimum":true,"maximum":1000000,"description":"Baht per 1 unit of currency."},"fc_total":{"type":"number","minimum":0,"maximum":10000000000000,"description":"Total in the foreign currency (default: total / fx_rate)."},"lines":{"type":"array","items":{"type":"object","properties":{"description":{"type":"string","maxLength":500},"quantity":{"type":"number","default":1},"unit":{"type":"string","maxLength":30},"unit_price":{"type":"number","minimum":-10000000000000,"maximum":10000000000000,"default":0},"discount_amount":{"type":"number","minimum":0,"maximum":10000000000000,"default":0},"amount":{"type":"number","minimum":0,"maximum":10000000000000},"vat_code":{"type":"string","enum":["vat","zero","exempt","none","non_claimable"],"default":"vat"},"vat_amount":{"type":"number","minimum":0,"maximum":10000000000000,"default":0},"account_code":{"type":"string","maxLength":40},"product_code":{"type":"string","maxLength":60,"description":"The previous system's product code; resolved through import_migration_products / the SKU. Unknown codes are an error."}},"required":["amount"]},"maxItems":500,"default":[]}},"required":["source_id","doc_type","doc_no","doc_date","party_name","subtotal","total"],"description":"The corrected document (same shape as import_accounting_documents; source_id = its id at the source)."},"dry_run":{"type":"boolean","default":false,"description":"Validate the whole batch in the database and roll it back. Always send a batch with dry_run=true first."},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["doc_type","doc_no","reason","source_ref","document"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MigrationAmendResult"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/accounting/migration/sync/quotations":{"post":{"operationId":"migration_sync.import_quotations","tags":["Migration"],"summary":"Import quotations as issued history","description":"Daily sync: quotations (ใบเสนอราคา) issued in the previous system come in as ISSUED history with their number, status (issued / accepted / rejected / void), lines and totals — unlike create_quotation_draft, which starts a new draft in Tonbab. The customer is matched by 13-digit tax ID, else by name (a new contact is created when nothing matches); sales_person (name or email) becomes the salesperson when it matches exactly ONE active member — work email, English name, Thai name, nickname, in that order — otherwise the name is kept on the quotation. A number already in Tonbab is skipped (a quotation issued in Tonbab is never overwritten). Dated before the job's cut-over. dry_run=true first. Max 100 per call.\n\n**Scopes:** `accounting.manage`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"quotations":{"type":"array","items":{"type":"object","properties":{"source_id":{"type":"string","minLength":1,"maxLength":120,"description":"The previous system's record id or number. Keys idempotency: the same source_id is never imported twice."},"doc_type":{"type":"string","enum":["quotation"],"default":"quotation"},"cash_sale":{"type":"boolean"},"doc_no":{"type":"string","minLength":1,"maxLength":40},"status":{"type":"string","enum":["issued","void","accepted","rejected"],"default":"issued","description":"issued | void (quotations also accepted | rejected)."},"doc_date":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2025-12-31"},"due_date":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2025-12-31"},"party_name":{"type":"string","minLength":1,"maxLength":300},"party_tax_id":{"type":"string","maxLength":40},"party_branch":{"type":"string","maxLength":60},"party_address":{"type":"string","maxLength":1000},"contact_name":{"type":"string","maxLength":200},"ref_type":{"type":"string","enum":["quotation","billing_note","invoice","credit_note","debit_note","bill","bill_credit"]},"ref_no":{"type":"string","maxLength":40,"description":"The document this came from / corrects (must be imported first)."},"entry_no":{"type":"string","maxLength":40,"description":"Full history: the voucher (already imported) that posted it. Nothing is posted again."},"is_vat":{"type":"boolean","default":false},"price_includes_vat":{"type":"boolean","default":false},"vat_rate":{"type":"number","minimum":0,"maximum":30,"default":7},"subtotal":{"type":"number","minimum":0,"maximum":10000000000000},"vat_amount":{"type":"number","minimum":0,"maximum":10000000000000,"default":0},"total":{"type":"number","minimum":0,"maximum":10000000000000},"wht_rate":{"type":"number","minimum":0,"maximum":30,"default":0},"wht_amount":{"type":"number","minimum":0,"maximum":10000000000000,"default":0},"discount_amount":{"type":"number","minimum":0,"maximum":10000000000000,"default":0},"external_no":{"type":"string","maxLength":60,"description":"Bills: the vendor's tax invoice number."},"external_date":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2025-12-31"},"vat_period":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2025-12-31","description":"VAT month (first day). Default: the document month."},"title":{"type":"string","maxLength":300},"notes":{"type":"string","maxLength":2000},"reason":{"type":"string","maxLength":500},"void_reason":{"type":"string","maxLength":500},"open_amount":{"type":"number","minimum":0,"maximum":10000000000000,"description":"Opening-balances mode: what is still unpaid at cut-over (default: the total)."},"sales_person":{"type":"string","maxLength":200,"description":"Salesperson name from the previous system (shown as the owner)."},"currency":{"type":"string","pattern":"^[A-Za-z]{3}$","description":"Foreign currency (ISO code). Amounts stay in baht; send fx_rate too."},"fx_rate":{"type":"number","minimum":0,"exclusiveMinimum":true,"maximum":1000000,"description":"Baht per 1 unit of currency."},"fc_total":{"type":"number","minimum":0,"maximum":10000000000000,"description":"Total in the foreign currency (default: total / fx_rate)."},"lines":{"type":"array","items":{"type":"object","properties":{"description":{"type":"string","maxLength":500},"quantity":{"type":"number","default":1},"unit":{"type":"string","maxLength":30},"unit_price":{"type":"number","minimum":-10000000000000,"maximum":10000000000000,"default":0},"discount_amount":{"type":"number","minimum":0,"maximum":10000000000000,"default":0},"amount":{"type":"number","minimum":0,"maximum":10000000000000},"vat_code":{"type":"string","enum":["vat","zero","exempt","none","non_claimable"],"default":"vat"},"vat_amount":{"type":"number","minimum":0,"maximum":10000000000000,"default":0},"account_code":{"type":"string","maxLength":40},"product_code":{"type":"string","maxLength":60,"description":"The previous system's product code; resolved through import_migration_products / the SKU. Unknown codes are an error."}},"required":["amount"]},"maxItems":500,"default":[]}},"required":["source_id","doc_no","doc_date","party_name","subtotal","total"]},"minItems":1,"maxItems":100},"dry_run":{"type":"boolean","default":false,"description":"Validate the whole batch in the database and roll it back. Always send a batch with dry_run=true first."},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["quotations"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MigrationBatchResult"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/accounting/migration/sync/replace-lines":{"post":{"operationId":"migration_sync.replace_lines","tags":["Migration"],"summary":"Replace amount-only lines with item lines","description":"Imported documents often carry one amount line per revenue account. This swaps them for the real item lines (product, quantity, unit price, discount) so stock and sales-by-product reports work. The new lines must add up to the document's subtotal AND VAT exactly, to the satang; the number, status, totals and voucher never change. Only documents this job imported; a document in a locked period or closed year is refused. Each document gets its own result. dry_run=true first. Max 100 documents per call. (Runs the database's imported-document tidy function — answers not_available_yet until that update is applied.)\n\n**Scopes:** `accounting.manage`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"documents":{"type":"array","items":{"type":"object","properties":{"source_id":{"type":"string","minLength":1,"maxLength":120,"description":"The previous system's record id or number. Keys idempotency: the same source_id is never imported twice."},"doc_type":{"type":"string","enum":["quotation","billing_note","invoice","credit_note","debit_note","bill","bill_credit"]},"doc_no":{"type":"string","minLength":1,"maxLength":40},"lines":{"type":"array","items":{"type":"object","properties":{"description":{"type":"string","maxLength":500},"product_id":{"type":"string","format":"uuid","description":"A Tonbab product (list_products / get_product)."},"quantity":{"type":"number","minimum":0,"exclusiveMinimum":true,"maximum":1000000000,"default":1},"unit":{"type":"string","maxLength":30},"unit_price":{"type":"number","minimum":0,"maximum":10000000000000,"default":0},"discount_amount":{"type":"number","minimum":0,"maximum":10000000000000,"default":0},"amount":{"type":"number","minimum":0,"maximum":10000000000000,"description":"Line amount before VAT, after the discount."},"vat_code":{"type":"string","enum":["vat","zero","exempt","none","non_claimable"]},"vat_amount":{"type":"number","minimum":0,"maximum":10000000000000,"default":0},"account_code":{"type":"string","maxLength":40,"description":"Revenue / expense account (Tonbab code). Default: the document's account when all its lines share one."}},"required":["amount"]},"minItems":1,"maxItems":500}},"required":["source_id","doc_type","doc_no","lines"]},"minItems":1,"maxItems":100},"dry_run":{"type":"boolean","default":false,"description":"Validate the whole batch in the database and roll it back. Always send a batch with dry_run=true first."},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["documents"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MigrationSyncBatchResult"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/accounting/migration/sync/relink":{"post":{"operationId":"migration_sync.relink","tags":["Migration"],"summary":"Move imported documents to the right company","description":"Imported documents (and, optionally, the imported receipts / payments that settle only them) linked to the wrong customer / supplier company — typically the wrong branch (สำนักงานใหญ่ vs สาขา 00001) — move to the right company row. Party rules: same company (tenant) only; the target must be the documents' legal entity (13-digit tax ID equal when both carry one) and not merged into another; when the target is a branch, the documents' branch must match. Amounts, VAT, status and voucher never change. Only documents this job imported; locked periods / closed years refused. All or nothing. dry_run=true first. Max 500 documents per call. (Runs the database's imported-document tidy function — answers not_available_yet until that update is applied.)\n\n**Scopes:** `accounting.manage`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"company_id":{"type":"string","format":"uuid","description":"The right company (list_companies / get_company)."},"documents":{"type":"array","items":{"type":"object","properties":{"doc_type":{"type":"string","enum":["quotation","billing_note","invoice","credit_note","debit_note","bill","bill_credit"]},"doc_no":{"type":"string","minLength":1,"maxLength":40}},"required":["doc_type","doc_no"]},"minItems":1,"maxItems":500},"payments":{"type":"array","items":{"type":"object","properties":{"kind":{"type":"string","enum":["receipt","payment"],"default":"receipt"},"pay_no":{"type":"string","minLength":1,"maxLength":40}},"required":["pay_no"]},"maxItems":500,"default":[]},"dry_run":{"type":"boolean","default":false,"description":"Validate the whole batch in the database and roll it back. Always send a batch with dry_run=true first."},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["company_id","documents"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MigrationRelinkResult"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/accounting/possible-duplicates":{"post":{"operationId":"accounting.possible_duplicates","tags":["Accounting"],"summary":"Find possible duplicates for a batch","description":"Read only. The server-side version of Accounting → ตรวจเอกสารซ้ำ (duplicate check) for a batch of documents you are about to send (e.g. today's sync from the previous system): for each candidate, the Tonbab documents within 7 days that look like the same one — same or VAT-equivalent amount, same party (record or 13-digit tax ID) or a near-equal name, the same vendor invoice number — scored like the page (strong ≥ 85), plus exact number clashes. Pairs a person marked \"not a duplicate\" are left out. Needs accounting.view; no migration job needed. Max 100 candidates per call.\n\n**Scopes:** `accounting.view`","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"documents":{"type":"array","items":{"type":"object","properties":{"ref":{"type":"string","minLength":1,"maxLength":120,"description":"Your id for this candidate (echoed back)."},"doc_type":{"type":"string","enum":["quotation","billing_note","invoice","bill","bill_credit","receipt"]},"doc_no":{"type":"string","maxLength":40},"external_no":{"type":"string","maxLength":60,"description":"Bills: the vendor's tax invoice / receipt number."},"doc_date":{"type":"string","format":"date","pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-11-20"},"total":{"type":"number","minimum":0,"maximum":10000000000000},"subtotal":{"type":"number","minimum":0,"maximum":10000000000000},"party_name":{"type":"string","maxLength":300},"party_tax_id":{"type":"string","maxLength":40}},"required":["ref","doc_type","doc_date","total"]},"minItems":1,"maxItems":100},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."}},"required":["documents"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PossibleDuplicates"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/accounting/migration/sync/request-extension":{"post":{"operationId":"migration_sync.request_extension","tags":["Migration"],"summary":"Ask the job owner to extend the migration job","description":"The migration job has a time limit (Settings → Migration → Accounting). When it is about to run out while the daily sync still needs it, this sends ONE notification to the person who opened the job, with the days you ask for and why. It never extends the job itself — that person decides and extends it in Settings. At most once every 24 hours per job (a repeat answers already_requested). Works on an open job granted to this connection, even shortly after it expired.\n\n**Scopes:** `accounting.manage`\n\nSupports `Idempotency-Key`. Test-mode keys validate without saving (`dry_run: true`).","security":[{"bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"days":{"type":"integer","minimum":1,"maximum":30,"description":"Days asked for (1–30)."},"reason":{"type":"string","minLength":1,"maxLength":500,"description":"Why the job is still needed, e.g. \"daily sync until the year-end close on 31 Dec\"."},"company":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"client_request_id":{"type":"string","minLength":1,"maxLength":200,"pattern":"^[\\w.:-]+$","description":"Optional retry key (letters, digits, . _ : -). Re-sending the same client_request_id with the same input within 24 h returns the first result and writes nothing new; with different input it fails (422)."}},"required":["days","reason"]}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MigrationExtensionRequest"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/announcements":{"get":{"operationId":"announcements.list","tags":["Account"],"summary":"Tonbab announcements","description":"Current announcements from Tonbab to this company — product updates, changes from outside providers (e.g. payment fees) and maintenance — newest first, in English and Thai. Items with kind action_required usually include cta_url, the place in Tonbab to act on it.","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AnnouncementList"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/documents/{type}/{id}/flow":{"get":{"operationId":"documents.flow","tags":["Documents"],"summary":"Related documents of a document","description":"The chain of documents linked to one document, as the \"Related documents\" panel in Tonbab shows it: purchase request → purchase order → goods receipt → supplier bill → payment; quotation → billing note → invoice ← delivery note, invoice → receipt; work order ↔ job ↔ delivery note; credit and debit notes with the invoice or bill they reference. Give the document type and id. Documents you may not open are listed with their number and url null. Read-only.","security":[{"bearer":[]}],"parameters":[{"schema":{"type":"string","enum":["purchase_request","purchase_order","goods_receipt","delivery_note","work_order","job_control","service_order","crm_deal","acc_document","acc_payment","expense_claim","payroll_run"],"description":"Document type"},"required":true,"description":"Document type","name":"type","in":"path"},{"schema":{"type":"string","format":"uuid","description":"Record id (uuid)"},"required":true,"description":"Record id (uuid)","name":"id","in":"path"},{"schema":{"type":"string","maxLength":100,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\"."},"required":false,"description":"Company slug or id (default: the connection's default company). Call list_my_companies to see the choices. Summary tools also accept \"all\".","name":"company","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DocumentFlow"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing / invalid credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope, IP not allowed, or feature switched off","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (or not visible to this credential)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/event-types":{"get":{"tags":["Events"],"summary":"Event catalog","description":"Every event type webhooks and GET /events can deliver. Payloads are thin (id, number, status); fetch the record for detail.","responses":{"200":{"description":"Event types","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EventTypes"}}}}}}}}}