{
  "openapi": "3.1.0",
  "info": {
    "title": "logiSA 2.0 TARGET DESIGN API",
    "version": "2.0.0",
    "description": "Cookbook contract; these endpoints are not yet deployed. Tenant is resolved from authenticated identity/session."
  },
  "paths": {
    "/internal/v2/events": {
      "post": {
        "operationId": "post_internal_v2_events",
        "description": "Durable acknowledgement after commit. Duplicate same payload returns 200; mismatch hash returns 409.",
        "security": [
          {
            "ServiceToken": []
          }
        ],
        "responses": {
          "202": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "eventId": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "ACCEPTED",
                        "RECORDED"
                      ]
                    }
                  },
                  "required": [
                    "eventId",
                    "status"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Structured error with traceId",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "error": {
                      "$ref": "./contracts.schema.json#/$defs/Error"
                    },
                    "traceId": {
                      "type": "string",
                      "minLength": 1
                    }
                  },
                  "required": [
                    "error",
                    "traceId"
                  ]
                }
              }
            }
          },
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "eventId": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "ACCEPTED",
                        "RECORDED"
                      ]
                    }
                  },
                  "required": [
                    "eventId",
                    "status"
                  ]
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "./contracts.schema.json#/$defs/InboundEvent"
              }
            }
          }
        }
      }
    },
    "/internal/v2/results": {
      "post": {
        "operationId": "post_internal_v2_results",
        "description": "Durable acknowledgement after commit. Duplicate same payload returns 200; mismatch hash returns 409.",
        "security": [
          {
            "ServiceToken": []
          }
        ],
        "responses": {
          "202": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "resultId": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "ACCEPTED",
                        "RECORDED"
                      ]
                    }
                  },
                  "required": [
                    "resultId",
                    "status"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Structured error with traceId",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "error": {
                      "$ref": "./contracts.schema.json#/$defs/Error"
                    },
                    "traceId": {
                      "type": "string",
                      "minLength": 1
                    }
                  },
                  "required": [
                    "error",
                    "traceId"
                  ]
                }
              }
            }
          },
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "resultId": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "ACCEPTED",
                        "RECORDED"
                      ]
                    }
                  },
                  "required": [
                    "resultId",
                    "status"
                  ]
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "./contracts.schema.json#/$defs/TaskResult"
              }
            }
          }
        }
      }
    },
    "/internal/v2/outbound": {
      "post": {
        "operationId": "post_internal_v2_outbound",
        "description": "Durable acknowledgement after commit. Duplicate same payload returns 200; mismatch hash returns 409.",
        "security": [
          {
            "ServiceToken": []
          }
        ],
        "responses": {
          "202": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "commandId": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "ACCEPTED",
                        "RECORDED"
                      ]
                    }
                  },
                  "required": [
                    "commandId",
                    "status"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Structured error with traceId",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "error": {
                      "$ref": "./contracts.schema.json#/$defs/Error"
                    },
                    "traceId": {
                      "type": "string",
                      "minLength": 1
                    }
                  },
                  "required": [
                    "error",
                    "traceId"
                  ]
                }
              }
            }
          },
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "commandId": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "ACCEPTED",
                        "RECORDED"
                      ]
                    }
                  },
                  "required": [
                    "commandId",
                    "status"
                  ]
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "./contracts.schema.json#/$defs/OutboundCommand"
              }
            }
          }
        }
      }
    },
    "/internal/v2/outbound/{commandId}": {
      "get": {
        "operationId": "get_internal_v2_outbound_commandId",
        "description": "",
        "security": [
          {
            "ServiceToken": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "./contracts.schema.json#/$defs/DeliveryReceipt"
                }
              }
            }
          },
          "default": {
            "description": "Structured error with traceId",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "error": {
                      "$ref": "./contracts.schema.json#/$defs/Error"
                    },
                    "traceId": {
                      "type": "string",
                      "minLength": 1
                    }
                  },
                  "required": [
                    "error",
                    "traceId"
                  ]
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "commandId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ]
      }
    },
    "/api/v2/roles": {
      "get": {
        "operationId": "get_api_v2_roles",
        "description": "Tenant-scoped cursor page; versioned definition payload validated against registered schema.",
        "security": [
          {
            "DashboardSession": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    },
                    "nextCursor": {
                      "anyOf": [
                        {
                          "type": "string",
                          "minLength": 1
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "items",
                    "nextCursor"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Structured error with traceId",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "error": {
                      "$ref": "./contracts.schema.json#/$defs/Error"
                    },
                    "traceId": {
                      "type": "string",
                      "minLength": 1
                    }
                  },
                  "required": [
                    "error",
                    "traceId"
                  ]
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          }
        ]
      },
      "post": {
        "operationId": "post_api_v2_roles",
        "description": "definition uses the versioned catalog schema; flow graph also requires semantic validation. Stale version 409, invalid graph 422.",
        "security": [
          {
            "DashboardSession": []
          }
        ],
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "version": {
                      "type": "integer",
                      "minimum": 1
                    }
                  },
                  "required": [
                    "id",
                    "version"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Structured error with traceId",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "error": {
                      "$ref": "./contracts.schema.json#/$defs/Error"
                    },
                    "traceId": {
                      "type": "string",
                      "minLength": 1
                    }
                  },
                  "required": [
                    "error",
                    "traceId"
                  ]
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "code": {
                    "type": "string",
                    "minLength": 1
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1
                  },
                  "definition": {
                    "$ref": "./contracts.schema.json#/$defs/RoleConfig"
                  }
                },
                "required": [
                  "code",
                  "name",
                  "definition"
                ]
              }
            }
          }
        }
      }
    },
    "/api/v2/roles/{id}/versions": {
      "put": {
        "operationId": "put_api_v2_roles_id_versions",
        "description": "definition uses the versioned catalog schema; flow graph also requires semantic validation. Stale version 409, invalid graph 422.",
        "security": [
          {
            "DashboardSession": []
          }
        ],
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "version": {
                      "type": "integer",
                      "minimum": 1
                    }
                  },
                  "required": [
                    "id",
                    "version"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Structured error with traceId",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "error": {
                      "$ref": "./contracts.schema.json#/$defs/Error"
                    },
                    "traceId": {
                      "type": "string",
                      "minLength": 1
                    }
                  },
                  "required": [
                    "error",
                    "traceId"
                  ]
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "expectedVersion": {
                    "type": "integer",
                    "minimum": 1
                  },
                  "definition": {
                    "$ref": "./contracts.schema.json#/$defs/RoleConfig"
                  }
                },
                "required": [
                  "expectedVersion",
                  "definition"
                ]
              }
            }
          }
        }
      }
    },
    "/api/v2/skills": {
      "get": {
        "operationId": "get_api_v2_skills",
        "description": "Tenant-scoped cursor page; versioned definition payload validated against registered schema.",
        "security": [
          {
            "DashboardSession": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    },
                    "nextCursor": {
                      "anyOf": [
                        {
                          "type": "string",
                          "minLength": 1
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "items",
                    "nextCursor"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Structured error with traceId",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "error": {
                      "$ref": "./contracts.schema.json#/$defs/Error"
                    },
                    "traceId": {
                      "type": "string",
                      "minLength": 1
                    }
                  },
                  "required": [
                    "error",
                    "traceId"
                  ]
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          }
        ]
      },
      "post": {
        "operationId": "post_api_v2_skills",
        "description": "definition uses the versioned catalog schema; flow graph also requires semantic validation. Stale version 409, invalid graph 422.",
        "security": [
          {
            "DashboardSession": []
          }
        ],
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "version": {
                      "type": "integer",
                      "minimum": 1
                    }
                  },
                  "required": [
                    "id",
                    "version"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Structured error with traceId",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "error": {
                      "$ref": "./contracts.schema.json#/$defs/Error"
                    },
                    "traceId": {
                      "type": "string",
                      "minLength": 1
                    }
                  },
                  "required": [
                    "error",
                    "traceId"
                  ]
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "code": {
                    "type": "string",
                    "minLength": 1
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1
                  },
                  "definition": {
                    "$ref": "./contracts.schema.json#/$defs/SkillConfig"
                  }
                },
                "required": [
                  "code",
                  "name",
                  "definition"
                ]
              }
            }
          }
        }
      }
    },
    "/api/v2/skills/{id}/versions": {
      "put": {
        "operationId": "put_api_v2_skills_id_versions",
        "description": "definition uses the versioned catalog schema; flow graph also requires semantic validation. Stale version 409, invalid graph 422.",
        "security": [
          {
            "DashboardSession": []
          }
        ],
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "version": {
                      "type": "integer",
                      "minimum": 1
                    }
                  },
                  "required": [
                    "id",
                    "version"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Structured error with traceId",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "error": {
                      "$ref": "./contracts.schema.json#/$defs/Error"
                    },
                    "traceId": {
                      "type": "string",
                      "minLength": 1
                    }
                  },
                  "required": [
                    "error",
                    "traceId"
                  ]
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "expectedVersion": {
                    "type": "integer",
                    "minimum": 1
                  },
                  "definition": {
                    "$ref": "./contracts.schema.json#/$defs/SkillConfig"
                  }
                },
                "required": [
                  "expectedVersion",
                  "definition"
                ]
              }
            }
          }
        }
      }
    },
    "/api/v2/task-types": {
      "get": {
        "operationId": "get_api_v2_task-types",
        "description": "Tenant-scoped cursor page; versioned definition payload validated against registered schema.",
        "security": [
          {
            "DashboardSession": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    },
                    "nextCursor": {
                      "anyOf": [
                        {
                          "type": "string",
                          "minLength": 1
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "items",
                    "nextCursor"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Structured error with traceId",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "error": {
                      "$ref": "./contracts.schema.json#/$defs/Error"
                    },
                    "traceId": {
                      "type": "string",
                      "minLength": 1
                    }
                  },
                  "required": [
                    "error",
                    "traceId"
                  ]
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          }
        ]
      }
    },
    "/api/v2/flows": {
      "get": {
        "operationId": "get_api_v2_flows",
        "description": "Tenant-scoped cursor page; versioned definition payload validated against registered schema.",
        "security": [
          {
            "DashboardSession": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    },
                    "nextCursor": {
                      "anyOf": [
                        {
                          "type": "string",
                          "minLength": 1
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "items",
                    "nextCursor"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Structured error with traceId",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "error": {
                      "$ref": "./contracts.schema.json#/$defs/Error"
                    },
                    "traceId": {
                      "type": "string",
                      "minLength": 1
                    }
                  },
                  "required": [
                    "error",
                    "traceId"
                  ]
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          }
        ]
      },
      "post": {
        "operationId": "post_api_v2_flows",
        "description": "definition uses the versioned catalog schema; flow graph also requires semantic validation. Stale version 409, invalid graph 422.",
        "security": [
          {
            "DashboardSession": []
          }
        ],
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "version": {
                      "type": "integer",
                      "minimum": 1
                    }
                  },
                  "required": [
                    "id",
                    "version"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Structured error with traceId",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "error": {
                      "$ref": "./contracts.schema.json#/$defs/Error"
                    },
                    "traceId": {
                      "type": "string",
                      "minLength": 1
                    }
                  },
                  "required": [
                    "error",
                    "traceId"
                  ]
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "code": {
                    "type": "string",
                    "minLength": 1
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1
                  },
                  "definition": {
                    "$ref": "./contracts.schema.json#/$defs/FlowConfig"
                  }
                },
                "required": [
                  "code",
                  "name",
                  "definition"
                ]
              }
            }
          }
        }
      }
    },
    "/api/v2/flows/{id}/versions": {
      "put": {
        "operationId": "put_api_v2_flows_id_versions",
        "description": "definition uses the versioned catalog schema; flow graph also requires semantic validation. Stale version 409, invalid graph 422.",
        "security": [
          {
            "DashboardSession": []
          }
        ],
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "version": {
                      "type": "integer",
                      "minimum": 1
                    }
                  },
                  "required": [
                    "id",
                    "version"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Structured error with traceId",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "error": {
                      "$ref": "./contracts.schema.json#/$defs/Error"
                    },
                    "traceId": {
                      "type": "string",
                      "minLength": 1
                    }
                  },
                  "required": [
                    "error",
                    "traceId"
                  ]
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "expectedVersion": {
                    "type": "integer",
                    "minimum": 1
                  },
                  "definition": {
                    "$ref": "./contracts.schema.json#/$defs/FlowConfig"
                  }
                },
                "required": [
                  "expectedVersion",
                  "definition"
                ]
              }
            }
          }
        }
      }
    },
    "/api/v2/flows/{id}/publish": {
      "post": {
        "operationId": "post_api_v2_flows_id_publish",
        "description": "",
        "security": [
          {
            "DashboardSession": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "version": {
                      "type": "integer",
                      "minimum": 1
                    }
                  },
                  "required": [
                    "id",
                    "version"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Structured error with traceId",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "error": {
                      "$ref": "./contracts.schema.json#/$defs/Error"
                    },
                    "traceId": {
                      "type": "string",
                      "minLength": 1
                    }
                  },
                  "required": [
                    "error",
                    "traceId"
                  ]
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "version": {
                    "type": "integer",
                    "minimum": 1
                  },
                  "expectedVersion": {
                    "type": "integer",
                    "minimum": 1
                  }
                },
                "required": [
                  "version",
                  "expectedVersion"
                ]
              }
            }
          }
        }
      }
    },
    "/api/v2/channel-groups": {
      "get": {
        "operationId": "get_api_v2_channel-groups",
        "description": "",
        "security": [
          {
            "DashboardSession": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "additionalProperties": false,
                        "properties": {
                          "id": {
                            "type": "string",
                            "minLength": 1
                          },
                          "name": {
                            "type": "string",
                            "minLength": 1
                          }
                        },
                        "required": [
                          "id",
                          "name"
                        ]
                      }
                    },
                    "nextCursor": {
                      "anyOf": [
                        {
                          "type": "string",
                          "minLength": 1
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "items",
                    "nextCursor"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Structured error with traceId",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "error": {
                      "$ref": "./contracts.schema.json#/$defs/Error"
                    },
                    "traceId": {
                      "type": "string",
                      "minLength": 1
                    }
                  },
                  "required": [
                    "error",
                    "traceId"
                  ]
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "sessionId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          }
        ]
      }
    },
    "/api/v2/tasks": {
      "get": {
        "operationId": "get_api_v2_tasks",
        "description": "Task detail includes pinned plan, state/version, executions, result, review and delivery receipt. Lists use {items,nextCursor}.",
        "security": [
          {
            "DashboardSession": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "$ref": "./contracts.schema.json#/$defs/TaskDetail"
                      }
                    },
                    "nextCursor": {
                      "anyOf": [
                        {
                          "type": "string",
                          "minLength": 1
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "items",
                    "nextCursor"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Structured error with traceId",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "error": {
                      "$ref": "./contracts.schema.json#/$defs/Error"
                    },
                    "traceId": {
                      "type": "string",
                      "minLength": 1
                    }
                  },
                  "required": [
                    "error",
                    "traceId"
                  ]
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          }
        ]
      }
    },
    "/api/v2/tasks/{id}": {
      "get": {
        "operationId": "get_api_v2_tasks_id",
        "description": "Task detail includes pinned plan, state/version, executions, result, review and delivery receipt. Lists use {items,nextCursor}.",
        "security": [
          {
            "DashboardSession": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "./contracts.schema.json#/$defs/TaskDetail"
                }
              }
            }
          },
          "default": {
            "description": "Structured error with traceId",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "error": {
                      "$ref": "./contracts.schema.json#/$defs/Error"
                    },
                    "traceId": {
                      "type": "string",
                      "minLength": 1
                    }
                  },
                  "required": [
                    "error",
                    "traceId"
                  ]
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ]
      }
    },
    "/api/v2/tasks/{id}/cancel": {
      "post": {
        "operationId": "post_api_v2_tasks_id_cancel",
        "description": "",
        "security": [
          {
            "DashboardSession": []
          }
        ],
        "responses": {
          "202": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "taskId": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "state": {
                      "type": "string",
                      "minLength": 1
                    },
                    "version": {
                      "type": "integer",
                      "minimum": 1
                    }
                  },
                  "required": [
                    "taskId",
                    "state",
                    "version"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Structured error with traceId",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "error": {
                      "$ref": "./contracts.schema.json#/$defs/Error"
                    },
                    "traceId": {
                      "type": "string",
                      "minLength": 1
                    }
                  },
                  "required": [
                    "error",
                    "traceId"
                  ]
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "expectedVersion": {
                    "type": "integer",
                    "minimum": 1
                  },
                  "reason": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "required": [
                  "expectedVersion",
                  "reason"
                ]
              }
            }
          }
        }
      }
    },
    "/api/v2/tasks/{id}/retry": {
      "post": {
        "operationId": "post_api_v2_tasks_id_retry",
        "description": "",
        "security": [
          {
            "DashboardSession": []
          }
        ],
        "responses": {
          "202": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "taskId": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "state": {
                      "type": "string",
                      "minLength": 1
                    },
                    "version": {
                      "type": "integer",
                      "minimum": 1
                    }
                  },
                  "required": [
                    "taskId",
                    "state",
                    "version"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Structured error with traceId",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "error": {
                      "$ref": "./contracts.schema.json#/$defs/Error"
                    },
                    "traceId": {
                      "type": "string",
                      "minLength": 1
                    }
                  },
                  "required": [
                    "error",
                    "traceId"
                  ]
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "expectedVersion": {
                    "type": "integer",
                    "minimum": 1
                  },
                  "reason": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "required": [
                  "expectedVersion",
                  "reason"
                ]
              }
            }
          }
        }
      }
    },
    "/api/v2/reviews/{id}/decisions": {
      "post": {
        "operationId": "post_api_v2_reviews_id_decisions",
        "description": "",
        "security": [
          {
            "DashboardSession": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "reviewId": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "version": {
                      "type": "integer",
                      "minimum": 1
                    },
                    "state": {
                      "type": "string",
                      "minLength": 1
                    }
                  },
                  "required": [
                    "reviewId",
                    "version",
                    "state"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Structured error with traceId",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "error": {
                      "$ref": "./contracts.schema.json#/$defs/Error"
                    },
                    "traceId": {
                      "type": "string",
                      "minLength": 1
                    }
                  },
                  "required": [
                    "error",
                    "traceId"
                  ]
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "./contracts.schema.json#/$defs/ReviewDecision"
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "DashboardSession": {
        "type": "apiKey",
        "in": "cookie",
        "name": "zalo_session"
      },
      "ServiceToken": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Internal-Token"
      }
    }
  }
}
