{
  "openapi": "3.1.0",
  "info": {
    "title": "OpexAIO API",
    "version": "1.0.0",
    "summary": "The supported (v1) HTTP API of OpexAIO.",
    "description": "The v1 contract of the OpexAIO API: every endpoint here is stable and kept backwards compatible. Guides: https://aio.opexcg.com/docs/. Authenticate with a personal API key in the `X-API-Key` header; API access needs an Enterprise plan on at least one product of the workspace. Times are epoch milliseconds unless a field says otherwise; money is integer minor units of its currency.",
    "x-generated": "Generated by `bun run docs:generate` from apps/aio/src/public-api. Do not edit by hand."
  },
  "servers": [
    {
      "url": "https://app.aio.opexcg.com",
      "description": "Production"
    },
    {
      "url": "https://staging.app.aio.opexcg.com",
      "description": "Staging"
    }
  ],
  "security": [
    {
      "ApiKey": []
    },
    {
      "OAuth2": [
        "workspace"
      ]
    }
  ],
  "tags": [
    {
      "name": "Account",
      "description": "The current user and notifications."
    },
    {
      "name": "Helpdesk",
      "description": "Tickets: open, read, reply, update and close."
    },
    {
      "name": "Timesheets",
      "description": "Time entries and the projects you log against."
    },
    {
      "name": "Project",
      "description": "Projects and their tasks."
    },
    {
      "name": "CRM",
      "description": "Contacts, companies, deals and activities."
    },
    {
      "name": "Expenses",
      "description": "Expenses, receipt capture and categories."
    },
    {
      "name": "Leave",
      "description": "Leave requests, balances, types and cover."
    },
    {
      "name": "Approvals",
      "description": "One approval inbox for every product."
    }
  ],
  "paths": {
    "/api/me": {
      "get": {
        "operationId": "getMe",
        "summary": "Get the current user",
        "description": "Who the API key acts as: user id, roles, the permission codes those roles grant in this workspace, and the products the workspace is entitled to. Call it first to check what a key can do.",
        "tags": [
          "Account"
        ],
        "x-opex-entitlement": null,
        "x-opex-permissions": [],
        "x-opex-stability": "stable",
        "responses": {
          "200": {
            "description": "The caller's profile.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "userId": {
                      "type": "string",
                      "description": "Your user id."
                    },
                    "role": {
                      "type": "string",
                      "description": "Primary role in this workspace, e.g. `admin`, `consultant`."
                    },
                    "roles": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      },
                      "description": "Every role you hold in this workspace."
                    },
                    "permissions": {
                      "description": "Permission codes your roles grant here, e.g. `crm:record:read`.",
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "tenantId": {
                      "type": "string",
                      "description": "The workspace this key acts in."
                    },
                    "tenantName": {
                      "type": "string"
                    },
                    "displayName": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "email": {
                      "type": "string"
                    },
                    "companyId": {
                      "description": "Your company, for client users.",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "language": {
                      "type": "string",
                      "description": "`en` or `id`."
                    },
                    "entitlements": {
                      "type": "array",
                      "items": {
                        "type": "string",
                        "enum": [
                          "helpdesk",
                          "pmo",
                          "crm",
                          "timesheets",
                          "expenses",
                          "leave"
                        ]
                      },
                      "description": "Products the workspace can use (read and write)."
                    },
                    "readOnlyProducts": {
                      "type": "array",
                      "items": {
                        "type": "string",
                        "enum": [
                          "helpdesk",
                          "pmo",
                          "crm",
                          "timesheets",
                          "expenses",
                          "leave"
                        ]
                      },
                      "description": "Products whose trial ended: still readable, writes answer 402."
                    },
                    "entitlementDetails": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "product": {
                            "type": "string",
                            "enum": [
                              "helpdesk",
                              "pmo",
                              "crm",
                              "timesheets",
                              "expenses",
                              "leave"
                            ]
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "active",
                              "trial",
                              "expired",
                              "suspended"
                            ]
                          },
                          "plan": {
                            "type": "string"
                          },
                          "trialEndsAt": {
                            "type": [
                              "number",
                              "null"
                            ]
                          }
                        },
                        "required": [
                          "product",
                          "status",
                          "plan",
                          "trialEndsAt"
                        ],
                        "additionalProperties": {}
                      }
                    }
                  },
                  "required": [
                    "userId",
                    "role",
                    "roles",
                    "tenantId",
                    "tenantName",
                    "displayName",
                    "email",
                    "companyId",
                    "language",
                    "entitlements",
                    "readOnlyProducts",
                    "entitlementDetails"
                  ],
                  "additionalProperties": {}
                },
                "example": {
                  "userId": "usr-fitri-handayani",
                  "role": "admin",
                  "roles": [
                    "admin"
                  ],
                  "permissions": [
                    "ticket:notes:read",
                    "helpdesk:masters:manage"
                  ],
                  "tenantId": "opexcg-tenant",
                  "homeTenantId": "opexcg-tenant",
                  "defaultTenantId": "opexcg-tenant",
                  "tenantName": "OpexCG",
                  "displayName": "Fitri Handayani",
                  "avatarUrl": null,
                  "email": "fitri.handayani@example.com",
                  "companyId": null,
                  "accessibleTenants": [
                    {
                      "id": "opexcg-tenant",
                      "name": "OpexCG"
                    }
                  ],
                  "theme": "system",
                  "language": "en",
                  "currency": null,
                  "entitlements": [
                    "timesheets",
                    "helpdesk"
                  ],
                  "readOnlyProducts": [],
                  "productAccessRestricted": false,
                  "entitlementDetails": [
                    {
                      "product": "timesheets",
                      "status": "active",
                      "plan": "dev",
                      "trialEndsAt": null,
                      "provisionedAt": 0,
                      "settingsJson": "{}",
                      "restricted": false
                    },
                    {
                      "product": "helpdesk",
                      "status": "active",
                      "plan": "dev",
                      "trialEndsAt": null,
                      "provisionedAt": 0,
                      "settingsJson": "{}",
                      "restricted": false
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/notifications": {
      "get": {
        "operationId": "listNotifications",
        "summary": "List notifications",
        "description": "The caller's 50 most recent notifications in this workspace, newest first, plus the unread count. There is no paging: older notifications are not returned.",
        "tags": [
          "Account"
        ],
        "x-opex-entitlement": null,
        "x-opex-permissions": [],
        "x-opex-stability": "stable",
        "responses": {
          "200": {
            "description": "Recent notifications and the unread count.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "kind": {
                            "type": "string",
                            "description": "What happened, e.g. `ticket_assigned`."
                          },
                          "title": {
                            "type": "string"
                          },
                          "body": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "actor_name": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "entity_type": {
                            "description": "Record type the notification is about.",
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "entity_id": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "link": {
                            "description": "Path in the web app, relative to the app origin.",
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "read": {
                            "type": "number",
                            "description": "1 = read, 0 = unread."
                          },
                          "created_at": {
                            "type": "number",
                            "description": "Epoch milliseconds."
                          }
                        },
                        "required": [
                          "id",
                          "kind",
                          "title",
                          "body",
                          "actor_name",
                          "entity_type",
                          "entity_id",
                          "link",
                          "read",
                          "created_at"
                        ],
                        "additionalProperties": {}
                      }
                    },
                    "unread": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "items",
                    "unread"
                  ]
                },
                "example": {
                  "items": [
                    {
                      "id": "d16873d6-2906-415c-b926-deef865e7c10",
                      "tenant_id": "opexcg-tenant",
                      "user_id": "usr-fajar-nugroho",
                      "ticket_id": null,
                      "entity_type": "leave_request",
                      "entity_id": "f5e82a9f-325e-4069-a3a7-5e3e56a039d5",
                      "link": "/leave/approvals?requestId=f5e82a9f-325e-4069-a3a7-5e3e56a039d5",
                      "approval_task_id": null,
                      "kind": "approval_decision",
                      "title": "Approved: Sick leave for Fajar Nugroho",
                      "body": "2028-03-31 → 2028-03-31 · 1 working day — Enjoy the day off",
                      "actor_name": "Fitri Handayani",
                      "read": 0,
                      "created_at": 1794052052042,
                      "created_by": "usr-fitri-handayani",
                      "deleted_at": null,
                      "deleted_by": null
                    },
                    {
                      "id": "f57e0d52-7c53-40a5-be96-9f4b97a76d46",
                      "tenant_id": "opexcg-tenant",
                      "user_id": "usr-fajar-nugroho",
                      "ticket_id": "8defe6e2-afcd-46ba-a041-da8fdd7665ff",
                      "entity_type": "ticket",
                      "entity_id": "8defe6e2-afcd-46ba-a041-da8fdd7665ff",
                      "link": "/helpdesk/tickets/8defe6e2-afcd-46ba-a041-da8fdd7665ff",
                      "approval_task_id": null,
                      "kind": "new_ticket",
                      "title": "New ticket: Export to CSV times out",
                      "body": "#SUP-2026-000013",
                      "actor_name": "Fitri Handayani",
                      "read": 0,
                      "created_at": 1794052049439,
                      "created_by": null,
                      "deleted_at": null,
                      "deleted_by": null
                    }
                  ],
                  "unread": 2
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/notifications/{id}/read": {
      "post": {
        "operationId": "markNotificationRead",
        "summary": "Mark a notification read",
        "description": "Marks one of the caller's notifications read. An id that is not the caller's is ignored and still answers `ok`.",
        "tags": [
          "Account"
        ],
        "x-opex-entitlement": null,
        "x-opex-permissions": [],
        "x-opex-stability": "stable",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Notification id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Done.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "ok"
                  ]
                },
                "example": {
                  "ok": true
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/notifications/read-all": {
      "post": {
        "operationId": "markAllNotificationsRead",
        "summary": "Mark all notifications read",
        "description": "Marks every notification of the caller in this workspace read.",
        "tags": [
          "Account"
        ],
        "x-opex-entitlement": null,
        "x-opex-permissions": [],
        "x-opex-stability": "stable",
        "responses": {
          "200": {
            "description": "Done.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "ok"
                  ]
                },
                "example": {
                  "ok": true
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/helpdesk/tickets": {
      "get": {
        "operationId": "listTickets",
        "summary": "List tickets",
        "description": "Tickets visible to the caller, newest first by default. Without `ticket:read` the page is empty. The workspace-wide queue needs `helpdesk:tickets:browse`; without it, pass `mine=1` to list your own tickets. Client users see their own tickets, and client admins their company's.\n\nSort keys: `created_at` (default), `modified_at`, `priority`, `status`, `number`, `title`, `sla_due` (soonest first).\n\nProduct: `helpdesk`. Permission (any of): `ticket:read`.",
        "tags": [
          "Helpdesk"
        ],
        "x-opex-entitlement": "helpdesk",
        "x-opex-permissions": [
          "ticket:read"
        ],
        "x-opex-stability": "stable",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "required": false,
            "description": "1-based page number. Default 1.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "required": false,
            "description": "Rows per page, 1 to 100. Larger values are clamped. Default 20.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "description": "Free-text filter (trimmed, first 200 characters).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "required": false,
            "description": "Sort key. Unknown keys fall back to the endpoint's default sort.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dir",
            "in": "query",
            "required": false,
            "description": "`asc` or `desc` (default).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "mine",
            "in": "query",
            "required": false,
            "description": "Only tickets you requested, created or the requester cc'd you on (collaborators). Follower assignments made by admins or support managers are not included. `1` or `true` to enable. Callers without helpdesk:tickets:browse need it to see anything.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Status code, e.g. `new`, `in_progress`, `resolved`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "priority",
            "in": "query",
            "required": false,
            "description": "Priority: `low`, `normal`, `high` or `urgent`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "category",
            "in": "query",
            "required": false,
            "description": "Category text.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "description": "Created at or after this time (epoch milliseconds).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "description": "Created at or before this time (epoch milliseconds).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "One page of tickets.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "number": {
                            "type": "string",
                            "description": "Human-facing number, e.g. `SUP-2026-000011`."
                          },
                          "title": {
                            "type": "string"
                          },
                          "body": {
                            "type": "string",
                            "description": "HTML."
                          },
                          "status": {
                            "type": "string",
                            "description": "Current status code."
                          },
                          "priority": {
                            "type": "string"
                          },
                          "category": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "module": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "product": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "project_id": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "product_id": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "requester_id": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "requester_name": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "assignee_id": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "assignee_name": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "company_name": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "sla_due": {
                            "description": "Resolution deadline, epoch milliseconds.",
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "ai_answered": {
                            "type": "number",
                            "description": "1 when the AI answered the ticket."
                          },
                          "created_at": {
                            "type": "number"
                          },
                          "modified_at": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "resolved_at": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "masters": {
                            "description": "Display data of the status, priority and category.",
                            "type": "object",
                            "properties": {
                              "status": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "code": {
                                    "type": "string"
                                  },
                                  "name": {
                                    "type": "string"
                                  },
                                  "color": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "final": {
                                    "type": "boolean",
                                    "description": "Status only: whether this status ends the ticket."
                                  }
                                },
                                "required": [
                                  "id",
                                  "code",
                                  "name",
                                  "color",
                                  "final"
                                ],
                                "additionalProperties": {}
                              },
                              "priority": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "code": {
                                    "type": "string"
                                  },
                                  "name": {
                                    "type": "string"
                                  },
                                  "color": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "final": {
                                    "type": "boolean",
                                    "description": "Status only: whether this status ends the ticket."
                                  }
                                },
                                "required": [
                                  "id",
                                  "code",
                                  "name",
                                  "color",
                                  "final"
                                ],
                                "additionalProperties": {}
                              },
                              "category": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "code": {
                                    "type": "string"
                                  },
                                  "name": {
                                    "type": "string"
                                  },
                                  "color": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "final": {
                                    "type": "boolean",
                                    "description": "Status only: whether this status ends the ticket."
                                  }
                                },
                                "required": [
                                  "id",
                                  "code",
                                  "name",
                                  "color",
                                  "final"
                                ],
                                "additionalProperties": {}
                              }
                            },
                            "required": [
                              "status",
                              "priority",
                              "category"
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "number",
                          "title",
                          "body",
                          "status",
                          "priority",
                          "category",
                          "module",
                          "product",
                          "ai_answered",
                          "created_at",
                          "resolved_at"
                        ],
                        "additionalProperties": {}
                      }
                    },
                    "total": {
                      "type": "number"
                    },
                    "page": {
                      "type": "number"
                    },
                    "pageSize": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "items",
                    "total",
                    "page",
                    "pageSize"
                  ]
                },
                "example": {
                  "items": [
                    {
                      "id": "8defe6e2-afcd-46ba-a041-da8fdd7665ff",
                      "tenant_id": "opexcg-tenant",
                      "company_id": "comp-xyzind",
                      "project_id": "99e5d1dd-334c-4bc3-88c7-7d84558bf7c6",
                      "product_id": "prod-epicor",
                      "scope": null,
                      "impact": null,
                      "complexity": null,
                      "service_contract_id": null,
                      "number": "SUP-2026-000013",
                      "title": "Export to CSV times out",
                      "body": "Exporting more than 5,000 rows times out after 30 seconds.",
                      "module": null,
                      "product": null,
                      "epicor_environment": null,
                      "priority": "high",
                      "status": "new",
                      "category": null,
                      "triage_confidence": null,
                      "triage_reasoning": null,
                      "triage_completed_at": null,
                      "triage_completed_by": null,
                      "triage_completed_reason": null,
                      "triage_completed_manually": 0,
                      "ai_answered": 0,
                      "suggested_assignee_id": null,
                      "assignee_id": null,
                      "assigned_product_group_id": null,
                      "assigned_project_group_id": null,
                      "requester_id": "usr-fitri-handayani",
                      "external_requester_email": null,
                      "external_requester_name": null,
                      "email_route_id": null,
                      "source": "web",
                      "external_id": null,
                      "duplicate_of_id": null,
                      "dup_score": null,
                      "resolution_text": null,
                      "sla_due": 1794138449198,
                      "sla_policy_id": "slp-default",
                      "sla_response_mins": 240,
                      "sla_resolution_mins": 1440,
                      "sla_business_hours": "24x7",
                      "effort_hours": null,
                      "week_start": null,
                      "created_at": 1794052049198,
                      "created_by": "usr-fitri-handayani",
                      "modified_at": 1794052049198,
                      "modified_by": "usr-fitri-handayani",
                      "deleted_at": null,
                      "deleted_by": null,
                      "resolved_at": null,
                      "last_client_reply_at": 1794052049198,
                      "last_agent_reply_at": 1794052049198,
                      "last_status_change_at": 1794052049198,
                      "external_updated_at": null,
                      "ticket_category_id": null,
                      "ticket_priority_id": null,
                      "ticket_status_id": "st-NEW",
                      "masters": {
                        "category": {
                          "id": null,
                          "code": "",
                          "name": "—",
                          "color": null,
                          "group": null,
                          "group_name": null,
                          "rank": null,
                          "active": false,
                          "resolved": false,
                          "final": false,
                          "isFallback": true
                        },
                        "priority": {
                          "id": null,
                          "code": "high",
                          "name": "High",
                          "color": null,
                          "group": null,
                          "group_name": null,
                          "rank": null,
                          "active": false,
                          "resolved": false,
                          "final": false,
                          "isFallback": true
                        },
                        "status": {
                          "id": "st-NEW",
                          "code": "NEW",
                          "name": "New",
                          "color": "blue",
                          "group": "OPEN",
                          "group_name": "Open",
                          "rank": null,
                          "active": true,
                          "resolved": false,
                          "final": false,
                          "isFallback": false
                        }
                      },
                      "company_name": "XYZ Industries",
                      "requester_name": "Fitri Handayani",
                      "product_name": "Epicor",
                      "assignee_name": null,
                      "assignee_avatar_url": null,
                      "assignee_active": null,
                      "sla_policy_name": "Workspace Default",
                      "triage": {
                        "locked": true,
                        "lockReason": "Complete the triage review before assigning a consultant."
                      }
                    }
                  ],
                  "total": 1,
                  "page": 1,
                  "pageSize": 2
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createTicket",
        "summary": "Open a ticket",
        "description": "Opens a ticket on a project (`projectId`), or on a product (`productId`), in which case the company is resolved from the requester's email domain. Any member may open a ticket. The response says whether the ticket looks like a duplicate and whether the AI answered it straight away.\n\nProduct: `helpdesk`.",
        "tags": [
          "Helpdesk"
        ],
        "x-opex-entitlement": "helpdesk",
        "x-opex-permissions": [],
        "x-opex-stability": "stable",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "projectId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "productId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "companyId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "companyName": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 120
                  },
                  "title": {
                    "type": "string",
                    "minLength": 3,
                    "maxLength": 200
                  },
                  "body": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 20000
                  },
                  "module": {
                    "type": "string",
                    "maxLength": 80
                  },
                  "epicorEnvironment": {
                    "type": "string",
                    "maxLength": 80
                  },
                  "priorityId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "categoryId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "priority": {
                    "default": "normal",
                    "type": "string",
                    "enum": [
                      "low",
                      "normal",
                      "high",
                      "urgent"
                    ]
                  },
                  "customFields": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {}
                  },
                  "collaboratorIds": {
                    "maxItems": 20,
                    "type": "array",
                    "items": {
                      "type": "string",
                      "minLength": 1
                    }
                  },
                  "ccCompanyGroup": {
                    "type": "boolean"
                  },
                  "ccEmails": {
                    "maxItems": 10,
                    "type": "array",
                    "items": {
                      "type": "string",
                      "maxLength": 254,
                      "format": "email",
                      "pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                    }
                  }
                },
                "required": [
                  "title",
                  "body"
                ]
              },
              "example": {
                "projectId": "99e5d1dd-334c-4bc3-88c7-7d84558bf7c6",
                "title": "Export to CSV times out",
                "body": "Exporting more than 5,000 rows times out after 30 seconds.",
                "priority": "high"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The new ticket.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ticket": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "number": {
                          "type": "string",
                          "description": "Human-facing number, e.g. `SUP-2026-000011`."
                        },
                        "title": {
                          "type": "string"
                        },
                        "body": {
                          "type": "string",
                          "description": "HTML."
                        },
                        "status": {
                          "type": "string",
                          "description": "Current status code."
                        },
                        "priority": {
                          "type": "string"
                        },
                        "category": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "module": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "product": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "project_id": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "product_id": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "requester_id": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "requester_name": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "assignee_id": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "assignee_name": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "company_name": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "sla_due": {
                          "description": "Resolution deadline, epoch milliseconds.",
                          "type": [
                            "number",
                            "null"
                          ]
                        },
                        "ai_answered": {
                          "type": "number",
                          "description": "1 when the AI answered the ticket."
                        },
                        "created_at": {
                          "type": "number"
                        },
                        "modified_at": {
                          "type": [
                            "number",
                            "null"
                          ]
                        },
                        "resolved_at": {
                          "type": [
                            "number",
                            "null"
                          ]
                        },
                        "masters": {
                          "description": "Display data of the status, priority and category.",
                          "type": "object",
                          "properties": {
                            "status": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": [
                                    "string",
                                    "null"
                                  ]
                                },
                                "code": {
                                  "type": "string"
                                },
                                "name": {
                                  "type": "string"
                                },
                                "color": {
                                  "type": [
                                    "string",
                                    "null"
                                  ]
                                },
                                "final": {
                                  "type": "boolean",
                                  "description": "Status only: whether this status ends the ticket."
                                }
                              },
                              "required": [
                                "id",
                                "code",
                                "name",
                                "color",
                                "final"
                              ],
                              "additionalProperties": {}
                            },
                            "priority": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": [
                                    "string",
                                    "null"
                                  ]
                                },
                                "code": {
                                  "type": "string"
                                },
                                "name": {
                                  "type": "string"
                                },
                                "color": {
                                  "type": [
                                    "string",
                                    "null"
                                  ]
                                },
                                "final": {
                                  "type": "boolean",
                                  "description": "Status only: whether this status ends the ticket."
                                }
                              },
                              "required": [
                                "id",
                                "code",
                                "name",
                                "color",
                                "final"
                              ],
                              "additionalProperties": {}
                            },
                            "category": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": [
                                    "string",
                                    "null"
                                  ]
                                },
                                "code": {
                                  "type": "string"
                                },
                                "name": {
                                  "type": "string"
                                },
                                "color": {
                                  "type": [
                                    "string",
                                    "null"
                                  ]
                                },
                                "final": {
                                  "type": "boolean",
                                  "description": "Status only: whether this status ends the ticket."
                                }
                              },
                              "required": [
                                "id",
                                "code",
                                "name",
                                "color",
                                "final"
                              ],
                              "additionalProperties": {}
                            }
                          },
                          "required": [
                            "status",
                            "priority",
                            "category"
                          ]
                        }
                      },
                      "required": [
                        "id",
                        "number",
                        "title",
                        "body",
                        "status",
                        "priority",
                        "category",
                        "module",
                        "product",
                        "ai_answered",
                        "created_at",
                        "resolved_at"
                      ],
                      "additionalProperties": {}
                    },
                    "duplicate": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string"
                            },
                            "number": {
                              "type": "string"
                            },
                            "title": {
                              "type": "string"
                            },
                            "score": {
                              "type": "number"
                            }
                          },
                          "required": [
                            "id",
                            "number",
                            "title",
                            "score"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "An open ticket this one most likely duplicates."
                    },
                    "aiAnswered": {
                      "type": "boolean"
                    },
                    "aiAnswerBody": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "supportWarning": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string"
                            },
                            "message": {
                              "type": "string"
                            },
                            "expiryDate": {
                              "type": [
                                "number",
                                "null"
                              ]
                            }
                          },
                          "required": [
                            "type",
                            "message",
                            "expiryDate"
                          ],
                          "additionalProperties": {}
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Set when the project's support service is missing or expired."
                    }
                  },
                  "required": [
                    "ticket",
                    "duplicate",
                    "aiAnswered",
                    "aiAnswerBody",
                    "supportWarning"
                  ]
                },
                "example": {
                  "ticket": {
                    "id": "8defe6e2-afcd-46ba-a041-da8fdd7665ff",
                    "tenant_id": "opexcg-tenant",
                    "company_id": "comp-xyzind",
                    "project_id": "99e5d1dd-334c-4bc3-88c7-7d84558bf7c6",
                    "product_id": "prod-epicor",
                    "scope": null,
                    "impact": null,
                    "complexity": null,
                    "service_contract_id": null,
                    "number": "SUP-2026-000013",
                    "title": "Export to CSV times out",
                    "body": "Exporting more than 5,000 rows times out after 30 seconds.",
                    "module": null,
                    "product": null,
                    "epicor_environment": null,
                    "priority": "high",
                    "status": "new",
                    "category": null,
                    "triage_confidence": null,
                    "triage_reasoning": null,
                    "triage_completed_at": null,
                    "triage_completed_by": null,
                    "triage_completed_reason": null,
                    "triage_completed_manually": 0,
                    "ai_answered": 0,
                    "suggested_assignee_id": null,
                    "assignee_id": null,
                    "assigned_product_group_id": null,
                    "assigned_project_group_id": null,
                    "requester_id": "usr-fitri-handayani",
                    "external_requester_email": null,
                    "external_requester_name": null,
                    "email_route_id": null,
                    "source": "web",
                    "external_id": null,
                    "duplicate_of_id": null,
                    "dup_score": null,
                    "resolution_text": null,
                    "sla_due": 1794138449198,
                    "sla_policy_id": "slp-default",
                    "sla_response_mins": 240,
                    "sla_resolution_mins": 1440,
                    "sla_business_hours": "24x7",
                    "effort_hours": null,
                    "week_start": null,
                    "created_at": 1794052049198,
                    "created_by": "usr-fitri-handayani",
                    "modified_at": 1794052049198,
                    "modified_by": "usr-fitri-handayani",
                    "deleted_at": null,
                    "deleted_by": null,
                    "resolved_at": null,
                    "last_client_reply_at": 1794052049198,
                    "last_agent_reply_at": 1794052049198,
                    "last_status_change_at": 1794052049198,
                    "external_updated_at": null,
                    "ticket_category_id": null,
                    "ticket_priority_id": null,
                    "ticket_status_id": "st-NEW",
                    "requester_name": "Fitri Handayani",
                    "assignee_name": null,
                    "assignee_avatar_url": null,
                    "masters": {
                      "category": {
                        "id": null,
                        "code": "",
                        "name": "—",
                        "color": null,
                        "group": null,
                        "group_name": null,
                        "rank": null,
                        "active": false,
                        "resolved": false,
                        "final": false,
                        "isFallback": true
                      },
                      "priority": {
                        "id": null,
                        "code": "high",
                        "name": "High",
                        "color": null,
                        "group": null,
                        "group_name": null,
                        "rank": null,
                        "active": false,
                        "resolved": false,
                        "final": false,
                        "isFallback": true
                      },
                      "status": {
                        "id": "st-NEW",
                        "code": "NEW",
                        "name": "New",
                        "color": "blue",
                        "group": "OPEN",
                        "group_name": "Open",
                        "rank": null,
                        "active": true,
                        "resolved": false,
                        "final": false,
                        "isFallback": false
                      }
                    }
                  },
                  "duplicate": null,
                  "aiAnswered": false,
                  "aiAnswerBody": null,
                  "supportWarning": {
                    "type": "no_agreement",
                    "message": "Project \"Customer portal rollout\" has no Support Service Agreement. Consider rejecting this ticket.",
                    "internalMessage": "Project \"Customer portal rollout\" has no Support Service Agreement. Consider rejecting this ticket.",
                    "clientMessage": "Project \"Customer portal rollout\" has no active Support Service Agreement. This ticket may be rejected.",
                    "expiryDate": null
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. Codes: `project_not_found`, `config_error`. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/helpdesk/tickets/{id}": {
      "get": {
        "operationId": "getTicket",
        "summary": "Get a ticket",
        "description": "One ticket with its conversation (`events`). Internal notes are included only for internal staff.\n\nProduct: `helpdesk`. Permission (any of): `ticket:read`.",
        "tags": [
          "Helpdesk"
        ],
        "x-opex-entitlement": "helpdesk",
        "x-opex-permissions": [
          "ticket:read"
        ],
        "x-opex-stability": "stable",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Ticket id (not the SUP- number).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The ticket.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ticket": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "number": {
                          "type": "string",
                          "description": "Human-facing number, e.g. `SUP-2026-000011`."
                        },
                        "title": {
                          "type": "string"
                        },
                        "body": {
                          "type": "string",
                          "description": "HTML."
                        },
                        "status": {
                          "type": "string",
                          "description": "Current status code."
                        },
                        "priority": {
                          "type": "string"
                        },
                        "category": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "module": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "product": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "project_id": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "product_id": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "requester_id": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "requester_name": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "assignee_id": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "assignee_name": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "company_name": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "sla_due": {
                          "description": "Resolution deadline, epoch milliseconds.",
                          "type": [
                            "number",
                            "null"
                          ]
                        },
                        "ai_answered": {
                          "type": "number",
                          "description": "1 when the AI answered the ticket."
                        },
                        "created_at": {
                          "type": "number"
                        },
                        "modified_at": {
                          "type": [
                            "number",
                            "null"
                          ]
                        },
                        "resolved_at": {
                          "type": [
                            "number",
                            "null"
                          ]
                        },
                        "masters": {
                          "description": "Display data of the status, priority and category.",
                          "type": "object",
                          "properties": {
                            "status": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": [
                                    "string",
                                    "null"
                                  ]
                                },
                                "code": {
                                  "type": "string"
                                },
                                "name": {
                                  "type": "string"
                                },
                                "color": {
                                  "type": [
                                    "string",
                                    "null"
                                  ]
                                },
                                "final": {
                                  "type": "boolean",
                                  "description": "Status only: whether this status ends the ticket."
                                }
                              },
                              "required": [
                                "id",
                                "code",
                                "name",
                                "color",
                                "final"
                              ],
                              "additionalProperties": {}
                            },
                            "priority": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": [
                                    "string",
                                    "null"
                                  ]
                                },
                                "code": {
                                  "type": "string"
                                },
                                "name": {
                                  "type": "string"
                                },
                                "color": {
                                  "type": [
                                    "string",
                                    "null"
                                  ]
                                },
                                "final": {
                                  "type": "boolean",
                                  "description": "Status only: whether this status ends the ticket."
                                }
                              },
                              "required": [
                                "id",
                                "code",
                                "name",
                                "color",
                                "final"
                              ],
                              "additionalProperties": {}
                            },
                            "category": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": [
                                    "string",
                                    "null"
                                  ]
                                },
                                "code": {
                                  "type": "string"
                                },
                                "name": {
                                  "type": "string"
                                },
                                "color": {
                                  "type": [
                                    "string",
                                    "null"
                                  ]
                                },
                                "final": {
                                  "type": "boolean",
                                  "description": "Status only: whether this status ends the ticket."
                                }
                              },
                              "required": [
                                "id",
                                "code",
                                "name",
                                "color",
                                "final"
                              ],
                              "additionalProperties": {}
                            }
                          },
                          "required": [
                            "status",
                            "priority",
                            "category"
                          ]
                        }
                      },
                      "required": [
                        "id",
                        "number",
                        "title",
                        "body",
                        "status",
                        "priority",
                        "category",
                        "module",
                        "product",
                        "ai_answered",
                        "created_at",
                        "resolved_at"
                      ],
                      "additionalProperties": {}
                    },
                    "events": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "kind": {
                            "type": "string",
                            "description": "`comment`, `internal_note`, `status_change`, …"
                          },
                          "author_kind": {
                            "type": "string",
                            "enum": [
                              "human",
                              "ai",
                              "system"
                            ]
                          },
                          "author_id": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "author_name": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "body": {
                            "description": "HTML.",
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "created_at": {
                            "type": "number"
                          }
                        },
                        "required": [
                          "id",
                          "kind",
                          "author_kind",
                          "body",
                          "created_at"
                        ],
                        "additionalProperties": {}
                      },
                      "description": "The conversation, oldest first."
                    }
                  },
                  "required": [
                    "ticket",
                    "events"
                  ],
                  "additionalProperties": {}
                },
                "example": {
                  "ticket": {
                    "id": "8defe6e2-afcd-46ba-a041-da8fdd7665ff",
                    "tenant_id": "opexcg-tenant",
                    "company_id": "comp-xyzind",
                    "project_id": "99e5d1dd-334c-4bc3-88c7-7d84558bf7c6",
                    "product_id": "prod-epicor",
                    "scope": null,
                    "impact": null,
                    "complexity": null,
                    "service_contract_id": null,
                    "number": "SUP-2026-000013",
                    "title": "Export to CSV times out",
                    "body": "Exporting more than 5,000 rows times out after 30 seconds.",
                    "module": null,
                    "product": null,
                    "epicor_environment": null,
                    "priority": "high",
                    "status": "new",
                    "category": null,
                    "triage_confidence": null,
                    "triage_reasoning": null,
                    "triage_completed_at": null,
                    "triage_completed_by": null,
                    "triage_completed_reason": null,
                    "triage_completed_manually": 0,
                    "ai_answered": 0,
                    "suggested_assignee_id": null,
                    "assignee_id": null,
                    "assigned_product_group_id": null,
                    "assigned_project_group_id": null,
                    "requester_id": "usr-fitri-handayani",
                    "external_requester_email": null,
                    "external_requester_name": null,
                    "email_route_id": null,
                    "source": "web",
                    "external_id": null,
                    "duplicate_of_id": null,
                    "dup_score": null,
                    "resolution_text": null,
                    "sla_due": 1794138449198,
                    "sla_policy_id": "slp-default",
                    "sla_response_mins": 240,
                    "sla_resolution_mins": 1440,
                    "sla_business_hours": "24x7",
                    "effort_hours": null,
                    "week_start": null,
                    "created_at": 1794052049198,
                    "created_by": "usr-fitri-handayani",
                    "modified_at": 1794052049198,
                    "modified_by": "usr-fitri-handayani",
                    "deleted_at": null,
                    "deleted_by": null,
                    "resolved_at": null,
                    "last_client_reply_at": 1794052049198,
                    "last_agent_reply_at": 1794052049198,
                    "last_status_change_at": 1794052049198,
                    "external_updated_at": null,
                    "ticket_category_id": null,
                    "ticket_priority_id": null,
                    "ticket_status_id": "st-NEW",
                    "requester_name": "Fitri Handayani",
                    "assignee_name": null,
                    "assignee_avatar_url": null,
                    "masters": {
                      "category": {
                        "id": null,
                        "code": "",
                        "name": "—",
                        "color": null,
                        "group": null,
                        "group_name": null,
                        "rank": null,
                        "active": false,
                        "resolved": false,
                        "final": false,
                        "isFallback": true
                      },
                      "priority": {
                        "id": null,
                        "code": "high",
                        "name": "High",
                        "color": null,
                        "group": null,
                        "group_name": null,
                        "rank": null,
                        "active": false,
                        "resolved": false,
                        "final": false,
                        "isFallback": true
                      },
                      "status": {
                        "id": "st-NEW",
                        "code": "NEW",
                        "name": "New",
                        "color": "blue",
                        "group": "OPEN",
                        "group_name": "Open",
                        "rank": null,
                        "active": true,
                        "resolved": false,
                        "final": false,
                        "isFallback": false
                      }
                    }
                  },
                  "events": [
                    {
                      "id": "5468efd1-0b36-4e67-9c5e-9abc6b03bd99",
                      "tenant_id": "opexcg-tenant",
                      "ticket_id": "8defe6e2-afcd-46ba-a041-da8fdd7665ff",
                      "author_id": null,
                      "author_kind": "system",
                      "kind": "status_change",
                      "body": "Ticket created — New",
                      "meta_json": null,
                      "created_at": 1794052049198,
                      "created_by": "usr-fitri-handayani",
                      "deleted_at": null,
                      "deleted_by": null,
                      "external_id": null,
                      "synced": 0,
                      "author_name": null,
                      "author_avatar_url": null
                    },
                    {
                      "id": "85307395-dee3-48b7-bede-1308e17fe64d",
                      "tenant_id": "opexcg-tenant",
                      "ticket_id": "8defe6e2-afcd-46ba-a041-da8fdd7665ff",
                      "author_id": null,
                      "author_kind": "system",
                      "kind": "comment",
                      "body": "Thank you for contacting OpexCG support. Your ticket has been received and our team will review it shortly. Ticket number: SUP-2026-000013",
                      "meta_json": "{\"source\":\"automation\",\"kind\":\"auto_reply\"}",
                      "created_at": 1794052049404,
                      "created_by": null,
                      "deleted_at": null,
                      "deleted_by": null,
                      "external_id": null,
                      "synced": 0,
                      "author_name": null,
                      "author_avatar_url": null
                    }
                  ],
                  "supportWarning": {
                    "type": "no_agreement",
                    "message": "Project \"Customer portal rollout\" has no Support Service Agreement. Consider rejecting this ticket.",
                    "internalMessage": "Project \"Customer portal rollout\" has no Support Service Agreement. Consider rejecting this ticket.",
                    "clientMessage": "Project \"Customer portal rollout\" has no active Support Service Agreement. This ticket may be rejected.",
                    "expiryDate": null
                  },
                  "collaborators": null,
                  "journey": {
                    "visitedCodes": [
                      "NEW"
                    ],
                    "currentCategory": "OPEN",
                    "previousStage": null
                  },
                  "triage": {
                    "complete": false,
                    "completeWithoutAi": false,
                    "awaitingReview": false,
                    "locked": true,
                    "lockReason": "Complete the triage review before assigning a consultant.",
                    "phase": "queued"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. Codes: `not_found`, `forbidden`. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateTicket",
        "summary": "Update a ticket",
        "description": "Changes priority, category, product, project or module (staff only). Pass master ids from the workspace's configured priorities and categories; omitted fields stay as they are.\n\nProduct: `helpdesk`. Permission (any of): `helpdesk:ticket:work`.",
        "tags": [
          "Helpdesk"
        ],
        "x-opex-entitlement": "helpdesk",
        "x-opex-permissions": [
          "helpdesk:ticket:work"
        ],
        "x-opex-stability": "stable",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Ticket id (not the SUP- number).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "priorityId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "categoryId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "productId": {
                    "anyOf": [
                      {
                        "type": "string",
                        "minLength": 1
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "projectId": {
                    "anyOf": [
                      {
                        "type": "string",
                        "minLength": 1
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "companyId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "module": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 80
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "requesterId": {
                    "type": "string",
                    "minLength": 1
                  }
                }
              },
              "example": {
                "priorityId": "prio-LOW"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated ticket.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ticket": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string"
                            },
                            "number": {
                              "type": "string",
                              "description": "Human-facing number, e.g. `SUP-2026-000011`."
                            },
                            "title": {
                              "type": "string"
                            },
                            "body": {
                              "type": "string",
                              "description": "HTML."
                            },
                            "status": {
                              "type": "string",
                              "description": "Current status code."
                            },
                            "priority": {
                              "type": "string"
                            },
                            "category": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "module": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "product": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "project_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "product_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "requester_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "requester_name": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "assignee_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "assignee_name": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "company_name": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "sla_due": {
                              "description": "Resolution deadline, epoch milliseconds.",
                              "type": [
                                "number",
                                "null"
                              ]
                            },
                            "ai_answered": {
                              "type": "number",
                              "description": "1 when the AI answered the ticket."
                            },
                            "created_at": {
                              "type": "number"
                            },
                            "modified_at": {
                              "type": [
                                "number",
                                "null"
                              ]
                            },
                            "resolved_at": {
                              "type": [
                                "number",
                                "null"
                              ]
                            },
                            "masters": {
                              "description": "Display data of the status, priority and category.",
                              "type": "object",
                              "properties": {
                                "status": {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": [
                                        "string",
                                        "null"
                                      ]
                                    },
                                    "code": {
                                      "type": "string"
                                    },
                                    "name": {
                                      "type": "string"
                                    },
                                    "color": {
                                      "type": [
                                        "string",
                                        "null"
                                      ]
                                    },
                                    "final": {
                                      "type": "boolean",
                                      "description": "Status only: whether this status ends the ticket."
                                    }
                                  },
                                  "required": [
                                    "id",
                                    "code",
                                    "name",
                                    "color",
                                    "final"
                                  ],
                                  "additionalProperties": {}
                                },
                                "priority": {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": [
                                        "string",
                                        "null"
                                      ]
                                    },
                                    "code": {
                                      "type": "string"
                                    },
                                    "name": {
                                      "type": "string"
                                    },
                                    "color": {
                                      "type": [
                                        "string",
                                        "null"
                                      ]
                                    },
                                    "final": {
                                      "type": "boolean",
                                      "description": "Status only: whether this status ends the ticket."
                                    }
                                  },
                                  "required": [
                                    "id",
                                    "code",
                                    "name",
                                    "color",
                                    "final"
                                  ],
                                  "additionalProperties": {}
                                },
                                "category": {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": [
                                        "string",
                                        "null"
                                      ]
                                    },
                                    "code": {
                                      "type": "string"
                                    },
                                    "name": {
                                      "type": "string"
                                    },
                                    "color": {
                                      "type": [
                                        "string",
                                        "null"
                                      ]
                                    },
                                    "final": {
                                      "type": "boolean",
                                      "description": "Status only: whether this status ends the ticket."
                                    }
                                  },
                                  "required": [
                                    "id",
                                    "code",
                                    "name",
                                    "color",
                                    "final"
                                  ],
                                  "additionalProperties": {}
                                }
                              },
                              "required": [
                                "status",
                                "priority",
                                "category"
                              ]
                            }
                          },
                          "required": [
                            "id",
                            "number",
                            "title",
                            "body",
                            "status",
                            "priority",
                            "category",
                            "module",
                            "product",
                            "ai_answered",
                            "created_at",
                            "resolved_at"
                          ],
                          "additionalProperties": {}
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "ticket"
                  ]
                },
                "example": {
                  "ticket": {
                    "id": "8defe6e2-afcd-46ba-a041-da8fdd7665ff",
                    "tenant_id": "opexcg-tenant",
                    "company_id": "comp-xyzind",
                    "project_id": "99e5d1dd-334c-4bc3-88c7-7d84558bf7c6",
                    "product_id": "prod-epicor",
                    "scope": null,
                    "impact": null,
                    "complexity": null,
                    "service_contract_id": null,
                    "number": "SUP-2026-000013",
                    "title": "Export to CSV times out",
                    "body": "Exporting more than 5,000 rows times out after 30 seconds.",
                    "module": null,
                    "product": null,
                    "epicor_environment": null,
                    "priority": "low",
                    "status": "new",
                    "category": null,
                    "triage_confidence": null,
                    "triage_reasoning": null,
                    "triage_completed_at": null,
                    "triage_completed_by": null,
                    "triage_completed_reason": null,
                    "triage_completed_manually": 0,
                    "triage_phase": "queued",
                    "ai_answered": 0,
                    "suggested_assignee_id": null,
                    "assignee_id": null,
                    "assigned_product_group_id": null,
                    "assigned_project_group_id": null,
                    "requester_id": "usr-fitri-handayani",
                    "external_requester_email": null,
                    "external_requester_name": null,
                    "email_route_id": null,
                    "source": "web",
                    "external_id": null,
                    "duplicate_of_id": null,
                    "dup_score": null,
                    "resolution_text": null,
                    "sla_due": 1794138449198,
                    "sla_policy_id": "slp-default",
                    "sla_response_mins": 240,
                    "sla_resolution_mins": 1440,
                    "sla_business_hours": "24x7",
                    "effort_hours": null,
                    "week_start": null,
                    "created_at": 1794052049198,
                    "created_by": "usr-fitri-handayani",
                    "modified_at": 1794052049795,
                    "modified_by": "usr-fitri-handayani",
                    "deleted_at": null,
                    "deleted_by": null,
                    "resolved_at": null,
                    "last_client_reply_at": 1794052049198,
                    "last_agent_reply_at": 1794052049198,
                    "last_status_change_at": 1794052049198,
                    "external_updated_at": null,
                    "ticket_category_id": null,
                    "ticket_priority_id": "prio-LOW",
                    "ticket_status_id": "st-NEW",
                    "requester_name": "Fitri Handayani",
                    "assignee_name": null,
                    "assignee_avatar_url": null,
                    "masters": {
                      "category": {
                        "id": null,
                        "code": "",
                        "name": "—",
                        "color": null,
                        "group": null,
                        "group_name": null,
                        "rank": null,
                        "active": false,
                        "resolved": false,
                        "final": false,
                        "isFallback": true
                      },
                      "priority": {
                        "id": "prio-LOW",
                        "code": "LOW",
                        "name": "Low",
                        "color": "gray",
                        "group": null,
                        "group_name": null,
                        "rank": 4,
                        "active": true,
                        "resolved": false,
                        "final": false,
                        "isFallback": false
                      },
                      "status": {
                        "id": "st-NEW",
                        "code": "NEW",
                        "name": "New",
                        "color": "blue",
                        "group": "OPEN",
                        "group_name": "Open",
                        "rank": null,
                        "active": true,
                        "resolved": false,
                        "final": false,
                        "isFallback": false
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. Codes: `not_found`, `forbidden`, `master_invalid`, `product_not_found`, `project_not_found`, `project_inactive`. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/helpdesk/tickets/{id}/events": {
      "post": {
        "operationId": "addTicketEvent",
        "summary": "Reply or add a note",
        "description": "Adds a public reply, or an internal note with `internal: true` (staff only). Staff can move the ticket in the same call with `statusPurpose` (a status code of the workspace's status workflow). Public staff replies are emailed to the requester.\n\nProduct: `helpdesk`. Permission (any of): `ticket:read`. Requesters may reply to their own tickets; internal notes and status moves need staff access.",
        "tags": [
          "Helpdesk"
        ],
        "x-opex-entitlement": "helpdesk",
        "x-opex-permissions": [
          "ticket:read"
        ],
        "x-opex-stability": "stable",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Ticket id (not the SUP- number).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "body": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 20000
                  },
                  "internal": {
                    "default": false,
                    "type": "boolean"
                  },
                  "mentions": {
                    "maxItems": 20,
                    "type": "array",
                    "items": {
                      "type": "string",
                      "minLength": 1
                    }
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "new",
                      "in_progress",
                      "awaiting_requester",
                      "pending_third_party",
                      "resolved"
                    ]
                  },
                  "statusPurpose": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 40
                  },
                  "cc": {
                    "maxItems": 10,
                    "type": "array",
                    "items": {
                      "type": "string",
                      "maxLength": 254
                    }
                  },
                  "bcc": {
                    "maxItems": 10,
                    "type": "array",
                    "items": {
                      "type": "string",
                      "maxLength": 254
                    }
                  },
                  "signature": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "body"
                ]
              },
              "example": {
                "body": "Reproduced on 6,200 rows. Looking at the query plan.",
                "internal": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The new event id.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "const": true
                    },
                    "id": {
                      "type": "string",
                      "description": "The new event's id."
                    }
                  },
                  "required": [
                    "ok",
                    "id"
                  ]
                },
                "example": {
                  "ok": true,
                  "id": "35cb9a0a-601e-4425-8676-de8e317d3136"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. Codes: `not_found`, `forbidden`, `cc_bcc_staff_only`, `cc_bcc_internal_note`. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/helpdesk/tickets/{id}/close": {
      "post": {
        "operationId": "closeTicket",
        "summary": "Close a ticket",
        "description": "Moves the ticket to the closed status of the workspace's status workflow and emails the requester. Consultants can close only tickets assigned to them. When the workflow still waits for other actions, the ticket stays put and the answer lists them in `awaitingTriggers`.\n\nProduct: `helpdesk`. Permission (any of): `helpdesk:ticket:work`.",
        "tags": [
          "Helpdesk"
        ],
        "x-opex-entitlement": "helpdesk",
        "x-opex-permissions": [
          "helpdesk:ticket:work"
        ],
        "x-opex-stability": "stable",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Ticket id (not the SUP- number).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The new status.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "const": true
                    },
                    "status": {
                      "type": "string",
                      "description": "The ticket's status code after the call."
                    },
                    "awaitingTriggers": {
                      "description": "Actions the status workflow still waits for; the ticket did not move.",
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "ok",
                    "status"
                  ]
                },
                "example": {
                  "ok": true,
                  "status": "CLOSED"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. Codes: `not_found`, `forbidden`. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/timesheets": {
      "get": {
        "operationId": "listTimeEntries",
        "summary": "List time entries",
        "description": "Time entries, newest first. Without `timesheets:entry:read_others` only your own entries are returned. This list pages with `limit` and `offset` (not `page`/`pageSize`).\n\nProduct: `timesheets`. Permission (any of): `timesheets:entry:read_own`, `timesheets:entry:read_others`.",
        "tags": [
          "Timesheets"
        ],
        "x-opex-entitlement": "timesheets",
        "x-opex-permissions": [
          "timesheets:entry:read_own",
          "timesheets:entry:read_others"
        ],
        "x-opex-stability": "stable",
        "parameters": [
          {
            "name": "dateFrom",
            "in": "query",
            "required": false,
            "description": "Started on or after this day (`YYYY-MM-DD`).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dateTo",
            "in": "query",
            "required": false,
            "description": "Started on or before this day (`YYYY-MM-DD`, inclusive).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dateFromMs",
            "in": "query",
            "required": false,
            "description": "Like `dateFrom`, as epoch milliseconds. Wins over `dateFrom`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dateToMs",
            "in": "query",
            "required": false,
            "description": "Like `dateTo`, as epoch milliseconds. Wins over `dateTo`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "projectId",
            "in": "query",
            "required": false,
            "description": "Only entries on this project.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "`running`, `pending`, `approved`, `rejected` or `invoiced`. Any other value answers 400.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "userId",
            "in": "query",
            "required": false,
            "description": "Only this member's entries. Needs timesheets:entry:read_others for anyone but you.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "mine",
            "in": "query",
            "required": false,
            "description": "`1` to return only your own entries.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "description": "Substring of the description.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Rows per page, 1 to 500. Default 50.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "description": "Rows to skip. Default 0.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "required": false,
            "description": "`started_at` (default), `duration` or `description`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dir",
            "in": "query",
            "required": false,
            "description": "`asc` or `desc`.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "One page of entries.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "entries": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "user_id": {
                            "type": "string"
                          },
                          "project_id": {
                            "type": "string"
                          },
                          "description": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "started_at": {
                            "type": "number",
                            "description": "Epoch milliseconds."
                          },
                          "ended_at": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "duration_minutes": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "running",
                              "pending",
                              "approved",
                              "rejected",
                              "invoiced"
                            ]
                          },
                          "billable": {
                            "type": "number",
                            "description": "1 = billable."
                          },
                          "source": {
                            "type": "string",
                            "description": "`manual`, `timer`, `calendar` or `agent`."
                          },
                          "subject_type": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "ticket",
                                  "task"
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "subject_id": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "created_at": {
                            "type": "number"
                          },
                          "total_cost": {
                            "description": "Cost at the member's rate, when a rate is set.",
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "project_name": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "task_name": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "user_name": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "tagIds": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          }
                        },
                        "required": [
                          "id",
                          "user_id",
                          "project_id",
                          "description",
                          "started_at",
                          "ended_at",
                          "duration_minutes",
                          "status",
                          "billable",
                          "source",
                          "subject_type",
                          "subject_id",
                          "created_at",
                          "total_cost",
                          "project_name",
                          "task_name",
                          "user_name",
                          "tagIds"
                        ],
                        "additionalProperties": {}
                      }
                    },
                    "total": {
                      "type": "number"
                    },
                    "limit": {
                      "type": "number"
                    },
                    "offset": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "entries",
                    "total",
                    "limit",
                    "offset"
                  ]
                },
                "example": {
                  "entries": [
                    {
                      "id": "728a50d8-ec6d-4b7e-b2f2-ea6d7ff79641",
                      "tenant_id": "opexcg-tenant",
                      "user_id": "usr-fitri-handayani",
                      "project_id": "99e5d1dd-334c-4bc3-88c7-7d84558bf7c6",
                      "description": "Integration workshop",
                      "started_at": 1794044848931,
                      "ended_at": 1794050248931,
                      "duration_minutes": 90,
                      "status": "approved",
                      "entry_method": "manual",
                      "source": "manual",
                      "billable": 1,
                      "subject_type": null,
                      "subject_id": null,
                      "clockify_id": null,
                      "agent_name": null,
                      "model": null,
                      "input_tokens": null,
                      "output_tokens": null,
                      "cache_read_tokens": null,
                      "cache_write_tokens": null,
                      "reasoning_tokens": null,
                      "approved_by": null,
                      "approved_at": null,
                      "rejection_reason": null,
                      "cost_rate": null,
                      "cost_currency": null,
                      "cost_source": "uncosted",
                      "cost_group_id": null,
                      "checksum": "03ce1d14ade9e654bc81e32a9f8b2325ecbc84f1ce17532ca55e0ad82f08792b",
                      "created_at": 1794052048976,
                      "created_by": "usr-fitri-handayani",
                      "modified_at": 1794052048976,
                      "modified_by": "usr-fitri-handayani",
                      "deleted_at": null,
                      "deleted_by": null,
                      "project_name": "Customer portal rollout",
                      "task_name": null,
                      "user_name": "Fitri Handayani",
                      "tagIds": [],
                      "total_cost": null,
                      "totalCost": null,
                      "costRate": null,
                      "costCurrency": null,
                      "costSource": "uncosted",
                      "costGroupId": null
                    }
                  ],
                  "total": 1,
                  "limit": 2,
                  "offset": 0
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. Codes: `own_entries_only`. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createTimeEntry",
        "summary": "Log time",
        "description": "Logs a time entry for the caller. Give `startedAt` and `endedAt` (epoch milliseconds), or `durationMinutes`. The entry is always yours: the user, status and checksum are set by the server.\n\nProduct: `timesheets`. Permission (any of): `timesheets:entry:create`.",
        "tags": [
          "Timesheets"
        ],
        "x-opex-entitlement": "timesheets",
        "x-opex-permissions": [
          "timesheets:entry:create"
        ],
        "x-opex-stability": "stable",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "projectId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "description": {
                    "type": "string",
                    "maxLength": 4000
                  },
                  "startedAt": {
                    "type": "number"
                  },
                  "endedAt": {
                    "type": "number"
                  },
                  "durationMinutes": {
                    "type": "number",
                    "minimum": 0
                  },
                  "entryMethod": {
                    "type": "string",
                    "enum": [
                      "timer",
                      "manual",
                      "import"
                    ]
                  },
                  "source": {
                    "type": "string",
                    "enum": [
                      "timer",
                      "manual",
                      "calendar",
                      "agent"
                    ]
                  },
                  "agentName": {
                    "type": "string",
                    "maxLength": 200
                  },
                  "model": {
                    "type": "string",
                    "maxLength": 200
                  },
                  "inputTokens": {
                    "type": "number"
                  },
                  "outputTokens": {
                    "type": "number"
                  },
                  "cacheReadTokens": {
                    "type": "number"
                  },
                  "cacheWriteTokens": {
                    "type": "number"
                  },
                  "reasoningTokens": {
                    "type": "number"
                  },
                  "billable": {
                    "type": "boolean"
                  },
                  "subjectType": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "ticket",
                          "task"
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "subjectId": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "tagIds": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                },
                "required": [
                  "projectId"
                ]
              },
              "example": {
                "projectId": "99e5d1dd-334c-4bc3-88c7-7d84558bf7c6",
                "description": "Integration workshop",
                "startedAt": 1794044848931,
                "endedAt": 1794050248931,
                "billable": true
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The new entry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "user_id": {
                      "type": "string"
                    },
                    "project_id": {
                      "type": "string"
                    },
                    "description": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "started_at": {
                      "type": "number",
                      "description": "Epoch milliseconds."
                    },
                    "ended_at": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "duration_minutes": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "running",
                        "pending",
                        "approved",
                        "rejected",
                        "invoiced"
                      ]
                    },
                    "billable": {
                      "type": "number",
                      "description": "1 = billable."
                    },
                    "source": {
                      "type": "string",
                      "description": "`manual`, `timer`, `calendar` or `agent`."
                    },
                    "subject_type": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "ticket",
                            "task"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "subject_id": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "created_at": {
                      "type": "number"
                    },
                    "total_cost": {
                      "description": "Cost at the member's rate, when a rate is set.",
                      "type": [
                        "number",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "user_id",
                    "project_id",
                    "description",
                    "started_at",
                    "ended_at",
                    "duration_minutes",
                    "status",
                    "billable",
                    "source",
                    "subject_type",
                    "subject_id",
                    "created_at",
                    "total_cost"
                  ],
                  "additionalProperties": {}
                },
                "example": {
                  "id": "728a50d8-ec6d-4b7e-b2f2-ea6d7ff79641",
                  "tenant_id": "opexcg-tenant",
                  "user_id": "usr-fitri-handayani",
                  "project_id": "99e5d1dd-334c-4bc3-88c7-7d84558bf7c6",
                  "description": "Integration workshop",
                  "started_at": 1794044848931,
                  "ended_at": 1794050248931,
                  "duration_minutes": 90,
                  "status": "approved",
                  "entry_method": "manual",
                  "source": "manual",
                  "billable": 1,
                  "subject_type": null,
                  "subject_id": null,
                  "clockify_id": null,
                  "agent_name": null,
                  "model": null,
                  "input_tokens": null,
                  "output_tokens": null,
                  "cache_read_tokens": null,
                  "cache_write_tokens": null,
                  "reasoning_tokens": null,
                  "approved_by": null,
                  "approved_at": null,
                  "rejection_reason": null,
                  "cost_rate": null,
                  "cost_currency": null,
                  "cost_source": "uncosted",
                  "cost_group_id": null,
                  "checksum": "03ce1d14ade9e654bc81e32a9f8b2325ecbc84f1ce17532ca55e0ad82f08792b",
                  "created_at": 1794052048976,
                  "created_by": "usr-fitri-handayani",
                  "modified_at": 1794052048976,
                  "modified_by": "usr-fitri-handayani",
                  "deleted_at": null,
                  "deleted_by": null,
                  "total_cost": null,
                  "totalCost": null
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. Codes: `project_archived`, `agent_name_required`. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/timesheets/{id}": {
      "patch": {
        "operationId": "updateTimeEntry",
        "summary": "Edit a time entry",
        "description": "Changes an entry. Your own entries need `timesheets:entry:update_own`, anyone else's `timesheets:entry:update_others`. Entries that are approved on a project requiring approval, invoiced, or older than the workspace's edit window answer 409.\n\nProduct: `timesheets`. Permission (any of): `timesheets:entry:update_own`, `timesheets:entry:update_others`.",
        "tags": [
          "Timesheets"
        ],
        "x-opex-entitlement": "timesheets",
        "x-opex-permissions": [
          "timesheets:entry:update_own",
          "timesheets:entry:update_others"
        ],
        "x-opex-stability": "stable",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Time entry id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "projectId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "source": {
                    "type": "string",
                    "enum": [
                      "timer",
                      "manual",
                      "calendar"
                    ]
                  },
                  "description": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 4000
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "startedAt": {
                    "type": "number"
                  },
                  "endedAt": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "durationMinutes": {
                    "type": "number",
                    "minimum": 0
                  },
                  "billable": {
                    "type": "boolean"
                  },
                  "subjectType": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "ticket",
                          "task"
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "subjectId": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "tagIds": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              },
              "example": {
                "description": "Integration workshop with the client team"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated entry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "user_id": {
                      "type": "string"
                    },
                    "project_id": {
                      "type": "string"
                    },
                    "description": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "started_at": {
                      "type": "number",
                      "description": "Epoch milliseconds."
                    },
                    "ended_at": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "duration_minutes": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "running",
                        "pending",
                        "approved",
                        "rejected",
                        "invoiced"
                      ]
                    },
                    "billable": {
                      "type": "number",
                      "description": "1 = billable."
                    },
                    "source": {
                      "type": "string",
                      "description": "`manual`, `timer`, `calendar` or `agent`."
                    },
                    "subject_type": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "ticket",
                            "task"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "subject_id": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "created_at": {
                      "type": "number"
                    },
                    "total_cost": {
                      "description": "Cost at the member's rate, when a rate is set.",
                      "type": [
                        "number",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "user_id",
                    "project_id",
                    "description",
                    "started_at",
                    "ended_at",
                    "duration_minutes",
                    "status",
                    "billable",
                    "source",
                    "subject_type",
                    "subject_id",
                    "created_at",
                    "total_cost"
                  ],
                  "additionalProperties": {}
                },
                "example": {
                  "id": "728a50d8-ec6d-4b7e-b2f2-ea6d7ff79641",
                  "tenant_id": "opexcg-tenant",
                  "user_id": "usr-fitri-handayani",
                  "project_id": "99e5d1dd-334c-4bc3-88c7-7d84558bf7c6",
                  "description": "Integration workshop with the client team",
                  "started_at": 1794044848931,
                  "ended_at": 1794050248931,
                  "duration_minutes": 90,
                  "status": "approved",
                  "entry_method": "manual",
                  "source": "manual",
                  "billable": 1,
                  "subject_type": null,
                  "subject_id": null,
                  "clockify_id": null,
                  "agent_name": null,
                  "model": null,
                  "input_tokens": null,
                  "output_tokens": null,
                  "cache_read_tokens": null,
                  "cache_write_tokens": null,
                  "reasoning_tokens": null,
                  "approved_by": null,
                  "approved_at": null,
                  "rejection_reason": null,
                  "cost_rate": null,
                  "cost_currency": null,
                  "cost_source": "uncosted",
                  "cost_group_id": null,
                  "checksum": "0cb792ff0a824c080c2b63bb4daa6bf82117fc1c0f894f1a6586fb832dfba063",
                  "created_at": 1794052048976,
                  "created_by": "usr-fitri-handayani",
                  "modified_at": 1794052049083,
                  "modified_by": "usr-fitri-handayani",
                  "deleted_at": null,
                  "deleted_by": null,
                  "total_cost": null,
                  "totalCost": null
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. Codes: `entry_not_found`, `own_entries_only`, `timer_running`, `entry_finalized`, `entry_outside_window`, `project_archived`, `invalid_time_range`. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteTimeEntry",
        "summary": "Delete a time entry",
        "description": "Deletes an entry (soft delete). Your own entries need `timesheets:entry:delete_own`, anyone else's `timesheets:entry:delete_others`. Entries that are approved on a project requiring approval, invoiced, or older than the workspace's edit window answer 409.\n\nProduct: `timesheets`. Permission (any of): `timesheets:entry:delete_own`, `timesheets:entry:delete_others`.",
        "tags": [
          "Timesheets"
        ],
        "x-opex-entitlement": "timesheets",
        "x-opex-permissions": [
          "timesheets:entry:delete_own",
          "timesheets:entry:delete_others"
        ],
        "x-opex-stability": "stable",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Time entry id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Done.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "ok"
                  ]
                },
                "example": {
                  "ok": true
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. Codes: `entry_not_found`, `own_entries_only`, `timer_running`, `entry_finalized`, `entry_outside_window`. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/timesheets/projects": {
      "get": {
        "operationId": "listTimesheetProjects",
        "summary": "List projects you can log time on",
        "description": "The workspace's projects you can see, with their timesheet settings and logged totals, as a plain array (no paging). Public projects are visible to every member; private ones only to their team and admins. Use an `id` from here as `projectId` when logging time.\n\nProduct: `timesheets`.",
        "tags": [
          "Timesheets"
        ],
        "x-opex-entitlement": "timesheets",
        "x-opex-permissions": [],
        "x-opex-stability": "stable",
        "responses": {
          "200": {
            "description": "The projects.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "name": {
                        "type": "string"
                      },
                      "company_id": {
                        "type": "string"
                      },
                      "company_name": {
                        "type": [
                          "string",
                          "null"
                        ]
                      },
                      "status": {
                        "type": "string"
                      },
                      "is_billable": {
                        "type": "boolean"
                      },
                      "requires_approval": {
                        "type": "boolean",
                        "description": "Entries on this project need approval."
                      },
                      "logged_hours": {
                        "type": "number"
                      },
                      "starred": {
                        "type": "boolean"
                      }
                    },
                    "required": [
                      "id",
                      "name",
                      "company_id",
                      "company_name",
                      "status",
                      "is_billable",
                      "requires_approval",
                      "logged_hours",
                      "starred"
                    ],
                    "additionalProperties": {}
                  }
                },
                "example": [
                  {
                    "id": "99e5d1dd-334c-4bc3-88c7-7d84558bf7c6",
                    "company_id": "comp-xyzind",
                    "tenant_id": "opexcg-tenant",
                    "name": "Customer portal rollout",
                    "solution_summary": "Roll out the public API to the integration team",
                    "product": null,
                    "product_id": "prod-epicor",
                    "epicor_instance": null,
                    "epicor_version": null,
                    "status": "planning",
                    "folder_id": null,
                    "has_support_service": 0,
                    "support_expiry_date": null,
                    "planned_start_at": null,
                    "planned_end_at": null,
                    "actual_start_at": null,
                    "actual_end_at": null,
                    "budget_cents": 0,
                    "budget_hours": 0,
                    "budget_currency": "USD",
                    "color": null,
                    "created_at": 1794052048552,
                    "created_by": "usr-fitri-handayani",
                    "modified_at": 1794052048631,
                    "modified_by": "usr-fitri-handayani",
                    "deleted_at": null,
                    "deleted_by": null,
                    "company_name": "XYZ Industries",
                    "code": null,
                    "start_date": null,
                    "end_date": null,
                    "logged_hours": 0,
                    "actual_cost": 0,
                    "access_type": "public",
                    "is_billable": true,
                    "hourly_rate": null,
                    "requires_approval": false,
                    "has_entries": false,
                    "estimation_mode": "per_project",
                    "progress_pct": null,
                    "budgetCents": 0,
                    "budgetHours": 0,
                    "budgetCurrency": "USD",
                    "startDate": null,
                    "endDate": null,
                    "loggedHours": 0,
                    "actualCost": 0,
                    "budgetUtilization": {
                      "percentage": 0,
                      "level": "normal"
                    },
                    "accessType": "public",
                    "isBillable": true,
                    "hourlyRate": null,
                    "estimationMode": "per_project",
                    "starred": false,
                    "progressPct": null
                  },
                  {
                    "id": "prj-adis",
                    "company_id": "comp-opexcg",
                    "tenant_id": "opexcg-tenant",
                    "name": "ADIS",
                    "solution_summary": null,
                    "product": null,
                    "product_id": null,
                    "epicor_instance": null,
                    "epicor_version": null,
                    "status": "planning",
                    "folder_id": null,
                    "has_support_service": 0,
                    "support_expiry_date": null,
                    "planned_start_at": null,
                    "planned_end_at": null,
                    "actual_start_at": null,
                    "actual_end_at": null,
                    "budget_cents": 7500000000,
                    "budget_hours": 0,
                    "budget_currency": "IDR",
                    "color": null,
                    "created_at": 1794052020883,
                    "created_by": "usr-sari-wulandari",
                    "modified_at": 1794052020883,
                    "modified_by": "usr-sari-wulandari",
                    "deleted_at": null,
                    "deleted_by": null,
                    "company_name": "OpexCG",
                    "code": null,
                    "start_date": null,
                    "end_date": null,
                    "logged_hours": 0,
                    "actual_cost": 0,
                    "access_type": "public",
                    "is_billable": true,
                    "hourly_rate": null,
                    "requires_approval": false,
                    "has_entries": false,
                    "estimation_mode": "per_project",
                    "progress_pct": 0,
                    "budgetCents": 7500000000,
                    "budgetHours": 0,
                    "budgetCurrency": "IDR",
                    "startDate": null,
                    "endDate": null,
                    "loggedHours": 0,
                    "actualCost": 0,
                    "budgetUtilization": {
                      "percentage": 0,
                      "level": "normal"
                    },
                    "accessType": "public",
                    "isBillable": true,
                    "hourlyRate": null,
                    "estimationMode": "per_project",
                    "starred": false,
                    "progressPct": 0
                  }
                ]
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/projects": {
      "get": {
        "operationId": "listProjects",
        "summary": "List projects",
        "description": "Projects of the workspace, alphabetical by default. Client users see only their company's projects. Consultants, consultant leads and project managers see only the projects they are assigned to unless they pass `scope=all`.\n\nSort keys: `name` (default, ascending), `created_at`, `status`, `epicor_version`.",
        "tags": [
          "Project"
        ],
        "x-opex-entitlement": null,
        "x-opex-permissions": [],
        "x-opex-stability": "stable",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "required": false,
            "description": "1-based page number. Default 1.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "required": false,
            "description": "Rows per page, 1 to 100. Larger values are clamped. Default 20.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "description": "Free-text filter (trimmed, first 200 characters).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "required": false,
            "description": "Sort key. Unknown keys fall back to the endpoint's default sort.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dir",
            "in": "query",
            "required": false,
            "description": "`asc` or `desc` (default).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "companyId",
            "in": "query",
            "required": false,
            "description": "Only this company's projects (ignored for client users, who see their own).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "scope",
            "in": "query",
            "required": false,
            "description": "`all` lists every project, not only the ones you are assigned to.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "productId",
            "in": "query",
            "required": false,
            "description": "Only projects delivering this product (helpdesk catalog id).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "support",
            "in": "query",
            "required": false,
            "description": "`has` = only projects with a support contract, `none` = only without.",
            "schema": {
              "type": "string",
              "enum": [
                "has",
                "none"
              ]
            }
          },
          {
            "name": "expiry",
            "in": "query",
            "required": false,
            "description": "Support-contract expiry bucket: already expired, expiring within 30 days, or within 90 days.",
            "schema": {
              "type": "string",
              "enum": [
                "expired",
                "expiring30",
                "expiring90"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "One page of projects.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "company_id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string",
                            "description": "Lifecycle status: `awaiting_payment`, `active`, `on_hold`, `completed`, `archived`."
                          },
                          "product_id": {
                            "description": "Product (helpdesk catalog) the project delivers.",
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "solution_summary": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "folder_id": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "planned_start_at": {
                            "description": "Epoch milliseconds.",
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "planned_end_at": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "actual_start_at": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "actual_end_at": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "budget_cents": {
                            "type": "number",
                            "description": "Budget in minor units of `budget_currency`."
                          },
                          "budget_hours": {
                            "type": "number"
                          },
                          "budget_currency": {
                            "type": "string"
                          },
                          "has_support_service": {
                            "type": "number",
                            "description": "1 when the project includes a support service."
                          },
                          "support_expiry_date": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "color": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "created_at": {
                            "type": "number"
                          }
                        },
                        "required": [
                          "id",
                          "company_id",
                          "name",
                          "status",
                          "product_id",
                          "solution_summary",
                          "folder_id",
                          "planned_start_at",
                          "planned_end_at",
                          "actual_start_at",
                          "actual_end_at",
                          "budget_cents",
                          "budget_hours",
                          "budget_currency",
                          "has_support_service",
                          "support_expiry_date",
                          "color",
                          "created_at"
                        ],
                        "additionalProperties": {}
                      }
                    },
                    "total": {
                      "type": "number"
                    },
                    "page": {
                      "type": "number"
                    },
                    "pageSize": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "items",
                    "total",
                    "page",
                    "pageSize"
                  ]
                },
                "example": {
                  "items": [],
                  "total": 0,
                  "page": 1,
                  "pageSize": 2
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createProject",
        "summary": "Create a project",
        "description": "Creates a project for a company and product. Without `name`, the project is named `<Company> <Product>`. Setting a budget also needs `pmo:budget:manage`. Dates are epoch milliseconds.\n\nPermission (any of): `pmo:project:create`.",
        "tags": [
          "Project"
        ],
        "x-opex-entitlement": null,
        "x-opex-permissions": [
          "pmo:project:create"
        ],
        "x-opex-stability": "stable",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "companyId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "productId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "name": {
                    "type": "string"
                  },
                  "status": {
                    "default": "active",
                    "type": "string",
                    "enum": [
                      "awaiting_payment",
                      "active",
                      "on_hold",
                      "completed",
                      "archived"
                    ]
                  },
                  "solutionSummary": {
                    "type": "string"
                  },
                  "epicorInstance": {
                    "type": "string"
                  },
                  "epicorVersion": {
                    "type": "string"
                  },
                  "hasSupportService": {
                    "default": false,
                    "type": "boolean"
                  },
                  "supportExpiryDate": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": -9007199254740991,
                        "maximum": 9007199254740991
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "plannedStartAt": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": -9007199254740991,
                        "maximum": 9007199254740991
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "plannedEndAt": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": -9007199254740991,
                        "maximum": 9007199254740991
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "actualStartAt": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": -9007199254740991,
                        "maximum": 9007199254740991
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "actualEndAt": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": -9007199254740991,
                        "maximum": 9007199254740991
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "budgetCents": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991
                  },
                  "budgetHours": {
                    "type": "number",
                    "minimum": 0
                  },
                  "budgetCurrency": {
                    "type": "string",
                    "enum": [
                      "IDR",
                      "SGD",
                      "MYR",
                      "USD",
                      "MVR"
                    ]
                  },
                  "color": {
                    "anyOf": [
                      {
                        "type": "string",
                        "pattern": "^#[0-9a-fA-F]{6}$"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": [
                  "companyId",
                  "productId"
                ]
              },
              "example": {
                "companyId": "comp-xyzind",
                "productId": "prod-epicor",
                "name": "Customer portal rollout",
                "status": "active"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The new project id.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "The new project's id."
                    }
                  },
                  "required": [
                    "id"
                  ]
                },
                "example": {
                  "id": "99e5d1dd-334c-4bc3-88c7-7d84558bf7c6"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. Codes: `org_not_found`, `product_not_found`, `name_taken`. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/projects/{id}": {
      "get": {
        "operationId": "getProject",
        "summary": "Get a project",
        "description": "One project with its dates, budget and support settings.",
        "tags": [
          "Project"
        ],
        "x-opex-entitlement": null,
        "x-opex-permissions": [],
        "x-opex-stability": "stable",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Project id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The project.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "company_id": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "description": "Lifecycle status: `awaiting_payment`, `active`, `on_hold`, `completed`, `archived`."
                    },
                    "product_id": {
                      "description": "Product (helpdesk catalog) the project delivers.",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "solution_summary": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "folder_id": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "planned_start_at": {
                      "description": "Epoch milliseconds.",
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "planned_end_at": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "actual_start_at": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "actual_end_at": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "budget_cents": {
                      "type": "number",
                      "description": "Budget in minor units of `budget_currency`."
                    },
                    "budget_hours": {
                      "type": "number"
                    },
                    "budget_currency": {
                      "type": "string"
                    },
                    "has_support_service": {
                      "type": "number",
                      "description": "1 when the project includes a support service."
                    },
                    "support_expiry_date": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "color": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "created_at": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "id",
                    "company_id",
                    "name",
                    "status",
                    "product_id",
                    "solution_summary",
                    "folder_id",
                    "planned_start_at",
                    "planned_end_at",
                    "actual_start_at",
                    "actual_end_at",
                    "budget_cents",
                    "budget_hours",
                    "budget_currency",
                    "has_support_service",
                    "support_expiry_date",
                    "color",
                    "created_at"
                  ],
                  "additionalProperties": {}
                },
                "example": {
                  "id": "99e5d1dd-334c-4bc3-88c7-7d84558bf7c6",
                  "company_id": "comp-xyzind",
                  "name": "Customer portal rollout",
                  "solution_summary": null,
                  "product_id": "prod-epicor",
                  "epicor_instance": null,
                  "epicor_version": null,
                  "status": "active",
                  "folder_id": null,
                  "has_support_service": 0,
                  "support_expiry_date": null,
                  "budget_cents": 0,
                  "budget_hours": 0,
                  "budget_currency": "USD",
                  "color": null,
                  "created_at": 1794052048552,
                  "planned_start_at": null,
                  "planned_end_at": null,
                  "actual_start_at": null,
                  "actual_end_at": null
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. Codes: `not_found`. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateProject",
        "summary": "Update a project",
        "description": "Changes any of the given fields; omitted fields stay as they are.\n\nPermission (any of): `pmo:project:update`.",
        "tags": [
          "Project"
        ],
        "x-opex-entitlement": null,
        "x-opex-permissions": [
          "pmo:project:update"
        ],
        "x-opex-stability": "stable",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Project id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "productId": {
                    "anyOf": [
                      {
                        "type": "string",
                        "minLength": 1
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "epicorInstance": {
                    "type": "string"
                  },
                  "epicorVersion": {
                    "type": "string"
                  },
                  "solutionSummary": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "awaiting_payment",
                      "active",
                      "on_hold",
                      "completed",
                      "archived"
                    ]
                  },
                  "folderId": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "hasSupportService": {
                    "type": "boolean"
                  },
                  "supportExpiryDate": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": -9007199254740991,
                        "maximum": 9007199254740991
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "plannedStartAt": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": -9007199254740991,
                        "maximum": 9007199254740991
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "plannedEndAt": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": -9007199254740991,
                        "maximum": 9007199254740991
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "actualStartAt": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": -9007199254740991,
                        "maximum": 9007199254740991
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "actualEndAt": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": -9007199254740991,
                        "maximum": 9007199254740991
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "color": {
                    "anyOf": [
                      {
                        "type": "string",
                        "pattern": "^#[0-9a-fA-F]{6}$"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              },
              "example": {
                "solutionSummary": "Roll out the public API to the integration team"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Done.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "ok"
                  ]
                },
                "example": {
                  "ok": true
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. Codes: `not_found`, `product_not_found`, `folder_not_found`, `no_fields`. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/pmo/rpc/tasks/list": {
      "post": {
        "operationId": "listTasks",
        "summary": "List tasks",
        "description": "Tasks of one project, paged. `pageSize` above 100 is clamped to 100. This is an RPC procedure: send the input as `{ \"json\": { … } }` with `content-type: application/json`, and read the result from the `json` field of the answer. Errors come back as `{ \"json\": { \"code\": \"NOT_FOUND\", \"status\": 404, \"message\": \"not_found\" } }`.\n\nProduct: `pmo`.",
        "tags": [
          "Project"
        ],
        "x-opex-entitlement": "pmo",
        "x-opex-permissions": [],
        "x-opex-stability": "stable",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "json": {
                    "type": "object",
                    "properties": {
                      "projectId": {
                        "type": "string",
                        "minLength": 1
                      },
                      "state": {
                        "type": "string"
                      },
                      "priority": {
                        "type": "string",
                        "enum": [
                          "none",
                          "urgent",
                          "high",
                          "medium",
                          "low"
                        ]
                      },
                      "search": {
                        "type": "string"
                      },
                      "page": {
                        "default": 1,
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 1000000
                      },
                      "pageSize": {
                        "default": 20,
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 9007199254740991
                      },
                      "sort": {
                        "default": "created",
                        "type": "string",
                        "enum": [
                          "created",
                          "name",
                          "priority",
                          "sequence",
                          "target_date"
                        ]
                      },
                      "dir": {
                        "default": "desc",
                        "type": "string",
                        "enum": [
                          "asc",
                          "desc"
                        ]
                      }
                    },
                    "required": [
                      "projectId"
                    ]
                  }
                },
                "required": [
                  "json"
                ]
              },
              "example": {
                "json": {
                  "projectId": "99e5d1dd-334c-4bc3-88c7-7d84558bf7c6",
                  "pageSize": 2
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "One page of tasks.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "json": {
                      "type": "object",
                      "properties": {
                        "items": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "project_id": {
                                "type": "string"
                              },
                              "sequence_id": {
                                "type": "number",
                                "description": "Number of the task within its project."
                              },
                              "name": {
                                "type": "string"
                              },
                              "priority": {
                                "type": "string",
                                "enum": [
                                  "none",
                                  "urgent",
                                  "high",
                                  "medium",
                                  "low"
                                ]
                              },
                              "description_html": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "state_id": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "parent_id": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "milestone_id": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "start_date": {
                                "description": "Epoch milliseconds.",
                                "type": [
                                  "number",
                                  "null"
                                ]
                              },
                              "target_date": {
                                "description": "Epoch milliseconds.",
                                "type": [
                                  "number",
                                  "null"
                                ]
                              },
                              "completed_at": {
                                "type": [
                                  "number",
                                  "null"
                                ]
                              },
                              "archived_at": {
                                "type": [
                                  "number",
                                  "null"
                                ]
                              },
                              "estimate_points": {
                                "type": [
                                  "number",
                                  "null"
                                ]
                              },
                              "created_at": {
                                "type": "number"
                              },
                              "state": {
                                "anyOf": [
                                  {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string"
                                      },
                                      "name": {
                                        "type": "string"
                                      },
                                      "color": {
                                        "type": [
                                          "string",
                                          "null"
                                        ]
                                      },
                                      "group_name": {
                                        "type": "string"
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "name",
                                      "color",
                                      "group_name"
                                    ],
                                    "additionalProperties": {}
                                  },
                                  {
                                    "type": "null"
                                  }
                                ],
                                "description": "The workflow state, e.g. group `backlog`, `started`, `completed`."
                              },
                              "assignees": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string"
                                    },
                                    "display_name": {
                                      "type": [
                                        "string",
                                        "null"
                                      ]
                                    },
                                    "email": {
                                      "type": [
                                        "string",
                                        "null"
                                      ]
                                    }
                                  },
                                  "required": [
                                    "id",
                                    "display_name",
                                    "email"
                                  ],
                                  "additionalProperties": {}
                                }
                              },
                              "labels": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string"
                                    },
                                    "name": {
                                      "type": "string"
                                    },
                                    "color": {
                                      "type": [
                                        "string",
                                        "null"
                                      ]
                                    }
                                  },
                                  "required": [
                                    "id",
                                    "name",
                                    "color"
                                  ],
                                  "additionalProperties": {}
                                }
                              },
                              "milestone": {
                                "anyOf": [
                                  {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string"
                                      },
                                      "name": {
                                        "type": "string"
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "name"
                                    ],
                                    "additionalProperties": {}
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "checklist_total": {
                                "type": "number"
                              },
                              "checklist_done": {
                                "type": "number"
                              }
                            },
                            "required": [
                              "id",
                              "project_id",
                              "sequence_id",
                              "name",
                              "priority",
                              "description_html",
                              "state_id",
                              "parent_id",
                              "milestone_id",
                              "start_date",
                              "target_date",
                              "completed_at",
                              "archived_at",
                              "estimate_points",
                              "created_at",
                              "state",
                              "assignees",
                              "labels",
                              "milestone",
                              "checklist_total",
                              "checklist_done"
                            ],
                            "additionalProperties": {}
                          }
                        },
                        "total": {
                          "type": "number"
                        },
                        "page": {
                          "type": "number"
                        },
                        "pageSize": {
                          "type": "number"
                        }
                      },
                      "required": [
                        "items",
                        "total",
                        "page",
                        "pageSize"
                      ]
                    }
                  },
                  "required": [
                    "json"
                  ]
                },
                "example": {
                  "json": {
                    "items": [
                      {
                        "id": "28a5a651-5baa-4a8b-b9c8-76b9f1a2fc24",
                        "tenant_id": "opexcg-tenant",
                        "project_id": "99e5d1dd-334c-4bc3-88c7-7d84558bf7c6",
                        "sequence_id": 1,
                        "name": "Write the integration guide",
                        "sort_order": 65535,
                        "priority": "high",
                        "start_date": null,
                        "target_date": null,
                        "completed_at": null,
                        "archived_at": null,
                        "is_draft": 0,
                        "is_decision": 0,
                        "description_json": null,
                        "description_html": null,
                        "description_stripped": null,
                        "parent_id": null,
                        "milestone_id": null,
                        "state_id": "07a4b6e4-d64d-47d6-8c65-5e5a5e9fca57",
                        "estimate_point_id": null,
                        "estimate_points": null,
                        "created_by_id": "usr-fitri-handayani",
                        "external_source": null,
                        "external_id": null,
                        "recurrence_json": null,
                        "recurrence_source_id": null,
                        "recurrence_seq": null,
                        "subject_type": null,
                        "subject_id": null,
                        "created_at": 1794052048728,
                        "created_by": "usr-fitri-handayani",
                        "modified_at": 1794052048728,
                        "modified_by": "usr-fitri-handayani",
                        "deleted_at": null,
                        "deleted_by": null,
                        "labels": [],
                        "assignees": [],
                        "state": {
                          "id": "07a4b6e4-d64d-47d6-8c65-5e5a5e9fca57",
                          "name": "Todo",
                          "color": "#3B82F6",
                          "group_name": "started"
                        },
                        "milestone": null,
                        "checklist_total": 0,
                        "checklist_done": 0
                      }
                    ],
                    "total": 1,
                    "page": 1,
                    "pageSize": 2
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/pmo/rpc/tasks/get": {
      "post": {
        "operationId": "getTask",
        "summary": "Get a task",
        "description": "One task with its assignees and labels. This is an RPC procedure: send the input as `{ \"json\": { … } }` with `content-type: application/json`, and read the result from the `json` field of the answer. Errors come back as `{ \"json\": { \"code\": \"NOT_FOUND\", \"status\": 404, \"message\": \"not_found\" } }`.\n\nProduct: `pmo`.",
        "tags": [
          "Project"
        ],
        "x-opex-entitlement": "pmo",
        "x-opex-permissions": [],
        "x-opex-stability": "stable",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "json": {
                    "type": "object",
                    "properties": {
                      "projectId": {
                        "type": "string",
                        "minLength": 1
                      },
                      "taskId": {
                        "type": "string",
                        "minLength": 1
                      }
                    },
                    "required": [
                      "projectId",
                      "taskId"
                    ]
                  }
                },
                "required": [
                  "json"
                ]
              },
              "example": {
                "json": {
                  "projectId": "99e5d1dd-334c-4bc3-88c7-7d84558bf7c6",
                  "taskId": "28a5a651-5baa-4a8b-b9c8-76b9f1a2fc24"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The task.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "json": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "project_id": {
                          "type": "string"
                        },
                        "sequence_id": {
                          "type": "number",
                          "description": "Number of the task within its project."
                        },
                        "name": {
                          "type": "string"
                        },
                        "priority": {
                          "type": "string",
                          "enum": [
                            "none",
                            "urgent",
                            "high",
                            "medium",
                            "low"
                          ]
                        },
                        "description_html": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "state_id": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "parent_id": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "milestone_id": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "start_date": {
                          "description": "Epoch milliseconds.",
                          "type": [
                            "number",
                            "null"
                          ]
                        },
                        "target_date": {
                          "description": "Epoch milliseconds.",
                          "type": [
                            "number",
                            "null"
                          ]
                        },
                        "completed_at": {
                          "type": [
                            "number",
                            "null"
                          ]
                        },
                        "archived_at": {
                          "type": [
                            "number",
                            "null"
                          ]
                        },
                        "estimate_points": {
                          "type": [
                            "number",
                            "null"
                          ]
                        },
                        "created_at": {
                          "type": "number"
                        },
                        "state": {
                          "anyOf": [
                            {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string"
                                },
                                "name": {
                                  "type": "string"
                                },
                                "color": {
                                  "type": [
                                    "string",
                                    "null"
                                  ]
                                },
                                "group_name": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "id",
                                "name",
                                "color",
                                "group_name"
                              ],
                              "additionalProperties": {}
                            },
                            {
                              "type": "null"
                            }
                          ],
                          "description": "The workflow state, e.g. group `backlog`, `started`, `completed`."
                        },
                        "assignees": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "display_name": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "email": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              }
                            },
                            "required": [
                              "id",
                              "display_name",
                              "email"
                            ],
                            "additionalProperties": {}
                          }
                        },
                        "labels": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "name": {
                                "type": "string"
                              },
                              "color": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              }
                            },
                            "required": [
                              "id",
                              "name",
                              "color"
                            ],
                            "additionalProperties": {}
                          }
                        },
                        "milestone": {
                          "anyOf": [
                            {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string"
                                },
                                "name": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "id",
                                "name"
                              ],
                              "additionalProperties": {}
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "checklist_total": {
                          "type": "number"
                        },
                        "checklist_done": {
                          "type": "number"
                        }
                      },
                      "required": [
                        "id",
                        "project_id",
                        "sequence_id",
                        "name",
                        "priority",
                        "description_html",
                        "state_id",
                        "parent_id",
                        "milestone_id",
                        "start_date",
                        "target_date",
                        "completed_at",
                        "archived_at",
                        "estimate_points",
                        "created_at",
                        "state",
                        "assignees",
                        "labels",
                        "milestone",
                        "checklist_total",
                        "checklist_done"
                      ],
                      "additionalProperties": {}
                    }
                  },
                  "required": [
                    "json"
                  ]
                },
                "example": {
                  "json": {
                    "id": "28a5a651-5baa-4a8b-b9c8-76b9f1a2fc24",
                    "tenant_id": "opexcg-tenant",
                    "project_id": "99e5d1dd-334c-4bc3-88c7-7d84558bf7c6",
                    "sequence_id": 1,
                    "name": "Write the integration guide",
                    "sort_order": 65535,
                    "priority": "high",
                    "start_date": null,
                    "target_date": null,
                    "completed_at": null,
                    "archived_at": null,
                    "is_draft": 0,
                    "is_decision": 0,
                    "description_json": null,
                    "description_html": null,
                    "description_stripped": null,
                    "parent_id": null,
                    "milestone_id": null,
                    "state_id": "07a4b6e4-d64d-47d6-8c65-5e5a5e9fca57",
                    "estimate_point_id": null,
                    "estimate_points": null,
                    "created_by_id": "usr-fitri-handayani",
                    "external_source": null,
                    "external_id": null,
                    "recurrence_json": null,
                    "recurrence_source_id": null,
                    "recurrence_seq": null,
                    "subject_type": null,
                    "subject_id": null,
                    "created_at": 1794052048728,
                    "created_by": "usr-fitri-handayani",
                    "modified_at": 1794052048728,
                    "modified_by": "usr-fitri-handayani",
                    "deleted_at": null,
                    "deleted_by": null,
                    "labels": [],
                    "assignees": [],
                    "state": {
                      "id": "07a4b6e4-d64d-47d6-8c65-5e5a5e9fca57",
                      "name": "Todo",
                      "color": "#3B82F6",
                      "group_name": "started"
                    },
                    "milestone": null,
                    "checklist_total": 0,
                    "checklist_done": 0
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. Codes: `not_found`. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/pmo/rpc/tasks/create": {
      "post": {
        "operationId": "createTask",
        "summary": "Create a task",
        "description": "Creates a task in a project. Without `state_id` it starts in the project's default state. Answers 200 (not 201). Dates are epoch milliseconds. This is an RPC procedure: send the input as `{ \"json\": { … } }` with `content-type: application/json`, and read the result from the `json` field of the answer. Errors come back as `{ \"json\": { \"code\": \"NOT_FOUND\", \"status\": 404, \"message\": \"not_found\" } }`.\n\nProduct: `pmo`. Permission (any of): `pmo:task:create`.",
        "tags": [
          "Project"
        ],
        "x-opex-entitlement": "pmo",
        "x-opex-permissions": [
          "pmo:task:create"
        ],
        "x-opex-stability": "stable",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "json": {
                    "type": "object",
                    "properties": {
                      "name": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 300
                      },
                      "description_html": {
                        "type": "string"
                      },
                      "priority": {
                        "default": "none",
                        "type": "string",
                        "enum": [
                          "none",
                          "urgent",
                          "high",
                          "medium",
                          "low"
                        ]
                      },
                      "state_id": {
                        "type": "string"
                      },
                      "start_date": {
                        "anyOf": [
                          {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "target_date": {
                        "anyOf": [
                          {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "estimate_points": {
                        "anyOf": [
                          {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "parent_id": {
                        "type": [
                          "string",
                          "null"
                        ]
                      },
                      "milestone_id": {
                        "type": [
                          "string",
                          "null"
                        ]
                      },
                      "label_ids": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      "assignee_ids": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      "projectId": {
                        "type": "string",
                        "minLength": 1
                      }
                    },
                    "required": [
                      "name",
                      "projectId"
                    ]
                  }
                },
                "required": [
                  "json"
                ]
              },
              "example": {
                "json": {
                  "projectId": "99e5d1dd-334c-4bc3-88c7-7d84558bf7c6",
                  "name": "Write the integration guide",
                  "priority": "high"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The new task.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "json": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "project_id": {
                          "type": "string"
                        },
                        "sequence_id": {
                          "type": "number",
                          "description": "Number of the task within its project."
                        },
                        "name": {
                          "type": "string"
                        },
                        "priority": {
                          "type": "string",
                          "enum": [
                            "none",
                            "urgent",
                            "high",
                            "medium",
                            "low"
                          ]
                        },
                        "description_html": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "state_id": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "parent_id": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "milestone_id": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "start_date": {
                          "description": "Epoch milliseconds.",
                          "type": [
                            "number",
                            "null"
                          ]
                        },
                        "target_date": {
                          "description": "Epoch milliseconds.",
                          "type": [
                            "number",
                            "null"
                          ]
                        },
                        "completed_at": {
                          "type": [
                            "number",
                            "null"
                          ]
                        },
                        "archived_at": {
                          "type": [
                            "number",
                            "null"
                          ]
                        },
                        "estimate_points": {
                          "type": [
                            "number",
                            "null"
                          ]
                        },
                        "created_at": {
                          "type": "number"
                        },
                        "state": {
                          "anyOf": [
                            {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string"
                                },
                                "name": {
                                  "type": "string"
                                },
                                "color": {
                                  "type": [
                                    "string",
                                    "null"
                                  ]
                                },
                                "group_name": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "id",
                                "name",
                                "color",
                                "group_name"
                              ],
                              "additionalProperties": {}
                            },
                            {
                              "type": "null"
                            }
                          ],
                          "description": "The workflow state, e.g. group `backlog`, `started`, `completed`."
                        },
                        "assignees": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "display_name": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "email": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              }
                            },
                            "required": [
                              "id",
                              "display_name",
                              "email"
                            ],
                            "additionalProperties": {}
                          }
                        },
                        "labels": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "name": {
                                "type": "string"
                              },
                              "color": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              }
                            },
                            "required": [
                              "id",
                              "name",
                              "color"
                            ],
                            "additionalProperties": {}
                          }
                        },
                        "milestone": {
                          "anyOf": [
                            {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string"
                                },
                                "name": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "id",
                                "name"
                              ],
                              "additionalProperties": {}
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "checklist_total": {
                          "type": "number"
                        },
                        "checklist_done": {
                          "type": "number"
                        }
                      },
                      "required": [
                        "id",
                        "project_id",
                        "sequence_id",
                        "name",
                        "priority",
                        "description_html",
                        "state_id",
                        "parent_id",
                        "milestone_id",
                        "start_date",
                        "target_date",
                        "completed_at",
                        "archived_at",
                        "estimate_points",
                        "created_at",
                        "state",
                        "assignees",
                        "labels",
                        "milestone",
                        "checklist_total",
                        "checklist_done"
                      ],
                      "additionalProperties": {}
                    }
                  },
                  "required": [
                    "json"
                  ]
                },
                "example": {
                  "json": {
                    "id": "28a5a651-5baa-4a8b-b9c8-76b9f1a2fc24",
                    "tenant_id": "opexcg-tenant",
                    "project_id": "99e5d1dd-334c-4bc3-88c7-7d84558bf7c6",
                    "sequence_id": 1,
                    "name": "Write the integration guide",
                    "sort_order": 65535,
                    "priority": "high",
                    "start_date": null,
                    "target_date": null,
                    "completed_at": null,
                    "archived_at": null,
                    "is_draft": 0,
                    "is_decision": 0,
                    "description_json": null,
                    "description_html": null,
                    "description_stripped": null,
                    "parent_id": null,
                    "milestone_id": null,
                    "state_id": "07a4b6e4-d64d-47d6-8c65-5e5a5e9fca57",
                    "estimate_point_id": null,
                    "estimate_points": null,
                    "created_by_id": "usr-fitri-handayani",
                    "external_source": null,
                    "external_id": null,
                    "recurrence_json": null,
                    "recurrence_source_id": null,
                    "recurrence_seq": null,
                    "subject_type": null,
                    "subject_id": null,
                    "created_at": 1794052048728,
                    "created_by": "usr-fitri-handayani",
                    "modified_at": 1794052048728,
                    "modified_by": "usr-fitri-handayani",
                    "deleted_at": null,
                    "deleted_by": null,
                    "labels": [],
                    "assignees": [],
                    "state": {
                      "id": "07a4b6e4-d64d-47d6-8c65-5e5a5e9fca57",
                      "name": "Todo",
                      "color": "#3B82F6",
                      "group_name": "started"
                    },
                    "milestone": null,
                    "checklist_total": 0,
                    "checklist_done": 0
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. Codes: `not_found`, `forbidden`. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/pmo/rpc/tasks/update": {
      "post": {
        "operationId": "updateTask",
        "summary": "Update a task",
        "description": "Changes any of the given fields of a task; `archived: true` archives it. This is an RPC procedure: send the input as `{ \"json\": { … } }` with `content-type: application/json`, and read the result from the `json` field of the answer. Errors come back as `{ \"json\": { \"code\": \"NOT_FOUND\", \"status\": 404, \"message\": \"not_found\" } }`.\n\nProduct: `pmo`. Permission (any of): `pmo:task:update`.",
        "tags": [
          "Project"
        ],
        "x-opex-entitlement": "pmo",
        "x-opex-permissions": [
          "pmo:task:update"
        ],
        "x-opex-stability": "stable",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "json": {
                    "type": "object",
                    "properties": {
                      "name": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 300
                      },
                      "description_html": {
                        "type": "string"
                      },
                      "priority": {
                        "default": "none",
                        "type": "string",
                        "enum": [
                          "none",
                          "urgent",
                          "high",
                          "medium",
                          "low"
                        ]
                      },
                      "state_id": {
                        "type": "string"
                      },
                      "start_date": {
                        "anyOf": [
                          {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "target_date": {
                        "anyOf": [
                          {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "estimate_points": {
                        "anyOf": [
                          {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "parent_id": {
                        "type": [
                          "string",
                          "null"
                        ]
                      },
                      "milestone_id": {
                        "type": [
                          "string",
                          "null"
                        ]
                      },
                      "label_ids": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      "assignee_ids": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      "archived": {
                        "type": "boolean"
                      },
                      "sort_order": {
                        "type": "number"
                      },
                      "recurrence": {
                        "anyOf": [
                          {
                            "type": "object",
                            "properties": {
                              "frequency": {
                                "type": "string",
                                "enum": [
                                  "daily",
                                  "weekly",
                                  "monthly",
                                  "yearly"
                                ]
                              },
                              "interval": {
                                "type": "integer",
                                "minimum": 1,
                                "maximum": 365
                              },
                              "weekdays": {
                                "maxItems": 7,
                                "type": "array",
                                "items": {
                                  "type": "integer",
                                  "minimum": 0,
                                  "maximum": 6
                                }
                              },
                              "anchor": {
                                "type": "string"
                              },
                              "ends": {
                                "anyOf": [
                                  {
                                    "type": "object",
                                    "properties": {
                                      "kind": {
                                        "type": "string",
                                        "const": "never"
                                      }
                                    },
                                    "required": [
                                      "kind"
                                    ]
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "kind": {
                                        "type": "string",
                                        "const": "on"
                                      },
                                      "date": {
                                        "type": "string"
                                      }
                                    },
                                    "required": [
                                      "kind",
                                      "date"
                                    ]
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "kind": {
                                        "type": "string",
                                        "const": "after"
                                      },
                                      "count": {
                                        "type": "integer",
                                        "minimum": 1,
                                        "maximum": 999
                                      }
                                    },
                                    "required": [
                                      "kind",
                                      "count"
                                    ]
                                  }
                                ]
                              }
                            },
                            "required": [
                              "frequency",
                              "interval",
                              "ends"
                            ]
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "projectId": {
                        "type": "string",
                        "minLength": 1
                      },
                      "taskId": {
                        "type": "string",
                        "minLength": 1
                      }
                    },
                    "required": [
                      "projectId",
                      "taskId"
                    ]
                  }
                },
                "required": [
                  "json"
                ]
              },
              "example": {
                "json": {
                  "projectId": "99e5d1dd-334c-4bc3-88c7-7d84558bf7c6",
                  "taskId": "28a5a651-5baa-4a8b-b9c8-76b9f1a2fc24",
                  "priority": "urgent"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated task.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "json": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string"
                            },
                            "project_id": {
                              "type": "string"
                            },
                            "sequence_id": {
                              "type": "number",
                              "description": "Number of the task within its project."
                            },
                            "name": {
                              "type": "string"
                            },
                            "priority": {
                              "type": "string",
                              "enum": [
                                "none",
                                "urgent",
                                "high",
                                "medium",
                                "low"
                              ]
                            },
                            "description_html": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "state_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "parent_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "milestone_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "start_date": {
                              "description": "Epoch milliseconds.",
                              "type": [
                                "number",
                                "null"
                              ]
                            },
                            "target_date": {
                              "description": "Epoch milliseconds.",
                              "type": [
                                "number",
                                "null"
                              ]
                            },
                            "completed_at": {
                              "type": [
                                "number",
                                "null"
                              ]
                            },
                            "archived_at": {
                              "type": [
                                "number",
                                "null"
                              ]
                            },
                            "estimate_points": {
                              "type": [
                                "number",
                                "null"
                              ]
                            },
                            "created_at": {
                              "type": "number"
                            },
                            "state": {
                              "anyOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string"
                                    },
                                    "name": {
                                      "type": "string"
                                    },
                                    "color": {
                                      "type": [
                                        "string",
                                        "null"
                                      ]
                                    },
                                    "group_name": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "id",
                                    "name",
                                    "color",
                                    "group_name"
                                  ],
                                  "additionalProperties": {}
                                },
                                {
                                  "type": "null"
                                }
                              ],
                              "description": "The workflow state, e.g. group `backlog`, `started`, `completed`."
                            },
                            "assignees": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string"
                                  },
                                  "display_name": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "email": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  }
                                },
                                "required": [
                                  "id",
                                  "display_name",
                                  "email"
                                ],
                                "additionalProperties": {}
                              }
                            },
                            "labels": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string"
                                  },
                                  "name": {
                                    "type": "string"
                                  },
                                  "color": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  }
                                },
                                "required": [
                                  "id",
                                  "name",
                                  "color"
                                ],
                                "additionalProperties": {}
                              }
                            },
                            "milestone": {
                              "anyOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string"
                                    },
                                    "name": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "id",
                                    "name"
                                  ],
                                  "additionalProperties": {}
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "checklist_total": {
                              "type": "number"
                            },
                            "checklist_done": {
                              "type": "number"
                            }
                          },
                          "required": [
                            "id",
                            "project_id",
                            "sequence_id",
                            "name",
                            "priority",
                            "description_html",
                            "state_id",
                            "parent_id",
                            "milestone_id",
                            "start_date",
                            "target_date",
                            "completed_at",
                            "archived_at",
                            "estimate_points",
                            "created_at",
                            "state",
                            "assignees",
                            "labels",
                            "milestone",
                            "checklist_total",
                            "checklist_done"
                          ],
                          "additionalProperties": {}
                        },
                        {
                          "type": "object",
                          "properties": {
                            "ok": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "ok"
                          ]
                        }
                      ]
                    }
                  },
                  "required": [
                    "json"
                  ]
                },
                "example": {
                  "json": {
                    "id": "28a5a651-5baa-4a8b-b9c8-76b9f1a2fc24",
                    "tenant_id": "opexcg-tenant",
                    "project_id": "99e5d1dd-334c-4bc3-88c7-7d84558bf7c6",
                    "sequence_id": 1,
                    "name": "Write the integration guide",
                    "sort_order": 65535,
                    "priority": "urgent",
                    "start_date": null,
                    "target_date": null,
                    "completed_at": null,
                    "archived_at": null,
                    "is_draft": 0,
                    "is_decision": 0,
                    "description_json": null,
                    "description_html": null,
                    "description_stripped": null,
                    "parent_id": null,
                    "milestone_id": null,
                    "state_id": "07a4b6e4-d64d-47d6-8c65-5e5a5e9fca57",
                    "estimate_point_id": null,
                    "estimate_points": null,
                    "created_by_id": "usr-fitri-handayani",
                    "external_source": null,
                    "external_id": null,
                    "recurrence_json": null,
                    "recurrence_source_id": null,
                    "recurrence_seq": null,
                    "subject_type": null,
                    "subject_id": null,
                    "created_at": 1794052048728,
                    "created_by": "usr-fitri-handayani",
                    "modified_at": 1794052048854,
                    "modified_by": "usr-fitri-handayani",
                    "deleted_at": null,
                    "deleted_by": null,
                    "labels": [],
                    "assignees": [],
                    "state": {
                      "id": "07a4b6e4-d64d-47d6-8c65-5e5a5e9fca57",
                      "name": "Todo",
                      "color": "#3B82F6",
                      "group_name": "started"
                    },
                    "milestone": null,
                    "checklist_total": 0,
                    "checklist_done": 0
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. Codes: `not_found`, `forbidden`. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/crm/contacts": {
      "get": {
        "operationId": "listContacts",
        "summary": "List contacts",
        "description": "Contacts, newest first by default. `search` matches name, email and company.\n\nSort keys: `created` (default), `name`, `email`, `status`.\n\nProduct: `crm`. Permission (any of): `crm:record:read`.",
        "tags": [
          "CRM"
        ],
        "x-opex-entitlement": "crm",
        "x-opex-permissions": [
          "crm:record:read"
        ],
        "x-opex-stability": "stable",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "required": false,
            "description": "1-based page number. Default 1.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "required": false,
            "description": "Rows per page, 1 to 100. Larger values are clamped. Default 20.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "description": "Free-text filter (trimmed, first 200 characters).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "required": false,
            "description": "Sort key. Unknown keys fall back to the endpoint's default sort.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dir",
            "in": "query",
            "required": false,
            "description": "`asc` or `desc` (default).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "`lead`, `active` or `churned`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "companyId",
            "in": "query",
            "required": false,
            "description": "Only contacts of this company.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "One page of contacts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "email": {
                            "type": "string"
                          },
                          "name": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "company": {
                            "description": "Company name as typed (free text).",
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "company_id": {
                            "description": "Linked company record.",
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "title": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "phone": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "address": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "lead",
                              "active",
                              "churned"
                            ]
                          },
                          "source": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "notes": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "created_at": {
                            "type": "number"
                          },
                          "modified_at": {
                            "type": "number"
                          }
                        },
                        "required": [
                          "id",
                          "email",
                          "name",
                          "company",
                          "company_id",
                          "title",
                          "phone",
                          "address",
                          "status",
                          "source",
                          "notes",
                          "created_at",
                          "modified_at"
                        ],
                        "additionalProperties": {}
                      }
                    },
                    "total": {
                      "type": "number"
                    },
                    "page": {
                      "type": "number"
                    },
                    "pageSize": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "items",
                    "total",
                    "page",
                    "pageSize"
                  ]
                },
                "example": {
                  "items": [
                    {
                      "id": "f611c550-75fd-452d-8de3-8ab46f9f1823",
                      "tenant_id": "opexcg-tenant",
                      "user_id": null,
                      "company_id": "c5615616-096f-4886-9894-58e10bb0482a",
                      "email": "sari@kencana.example",
                      "name": "Sari Wulandari",
                      "company": "Kencana Logistik Tbk",
                      "title": "Head of Operations",
                      "phone": null,
                      "address": null,
                      "avatar_url": null,
                      "custom_fields_json": "{}",
                      "status": "lead",
                      "source": "api",
                      "notes": null,
                      "created_at": 1794052050080,
                      "created_by": "usr-fitri-handayani",
                      "modified_at": 1794052050080,
                      "modified_by": "usr-fitri-handayani",
                      "deleted_at": null,
                      "deleted_by": null
                    }
                  ],
                  "total": 1,
                  "page": 1,
                  "pageSize": 2
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createContact",
        "summary": "Create a contact",
        "description": "Creates a contact. Contacts are unique by email: posting an email that already exists answers **200** with the existing contact, filling only its blank fields from the request (nothing set is overwritten). Safe to retry.\n\nProduct: `crm`. Permission (any of): `crm:record:write`.",
        "tags": [
          "CRM"
        ],
        "x-opex-entitlement": "crm",
        "x-opex-permissions": [
          "crm:record:write"
        ],
        "x-opex-stability": "stable",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email",
                    "pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                  },
                  "name": {
                    "type": "string",
                    "maxLength": 200
                  },
                  "company": {
                    "type": "string",
                    "maxLength": 200
                  },
                  "title": {
                    "type": "string",
                    "maxLength": 120
                  },
                  "phone": {
                    "type": "string",
                    "maxLength": 60
                  },
                  "address": {
                    "type": "string",
                    "maxLength": 500
                  },
                  "source": {
                    "type": "string",
                    "maxLength": 120
                  },
                  "notes": {
                    "type": "string",
                    "maxLength": 2000
                  },
                  "companyId": {
                    "type": "string"
                  }
                },
                "required": [
                  "email"
                ]
              },
              "example": {
                "email": "sari@kencana.example",
                "name": "Sari Wulandari",
                "title": "Head of Operations",
                "companyId": "c5615616-096f-4886-9894-58e10bb0482a",
                "source": "api"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The new contact.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "email": {
                      "type": "string"
                    },
                    "name": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "company": {
                      "description": "Company name as typed (free text).",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "company_id": {
                      "description": "Linked company record.",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "title": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "phone": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "address": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "lead",
                        "active",
                        "churned"
                      ]
                    },
                    "source": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "notes": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "created_at": {
                      "type": "number"
                    },
                    "modified_at": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "id",
                    "email",
                    "name",
                    "company",
                    "company_id",
                    "title",
                    "phone",
                    "address",
                    "status",
                    "source",
                    "notes",
                    "created_at",
                    "modified_at"
                  ],
                  "additionalProperties": {}
                },
                "example": {
                  "id": "f611c550-75fd-452d-8de3-8ab46f9f1823",
                  "tenant_id": "opexcg-tenant",
                  "user_id": null,
                  "company_id": "c5615616-096f-4886-9894-58e10bb0482a",
                  "email": "sari@kencana.example",
                  "name": "Sari Wulandari",
                  "company": "Kencana Logistik Tbk",
                  "title": "Head of Operations",
                  "phone": null,
                  "address": null,
                  "avatar_url": null,
                  "custom_fields_json": "{}",
                  "status": "lead",
                  "source": "api",
                  "notes": null,
                  "created_at": 1794052050080,
                  "created_by": "usr-fitri-handayani",
                  "modified_at": 1794052050080,
                  "modified_by": "usr-fitri-handayani",
                  "deleted_at": null,
                  "deleted_by": null
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. Codes: `company_not_found`. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/crm/contacts/{id}": {
      "get": {
        "operationId": "getContact",
        "summary": "Get a contact",
        "description": "One contact with its company link and status.\n\nProduct: `crm`. Permission (any of): `crm:record:read`.",
        "tags": [
          "CRM"
        ],
        "x-opex-entitlement": "crm",
        "x-opex-permissions": [
          "crm:record:read"
        ],
        "x-opex-stability": "stable",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Contact id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The contact.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "email": {
                      "type": "string"
                    },
                    "name": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "company": {
                      "description": "Company name as typed (free text).",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "company_id": {
                      "description": "Linked company record.",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "title": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "phone": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "address": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "lead",
                        "active",
                        "churned"
                      ]
                    },
                    "source": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "notes": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "created_at": {
                      "type": "number"
                    },
                    "modified_at": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "id",
                    "email",
                    "name",
                    "company",
                    "company_id",
                    "title",
                    "phone",
                    "address",
                    "status",
                    "source",
                    "notes",
                    "created_at",
                    "modified_at"
                  ],
                  "additionalProperties": {}
                },
                "example": {
                  "id": "f611c550-75fd-452d-8de3-8ab46f9f1823",
                  "tenant_id": "opexcg-tenant",
                  "user_id": null,
                  "company_id": "c5615616-096f-4886-9894-58e10bb0482a",
                  "email": "sari@kencana.example",
                  "name": "Sari Wulandari",
                  "company": "Kencana Logistik Tbk",
                  "title": "Head of Operations",
                  "phone": null,
                  "address": null,
                  "avatar_url": null,
                  "custom_fields_json": "{}",
                  "status": "lead",
                  "source": "api",
                  "notes": null,
                  "created_at": 1794052050080,
                  "created_by": "usr-fitri-handayani",
                  "modified_at": 1794052050080,
                  "modified_by": "usr-fitri-handayani",
                  "deleted_at": null,
                  "deleted_by": null
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. Codes: `not_found`. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateContact",
        "summary": "Update a contact",
        "description": "Changes any of the given fields. `companyId: null` unlinks the company.\n\nProduct: `crm`. Permission (any of): `crm:record:write`.",
        "tags": [
          "CRM"
        ],
        "x-opex-entitlement": "crm",
        "x-opex-permissions": [
          "crm:record:write"
        ],
        "x-opex-stability": "stable",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Contact id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email",
                    "pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                  },
                  "name": {
                    "type": "string",
                    "maxLength": 200
                  },
                  "company": {
                    "type": "string",
                    "maxLength": 200
                  },
                  "title": {
                    "type": "string",
                    "maxLength": 120
                  },
                  "phone": {
                    "type": "string",
                    "maxLength": 60
                  },
                  "address": {
                    "type": "string",
                    "maxLength": 500
                  },
                  "source": {
                    "type": "string",
                    "maxLength": 120
                  },
                  "notes": {
                    "type": "string",
                    "maxLength": 2000
                  },
                  "companyId": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "lead",
                      "active",
                      "churned"
                    ]
                  }
                }
              },
              "example": {
                "status": "active",
                "phone": "+62 21 555 0100"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated contact.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "email": {
                      "type": "string"
                    },
                    "name": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "company": {
                      "description": "Company name as typed (free text).",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "company_id": {
                      "description": "Linked company record.",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "title": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "phone": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "address": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "lead",
                        "active",
                        "churned"
                      ]
                    },
                    "source": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "notes": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "created_at": {
                      "type": "number"
                    },
                    "modified_at": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "id",
                    "email",
                    "name",
                    "company",
                    "company_id",
                    "title",
                    "phone",
                    "address",
                    "status",
                    "source",
                    "notes",
                    "created_at",
                    "modified_at"
                  ],
                  "additionalProperties": {}
                },
                "example": {
                  "id": "f611c550-75fd-452d-8de3-8ab46f9f1823",
                  "tenant_id": "opexcg-tenant",
                  "user_id": null,
                  "company_id": "c5615616-096f-4886-9894-58e10bb0482a",
                  "email": "sari@kencana.example",
                  "name": "Sari Wulandari",
                  "company": "Kencana Logistik Tbk",
                  "title": "Head of Operations",
                  "phone": "+62 21 555 0100",
                  "address": null,
                  "avatar_url": null,
                  "custom_fields_json": "{}",
                  "status": "active",
                  "source": "api",
                  "notes": null,
                  "created_at": 1794052050080,
                  "created_by": "usr-fitri-handayani",
                  "modified_at": 1794052050163,
                  "modified_by": "usr-fitri-handayani",
                  "deleted_at": null,
                  "deleted_by": null
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. Codes: `not_found`, `company_not_found`. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/crm/companies": {
      "get": {
        "operationId": "listCrmCompanies",
        "summary": "List companies",
        "description": "Companies (your clients and your own organisation), with their contact and deal counts.\n\nSort keys: `name` (default), `created`, `type`.\n\nProduct: `crm`. Permission (any of): `crm:record:read`.",
        "tags": [
          "CRM"
        ],
        "x-opex-entitlement": "crm",
        "x-opex-permissions": [
          "crm:record:read"
        ],
        "x-opex-stability": "stable",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "required": false,
            "description": "1-based page number. Default 1.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "required": false,
            "description": "Rows per page, 1 to 100. Larger values are clamped. Default 20.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "description": "Free-text filter (trimmed, first 200 characters).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "required": false,
            "description": "Sort key. Unknown keys fall back to the endpoint's default sort.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dir",
            "in": "query",
            "required": false,
            "description": "`asc` or `desc` (default).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "type",
            "in": "query",
            "required": false,
            "description": "`client` or `internal`.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "One page of companies.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "type": {
                            "type": "string",
                            "enum": [
                              "client",
                              "internal"
                            ]
                          },
                          "created_at": {
                            "type": "number"
                          },
                          "contactCount": {
                            "type": "number"
                          },
                          "dealCount": {
                            "type": "number"
                          }
                        },
                        "required": [
                          "id",
                          "name",
                          "type",
                          "created_at",
                          "contactCount",
                          "dealCount"
                        ],
                        "additionalProperties": {}
                      }
                    },
                    "total": {
                      "type": "number"
                    },
                    "page": {
                      "type": "number"
                    },
                    "pageSize": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "items",
                    "total",
                    "page",
                    "pageSize"
                  ]
                },
                "example": {
                  "items": [
                    {
                      "id": "comp-xyzind",
                      "tenant_id": "opexcg-tenant",
                      "name": "XYZ Industries",
                      "type": "client",
                      "settings_json": "{}",
                      "created_at": 1768132020883,
                      "created_by": null,
                      "modified_at": 1768132020883,
                      "modified_by": null,
                      "deleted_at": null,
                      "deleted_by": null,
                      "contactCount": 0,
                      "dealCount": 0
                    },
                    {
                      "id": "comp-opexcg",
                      "tenant_id": "opexcg-tenant",
                      "name": "OpexCG",
                      "type": "internal",
                      "settings_json": "{}",
                      "created_at": 1759492020883,
                      "created_by": null,
                      "modified_at": 1759492020883,
                      "modified_by": null,
                      "deleted_at": null,
                      "deleted_by": null,
                      "contactCount": 0,
                      "dealCount": 0
                    }
                  ],
                  "total": 5,
                  "page": 1,
                  "pageSize": 5
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createCrmCompany",
        "summary": "Create a company",
        "description": "Creates a company. Needs `crm:company:create` as well as `crm:record:write`.\n\nProduct: `crm`. Permission (any of): `crm:company:create`.",
        "tags": [
          "CRM"
        ],
        "x-opex-entitlement": "crm",
        "x-opex-permissions": [
          "crm:company:create"
        ],
        "x-opex-stability": "stable",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "client",
                      "internal"
                    ]
                  }
                },
                "required": [
                  "name"
                ]
              },
              "example": {
                "name": "Kencana Logistik",
                "type": "client"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The new company.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string",
                      "enum": [
                        "client",
                        "internal"
                      ]
                    },
                    "created_at": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "id",
                    "name",
                    "type",
                    "created_at"
                  ],
                  "additionalProperties": {}
                },
                "example": {
                  "id": "c5615616-096f-4886-9894-58e10bb0482a",
                  "tenant_id": "opexcg-tenant",
                  "name": "Kencana Logistik",
                  "type": "client",
                  "settings_json": null,
                  "support_package": null,
                  "email_domains_json": null,
                  "website": null,
                  "domain": null,
                  "industry": null,
                  "description": null,
                  "created_at": 1794052049968,
                  "created_by": "usr-fitri-handayani",
                  "modified_at": 1794052049968,
                  "modified_by": "usr-fitri-handayani",
                  "deleted_at": null,
                  "deleted_by": null
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. Codes: `forbidden`. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/crm/companies/{id}": {
      "get": {
        "operationId": "getCrmCompany",
        "summary": "Get a company",
        "description": "One company with its contact count, deal count and pipeline totals.\n\nProduct: `crm`. Permission (any of): `crm:record:read`.",
        "tags": [
          "CRM"
        ],
        "x-opex-entitlement": "crm",
        "x-opex-permissions": [
          "crm:record:read"
        ],
        "x-opex-stability": "stable",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Company id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The company.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "company": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "type": {
                          "type": "string",
                          "enum": [
                            "client",
                            "internal"
                          ]
                        },
                        "created_at": {
                          "type": "number"
                        }
                      },
                      "required": [
                        "id",
                        "name",
                        "type",
                        "created_at"
                      ],
                      "additionalProperties": {}
                    },
                    "rollups": {
                      "type": "object",
                      "properties": {
                        "contactCount": {
                          "type": "number"
                        },
                        "dealCount": {
                          "type": "number"
                        },
                        "totals": {
                          "description": "Pipeline totals per currency."
                        }
                      },
                      "required": [
                        "contactCount",
                        "dealCount",
                        "totals"
                      ],
                      "additionalProperties": {}
                    }
                  },
                  "required": [
                    "company",
                    "rollups"
                  ]
                },
                "example": {
                  "company": {
                    "id": "c5615616-096f-4886-9894-58e10bb0482a",
                    "tenant_id": "opexcg-tenant",
                    "name": "Kencana Logistik",
                    "type": "client",
                    "settings_json": null,
                    "support_package": null,
                    "email_domains_json": null,
                    "website": null,
                    "domain": null,
                    "industry": null,
                    "description": null,
                    "created_at": 1794052049968,
                    "created_by": "usr-fitri-handayani",
                    "modified_at": 1794052049968,
                    "modified_by": "usr-fitri-handayani",
                    "deleted_at": null,
                    "deleted_by": null
                  },
                  "rollups": {
                    "contactCount": 0,
                    "dealCount": 0,
                    "totals": []
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. Codes: `not_found`. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateCrmCompany",
        "summary": "Update a company",
        "description": "Renames a company or changes its type. Needs `crm:company:update` as well as `crm:record:write`.\n\nProduct: `crm`. Permission (any of): `crm:company:update`.",
        "tags": [
          "CRM"
        ],
        "x-opex-entitlement": "crm",
        "x-opex-permissions": [
          "crm:company:update"
        ],
        "x-opex-stability": "stable",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Company id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "client",
                      "internal"
                    ]
                  }
                }
              },
              "example": {
                "name": "Kencana Logistik Tbk"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated company.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string",
                      "enum": [
                        "client",
                        "internal"
                      ]
                    },
                    "created_at": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "id",
                    "name",
                    "type",
                    "created_at"
                  ],
                  "additionalProperties": {}
                },
                "example": {
                  "id": "c5615616-096f-4886-9894-58e10bb0482a",
                  "tenant_id": "opexcg-tenant",
                  "name": "Kencana Logistik Tbk",
                  "type": "client",
                  "settings_json": null,
                  "support_package": null,
                  "email_domains_json": null,
                  "website": null,
                  "domain": null,
                  "industry": null,
                  "description": null,
                  "created_at": 1794052049968,
                  "created_by": "usr-fitri-handayani",
                  "modified_at": 1794052050044,
                  "modified_by": "usr-fitri-handayani",
                  "deleted_at": null,
                  "deleted_by": null
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. Codes: `not_found`, `forbidden`. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/crm/deals": {
      "get": {
        "operationId": "listDeals",
        "summary": "List deals",
        "description": "Deals, newest first by default. Amounts are integer minor units (`amount_cents`) in the deal's `currency`.\n\nSort keys: `created` (default), `name`, `amount`, `stage`, `expected_close`.\n\nProduct: `crm`. Permission (any of): `crm:record:read`.",
        "tags": [
          "CRM"
        ],
        "x-opex-entitlement": "crm",
        "x-opex-permissions": [
          "crm:record:read"
        ],
        "x-opex-stability": "stable",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "required": false,
            "description": "1-based page number. Default 1.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "required": false,
            "description": "Rows per page, 1 to 100. Larger values are clamped. Default 20.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "description": "Free-text filter (trimmed, first 200 characters).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "required": false,
            "description": "Sort key. Unknown keys fall back to the endpoint's default sort.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dir",
            "in": "query",
            "required": false,
            "description": "`asc` or `desc` (default).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "stage",
            "in": "query",
            "required": false,
            "description": "`lead`, `qualified`, `demo_poc`, `proposal`, `negotiation`, `won` or `lost`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "contactId",
            "in": "query",
            "required": false,
            "description": "Only deals of this contact.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "companyId",
            "in": "query",
            "required": false,
            "description": "Only deals of this company.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "One page of deals.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "contact_id": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "company_id": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "project_id": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "sales_owner_id": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "stage": {
                            "type": "string",
                            "enum": [
                              "lead",
                              "qualified",
                              "demo_poc",
                              "proposal",
                              "negotiation",
                              "won",
                              "lost"
                            ]
                          },
                          "amount_cents": {
                            "type": "number",
                            "description": "Integer minor units of `currency`."
                          },
                          "currency": {
                            "type": "string"
                          },
                          "win_probability": {
                            "description": "0 to 100; null follows the stage default.",
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "expected_close_at": {
                            "description": "Epoch milliseconds.",
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "closed_at": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "lost_reason": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "source": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "notes": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "created_at": {
                            "type": "number"
                          },
                          "modified_at": {
                            "type": "number"
                          }
                        },
                        "required": [
                          "id",
                          "name",
                          "contact_id",
                          "company_id",
                          "project_id",
                          "sales_owner_id",
                          "stage",
                          "amount_cents",
                          "currency",
                          "win_probability",
                          "expected_close_at",
                          "closed_at",
                          "lost_reason",
                          "source",
                          "notes",
                          "created_at",
                          "modified_at"
                        ],
                        "additionalProperties": {}
                      }
                    },
                    "total": {
                      "type": "number"
                    },
                    "page": {
                      "type": "number"
                    },
                    "pageSize": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "items",
                    "total",
                    "page",
                    "pageSize"
                  ]
                },
                "example": {
                  "items": [
                    {
                      "id": "c80cad76-7ec0-4641-a5f2-30ea2aaa4561",
                      "tenant_id": "opexcg-tenant",
                      "contact_id": "f611c550-75fd-452d-8de3-8ab46f9f1823",
                      "company_id": "c5615616-096f-4886-9894-58e10bb0482a",
                      "project_id": null,
                      "sales_owner_id": null,
                      "name": "Fleet maintenance rollout",
                      "amount_cents": 4500000000,
                      "currency": "IDR",
                      "stage": "qualified",
                      "stage_sort": 1,
                      "expected_close_at": 1796644050172,
                      "source": null,
                      "win_probability": null,
                      "lost_reason": null,
                      "competitor_name": null,
                      "demand_role": null,
                      "demand_hours_per_day": null,
                      "demand_start_at": null,
                      "demand_weeks": null,
                      "win_reason": null,
                      "loss_reason": null,
                      "closed_at": null,
                      "notes": null,
                      "created_at": 1794052050203,
                      "created_by": "usr-fitri-handayani",
                      "modified_at": 1794052050203,
                      "modified_by": "usr-fitri-handayani",
                      "deleted_at": null,
                      "deleted_by": null
                    }
                  ],
                  "total": 1,
                  "page": 1,
                  "pageSize": 2
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createDeal",
        "summary": "Create a deal",
        "description": "Creates a deal, by default in the `lead` stage. `amountCents` is in minor units of `currency`. A deal created as `lost` needs a `lostReason`.\n\nProduct: `crm`. Permission (any of): `crm:record:write`.",
        "tags": [
          "CRM"
        ],
        "x-opex-entitlement": "crm",
        "x-opex-permissions": [
          "crm:record:write"
        ],
        "x-opex-stability": "stable",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "contactId": {
                    "type": "string"
                  },
                  "companyId": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "projectId": {
                    "type": "string"
                  },
                  "notes": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 5000
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "salesOwnerId": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "source": {
                    "type": "string",
                    "maxLength": 120
                  },
                  "amountCents": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991
                  },
                  "currency": {
                    "type": "string",
                    "maxLength": 8
                  },
                  "expectedCloseAt": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": -9007199254740991,
                        "maximum": 9007199254740991
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "stage": {
                    "type": "string",
                    "enum": [
                      "lead",
                      "qualified",
                      "demo_poc",
                      "proposal",
                      "negotiation",
                      "won",
                      "lost"
                    ]
                  },
                  "winProbability": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 100
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "lostReason": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "price",
                          "scope",
                          "no_budget",
                          "competitor",
                          "stalled"
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "competitorName": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 200
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "demandRole": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "SE",
                          "FC",
                          "TC",
                          "PM"
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "demandHoursPerDay": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 24
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "demandStartAt": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": -9007199254740991,
                        "maximum": 9007199254740991
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "demandWeeks": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 520
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": [
                  "name"
                ]
              },
              "example": {
                "name": "Fleet maintenance rollout",
                "contactId": "f611c550-75fd-452d-8de3-8ab46f9f1823",
                "companyId": "c5615616-096f-4886-9894-58e10bb0482a",
                "amountCents": 4500000000,
                "currency": "IDR",
                "stage": "qualified",
                "expectedCloseAt": 1796644050172
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The new deal.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "contact_id": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "company_id": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "project_id": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "sales_owner_id": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "stage": {
                      "type": "string",
                      "enum": [
                        "lead",
                        "qualified",
                        "demo_poc",
                        "proposal",
                        "negotiation",
                        "won",
                        "lost"
                      ]
                    },
                    "amount_cents": {
                      "type": "number",
                      "description": "Integer minor units of `currency`."
                    },
                    "currency": {
                      "type": "string"
                    },
                    "win_probability": {
                      "description": "0 to 100; null follows the stage default.",
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "expected_close_at": {
                      "description": "Epoch milliseconds.",
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "closed_at": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "lost_reason": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "source": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "notes": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "created_at": {
                      "type": "number"
                    },
                    "modified_at": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "id",
                    "name",
                    "contact_id",
                    "company_id",
                    "project_id",
                    "sales_owner_id",
                    "stage",
                    "amount_cents",
                    "currency",
                    "win_probability",
                    "expected_close_at",
                    "closed_at",
                    "lost_reason",
                    "source",
                    "notes",
                    "created_at",
                    "modified_at"
                  ],
                  "additionalProperties": {}
                },
                "example": {
                  "id": "c80cad76-7ec0-4641-a5f2-30ea2aaa4561",
                  "tenant_id": "opexcg-tenant",
                  "contact_id": "f611c550-75fd-452d-8de3-8ab46f9f1823",
                  "company_id": "c5615616-096f-4886-9894-58e10bb0482a",
                  "project_id": null,
                  "sales_owner_id": null,
                  "name": "Fleet maintenance rollout",
                  "amount_cents": 4500000000,
                  "currency": "IDR",
                  "stage": "qualified",
                  "stage_sort": 1,
                  "expected_close_at": 1796644050172,
                  "source": null,
                  "win_probability": null,
                  "lost_reason": null,
                  "competitor_name": null,
                  "demand_role": null,
                  "demand_hours_per_day": null,
                  "demand_start_at": null,
                  "demand_weeks": null,
                  "win_reason": null,
                  "loss_reason": null,
                  "closed_at": null,
                  "notes": null,
                  "created_at": 1794052050203,
                  "created_by": "usr-fitri-handayani",
                  "modified_at": 1794052050203,
                  "modified_by": "usr-fitri-handayani",
                  "deleted_at": null,
                  "deleted_by": null
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. Codes: `company_not_found`, `missing_lost_reason`. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/crm/deals/{id}": {
      "get": {
        "operationId": "getDeal",
        "summary": "Get a deal",
        "description": "One deal with its stage, amount and linked contact, company and project.\n\nProduct: `crm`. Permission (any of): `crm:record:read`.",
        "tags": [
          "CRM"
        ],
        "x-opex-entitlement": "crm",
        "x-opex-permissions": [
          "crm:record:read"
        ],
        "x-opex-stability": "stable",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Deal id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The deal.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "contact_id": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "company_id": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "project_id": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "sales_owner_id": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "stage": {
                      "type": "string",
                      "enum": [
                        "lead",
                        "qualified",
                        "demo_poc",
                        "proposal",
                        "negotiation",
                        "won",
                        "lost"
                      ]
                    },
                    "amount_cents": {
                      "type": "number",
                      "description": "Integer minor units of `currency`."
                    },
                    "currency": {
                      "type": "string"
                    },
                    "win_probability": {
                      "description": "0 to 100; null follows the stage default.",
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "expected_close_at": {
                      "description": "Epoch milliseconds.",
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "closed_at": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "lost_reason": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "source": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "notes": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "created_at": {
                      "type": "number"
                    },
                    "modified_at": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "id",
                    "name",
                    "contact_id",
                    "company_id",
                    "project_id",
                    "sales_owner_id",
                    "stage",
                    "amount_cents",
                    "currency",
                    "win_probability",
                    "expected_close_at",
                    "closed_at",
                    "lost_reason",
                    "source",
                    "notes",
                    "created_at",
                    "modified_at"
                  ],
                  "additionalProperties": {}
                },
                "example": {
                  "id": "c80cad76-7ec0-4641-a5f2-30ea2aaa4561",
                  "tenant_id": "opexcg-tenant",
                  "contact_id": "f611c550-75fd-452d-8de3-8ab46f9f1823",
                  "company_id": "c5615616-096f-4886-9894-58e10bb0482a",
                  "project_id": null,
                  "sales_owner_id": null,
                  "name": "Fleet maintenance rollout",
                  "amount_cents": 4500000000,
                  "currency": "IDR",
                  "stage": "qualified",
                  "stage_sort": 1,
                  "expected_close_at": 1796644050172,
                  "source": null,
                  "win_probability": null,
                  "lost_reason": null,
                  "competitor_name": null,
                  "demand_role": null,
                  "demand_hours_per_day": null,
                  "demand_start_at": null,
                  "demand_weeks": null,
                  "win_reason": null,
                  "loss_reason": null,
                  "closed_at": null,
                  "notes": null,
                  "created_at": 1794052050203,
                  "created_by": "usr-fitri-handayani",
                  "modified_at": 1794052050203,
                  "modified_by": "usr-fitri-handayani",
                  "deleted_at": null,
                  "deleted_by": null
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. Codes: `not_found`. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateDeal",
        "summary": "Update a deal",
        "description": "Changes any of the given fields. Use the move endpoint to change the stage with a timeline entry.\n\nProduct: `crm`. Permission (any of): `crm:record:write`.",
        "tags": [
          "CRM"
        ],
        "x-opex-entitlement": "crm",
        "x-opex-permissions": [
          "crm:record:write"
        ],
        "x-opex-stability": "stable",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Deal id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "contactId": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "companyId": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "projectId": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "notes": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 5000
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "salesOwnerId": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "source": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 120
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "amountCents": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991
                  },
                  "currency": {
                    "type": "string",
                    "maxLength": 8
                  },
                  "expectedCloseAt": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": -9007199254740991,
                        "maximum": 9007199254740991
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "stage": {
                    "type": "string",
                    "enum": [
                      "lead",
                      "qualified",
                      "demo_poc",
                      "proposal",
                      "negotiation",
                      "won",
                      "lost"
                    ]
                  },
                  "winProbability": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 100
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "lostReason": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "price",
                          "scope",
                          "no_budget",
                          "competitor",
                          "stalled"
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "competitorName": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 200
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "demandRole": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "SE",
                          "FC",
                          "TC",
                          "PM"
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "demandHoursPerDay": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 24
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "demandStartAt": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": -9007199254740991,
                        "maximum": 9007199254740991
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "demandWeeks": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 520
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              },
              "example": {
                "winProbability": 60
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated deal.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "contact_id": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "company_id": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "project_id": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "sales_owner_id": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "stage": {
                      "type": "string",
                      "enum": [
                        "lead",
                        "qualified",
                        "demo_poc",
                        "proposal",
                        "negotiation",
                        "won",
                        "lost"
                      ]
                    },
                    "amount_cents": {
                      "type": "number",
                      "description": "Integer minor units of `currency`."
                    },
                    "currency": {
                      "type": "string"
                    },
                    "win_probability": {
                      "description": "0 to 100; null follows the stage default.",
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "expected_close_at": {
                      "description": "Epoch milliseconds.",
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "closed_at": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "lost_reason": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "source": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "notes": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "created_at": {
                      "type": "number"
                    },
                    "modified_at": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "id",
                    "name",
                    "contact_id",
                    "company_id",
                    "project_id",
                    "sales_owner_id",
                    "stage",
                    "amount_cents",
                    "currency",
                    "win_probability",
                    "expected_close_at",
                    "closed_at",
                    "lost_reason",
                    "source",
                    "notes",
                    "created_at",
                    "modified_at"
                  ],
                  "additionalProperties": {}
                },
                "example": {
                  "id": "c80cad76-7ec0-4641-a5f2-30ea2aaa4561",
                  "tenant_id": "opexcg-tenant",
                  "contact_id": "f611c550-75fd-452d-8de3-8ab46f9f1823",
                  "company_id": "c5615616-096f-4886-9894-58e10bb0482a",
                  "project_id": null,
                  "sales_owner_id": null,
                  "name": "Fleet maintenance rollout",
                  "amount_cents": 4500000000,
                  "currency": "IDR",
                  "stage": "qualified",
                  "stage_sort": 1,
                  "expected_close_at": 1796644050172,
                  "source": null,
                  "win_probability": 60,
                  "lost_reason": null,
                  "competitor_name": null,
                  "demand_role": null,
                  "demand_hours_per_day": null,
                  "demand_start_at": null,
                  "demand_weeks": null,
                  "win_reason": null,
                  "loss_reason": null,
                  "closed_at": null,
                  "notes": null,
                  "created_at": 1794052050203,
                  "created_by": "usr-fitri-handayani",
                  "modified_at": 1794052050299,
                  "modified_by": "usr-fitri-handayani",
                  "deleted_at": null,
                  "deleted_by": null
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. Codes: `not_found`, `company_not_found`, `missing_lost_reason`. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/crm/deals/{id}/move": {
      "post": {
        "operationId": "moveDeal",
        "summary": "Move a deal to another stage",
        "description": "Moves a deal along the pipeline and records the move on its timeline. Moving to `won` or `lost` stamps `closed_at` (and `lost` needs a `lostReason`); moving back to an open stage clears it.\n\nProduct: `crm`. Permission (any of): `crm:record:write`.",
        "tags": [
          "CRM"
        ],
        "x-opex-entitlement": "crm",
        "x-opex-permissions": [
          "crm:record:write"
        ],
        "x-opex-stability": "stable",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Deal id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "stage": {
                    "type": "string",
                    "enum": [
                      "lead",
                      "qualified",
                      "demo_poc",
                      "proposal",
                      "negotiation",
                      "won",
                      "lost"
                    ]
                  },
                  "lostReason": {
                    "type": "string",
                    "enum": [
                      "price",
                      "scope",
                      "no_budget",
                      "competitor",
                      "stalled"
                    ]
                  },
                  "competitorName": {
                    "type": "string",
                    "maxLength": 200
                  }
                },
                "required": [
                  "stage"
                ]
              },
              "example": {
                "stage": "proposal"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The moved deal.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "contact_id": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "company_id": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "project_id": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "sales_owner_id": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "stage": {
                      "type": "string",
                      "enum": [
                        "lead",
                        "qualified",
                        "demo_poc",
                        "proposal",
                        "negotiation",
                        "won",
                        "lost"
                      ]
                    },
                    "amount_cents": {
                      "type": "number",
                      "description": "Integer minor units of `currency`."
                    },
                    "currency": {
                      "type": "string"
                    },
                    "win_probability": {
                      "description": "0 to 100; null follows the stage default.",
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "expected_close_at": {
                      "description": "Epoch milliseconds.",
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "closed_at": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "lost_reason": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "source": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "notes": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "created_at": {
                      "type": "number"
                    },
                    "modified_at": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "id",
                    "name",
                    "contact_id",
                    "company_id",
                    "project_id",
                    "sales_owner_id",
                    "stage",
                    "amount_cents",
                    "currency",
                    "win_probability",
                    "expected_close_at",
                    "closed_at",
                    "lost_reason",
                    "source",
                    "notes",
                    "created_at",
                    "modified_at"
                  ],
                  "additionalProperties": {}
                },
                "example": {
                  "id": "c80cad76-7ec0-4641-a5f2-30ea2aaa4561",
                  "tenant_id": "opexcg-tenant",
                  "contact_id": "f611c550-75fd-452d-8de3-8ab46f9f1823",
                  "company_id": "c5615616-096f-4886-9894-58e10bb0482a",
                  "project_id": null,
                  "sales_owner_id": null,
                  "name": "Fleet maintenance rollout",
                  "amount_cents": 4500000000,
                  "currency": "IDR",
                  "stage": "proposal",
                  "stage_sort": 3,
                  "expected_close_at": 1796644050172,
                  "source": null,
                  "win_probability": 60,
                  "lost_reason": null,
                  "competitor_name": null,
                  "demand_role": null,
                  "demand_hours_per_day": null,
                  "demand_start_at": null,
                  "demand_weeks": null,
                  "win_reason": null,
                  "loss_reason": null,
                  "closed_at": null,
                  "notes": null,
                  "created_at": 1794052050203,
                  "created_by": "usr-fitri-handayani",
                  "modified_at": 1794052050329,
                  "modified_by": "usr-fitri-handayani",
                  "deleted_at": null,
                  "deleted_by": null
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. Codes: `not_found`, `missing_lost_reason`. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/crm/activities": {
      "get": {
        "operationId": "listActivities",
        "summary": "List activities",
        "description": "Calls, emails, meetings and notes, most recent first. Pass `subjectType` and `subjectId` for one contact's or deal's timeline.\n\nProduct: `crm`. Permission (any of): `crm:record:read`.",
        "tags": [
          "CRM"
        ],
        "x-opex-entitlement": "crm",
        "x-opex-permissions": [
          "crm:record:read"
        ],
        "x-opex-stability": "stable",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "required": false,
            "description": "1-based page number. Default 1.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "required": false,
            "description": "Rows per page, 1 to 100. Larger values are clamped. Default 20.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "description": "Free-text filter (trimmed, first 200 characters).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "required": false,
            "description": "Sort key. Unknown keys fall back to the endpoint's default sort.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dir",
            "in": "query",
            "required": false,
            "description": "`asc` or `desc` (default).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "subjectType",
            "in": "query",
            "required": false,
            "description": "`contact` or `deal`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "subjectId",
            "in": "query",
            "required": false,
            "description": "With `subjectType`: one contact's or deal's timeline.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "kind",
            "in": "query",
            "required": false,
            "description": "`call`, `email`, `meeting`, `note` or `system`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "done",
            "in": "query",
            "required": false,
            "description": "`true` for completed follow-ups, `false` for open ones.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "One page of activities.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "subject_type": {
                            "type": "string",
                            "enum": [
                              "contact",
                              "deal"
                            ]
                          },
                          "subject_id": {
                            "type": "string"
                          },
                          "kind": {
                            "type": "string",
                            "enum": [
                              "call",
                              "email",
                              "meeting",
                              "note",
                              "system"
                            ]
                          },
                          "title": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "body": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "occurred_at": {
                            "type": "number",
                            "description": "Epoch milliseconds."
                          },
                          "due_at": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "done_at": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "created_by": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "created_at": {
                            "type": "number"
                          }
                        },
                        "required": [
                          "id",
                          "subject_type",
                          "subject_id",
                          "kind",
                          "title",
                          "body",
                          "occurred_at",
                          "due_at",
                          "done_at",
                          "created_by",
                          "created_at"
                        ],
                        "additionalProperties": {}
                      }
                    },
                    "total": {
                      "type": "number"
                    },
                    "page": {
                      "type": "number"
                    },
                    "pageSize": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "items",
                    "total",
                    "page",
                    "pageSize"
                  ]
                },
                "example": {
                  "items": [
                    {
                      "id": "b5c5c795-91da-4d91-b53d-fe7bd8b48d91",
                      "tenant_id": "opexcg-tenant",
                      "subject_type": "deal",
                      "subject_id": "c80cad76-7ec0-4641-a5f2-30ea2aaa4561",
                      "kind": "meeting",
                      "title": "Proposal walkthrough",
                      "body": null,
                      "occurred_at": 1794052050341,
                      "due_at": null,
                      "done_at": null,
                      "created_at": 1794052050369,
                      "created_by": "usr-fitri-handayani",
                      "modified_at": 1794052050369,
                      "modified_by": "usr-fitri-handayani",
                      "deleted_at": null,
                      "deleted_by": null
                    },
                    {
                      "id": "abef4b47-4708-4a32-b00f-d60262d580eb",
                      "tenant_id": "opexcg-tenant",
                      "subject_type": "deal",
                      "subject_id": "c80cad76-7ec0-4641-a5f2-30ea2aaa4561",
                      "kind": "system",
                      "title": "Stage → Proposal sent",
                      "body": null,
                      "occurred_at": 1794052050335,
                      "due_at": null,
                      "done_at": null,
                      "created_at": 1794052050335,
                      "created_by": "usr-fitri-handayani",
                      "modified_at": 1794052050335,
                      "modified_by": "usr-fitri-handayani",
                      "deleted_at": null,
                      "deleted_by": null
                    }
                  ],
                  "total": 2,
                  "page": 1,
                  "pageSize": 2
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. Codes: `invalid_subject_type`. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createActivity",
        "summary": "Log an activity",
        "description": "Logs a call, email, meeting or note on a contact's or deal's timeline. `occurredAt` defaults to now; `dueAt` makes it a follow-up. Times are epoch milliseconds.\n\nProduct: `crm`. Permission (any of): `crm:record:write`.",
        "tags": [
          "CRM"
        ],
        "x-opex-entitlement": "crm",
        "x-opex-permissions": [
          "crm:record:write"
        ],
        "x-opex-stability": "stable",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "subjectType": {
                    "type": "string",
                    "enum": [
                      "contact",
                      "deal"
                    ]
                  },
                  "subjectId": {
                    "type": "string"
                  },
                  "kind": {
                    "type": "string",
                    "enum": [
                      "call",
                      "email",
                      "meeting",
                      "note",
                      "system"
                    ]
                  },
                  "title": {
                    "type": "string",
                    "maxLength": 300
                  },
                  "body": {
                    "type": "string",
                    "maxLength": 5000
                  },
                  "occurredAt": {
                    "type": "integer",
                    "minimum": -9007199254740991,
                    "maximum": 9007199254740991
                  },
                  "dueAt": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": -9007199254740991,
                        "maximum": 9007199254740991
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": [
                  "subjectType",
                  "subjectId",
                  "kind"
                ]
              },
              "example": {
                "subjectType": "deal",
                "subjectId": "c80cad76-7ec0-4641-a5f2-30ea2aaa4561",
                "kind": "meeting",
                "title": "Proposal walkthrough",
                "occurredAt": 1794052050341
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The new activity.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "subject_type": {
                      "type": "string",
                      "enum": [
                        "contact",
                        "deal"
                      ]
                    },
                    "subject_id": {
                      "type": "string"
                    },
                    "kind": {
                      "type": "string",
                      "enum": [
                        "call",
                        "email",
                        "meeting",
                        "note",
                        "system"
                      ]
                    },
                    "title": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "body": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "occurred_at": {
                      "type": "number",
                      "description": "Epoch milliseconds."
                    },
                    "due_at": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "done_at": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "created_by": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "created_at": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "id",
                    "subject_type",
                    "subject_id",
                    "kind",
                    "title",
                    "body",
                    "occurred_at",
                    "due_at",
                    "done_at",
                    "created_by",
                    "created_at"
                  ],
                  "additionalProperties": {}
                },
                "example": {
                  "id": "b5c5c795-91da-4d91-b53d-fe7bd8b48d91",
                  "tenant_id": "opexcg-tenant",
                  "subject_type": "deal",
                  "subject_id": "c80cad76-7ec0-4641-a5f2-30ea2aaa4561",
                  "kind": "meeting",
                  "title": "Proposal walkthrough",
                  "body": null,
                  "occurred_at": 1794052050341,
                  "due_at": null,
                  "done_at": null,
                  "created_at": 1794052050369,
                  "created_by": "usr-fitri-handayani",
                  "modified_at": 1794052050369,
                  "modified_by": "usr-fitri-handayani",
                  "deleted_at": null,
                  "deleted_by": null
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. Codes: `invalid_subject_type`, `subject_not_found`. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/expenses": {
      "get": {
        "operationId": "listExpenses",
        "summary": "List expenses",
        "description": "Expenses you may see, newest first by default. A `dateFrom` or `dateTo` that is not `YYYY-MM-DD` answers 400. Amounts are integer minor units of `currency` (`totalCents: 8500000` in IDR is Rp 85.000).\n\nSort keys: `created` (default), `issued`, `total`, `vendor`, `status`, `submittedBy`.\n\nProduct: `expenses`.",
        "tags": [
          "Expenses"
        ],
        "x-opex-entitlement": "expenses",
        "x-opex-permissions": [],
        "x-opex-stability": "stable",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "required": false,
            "description": "1-based page number. Default 1.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "required": false,
            "description": "Rows per page, 1 to 100. Larger values are clamped. Default 20.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "description": "Free-text filter (trimmed, first 200 characters).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "required": false,
            "description": "Sort key. Unknown keys fall back to the endpoint's default sort.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dir",
            "in": "query",
            "required": false,
            "description": "`asc` or `desc` (default).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "`draft`, `pending`, `approved`, `rejected` or `paid`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "mine",
            "in": "query",
            "required": false,
            "description": "`1` or `true`: only expenses you submitted.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "submitterId",
            "in": "query",
            "required": false,
            "description": "Only expenses of this member.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "projectId",
            "in": "query",
            "required": false,
            "description": "Only expenses charged to this project.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dateFrom",
            "in": "query",
            "required": false,
            "description": "Issued on or after this day (`YYYY-MM-DD`).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dateTo",
            "in": "query",
            "required": false,
            "description": "Issued on or before this day (`YYYY-MM-DD`).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "category",
            "in": "query",
            "required": false,
            "description": "Category name.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "One page of expenses.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "submitted_by_user_id": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "draft",
                              "pending",
                              "approved",
                              "rejected",
                              "paid"
                            ]
                          },
                          "vendor_name": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "invoice_number": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "document_kind": {
                            "type": "string",
                            "description": "`receipt`, `invoice`, … (`other` until recognised)."
                          },
                          "issued_at": {
                            "description": "Epoch milliseconds.",
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "currency": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "subtotal_cents": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "tax_cents": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "total_cents": {
                            "description": "Integer minor units of `currency`.",
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "category": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "project_id": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "submission_id": {
                            "description": "The batch this expense was filed in, if any.",
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "rejection_reason": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "ocr_confidence": {
                            "description": "Set once receipt recognition ran.",
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "created_at": {
                            "type": "number"
                          },
                          "project_name": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "submitted_by_name": {
                            "type": [
                              "string",
                              "null"
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "submitted_by_user_id",
                          "status",
                          "vendor_name",
                          "invoice_number",
                          "document_kind",
                          "issued_at",
                          "currency",
                          "subtotal_cents",
                          "tax_cents",
                          "total_cents",
                          "category",
                          "project_id",
                          "submission_id",
                          "rejection_reason",
                          "ocr_confidence",
                          "created_at",
                          "project_name",
                          "submitted_by_name"
                        ],
                        "additionalProperties": {}
                      }
                    },
                    "total": {
                      "type": "number"
                    },
                    "page": {
                      "type": "number"
                    },
                    "pageSize": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "items",
                    "total",
                    "page",
                    "pageSize"
                  ]
                },
                "example": {
                  "items": [
                    {
                      "id": "79a3e8b7-b420-499b-adb9-a8d52c1fc5dc",
                      "tenant_id": "opexcg-tenant",
                      "submitted_by_user_id": "usr-fitri-handayani",
                      "vendor_name": "Kopi Kenangan",
                      "vendor_tax_id": null,
                      "invoice_number": null,
                      "document_kind": "receipt",
                      "issued_at": 1793965650435,
                      "due_at": null,
                      "currency": "IDR",
                      "subtotal_cents": 0,
                      "tax_cents": 0,
                      "total_cents": 8500000,
                      "category": "Meals & Entertainment",
                      "project_id": "99e5d1dd-334c-4bc3-88c7-7d84558bf7c6",
                      "submission_id": null,
                      "subject_type": null,
                      "subject_id": null,
                      "status": "draft",
                      "ocr_raw_json": null,
                      "ocr_confidence": null,
                      "file_asset_id": null,
                      "approved_by": null,
                      "approved_at": null,
                      "pm_approved_amount_cents": null,
                      "pm_approved_currency": null,
                      "pm_approved_project_id": null,
                      "correction_requested_at": null,
                      "rejection_reason": null,
                      "reimbursed_at": null,
                      "paid_at": null,
                      "created_at": 1794052050465,
                      "created_by": "usr-fitri-handayani",
                      "modified_at": 1794052050465,
                      "modified_by": "usr-fitri-handayani",
                      "deleted_at": null,
                      "deleted_by": null,
                      "project_name": "Customer portal rollout",
                      "submitted_by_name": "Fitri Handayani"
                    },
                    {
                      "id": "exp-opexcg-target-073",
                      "tenant_id": "opexcg-tenant",
                      "submitted_by_user_id": "usr-sari-wulandari",
                      "vendor_name": "Kopi Kalyan",
                      "vendor_tax_id": null,
                      "invoice_number": "OPEXCG-TARGET-073",
                      "document_kind": "receipt",
                      "issued_at": 1789862400000,
                      "due_at": null,
                      "currency": "IDR",
                      "subtotal_cents": 29000000,
                      "tax_cents": 0,
                      "total_cents": 29000000,
                      "category": "Meals",
                      "project_id": "prj-presales",
                      "submission_id": "sub-opexcg-presales-01",
                      "subject_type": null,
                      "subject_id": null,
                      "status": "pending",
                      "ocr_raw_json": null,
                      "ocr_confidence": null,
                      "file_asset_id": null,
                      "approved_by": null,
                      "approved_at": null,
                      "pm_approved_amount_cents": null,
                      "pm_approved_currency": null,
                      "pm_approved_project_id": null,
                      "correction_requested_at": null,
                      "rejection_reason": null,
                      "reimbursed_at": null,
                      "paid_at": null,
                      "created_at": 1789776000000,
                      "created_by": "usr-sari-wulandari",
                      "modified_at": 1789776000000,
                      "modified_by": "usr-sari-wulandari",
                      "deleted_at": null,
                      "deleted_by": null,
                      "project_name": "Presales",
                      "submitted_by_name": "Sari Wulandari"
                    }
                  ],
                  "total": 2,
                  "page": 1,
                  "pageSize": 2
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. Codes: `invalid_date_range`. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createExpense",
        "summary": "Create an expense",
        "description": "Creates a draft expense filed by the caller. Amounts are integer minor units of `currency` (`totalCents: 8500000` in IDR is Rp 85.000). Dates are epoch milliseconds. Charging a project needs access to that project.\n\nProduct: `expenses`.",
        "tags": [
          "Expenses"
        ],
        "x-opex-entitlement": "expenses",
        "x-opex-permissions": [],
        "x-opex-stability": "stable",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "vendorName": {
                    "type": "string",
                    "maxLength": 200
                  },
                  "vendorTaxId": {
                    "type": "string",
                    "maxLength": 60
                  },
                  "invoiceNumber": {
                    "type": "string",
                    "maxLength": 120
                  },
                  "documentKind": {
                    "type": "string",
                    "enum": [
                      "invoice",
                      "receipt",
                      "nota",
                      "billing",
                      "other"
                    ]
                  },
                  "issuedAt": {
                    "type": "integer",
                    "minimum": -9007199254740991,
                    "maximum": 9007199254740991
                  },
                  "dueAt": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": -9007199254740991,
                        "maximum": 9007199254740991
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "currency": {
                    "type": "string",
                    "maxLength": 8
                  },
                  "subtotalCents": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991
                  },
                  "taxCents": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991
                  },
                  "totalCents": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991
                  },
                  "category": {
                    "type": "string",
                    "maxLength": 120
                  },
                  "projectId": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "subjectType": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "ticket",
                          "task"
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "subjectId": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "lines": {
                    "maxItems": 200,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "description": {
                          "type": "string",
                          "maxLength": 300
                        },
                        "qty": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991
                        },
                        "unitAmountCents": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991
                        },
                        "amountCents": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991
                        },
                        "taxCents": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991
                        },
                        "glCode": {
                          "type": "string",
                          "maxLength": 60
                        }
                      }
                    }
                  }
                }
              },
              "example": {
                "vendorName": "Kopi Kenangan",
                "documentKind": "receipt",
                "issuedAt": 1793965650435,
                "currency": "IDR",
                "totalCents": 8500000,
                "category": "Meals & Entertainment",
                "projectId": "99e5d1dd-334c-4bc3-88c7-7d84558bf7c6"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The new draft.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "submitted_by_user_id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "draft",
                        "pending",
                        "approved",
                        "rejected",
                        "paid"
                      ]
                    },
                    "vendor_name": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "invoice_number": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "document_kind": {
                      "type": "string",
                      "description": "`receipt`, `invoice`, … (`other` until recognised)."
                    },
                    "issued_at": {
                      "description": "Epoch milliseconds.",
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "currency": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "subtotal_cents": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "tax_cents": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "total_cents": {
                      "description": "Integer minor units of `currency`.",
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "category": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "project_id": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "submission_id": {
                      "description": "The batch this expense was filed in, if any.",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "rejection_reason": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "ocr_confidence": {
                      "description": "Set once receipt recognition ran.",
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "created_at": {
                      "type": "number"
                    },
                    "lines": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "description": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "qty": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "unit_amount_cents": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "amount_cents": {
                            "type": "number"
                          },
                          "tax_cents": {
                            "type": "number"
                          },
                          "gl_code": {
                            "type": [
                              "string",
                              "null"
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "description",
                          "qty",
                          "unit_amount_cents",
                          "amount_cents",
                          "tax_cents",
                          "gl_code"
                        ],
                        "additionalProperties": {}
                      }
                    }
                  },
                  "required": [
                    "id",
                    "submitted_by_user_id",
                    "status",
                    "vendor_name",
                    "invoice_number",
                    "document_kind",
                    "issued_at",
                    "currency",
                    "subtotal_cents",
                    "tax_cents",
                    "total_cents",
                    "category",
                    "project_id",
                    "submission_id",
                    "rejection_reason",
                    "ocr_confidence",
                    "created_at",
                    "lines"
                  ],
                  "additionalProperties": {}
                },
                "example": {
                  "id": "79a3e8b7-b420-499b-adb9-a8d52c1fc5dc",
                  "tenant_id": "opexcg-tenant",
                  "submitted_by_user_id": "usr-fitri-handayani",
                  "vendor_name": "Kopi Kenangan",
                  "vendor_tax_id": null,
                  "invoice_number": null,
                  "document_kind": "receipt",
                  "issued_at": 1793965650435,
                  "due_at": null,
                  "currency": "IDR",
                  "subtotal_cents": 0,
                  "tax_cents": 0,
                  "total_cents": 8500000,
                  "category": "Meals & Entertainment",
                  "project_id": "99e5d1dd-334c-4bc3-88c7-7d84558bf7c6",
                  "submission_id": null,
                  "subject_type": null,
                  "subject_id": null,
                  "status": "draft",
                  "ocr_raw_json": null,
                  "ocr_confidence": null,
                  "file_asset_id": null,
                  "approved_by": null,
                  "approved_at": null,
                  "pm_approved_amount_cents": null,
                  "pm_approved_currency": null,
                  "pm_approved_project_id": null,
                  "correction_requested_at": null,
                  "rejection_reason": null,
                  "reimbursed_at": null,
                  "paid_at": null,
                  "created_at": 1794052050465,
                  "created_by": "usr-fitri-handayani",
                  "modified_at": 1794052050465,
                  "modified_by": "usr-fitri-handayani",
                  "deleted_at": null,
                  "deleted_by": null,
                  "lines": []
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/expenses/{id}": {
      "get": {
        "operationId": "getExpense",
        "summary": "Get an expense",
        "description": "One expense with its line items. Amounts are integer minor units of `currency` (`totalCents: 8500000` in IDR is Rp 85.000).\n\nProduct: `expenses`.",
        "tags": [
          "Expenses"
        ],
        "x-opex-entitlement": "expenses",
        "x-opex-permissions": [],
        "x-opex-stability": "stable",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Expense id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The expense.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "submitted_by_user_id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "draft",
                        "pending",
                        "approved",
                        "rejected",
                        "paid"
                      ]
                    },
                    "vendor_name": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "invoice_number": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "document_kind": {
                      "type": "string",
                      "description": "`receipt`, `invoice`, … (`other` until recognised)."
                    },
                    "issued_at": {
                      "description": "Epoch milliseconds.",
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "currency": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "subtotal_cents": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "tax_cents": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "total_cents": {
                      "description": "Integer minor units of `currency`.",
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "category": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "project_id": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "submission_id": {
                      "description": "The batch this expense was filed in, if any.",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "rejection_reason": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "ocr_confidence": {
                      "description": "Set once receipt recognition ran.",
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "created_at": {
                      "type": "number"
                    },
                    "lines": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "description": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "qty": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "unit_amount_cents": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "amount_cents": {
                            "type": "number"
                          },
                          "tax_cents": {
                            "type": "number"
                          },
                          "gl_code": {
                            "type": [
                              "string",
                              "null"
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "description",
                          "qty",
                          "unit_amount_cents",
                          "amount_cents",
                          "tax_cents",
                          "gl_code"
                        ],
                        "additionalProperties": {}
                      }
                    },
                    "fileUrl": {
                      "description": "Path of the captured document (send your API key).",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "submitter_name": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "approval_instance_id": {
                      "description": "Approval timeline: GET /api/approvals/instances/{id}.",
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "submitted_by_user_id",
                    "status",
                    "vendor_name",
                    "invoice_number",
                    "document_kind",
                    "issued_at",
                    "currency",
                    "subtotal_cents",
                    "tax_cents",
                    "total_cents",
                    "category",
                    "project_id",
                    "submission_id",
                    "rejection_reason",
                    "ocr_confidence",
                    "created_at",
                    "lines",
                    "fileUrl",
                    "submitter_name",
                    "approval_instance_id"
                  ],
                  "additionalProperties": {}
                },
                "example": {
                  "id": "79a3e8b7-b420-499b-adb9-a8d52c1fc5dc",
                  "tenant_id": "opexcg-tenant",
                  "submitted_by_user_id": "usr-fitri-handayani",
                  "vendor_name": "Kopi Kenangan",
                  "vendor_tax_id": null,
                  "invoice_number": null,
                  "document_kind": "receipt",
                  "issued_at": 1793965650435,
                  "due_at": null,
                  "currency": "IDR",
                  "subtotal_cents": 0,
                  "tax_cents": 0,
                  "total_cents": 8500000,
                  "category": "Meals & Entertainment",
                  "project_id": "99e5d1dd-334c-4bc3-88c7-7d84558bf7c6",
                  "submission_id": null,
                  "subject_type": null,
                  "subject_id": null,
                  "status": "draft",
                  "ocr_raw_json": null,
                  "ocr_confidence": null,
                  "file_asset_id": null,
                  "approved_by": null,
                  "approved_at": null,
                  "pm_approved_amount_cents": null,
                  "pm_approved_currency": null,
                  "pm_approved_project_id": null,
                  "correction_requested_at": null,
                  "rejection_reason": null,
                  "reimbursed_at": null,
                  "paid_at": null,
                  "created_at": 1794052050465,
                  "created_by": "usr-fitri-handayani",
                  "modified_at": 1794052050465,
                  "modified_by": "usr-fitri-handayani",
                  "deleted_at": null,
                  "deleted_by": null,
                  "lines": [],
                  "fileUrl": null,
                  "attachments": [],
                  "submitter_currency": null,
                  "submitter_name": "Fitri Handayani",
                  "approval_instance_id": null
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. Codes: `not_found`. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateExpense",
        "summary": "Update an expense",
        "description": "Changes a draft. You can edit your own drafts; editing someone else's needs `expenses:submission:manage`. Expenses that left draft answer 409 `locked`.\n\nProduct: `expenses`. Own drafts, or expenses:submission:manage.",
        "tags": [
          "Expenses"
        ],
        "x-opex-entitlement": "expenses",
        "x-opex-permissions": [],
        "x-opex-stability": "stable",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Expense id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "vendorName": {
                    "type": "string",
                    "maxLength": 200
                  },
                  "vendorTaxId": {
                    "type": "string",
                    "maxLength": 60
                  },
                  "invoiceNumber": {
                    "type": "string",
                    "maxLength": 120
                  },
                  "documentKind": {
                    "type": "string",
                    "enum": [
                      "invoice",
                      "receipt",
                      "nota",
                      "billing",
                      "other"
                    ]
                  },
                  "issuedAt": {
                    "type": "integer",
                    "minimum": -9007199254740991,
                    "maximum": 9007199254740991
                  },
                  "dueAt": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": -9007199254740991,
                        "maximum": 9007199254740991
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "currency": {
                    "type": "string",
                    "maxLength": 8
                  },
                  "subtotalCents": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991
                  },
                  "taxCents": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991
                  },
                  "totalCents": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991
                  },
                  "category": {
                    "type": "string",
                    "maxLength": 120
                  },
                  "projectId": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "subjectType": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "ticket",
                          "task"
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "subjectId": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "lines": {
                    "maxItems": 200,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "description": {
                          "type": "string",
                          "maxLength": 300
                        },
                        "qty": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991
                        },
                        "unitAmountCents": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991
                        },
                        "amountCents": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991
                        },
                        "taxCents": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991
                        },
                        "glCode": {
                          "type": "string",
                          "maxLength": 60
                        }
                      }
                    }
                  }
                }
              },
              "example": {
                "totalCents": 9000000
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated draft.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "submitted_by_user_id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "draft",
                        "pending",
                        "approved",
                        "rejected",
                        "paid"
                      ]
                    },
                    "vendor_name": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "invoice_number": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "document_kind": {
                      "type": "string",
                      "description": "`receipt`, `invoice`, … (`other` until recognised)."
                    },
                    "issued_at": {
                      "description": "Epoch milliseconds.",
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "currency": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "subtotal_cents": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "tax_cents": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "total_cents": {
                      "description": "Integer minor units of `currency`.",
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "category": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "project_id": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "submission_id": {
                      "description": "The batch this expense was filed in, if any.",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "rejection_reason": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "ocr_confidence": {
                      "description": "Set once receipt recognition ran.",
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "created_at": {
                      "type": "number"
                    },
                    "lines": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "description": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "qty": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "unit_amount_cents": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "amount_cents": {
                            "type": "number"
                          },
                          "tax_cents": {
                            "type": "number"
                          },
                          "gl_code": {
                            "type": [
                              "string",
                              "null"
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "description",
                          "qty",
                          "unit_amount_cents",
                          "amount_cents",
                          "tax_cents",
                          "gl_code"
                        ],
                        "additionalProperties": {}
                      }
                    }
                  },
                  "required": [
                    "id",
                    "submitted_by_user_id",
                    "status",
                    "vendor_name",
                    "invoice_number",
                    "document_kind",
                    "issued_at",
                    "currency",
                    "subtotal_cents",
                    "tax_cents",
                    "total_cents",
                    "category",
                    "project_id",
                    "submission_id",
                    "rejection_reason",
                    "ocr_confidence",
                    "created_at",
                    "lines"
                  ],
                  "additionalProperties": {}
                },
                "example": {
                  "id": "79a3e8b7-b420-499b-adb9-a8d52c1fc5dc",
                  "tenant_id": "opexcg-tenant",
                  "submitted_by_user_id": "usr-fitri-handayani",
                  "vendor_name": "Kopi Kenangan",
                  "vendor_tax_id": null,
                  "invoice_number": null,
                  "document_kind": "receipt",
                  "issued_at": 1793965650435,
                  "due_at": null,
                  "currency": "IDR",
                  "subtotal_cents": 0,
                  "tax_cents": 0,
                  "total_cents": 9000000,
                  "category": "Meals & Entertainment",
                  "project_id": "99e5d1dd-334c-4bc3-88c7-7d84558bf7c6",
                  "submission_id": null,
                  "subject_type": null,
                  "subject_id": null,
                  "status": "draft",
                  "ocr_raw_json": null,
                  "ocr_confidence": null,
                  "file_asset_id": null,
                  "approved_by": null,
                  "approved_at": null,
                  "pm_approved_amount_cents": null,
                  "pm_approved_currency": null,
                  "pm_approved_project_id": null,
                  "correction_requested_at": null,
                  "rejection_reason": null,
                  "reimbursed_at": null,
                  "paid_at": null,
                  "created_at": 1794052050465,
                  "created_by": "usr-fitri-handayani",
                  "modified_at": 1794052050649,
                  "modified_by": "usr-fitri-handayani",
                  "deleted_at": null,
                  "deleted_by": null,
                  "lines": []
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. Codes: `not_found`, `forbidden`, `locked`, `project_mismatch`. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/expenses/{id}/submit": {
      "post": {
        "operationId": "submitExpense",
        "summary": "Submit an expense for approval",
        "description": "Sends a draft (or a rejected expense) for approval. The answer carries the new status, usually `pending`; approvers then decide it through the approvals endpoints. Pending, approved and paid expenses answer 409 `invalid_transition`.\n\nProduct: `expenses`. Own drafts, or expenses:submission:manage.",
        "tags": [
          "Expenses"
        ],
        "x-opex-entitlement": "expenses",
        "x-opex-permissions": [],
        "x-opex-stability": "stable",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Expense id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The submitted expense.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "submitted_by_user_id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "draft",
                        "pending",
                        "approved",
                        "rejected",
                        "paid"
                      ]
                    },
                    "vendor_name": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "invoice_number": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "document_kind": {
                      "type": "string",
                      "description": "`receipt`, `invoice`, … (`other` until recognised)."
                    },
                    "issued_at": {
                      "description": "Epoch milliseconds.",
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "currency": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "subtotal_cents": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "tax_cents": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "total_cents": {
                      "description": "Integer minor units of `currency`.",
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "category": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "project_id": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "submission_id": {
                      "description": "The batch this expense was filed in, if any.",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "rejection_reason": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "ocr_confidence": {
                      "description": "Set once receipt recognition ran.",
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "created_at": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "id",
                    "submitted_by_user_id",
                    "status",
                    "vendor_name",
                    "invoice_number",
                    "document_kind",
                    "issued_at",
                    "currency",
                    "subtotal_cents",
                    "tax_cents",
                    "total_cents",
                    "category",
                    "project_id",
                    "submission_id",
                    "rejection_reason",
                    "ocr_confidence",
                    "created_at"
                  ],
                  "additionalProperties": {}
                },
                "example": {
                  "id": "79a3e8b7-b420-499b-adb9-a8d52c1fc5dc",
                  "tenant_id": "opexcg-tenant",
                  "submitted_by_user_id": "usr-fitri-handayani",
                  "vendor_name": "Kopi Kenangan",
                  "vendor_tax_id": null,
                  "invoice_number": null,
                  "document_kind": "receipt",
                  "issued_at": 1793965650435,
                  "due_at": null,
                  "currency": "IDR",
                  "subtotal_cents": 0,
                  "tax_cents": 0,
                  "total_cents": 9000000,
                  "category": "Meals & Entertainment",
                  "project_id": "99e5d1dd-334c-4bc3-88c7-7d84558bf7c6",
                  "submission_id": null,
                  "subject_type": null,
                  "subject_id": null,
                  "status": "pending",
                  "ocr_raw_json": null,
                  "ocr_confidence": null,
                  "file_asset_id": null,
                  "approved_by": null,
                  "approved_at": null,
                  "pm_approved_amount_cents": null,
                  "pm_approved_currency": null,
                  "pm_approved_project_id": null,
                  "correction_requested_at": null,
                  "rejection_reason": null,
                  "reimbursed_at": null,
                  "paid_at": null,
                  "created_at": 1794052050465,
                  "created_by": "usr-fitri-handayani",
                  "modified_at": 1794052050824,
                  "modified_by": "usr-fitri-handayani",
                  "deleted_at": null,
                  "deleted_by": null
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. Codes: `not_found`, `forbidden`, `invalid_transition`, `submission_locked`. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/expenses/capture": {
      "post": {
        "operationId": "captureExpense",
        "summary": "Capture a receipt",
        "description": "Uploads a receipt or invoice as `multipart/form-data` (field `file`) and creates a draft expense for it. Text recognition fills vendor, totals and lines a few seconds later, so read the expense again before submitting. Needs the Expenses `pro` tier; the file counts toward the workspace's storage.\n\nProduct: `expenses`. Expenses pro tier (402 tier_required otherwise).",
        "tags": [
          "Expenses"
        ],
        "x-opex-entitlement": "expenses",
        "x-opex-permissions": [],
        "x-opex-stability": "stable",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary",
                    "contentEncoding": "binary",
                    "description": "The receipt or invoice: an image or PDF, up to 25 MB."
                  }
                },
                "required": [
                  "file"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The new draft's id.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "The new draft's id."
                    }
                  },
                  "required": [
                    "id"
                  ]
                },
                "example": {
                  "id": "91a2aee5-6803-4a61-b64e-47e0b3462139"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. Codes: `no_file`, `empty_file`, `too_large`, `quota_exceeded`, `tier_required`. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/expenses/categories": {
      "get": {
        "operationId": "listExpenseCategories",
        "summary": "List expense categories",
        "description": "The workspace's active expense categories. Use a category `name` as `category` on an expense.\n\nProduct: `expenses`.",
        "tags": [
          "Expenses"
        ],
        "x-opex-entitlement": "expenses",
        "x-opex-permissions": [],
        "x-opex-stability": "stable",
        "responses": {
          "200": {
            "description": "The categories.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "description": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "is_active": {
                            "type": "number"
                          },
                          "display_order": {
                            "type": "number"
                          }
                        },
                        "required": [
                          "id",
                          "name",
                          "description",
                          "is_active",
                          "display_order"
                        ],
                        "additionalProperties": {}
                      }
                    }
                  },
                  "required": [
                    "items"
                  ]
                },
                "example": {
                  "items": [
                    {
                      "id": "canonical:Travel & Transportation",
                      "tenant_id": "",
                      "name": "Travel & Transportation",
                      "description": null,
                      "is_active": 1,
                      "display_order": 0,
                      "created_at": 0,
                      "created_by": null,
                      "modified_at": 0,
                      "modified_by": null,
                      "deleted_at": null,
                      "deleted_by": null
                    },
                    {
                      "id": "canonical:Meals & Entertainment",
                      "tenant_id": "",
                      "name": "Meals & Entertainment",
                      "description": null,
                      "is_active": 1,
                      "display_order": 1,
                      "created_at": 0,
                      "created_by": null,
                      "modified_at": 0,
                      "modified_by": null,
                      "deleted_at": null,
                      "deleted_by": null
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/leave/requests": {
      "get": {
        "operationId": "listLeaveRequests",
        "summary": "List leave requests",
        "description": "Your own leave requests, or the team's with `scope=team`. Dates are epoch milliseconds at UTC midnight.\n\nSort keys: `start_date` (default), `status`, `created_at`.\n\nProduct: `leave`. Permission (any of): `leave:request:read_own`, `leave:request:read_others`, `leave:report:read`.",
        "tags": [
          "Leave"
        ],
        "x-opex-entitlement": "leave",
        "x-opex-permissions": [
          "leave:request:read_own",
          "leave:request:read_others",
          "leave:report:read"
        ],
        "x-opex-stability": "stable",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "required": false,
            "description": "1-based page number. Default 1.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "required": false,
            "description": "Rows per page, 1 to 100. Larger values are clamped. Default 20.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "description": "Free-text filter (trimmed, first 200 characters).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "required": false,
            "description": "Sort key. Unknown keys fall back to the endpoint's default sort.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dir",
            "in": "query",
            "required": false,
            "description": "`asc` or `desc` (default).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "scope",
            "in": "query",
            "required": false,
            "description": "`mine` (default) or `team`. `team` needs leave:request:read_others, leave:report:read, leave:approval:approve or leave:approval:override.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "`pending`, `approved`, `rejected`, `cancelled` or `revision_requested`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "description": "Requests ending on or after this time (epoch milliseconds).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "description": "Requests starting on or before this time (epoch milliseconds).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "year",
            "in": "query",
            "required": false,
            "description": "Calendar year, e.g. `2026`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "month",
            "in": "query",
            "required": false,
            "description": "Month `1` to `12` (with `year`).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "type_id",
            "in": "query",
            "required": false,
            "description": "Only this leave type.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "One page of requests.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "requester_id": {
                            "type": "string"
                          },
                          "type_id": {
                            "type": "string"
                          },
                          "start_date": {
                            "type": "number",
                            "description": "First day, epoch milliseconds (UTC midnight)."
                          },
                          "end_date": {
                            "type": "number",
                            "description": "Last day, epoch milliseconds (UTC midnight)."
                          },
                          "days": {
                            "type": "number",
                            "description": "Working days the request counts."
                          },
                          "is_backdated": {
                            "description": "1 = emergency or retroactive request filed on or after start date.",
                            "type": "number"
                          },
                          "reason": {
                            "type": "string"
                          },
                          "covering_peer_id": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "pending",
                              "approved",
                              "rejected",
                              "cancelled",
                              "revision_requested"
                            ]
                          },
                          "approver_id": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "decided_at": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "decision_note": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "created_at": {
                            "type": "number"
                          },
                          "requester_name": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "type_name": {
                            "type": "string"
                          },
                          "covering_peer_name": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "approval_instance_id": {
                            "description": "Approval timeline: GET /api/approvals/instances/{id}.",
                            "type": [
                              "string",
                              "null"
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "requester_id",
                          "type_id",
                          "start_date",
                          "end_date",
                          "days",
                          "reason",
                          "covering_peer_id",
                          "status",
                          "approver_id",
                          "decided_at",
                          "decision_note",
                          "created_at",
                          "requester_name",
                          "type_name",
                          "covering_peer_name",
                          "approval_instance_id"
                        ],
                        "additionalProperties": {}
                      }
                    },
                    "total": {
                      "type": "number"
                    },
                    "page": {
                      "type": "number"
                    },
                    "pageSize": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "items",
                    "total",
                    "page",
                    "pageSize"
                  ]
                },
                "example": {
                  "items": [
                    {
                      "id": "cf0af695-a15a-4b4f-abba-4caa5cc54d7c",
                      "tenant_id": "opexcg-tenant",
                      "requester_id": "usr-fitri-handayani",
                      "requester_name": "Fitri Handayani",
                      "type_id": "e1ca06b1-cf8d-41e9-b2ff-85f1a1c3706a",
                      "type_name": "Sick",
                      "paid": 1,
                      "start_date": 1837814400000,
                      "end_date": 1837900800000,
                      "days": 2,
                      "reason": "Family event",
                      "covering_peer_id": "usr-sari-wulandari",
                      "covering_peer_name": "Sari Wulandari",
                      "status": "pending",
                      "approver_id": null,
                      "approver_name": null,
                      "decided_at": null,
                      "decision_note": null,
                      "created_at": 1794052051232,
                      "modified_at": 1794052051232,
                      "deleted_at": null,
                      "approval_instance_id": "3ff4d93a-c92b-4a2c-b9de-3c3faf0718c9"
                    }
                  ],
                  "total": 1,
                  "page": 1,
                  "pageSize": 2
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. Codes: `forbidden`. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createLeaveRequest",
        "summary": "Request leave",
        "description": "Files a leave request for the caller and starts its approval. `start_date` and `end_date` are calendar days (`YYYY-MM-DD`); `covering_peer_id` is a colleague from the peers list who covers while you are away.\n\nProduct: `leave`. Permission (any of): `leave:request:create`.",
        "tags": [
          "Leave"
        ],
        "x-opex-entitlement": "leave",
        "x-opex-permissions": [
          "leave:request:create"
        ],
        "x-opex-stability": "stable",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "type_id": {
                    "type": "string",
                    "minLength": 1
                  },
                  "start_date": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": -9007199254740991,
                        "maximum": 9007199254740991
                      },
                      {
                        "type": "string",
                        "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                      }
                    ]
                  },
                  "end_date": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": -9007199254740991,
                        "maximum": 9007199254740991
                      },
                      {
                        "type": "string",
                        "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                      }
                    ]
                  },
                  "reason": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 2000
                  },
                  "covering_peer_id": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "required": [
                  "type_id",
                  "start_date",
                  "end_date",
                  "reason",
                  "covering_peer_id"
                ],
                "additionalProperties": false
              },
              "example": {
                "type_id": "e1ca06b1-cf8d-41e9-b2ff-85f1a1c3706a",
                "start_date": "2028-03-28",
                "end_date": "2028-03-29",
                "reason": "Family event",
                "covering_peer_id": "usr-sari-wulandari"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The new request.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "requester_id": {
                      "type": "string"
                    },
                    "type_id": {
                      "type": "string"
                    },
                    "start_date": {
                      "type": "number",
                      "description": "First day, epoch milliseconds (UTC midnight)."
                    },
                    "end_date": {
                      "type": "number",
                      "description": "Last day, epoch milliseconds (UTC midnight)."
                    },
                    "days": {
                      "type": "number",
                      "description": "Working days the request counts."
                    },
                    "is_backdated": {
                      "description": "1 = emergency or retroactive request filed on or after start date.",
                      "type": "number"
                    },
                    "reason": {
                      "type": "string"
                    },
                    "covering_peer_id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "pending",
                        "approved",
                        "rejected",
                        "cancelled",
                        "revision_requested"
                      ]
                    },
                    "approver_id": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "decided_at": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "decision_note": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "created_at": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "id",
                    "requester_id",
                    "type_id",
                    "start_date",
                    "end_date",
                    "days",
                    "reason",
                    "covering_peer_id",
                    "status",
                    "approver_id",
                    "decided_at",
                    "decision_note",
                    "created_at"
                  ],
                  "additionalProperties": {}
                },
                "example": {
                  "id": "cf0af695-a15a-4b4f-abba-4caa5cc54d7c",
                  "tenant_id": "opexcg-tenant",
                  "requester_id": "usr-fitri-handayani",
                  "type_id": "e1ca06b1-cf8d-41e9-b2ff-85f1a1c3706a",
                  "start_date": 1837814400000,
                  "end_date": 1837900800000,
                  "days": 2,
                  "reason": "Family event",
                  "covering_peer_id": "usr-sari-wulandari",
                  "status": "pending",
                  "approver_id": null,
                  "decided_at": null,
                  "decision_note": null,
                  "created_at": 1794052051232,
                  "created_by": "usr-fitri-handayani",
                  "modified_at": 1794052051232,
                  "modified_by": "usr-fitri-handayani",
                  "deleted_at": null,
                  "deleted_by": null
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. Codes: `forbidden`, `invalid_window`, `window_too_long`, `type_not_found`, `zero_working_days`, `overlapping_leave`, `leave_balance_not_allocated`, `backdated_not_allowed`, `exceeds_max_backdated_days`. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/leave/requests/{id}": {
      "get": {
        "operationId": "getLeaveRequest",
        "summary": "Get a leave request",
        "description": "One leave request. Visible to the requester and to the people who approve or manage leave.\n\nProduct: `leave`.",
        "tags": [
          "Leave"
        ],
        "x-opex-entitlement": "leave",
        "x-opex-permissions": [],
        "x-opex-stability": "stable",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Leave request id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "requester_id": {
                      "type": "string"
                    },
                    "type_id": {
                      "type": "string"
                    },
                    "start_date": {
                      "type": "number",
                      "description": "First day, epoch milliseconds (UTC midnight)."
                    },
                    "end_date": {
                      "type": "number",
                      "description": "Last day, epoch milliseconds (UTC midnight)."
                    },
                    "days": {
                      "type": "number",
                      "description": "Working days the request counts."
                    },
                    "is_backdated": {
                      "description": "1 = emergency or retroactive request filed on or after start date.",
                      "type": "number"
                    },
                    "reason": {
                      "type": "string"
                    },
                    "covering_peer_id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "pending",
                        "approved",
                        "rejected",
                        "cancelled",
                        "revision_requested"
                      ]
                    },
                    "approver_id": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "decided_at": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "decision_note": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "created_at": {
                      "type": "number"
                    },
                    "requester_name": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "type_name": {
                      "type": "string"
                    },
                    "covering_peer_name": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "approval_instance_id": {
                      "description": "Approval timeline: GET /api/approvals/instances/{id}.",
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "requester_id",
                    "type_id",
                    "start_date",
                    "end_date",
                    "days",
                    "reason",
                    "covering_peer_id",
                    "status",
                    "approver_id",
                    "decided_at",
                    "decision_note",
                    "created_at",
                    "requester_name",
                    "type_name",
                    "covering_peer_name",
                    "approval_instance_id"
                  ],
                  "additionalProperties": {}
                },
                "example": {
                  "id": "cf0af695-a15a-4b4f-abba-4caa5cc54d7c",
                  "tenant_id": "opexcg-tenant",
                  "requester_id": "usr-fitri-handayani",
                  "requester_name": "Fitri Handayani",
                  "type_id": "e1ca06b1-cf8d-41e9-b2ff-85f1a1c3706a",
                  "type_name": "Sick",
                  "paid": 1,
                  "start_date": 1837814400000,
                  "end_date": 1837900800000,
                  "days": 2,
                  "reason": "Family event",
                  "covering_peer_id": "usr-sari-wulandari",
                  "covering_peer_name": "Sari Wulandari",
                  "status": "pending",
                  "approver_id": null,
                  "approver_name": null,
                  "decided_at": null,
                  "decision_note": null,
                  "created_at": 1794052051232,
                  "modified_at": 1794052051232,
                  "deleted_at": null,
                  "approval_instance_id": "3ff4d93a-c92b-4a2c-b9de-3c3faf0718c9"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. Codes: `not_found`, `forbidden`. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/leave/requests/{id}/cancel": {
      "post": {
        "operationId": "cancelLeaveRequest",
        "summary": "Cancel a leave request",
        "description": "Cancels a request. Your own need `leave:request:cancel_own`, anyone else's `leave:request:cancel_others`.\n\nProduct: `leave`. Permission (any of): `leave:request:cancel_own`, `leave:request:cancel_others`.",
        "tags": [
          "Leave"
        ],
        "x-opex-entitlement": "leave",
        "x-opex-permissions": [
          "leave:request:cancel_own",
          "leave:request:cancel_others"
        ],
        "x-opex-stability": "stable",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Leave request id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The cancelled request.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "requester_id": {
                      "type": "string"
                    },
                    "type_id": {
                      "type": "string"
                    },
                    "start_date": {
                      "type": "number",
                      "description": "First day, epoch milliseconds (UTC midnight)."
                    },
                    "end_date": {
                      "type": "number",
                      "description": "Last day, epoch milliseconds (UTC midnight)."
                    },
                    "days": {
                      "type": "number",
                      "description": "Working days the request counts."
                    },
                    "is_backdated": {
                      "description": "1 = emergency or retroactive request filed on or after start date.",
                      "type": "number"
                    },
                    "reason": {
                      "type": "string"
                    },
                    "covering_peer_id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "pending",
                        "approved",
                        "rejected",
                        "cancelled",
                        "revision_requested"
                      ]
                    },
                    "approver_id": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "decided_at": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "decision_note": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "created_at": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "id",
                    "requester_id",
                    "type_id",
                    "start_date",
                    "end_date",
                    "days",
                    "reason",
                    "covering_peer_id",
                    "status",
                    "approver_id",
                    "decided_at",
                    "decision_note",
                    "created_at"
                  ],
                  "additionalProperties": {}
                },
                "example": {
                  "id": "cf0af695-a15a-4b4f-abba-4caa5cc54d7c",
                  "tenant_id": "opexcg-tenant",
                  "requester_id": "usr-fitri-handayani",
                  "type_id": "e1ca06b1-cf8d-41e9-b2ff-85f1a1c3706a",
                  "start_date": 1837814400000,
                  "end_date": 1837900800000,
                  "days": 2,
                  "reason": "Family event",
                  "covering_peer_id": "usr-sari-wulandari",
                  "status": "cancelled",
                  "approver_id": null,
                  "decided_at": 1794052051531,
                  "decision_note": null,
                  "created_at": 1794052051232,
                  "created_by": "usr-fitri-handayani",
                  "modified_at": 1794052051532,
                  "modified_by": "usr-fitri-handayani",
                  "deleted_at": null,
                  "deleted_by": null
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. Codes: `not_found`, `forbidden`, `invalid_transition`. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/leave/balances/mine": {
      "get": {
        "operationId": "listMyLeaveBalances",
        "summary": "Get your leave balances",
        "description": "Your allowance, used and remaining days per leave type for one year.\n\nProduct: `leave`. Permission (any of): `leave:balance:read_own`.",
        "tags": [
          "Leave"
        ],
        "x-opex-entitlement": "leave",
        "x-opex-permissions": [
          "leave:balance:read_own"
        ],
        "x-opex-stability": "stable",
        "parameters": [
          {
            "name": "year",
            "in": "query",
            "required": false,
            "description": "Balance year, e.g. `2026`. Default: the current year (UTC).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Your balances.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type_id": {
                            "type": "string"
                          },
                          "type_name": {
                            "type": "string"
                          },
                          "year": {
                            "type": "number"
                          },
                          "total_allowance": {
                            "type": "number"
                          },
                          "used_days": {
                            "type": "number"
                          },
                          "pending_days": {
                            "type": "number",
                            "description": "Days in requests still waiting for approval."
                          },
                          "expires_at": {
                            "type": [
                              "number",
                              "null"
                            ]
                          }
                        },
                        "required": [
                          "type_id",
                          "type_name",
                          "year",
                          "total_allowance",
                          "used_days",
                          "pending_days",
                          "expires_at"
                        ],
                        "additionalProperties": {}
                      }
                    },
                    "has_active_policy": {
                      "type": "boolean"
                    },
                    "missing_hire_date": {
                      "type": "boolean"
                    },
                    "missing_hire_date_count": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "items"
                  ],
                  "additionalProperties": {}
                },
                "example": {
                  "items": []
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/leave/types": {
      "get": {
        "operationId": "listLeaveTypes",
        "summary": "List leave types",
        "description": "The workspace's leave types. Use an `id` as `type_id` when requesting leave.\n\nProduct: `leave`. Permission (any of): `leave:type:read`.",
        "tags": [
          "Leave"
        ],
        "x-opex-entitlement": "leave",
        "x-opex-permissions": [
          "leave:type:read"
        ],
        "x-opex-stability": "stable",
        "responses": {
          "200": {
            "description": "The leave types.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "paid": {
                            "type": "number",
                            "description": "1 = paid leave."
                          },
                          "requires_quota": {
                            "type": "number",
                            "description": "1 = counted against a yearly allowance."
                          },
                          "default_allowance": {
                            "type": "number"
                          },
                          "allow_backdated": {
                            "description": "1 = allows emergency or retroactive leave requests.",
                            "type": "number"
                          },
                          "max_backdated_days": {
                            "description": "Maximum past days allowed for retroactive requests.",
                            "type": "number"
                          },
                          "description": {
                            "type": [
                              "string",
                              "null"
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "name",
                          "paid",
                          "requires_quota",
                          "default_allowance",
                          "description"
                        ],
                        "additionalProperties": {}
                      }
                    }
                  },
                  "required": [
                    "items"
                  ]
                },
                "example": {
                  "items": [
                    {
                      "id": "b09deadf-87b7-4f11-bce1-d9b2c63c34ce",
                      "name": "Annual",
                      "paid": 1,
                      "requires_quota": 1,
                      "default_allowance": 12,
                      "description": "Cuti tahunan berbayar (12 hari/tahun)"
                    },
                    {
                      "id": "e1ca06b1-cf8d-41e9-b2ff-85f1a1c3706a",
                      "name": "Sick",
                      "paid": 1,
                      "requires_quota": 0,
                      "default_allowance": 0,
                      "description": "Izin sakit berbayar tanpa pemotongan kuota"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/leave/peers": {
      "get": {
        "operationId": "listLeavePeers",
        "summary": "List colleagues who can cover",
        "description": "Active members of the workspace other than you (up to 100), for `covering_peer_id`.\n\nProduct: `leave`.",
        "tags": [
          "Leave"
        ],
        "x-opex-entitlement": "leave",
        "x-opex-permissions": [],
        "x-opex-stability": "stable",
        "parameters": [
          {
            "name": "search",
            "in": "query",
            "required": false,
            "description": "Substring of the member's name or email.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "includeInactive",
            "in": "query",
            "required": false,
            "description": "`true` to include deactivated members.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "includeSelf",
            "in": "query",
            "required": false,
            "description": "`true` to include yourself.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The members.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "email": {
                            "type": "string"
                          },
                          "role": {
                            "type": "string"
                          },
                          "is_active": {
                            "type": "number"
                          }
                        },
                        "required": [
                          "id",
                          "name",
                          "email",
                          "role",
                          "is_active"
                        ],
                        "additionalProperties": {}
                      }
                    }
                  },
                  "required": [
                    "items"
                  ]
                },
                "example": {
                  "items": [
                    {
                      "id": "usr-sari-wulandari",
                      "name": "Sari Wulandari",
                      "email": "sari.wulandari@example.com",
                      "role": "admin",
                      "is_active": 1
                    },
                    {
                      "id": "usr-budi-santoso",
                      "name": "Budi Santoso",
                      "email": "budi.santoso@example.com",
                      "role": "admin",
                      "is_active": 1
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/approvals/inbox": {
      "get": {
        "operationId": "listApprovalInbox",
        "summary": "List your pending approvals",
        "description": "Approval tasks waiting for the caller across every product the workspace can use, oldest first. Each item names the record (`product`, `entityType`, `entityId`) and carries `rev`, the instance revision.",
        "tags": [
          "Approvals"
        ],
        "x-opex-entitlement": null,
        "x-opex-permissions": [],
        "x-opex-stability": "stable",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Most tasks to return, 1 to 100. Default 50.",
            "schema": {
              "default": 50,
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            }
          },
          {
            "name": "product",
            "in": "query",
            "required": false,
            "description": "Only this product's tasks, e.g. `expenses`. All products when absent.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 32
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Pending tasks.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "taskId": {
                            "type": "string",
                            "description": "Decide with this id."
                          },
                          "instanceId": {
                            "type": "string"
                          },
                          "product": {
                            "type": "string",
                            "description": "Owning product, e.g. `expenses`, `leave`."
                          },
                          "entityType": {
                            "type": "string"
                          },
                          "entityId": {
                            "type": "string",
                            "description": "Id of the record being approved."
                          },
                          "requesterId": {
                            "type": "string"
                          },
                          "requesterName": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "stageName": {
                            "type": "string"
                          },
                          "stageIndex": {
                            "type": "number"
                          },
                          "stageCount": {
                            "type": "number"
                          },
                          "mode": {
                            "type": "string",
                            "enum": [
                              "any",
                              "all",
                              "n_of_m"
                            ],
                            "description": "How many approvers a stage needs."
                          },
                          "requiredCount": {
                            "type": "number"
                          },
                          "approvedCount": {
                            "type": "number"
                          },
                          "rev": {
                            "type": "number",
                            "description": "Instance revision."
                          },
                          "submittedAt": {
                            "type": "number"
                          },
                          "dueAt": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "title": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "summary": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "link": {
                            "description": "Path in the web app.",
                            "type": [
                              "string",
                              "null"
                            ]
                          }
                        },
                        "required": [
                          "taskId",
                          "instanceId",
                          "product",
                          "entityType",
                          "entityId",
                          "requesterId",
                          "requesterName",
                          "stageName",
                          "stageIndex",
                          "stageCount",
                          "mode",
                          "requiredCount",
                          "approvedCount",
                          "rev",
                          "submittedAt",
                          "dueAt",
                          "title",
                          "summary",
                          "link"
                        ],
                        "additionalProperties": {}
                      }
                    }
                  },
                  "required": [
                    "items"
                  ]
                },
                "example": {
                  "items": [
                    {
                      "taskId": "5463c184-da51-4b84-9c77-4a7229e51fc2",
                      "instanceId": "c85d566c-fe01-453e-bd0f-3088c2026c26",
                      "product": "leave",
                      "entityType": "leave_request",
                      "entityId": "f5e82a9f-325e-4069-a3a7-5e3e56a039d5",
                      "requesterId": "usr-fajar-nugroho",
                      "requesterName": "Fajar Nugroho",
                      "stageName": "Approval",
                      "stageIndex": 0,
                      "stageCount": 1,
                      "mode": "any",
                      "requiredCount": 1,
                      "approvedCount": 0,
                      "rev": 0,
                      "submittedAt": 1794052051774,
                      "dueAt": null,
                      "title": "Sick leave for Fajar Nugroho",
                      "summary": "2028-03-31 → 2028-03-31 · 1 working day",
                      "link": "/leave/approvals?requestId=f5e82a9f-325e-4069-a3a7-5e3e56a039d5"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/approvals/tasks/{id}/decide": {
      "post": {
        "operationId": "decideApprovalTask",
        "summary": "Approve or reject",
        "description": "Records the caller's decision on one approval task. The answer says what happened: the vote was `recorded` (the stage needs more approvers), the instance `advanced` to its next stage, or it ended `approved` or `rejected`. A task that was already decided, or whose instance moved on, answers 409; re-read the inbox and try again.\n\nOnly the task's assignee may decide it; the record's product must be entitled.",
        "tags": [
          "Approvals"
        ],
        "x-opex-entitlement": null,
        "x-opex-permissions": [],
        "x-opex-stability": "stable",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Approval task id (`taskId` from the inbox).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "decision": {
                    "type": "string",
                    "enum": [
                      "approved",
                      "rejected"
                    ]
                  },
                  "comment": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 2000
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": [
                  "decision"
                ]
              },
              "example": {
                "decision": "approved",
                "comment": "Enjoy the day off"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The outcome.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "instanceId": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "pending",
                        "approved",
                        "rejected",
                        "cancelled"
                      ]
                    },
                    "currentStage": {
                      "type": "number"
                    },
                    "outcome": {
                      "type": "string",
                      "enum": [
                        "recorded",
                        "advanced",
                        "approved",
                        "rejected"
                      ],
                      "description": "What the decision did."
                    }
                  },
                  "required": [
                    "instanceId",
                    "status",
                    "currentStage",
                    "outcome"
                  ]
                },
                "example": {
                  "instanceId": "c85d566c-fe01-453e-bd0f-3088c2026c26",
                  "status": "approved",
                  "currentStage": 0,
                  "outcome": "approved"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. Codes: `not_found`, `approval_conflict`, `approval_not_assignee`, `self_approval_not_allowed`. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/approvals/instances/{id}": {
      "get": {
        "operationId": "getApprovalInstance",
        "summary": "Get an approval's timeline",
        "description": "One approval instance: its status, every stage with its tasks and decisions, and the event history.\n\nThe requester, a participant, or a holder of the product's approve or override permission.",
        "tags": [
          "Approvals"
        ],
        "x-opex-entitlement": null,
        "x-opex-permissions": [],
        "x-opex-stability": "stable",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Approval instance id (`instanceId`).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The timeline.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "product": {
                      "type": "string"
                    },
                    "entityType": {
                      "type": "string"
                    },
                    "entityId": {
                      "type": "string"
                    },
                    "requesterId": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "pending",
                        "approved",
                        "rejected",
                        "cancelled"
                      ]
                    },
                    "currentStage": {
                      "type": "number"
                    },
                    "rev": {
                      "type": "number"
                    },
                    "submittedAt": {
                      "type": "number"
                    },
                    "closedAt": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "definitionName": {
                      "type": "string",
                      "description": "The approval workflow that applied."
                    },
                    "version": {
                      "type": "number"
                    },
                    "stages": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "index": {
                            "type": "number"
                          },
                          "name": {
                            "type": "string"
                          },
                          "mode": {
                            "type": "string",
                            "enum": [
                              "any",
                              "all",
                              "n_of_m"
                            ],
                            "description": "How many approvers a stage needs."
                          },
                          "requiredCount": {
                            "type": "number"
                          },
                          "approvedCount": {
                            "type": "number"
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "pending",
                              "approved",
                              "rejected",
                              "skipped",
                              "cancelled",
                              "upcoming"
                            ]
                          },
                          "dueAt": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "tasks": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string"
                                },
                                "assigneeId": {
                                  "type": "string"
                                },
                                "assigneeName": {
                                  "type": [
                                    "string",
                                    "null"
                                  ]
                                },
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "pending",
                                    "approved",
                                    "rejected",
                                    "skipped",
                                    "superseded"
                                  ]
                                },
                                "decidedAt": {
                                  "type": [
                                    "number",
                                    "null"
                                  ]
                                },
                                "comment": {
                                  "type": [
                                    "string",
                                    "null"
                                  ]
                                }
                              },
                              "required": [
                                "id",
                                "assigneeId",
                                "assigneeName",
                                "status",
                                "decidedAt",
                                "comment"
                              ],
                              "additionalProperties": {}
                            }
                          }
                        },
                        "required": [
                          "index",
                          "name",
                          "mode",
                          "requiredCount",
                          "approvedCount",
                          "status",
                          "dueAt",
                          "tasks"
                        ],
                        "additionalProperties": {}
                      }
                    },
                    "events": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string"
                          },
                          "actorId": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "actorName": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "createdAt": {
                            "type": "number"
                          }
                        },
                        "required": [
                          "kind",
                          "actorId",
                          "actorName",
                          "createdAt"
                        ],
                        "additionalProperties": {}
                      }
                    }
                  },
                  "required": [
                    "id",
                    "product",
                    "entityType",
                    "entityId",
                    "requesterId",
                    "status",
                    "currentStage",
                    "rev",
                    "submittedAt",
                    "closedAt",
                    "definitionName",
                    "version",
                    "stages",
                    "events"
                  ],
                  "additionalProperties": {}
                },
                "example": {
                  "id": "c85d566c-fe01-453e-bd0f-3088c2026c26",
                  "product": "leave",
                  "entityType": "leave_request",
                  "entityId": "f5e82a9f-325e-4069-a3a7-5e3e56a039d5",
                  "requesterId": "usr-fajar-nugroho",
                  "status": "pending",
                  "currentStage": 0,
                  "rev": 0,
                  "submittedAt": 1794052051774,
                  "closedAt": null,
                  "definitionName": "Standard leave approval",
                  "version": 1,
                  "stages": [
                    {
                      "index": 0,
                      "key": "approve",
                      "name": "Approval",
                      "mode": "any",
                      "requiredCount": 1,
                      "approvedCount": 0,
                      "status": "pending",
                      "dueAt": null,
                      "tasks": [
                        {
                          "id": "9b522958-fa67-4bdb-b93f-c8ed3a0ff898",
                          "assigneeId": "usr-sari-wulandari",
                          "assigneeName": "Sari Wulandari",
                          "delegatedFrom": null,
                          "status": "pending",
                          "decidedAt": null,
                          "comment": null
                        },
                        {
                          "id": "5fb7f2ae-773e-4880-a915-86fbeca7bb8b",
                          "assigneeId": "usr-wulan-sari",
                          "assigneeName": "Wulan Sari",
                          "delegatedFrom": null,
                          "status": "pending",
                          "decidedAt": null,
                          "comment": null
                        }
                      ]
                    }
                  ],
                  "events": [
                    {
                      "kind": "submitted",
                      "actorId": "usr-fajar-nugroho",
                      "actorName": "Fajar Nugroho",
                      "taskId": null,
                      "createdAt": 1794052051774,
                      "data": {
                        "version": 1
                      }
                    },
                    {
                      "kind": "stage_opened",
                      "actorId": null,
                      "actorName": null,
                      "taskId": null,
                      "createdAt": 1794052051774,
                      "data": {
                        "stage": "approve",
                        "approvers": 16,
                        "fallback": false
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "4XX": {
            "description": "Other errors. Codes: `not_found`, `forbidden`. See https://aio.opexcg.com/docs/errors/.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key",
        "description": "A personal key (`pk_live_…`) created in the app: sidebar **MCP**, then **Create API key**. It acts as you, in the workspace it was created in."
      },
      "OAuth2": {
        "type": "oauth2",
        "description": "OAuth 2.1 for MCP connectors (ChatGPT, Claude.ai): authorization code with PKCE (S256), Dynamic Client Registration at `/api/auth/oauth2/register`. A token acts as you in the workspace picked at consent. See the OAuth section of the Authentication guide.",
        "flows": {
          "authorizationCode": {
            "authorizationUrl": "https://app.aio.opexcg.com/api/auth/oauth2/authorize",
            "tokenUrl": "https://app.aio.opexcg.com/api/auth/oauth2/token",
            "refreshUrl": "https://app.aio.opexcg.com/api/auth/oauth2/token",
            "scopes": {
              "workspace": "Act as you in the workspace picked at consent.",
              "offline_access": "Receive a refresh token."
            }
          }
        }
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "oneOf": [
              {
                "type": "string",
                "description": "Machine-readable error code. Catalogue: https://aio.opexcg.com/docs/errors/."
              },
              {
                "type": "object",
                "description": "Request validation failure (400): `message` is a JSON array of the issues, each with `path` and `message`.",
                "properties": {
                  "name": {
                    "const": "ZodError"
                  },
                  "message": {
                    "type": "string"
                  }
                }
              }
            ]
          },
          "success": {
            "const": false,
            "description": "Present on validation failures only."
          }
        },
        "additionalProperties": {
          "description": "Details for the code, e.g. `product`, `permission`, `reason`."
        }
      }
    },
    "responses": {
      "Error": {
        "description": "Error envelope `{ \"error\": \"<code>\", ...details }`. 400 with `{ \"success\": false, \"error\": { \"name\": \"ZodError\", ... } }`: the request failed validation. 401 `unauthorized`: missing or invalid key or token. 402 `product_not_entitled`, `product_read_only` or `tier_required`: the workspace lacks the product or plan (API keys need an Enterprise plan on at least one product: `tier_required` with `feature: \"api\"`). 403 `forbidden` (often with `permission`): your roles do not allow it.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    }
  }
}
