{"openapi":"3.1.0","info":{"title":"AG|CM platform API","version":"0.1.0","description":"Session-authenticated JSON API over the same records as the application. Every request runs with the caller's own permissions, enforced by row-level security in the database."},"servers":[{"url":"/"}],"components":{"schemas":{"RFI":{"type":"object","required":["subject","question","discipline","priority","assigned_to"],"properties":{"subject":{"type":"string","title":"Subject"},"question":{"type":"string","title":"Question"},"discipline":{"type":"string","enum":["Architectural","Structural","Civil","Mechanical","Electrical","Plumbing","Fire protection","Technology"],"title":"Discipline"},"priority":{"type":"string","enum":["Low","Normal","High","Critical"],"title":"Priority"},"spec_section":{"type":"string","title":"Specification section"},"drawing_ref":{"type":"string","title":"Drawing reference"},"assigned_to":{"type":"string","format":"uuid","description":"Identifier of a person","title":"Reviewer"},"due_date":{"type":"string","format":"date","title":"Answer due"}}},"Submittal":{"type":"object","required":["title","kind"],"properties":{"title":{"type":"string","title":"Title"},"spec_section":{"type":"string","title":"Specification section"},"kind":{"type":"string","enum":["Product data","Shop drawing","Sample","Mock-up","Test report","Closeout"],"title":"Type"},"vendor_id":{"type":"string","format":"uuid","description":"Identifier of a vendor","title":"Submitted by"},"reviewer_id":{"type":"string","format":"uuid","description":"Identifier of a person","title":"Reviewer"},"due_date":{"type":"string","format":"date","title":"Review due"},"notes":{"type":"string","title":"Review notes"}}},"Meeting":{"type":"object","required":["title","kind","held_on"],"properties":{"title":{"type":"string","title":"Title"},"kind":{"type":"string","enum":["Owner-architect-contractor","Design review","Preconstruction","Safety","Closeout","Internal"],"title":"Type"},"held_on":{"type":"string","format":"date","title":"Date"},"location":{"type":"string","title":"Location"},"attendees":{"type":"string","title":"Attendees"},"minutes":{"type":"string","title":"Minutes"},"action_items":{"type":"string","title":"Action items"}}},"Contract":{"type":"object","required":["title","vendor_id","kind","budget_line_id","original_value"],"properties":{"title":{"type":"string","title":"Title"},"vendor_id":{"type":"string","format":"uuid","description":"Identifier of a vendor","title":"Vendor"},"kind":{"type":"string","enum":["Construction","Professional services","Purchase order"],"title":"Type"},"budget_line_id":{"type":"string","format":"uuid","description":"Identifier of a budget line","title":"Budget line"},"original_value":{"type":"number","minimum":1,"title":"Original value"},"retainage_pct":{"type":"number","minimum":0,"maximum":10,"title":"Retainage, percent"},"substantial_completion":{"type":"string","format":"date","title":"Substantial completion"}}},"ChangeOrder":{"type":"object","required":["title","contract_id","reason","amount"],"properties":{"title":{"type":"string","title":"Title"},"contract_id":{"type":"string","format":"uuid","description":"Identifier of a contract","title":"Contract"},"reason":{"type":"string","enum":["Owner request","Unforeseen condition","Design clarification","Code requirement","Value engineering","Allowance reconciliation"],"title":"Reason"},"amount":{"type":"number","title":"Amount"},"schedule_days":{"type":"number","title":"Added days"},"description":{"type":"string","title":"Description"}}},"PayApplication":{"type":"object","required":["title","contract_id","kind","period_end","work_this_period"],"properties":{"title":{"type":"string","title":"Title"},"contract_id":{"type":"string","format":"uuid","description":"Identifier of a contract","title":"Contract"},"kind":{"type":"string","enum":["Progress","Retainage release"],"title":"Type"},"period_end":{"type":"string","format":"date","title":"Period ending"},"work_this_period":{"type":"number","minimum":0,"title":"Work completed this period"},"stored_materials":{"type":"number","minimum":0,"title":"Materials stored"},"notes":{"type":"string","title":"Notes"}}},"Invoice":{"type":"object","required":["title","vendor_id","amount","received_on"],"properties":{"title":{"type":"string","title":"Description"},"vendor_id":{"type":"string","format":"uuid","description":"Identifier of a vendor","title":"Vendor"},"contract_id":{"type":"string","format":"uuid","description":"Identifier of a contract","title":"Contract"},"amount":{"type":"number","minimum":1,"title":"Amount"},"received_on":{"type":"string","format":"date","title":"Received"},"due_on":{"type":"string","format":"date","title":"Due"}}},"Risk":{"type":"object","required":["title","category","probability","impact"],"properties":{"title":{"type":"string","title":"Risk"},"category":{"type":"string","enum":["Schedule","Cost","Scope","Safety","Weather","Permitting","Supply chain","Stakeholder"],"title":"Category"},"probability":{"type":"number","minimum":1,"maximum":5,"title":"Probability, 1 to 5"},"impact":{"type":"number","minimum":1,"maximum":5,"title":"Impact, 1 to 5"},"exposure":{"type":"number","minimum":0,"title":"Exposure"},"owner_id":{"type":"string","format":"uuid","description":"Identifier of a person","title":"Owner"},"mitigation":{"type":"string","title":"Mitigation"}}},"Observation":{"type":"object","required":["title","category","severity","observed_on"],"properties":{"title":{"type":"string","title":"What you observed"},"category":{"type":"string","enum":["Quality","Safety","Progress","Environmental","Housekeeping"],"title":"Category"},"severity":{"type":"string","enum":["Note","Minor","Major","Critical"],"title":"Severity"},"location":{"type":"string","title":"Location"},"observed_on":{"type":"string","format":"date","title":"Date observed"},"description":{"type":"string","title":"Details"}}},"Inspection":{"type":"object","required":["title","kind","scheduled_on"],"properties":{"title":{"type":"string","title":"Inspection"},"kind":{"type":"string","enum":["Quality assurance","Pre-pour","Framing","Above ceiling","MEP rough-in","Fire and life safety","Envelope","Substantial completion","Final"],"title":"Type"},"scheduled_on":{"type":"string","format":"date","title":"Scheduled for"},"inspector_id":{"type":"string","format":"uuid","description":"Identifier of a person","title":"Inspector"},"location":{"type":"string","title":"Location"},"notes":{"type":"string","title":"Notes"}}},"Deficiency":{"type":"object","required":["title","severity"],"properties":{"title":{"type":"string","title":"Deficiency"},"severity":{"type":"string","enum":["Minor","Major","Critical"],"title":"Severity"},"location":{"type":"string","title":"Location"},"vendor_id":{"type":"string","format":"uuid","description":"Identifier of a vendor","title":"Responsible contractor"},"due_date":{"type":"string","format":"date","title":"Correct by"},"description":{"type":"string","title":"Details"}}},"CloseoutItem":{"type":"object","required":["title","category"],"properties":{"title":{"type":"string","title":"Item"},"category":{"type":"string","enum":["Operation and maintenance manuals","Record drawings","Owner training","Attic stock","Final lien waivers","Certificate of occupancy","Commissioning report","Final pay application"],"title":"Category"},"vendor_id":{"type":"string","format":"uuid","description":"Identifier of a vendor","title":"From"},"due_date":{"type":"string","format":"date","title":"Due"},"notes":{"type":"string","title":"Notes"}}},"Warranty":{"type":"object","required":["title","starts_on","ends_on"],"properties":{"title":{"type":"string","title":"Warranty"},"system":{"type":"string","title":"System"},"vendor_id":{"type":"string","format":"uuid","description":"Identifier of a vendor","title":"Warrantor"},"starts_on":{"type":"string","format":"date","title":"Starts"},"ends_on":{"type":"string","format":"date","title":"Ends"},"terms":{"type":"string","title":"Terms"}}}},"securitySchemes":{"session":{"type":"apiKey","in":"cookie","name":"authjs.session-token"}}},"security":[{"session":[]}],"paths":{"/api/v1/projects":{"get":{"summary":"List the projects the caller can open","tags":["Portfolio"],"responses":{"200":{"description":"Projects with cost and schedule roll-ups. Cost fields are null without cost access."},"401":{"description":"Not signed in"}}}},"/api/v1/projects/{projectId}/rfis":{"get":{"summary":"List rfis","tags":["Delivery"],"description":"Questions about the contract documents, tracked to an answer.","parameters":[{"name":"projectId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Records, newest first"},"401":{"description":"Not signed in"},"404":{"description":"The project does not exist or the caller cannot open it"}}},"post":{"summary":"Create a rfi","tags":["Delivery"],"description":"Requires the capability rfi.create on the project. The record is created in its first status; workflow steps (submit rfi, answer rfi, close rfi) are taken in the application.","parameters":[{"name":"projectId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RFI"}}}},"responses":{"201":{"description":"Created"},"400":{"description":"Validation failed; the message names the field"},"401":{"description":"Not signed in"},"403":{"description":"The caller lacks the capability. The refusal is written to the audit log"}}}},"/api/v1/projects/{projectId}/submittals":{"get":{"summary":"List submittals","tags":["Delivery"],"description":"Contractor submittals and their review status.","parameters":[{"name":"projectId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Records, newest first"},"401":{"description":"Not signed in"},"404":{"description":"The project does not exist or the caller cannot open it"}}},"post":{"summary":"Create a submittal","tags":["Delivery"],"description":"Requires the capability submittal.manage on the project. The record is created in its first status; workflow steps (log as submitted, start review, approve, approve as noted, revise and resubmit, log resubmission) are taken in the application.","parameters":[{"name":"projectId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Submittal"}}}},"responses":{"201":{"description":"Created"},"400":{"description":"Validation failed; the message names the field"},"401":{"description":"Not signed in"},"403":{"description":"The caller lacks the capability. The refusal is written to the audit log"}}}},"/api/v1/projects/{projectId}/meetings":{"get":{"summary":"List meetings","tags":["Delivery"],"description":"Meetings, minutes and action items.","parameters":[{"name":"projectId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Records, newest first"},"401":{"description":"Not signed in"},"404":{"description":"The project does not exist or the caller cannot open it"}}},"post":{"summary":"Create a meeting","tags":["Delivery"],"description":"Requires the capability meeting.manage on the project. The record is created in its first status; workflow steps (mark as held, issue minutes) are taken in the application.","parameters":[{"name":"projectId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Meeting"}}}},"responses":{"201":{"description":"Created"},"400":{"description":"Validation failed; the message names the field"},"401":{"description":"Not signed in"},"403":{"description":"The caller lacks the capability. The refusal is written to the audit log"}}}},"/api/v1/projects/{projectId}/contracts":{"get":{"summary":"List contracts and commitments","tags":["Cost"],"description":"Commitments against the budget. Requires cost access on the project.","parameters":[{"name":"projectId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Records, newest first"},"401":{"description":"Not signed in"},"404":{"description":"The project does not exist or the caller cannot open it"}}},"post":{"summary":"Create a contract","tags":["Cost"],"description":"Requires the capability contract.manage on the project. The record is created in its first status; workflow steps (record execution, close contract) are taken in the application.","parameters":[{"name":"projectId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Contract"}}}},"responses":{"201":{"description":"Created"},"400":{"description":"Validation failed; the message names the field"},"401":{"description":"Not signed in"},"403":{"description":"The caller lacks the capability. The refusal is written to the audit log"}}}},"/api/v1/projects/{projectId}/change-orders":{"get":{"summary":"List change orders","tags":["Cost"],"description":"Changes to contract value and time, routed for approval by amount. Requires cost access on the project.","parameters":[{"name":"projectId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Records, newest first"},"401":{"description":"Not signed in"},"404":{"description":"The project does not exist or the caller cannot open it"}}},"post":{"summary":"Create a change order","tags":["Cost"],"description":"Requires the capability co.create on the project. The record is created in its first status; workflow steps (submit for approval, void) are taken in the application.","parameters":[{"name":"projectId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChangeOrder"}}}},"responses":{"201":{"description":"Created"},"400":{"description":"Validation failed; the message names the field"},"401":{"description":"Not signed in"},"403":{"description":"The caller lacks the capability. The refusal is written to the audit log"}}}},"/api/v1/projects/{projectId}/pay-apps":{"get":{"summary":"List pay applications","tags":["Cost"],"description":"Contractor applications for payment, with retainage held automatically. Requires cost access on the project.","parameters":[{"name":"projectId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Records, newest first"},"401":{"description":"Not signed in"},"404":{"description":"The project does not exist or the caller cannot open it"}}},"post":{"summary":"Create a pay application","tags":["Cost"],"description":"Requires the capability payapp.manage on the project. The record is created in its first status; workflow steps (submit, certify and route for approval) are taken in the application.","parameters":[{"name":"projectId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PayApplication"}}}},"responses":{"201":{"description":"Created"},"400":{"description":"Validation failed; the message names the field"},"401":{"description":"Not signed in"},"403":{"description":"The caller lacks the capability. The refusal is written to the audit log"}}}},"/api/v1/projects/{projectId}/invoices":{"get":{"summary":"List invoices","tags":["Cost"],"description":"Invoices and payments. Approved pay applications arrive here automatically. Requires cost access on the project.","parameters":[{"name":"projectId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Records, newest first"},"401":{"description":"Not signed in"},"404":{"description":"The project does not exist or the caller cannot open it"}}},"post":{"summary":"Create a invoice","tags":["Cost"],"description":"Requires the capability payapp.manage on the project. The record is created in its first status; workflow steps (approve invoice, dispute, release payment) are taken in the application.","parameters":[{"name":"projectId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Invoice"}}}},"responses":{"201":{"description":"Created"},"400":{"description":"Validation failed; the message names the field"},"401":{"description":"Not signed in"},"403":{"description":"The caller lacks the capability. The refusal is written to the audit log"}}}},"/api/v1/projects/{projectId}/risks":{"get":{"summary":"List risk register","tags":["Cost"],"description":"What could move cost or schedule, and what is being done about it.","parameters":[{"name":"projectId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Records, newest first"},"401":{"description":"Not signed in"},"404":{"description":"The project does not exist or the caller cannot open it"}}},"post":{"summary":"Create a risk","tags":["Cost"],"description":"Requires the capability risk.manage on the project. The record is created in its first status; workflow steps (mark as mitigating, close risk, reopen) are taken in the application.","parameters":[{"name":"projectId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Risk"}}}},"responses":{"201":{"description":"Created"},"400":{"description":"Validation failed; the message names the field"},"401":{"description":"Not signed in"},"403":{"description":"The caller lacks the capability. The refusal is written to the audit log"}}}},"/api/v1/projects/{projectId}/observations":{"get":{"summary":"List field observations","tags":["Field"],"description":"What was seen on site, with photographs.","parameters":[{"name":"projectId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Records, newest first"},"401":{"description":"Not signed in"},"404":{"description":"The project does not exist or the caller cannot open it"}}},"post":{"summary":"Create a observation","tags":["Field"],"description":"Requires the capability field.observe on the project. The record is created in its first status; workflow steps (acknowledge, close observation, reopen) are taken in the application.","parameters":[{"name":"projectId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Observation"}}}},"responses":{"201":{"description":"Created"},"400":{"description":"Validation failed; the message names the field"},"401":{"description":"Not signed in"},"403":{"description":"The caller lacks the capability. The refusal is written to the audit log"}}}},"/api/v1/projects/{projectId}/inspections":{"get":{"summary":"List inspections","tags":["Field"],"description":"Scheduled inspections and their results.","parameters":[{"name":"projectId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Records, newest first"},"401":{"description":"Not signed in"},"404":{"description":"The project does not exist or the caller cannot open it"}}},"post":{"summary":"Create a inspection","tags":["Field"],"description":"Requires the capability inspection.manage on the project. The record is created in its first status; workflow steps (record result, cancel inspection) are taken in the application.","parameters":[{"name":"projectId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Inspection"}}}},"responses":{"201":{"description":"Created"},"400":{"description":"Validation failed; the message names the field"},"401":{"description":"Not signed in"},"403":{"description":"The caller lacks the capability. The refusal is written to the audit log"}}}},"/api/v1/projects/{projectId}/deficiencies":{"get":{"summary":"List deficiencies","tags":["Field"],"description":"Work to correct, tracked to closure.","parameters":[{"name":"projectId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Records, newest first"},"401":{"description":"Not signed in"},"404":{"description":"The project does not exist or the caller cannot open it"}}},"post":{"summary":"Create a deficiency","tags":["Field"],"description":"Requires the capability field.observe on the project. The record is created in its first status; workflow steps (correction started, ready for review, verify and close, reopen) are taken in the application.","parameters":[{"name":"projectId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Deficiency"}}}},"responses":{"201":{"description":"Created"},"400":{"description":"Validation failed; the message names the field"},"401":{"description":"Not signed in"},"403":{"description":"The caller lacks the capability. The refusal is written to the audit log"}}}},"/api/v1/projects/{projectId}/closeout":{"get":{"summary":"List closeout","tags":["Closeout"],"description":"What the owner must receive before final payment.","parameters":[{"name":"projectId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Records, newest first"},"401":{"description":"Not signed in"},"404":{"description":"The project does not exist or the caller cannot open it"}}},"post":{"summary":"Create a closeout item","tags":["Closeout"],"description":"Requires the capability closeout.manage on the project. The record is created in its first status; workflow steps (mark as requested, mark as received, accept) are taken in the application.","parameters":[{"name":"projectId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CloseoutItem"}}}},"responses":{"201":{"description":"Created"},"400":{"description":"Validation failed; the message names the field"},"401":{"description":"Not signed in"},"403":{"description":"The caller lacks the capability. The refusal is written to the audit log"}}}},"/api/v1/projects/{projectId}/warranties":{"get":{"summary":"List warranties","tags":["Closeout"],"description":"Warranty periods and claims after turnover.","parameters":[{"name":"projectId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Records, newest first"},"401":{"description":"Not signed in"},"404":{"description":"The project does not exist or the caller cannot open it"}}},"post":{"summary":"Create a warranty","tags":["Closeout"],"description":"Requires the capability closeout.manage on the project. The record is created in its first status; workflow steps (open a claim, resolve claim, mark as expired) are taken in the application.","parameters":[{"name":"projectId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Warranty"}}}},"responses":{"201":{"description":"Created"},"400":{"description":"Validation failed; the message names the field"},"401":{"description":"Not signed in"},"403":{"description":"The caller lacks the capability. The refusal is written to the audit log"}}}}}}