{
  "openapi": "3.0.0",
  "info": {
    "title": "Transactions API",
    "version": "1.0.0",
    "description": "API for managing financial transactions"
  },
  "tags": [
    {
      "name": "Transactions",
      "description": "Transaction management operations"
    }
  ],
  "paths": {
    "/v1/customers/{customer_id}/transaction": {
      "post": {
        "summary": "Create transaction",
        "description": "Create a new transaction",
        "tags": ["Transactions"],
        "parameters": [
          {
            "name": "customer_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateTransactionRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Transaction created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Transaction"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/v1/customers/{customer_id}/transaction/{transaction_id}/sign": {
      "post": {
        "summary": "Sign transaction",
        "description": "Sign a transaction for processing",
        "tags": ["Transactions"],
        "parameters": [
          {
            "name": "customer_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "transaction_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Transaction signed successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Transaction"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFoundError"
          }
        }
      }
    },
    "/v1/transaction/{transaction_id}/cancel": {
      "patch": {
        "summary": "Cancel transaction",
        "description": "Cancel a pending transaction",
        "tags": ["Transactions"],
        "parameters": [
          {
            "name": "transaction_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Transaction cancelled successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Transaction"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFoundError"
          }
        }
      }
    },
    "/v1/transactions": {
      "get": {
        "summary": "List transactions",
        "description": "List all transactions with optional filtering",
        "tags": ["Transactions"],
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "waiting-for-signature",
                "pending",
                "in-progress",
                "completed",
                "cancelled",
                "failed",
                "suspended"
              ]
            }
          },
          {
            "name": "recipient_type",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": ["recipient", "account"]
            }
          },
          {
            "name": "sender_type",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": ["recipient", "account"]
            }
          },
          {
            "name": "type",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": ["iwt", "owt", "int"]
            }
          },
          {
            "name": "customer_id",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "List of transactions",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "transactions": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Transaction"
                      }
                    },
                    "total": {
                      "type": "integer",
                      "minimum": 0
                    },
                    "hasMore": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/transactions/{transaction_id}": {
      "get": {
        "summary": "Get transaction",
        "description": "Get transaction details",
        "tags": ["Transactions"],
        "parameters": [
          {
            "name": "transaction_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Transaction details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Transaction"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFoundError"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "CreateTransactionRequest": {
        "type": "object",
        "required": [
          "recipient_type",
          "sender_id",
          "sender_type",
          "destination_currency",
          "source_currency",
          "channel"
        ],
        "properties": {
          "recipient_id": {
            "type": "string",
            "format": "uuid"
          },
          "recipient_type": {
            "type": "string",
            "enum": ["recipient", "account"]
          },
          "sender_id": {
            "type": "string",
            "format": "uuid"
          },
          "sender_type": {
            "type": "string",
            "enum": ["recipient", "account"]
          },
          "destination_currency": {
            "$ref": "#/components/schemas/TransactionCurrency"
          },
          "source_currency": {
            "$ref": "#/components/schemas/TransactionCurrency"
          },
          "channel": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "scheduled_date": {
            "type": "integer",
            "format": "int64"
          },
          "assignees": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            }
          }
        }
      },
      "Transaction": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "recipient_id": {
            "type": "string",
            "format": "uuid"
          },
          "recipient_name": {
            "type": "string"
          },
          "recipient_type": {
            "type": "string",
            "enum": ["recipient", "account"]
          },
          "recipient": {
            "type": "object",
            "additionalProperties": true
          },
          "sender_id": {
            "type": "string",
            "format": "uuid"
          },
          "sender_name": {
            "type": "string"
          },
          "sender_type": {
            "type": "string",
            "enum": ["recipient", "account"]
          },
          "destination_currency": {
            "$ref": "#/components/schemas/TransactionCurrency"
          },
          "source_currency": {
            "$ref": "#/components/schemas/TransactionCurrency"
          },
          "status": {
            "type": "string",
            "enum": [
              "waiting-for-signature",
              "pending",
              "in-progress",
              "completed",
              "cancelled",
              "failed",
              "suspended"
            ]
          },
          "channel": {
            "type": "string"
          },
          "tariff_id": {
            "type": "string",
            "format": "uuid"
          },
          "task_id": {
            "type": "string",
            "format": "uuid"
          },
          "customer_id": {
            "type": "string",
            "format": "uuid"
          },
          "fee": {
            "type": "string"
          },
          "tax": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": ["iwt", "owt", "int"]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "modified_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "TransactionCurrency": {
        "type": "object",
        "required": ["currency", "amount"],
        "properties": {
          "currency": {
            "type": "string"
          },
          "amount": {
            "type": "string"
          }
        }
      },
      "Error": {
        "type": "object",
        "required": ["code", "message"],
        "properties": {
          "code": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        }
      }
    },
    "responses": {
      "ValidationError": {
        "description": "Invalid input data",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "code": "transactions.invalid_transaction_data",
              "message": "Invalid transaction data"
            }
          }
        }
      },
      "NotFoundError": {
        "description": "Resource not found",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "code": "transactions.transaction_not_found",
              "message": "Transaction not found"
            }
          }
        }
      }
    },
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      }
    }
  },
  "security": [
    {
      "bearerAuth": []
    }
  ]
} 