{
  "openapi": "3.1.0",
  "info": {
    "title": "Mokuna Preview API",
    "version": "0.1.0-preview",
    "description": "Proposed API contract. All servers, methods, limits and responses are illustrative; no live service is represented. Shared design budget: 120 requests per minute per key. Never send real credentials or transactions to preview addresses."
  },
  "servers": [
    {
      "url": "https://api.mokuna.xyz/v1",
      "description": "Proposed base URL \u2014 not a live service"
    }
  ],
  "security": [
    {
      "BearerAuth": []
    }
  ],
  "paths": {
    "/transactions": {
      "post": {
        "operationId": "submitTransaction",
        "summary": "Submit a signed transaction",
        "description": "202 acknowledges receipt, not inclusion. Idempotency keys are retained per API key for 24 hours. Reuse with the same body returns the original accepted response; a different body returns 409.",
        "parameters": [
          {
            "in": "header",
            "name": "Idempotency-Key",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SubmitTransaction"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Accepted for processing",
            "headers": {
              "X-Request-ID": {
                "description": "Diagnostic request identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AcceptedTransaction"
                }
              }
            }
          },
          "400": {
            "description": "invalid_request",
            "headers": {
              "X-Request-ID": {
                "description": "Diagnostic request identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "unauthorized",
            "headers": {
              "X-Request-ID": {
                "description": "Diagnostic request identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "network_not_enabled",
            "headers": {
              "X-Request-ID": {
                "description": "Diagnostic request identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "idempotency_conflict",
            "headers": {
              "X-Request-ID": {
                "description": "Diagnostic request identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "invalid_transaction",
            "headers": {
              "X-Request-ID": {
                "description": "Diagnostic request identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited",
            "headers": {
              "X-Request-ID": {
                "description": "Diagnostic request identifier.",
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "description": "Seconds to wait before retrying; optional for 503.",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "internal_error",
            "headers": {
              "X-Request-ID": {
                "description": "Diagnostic request identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "temporarily_unavailable",
            "headers": {
              "X-Request-ID": {
                "description": "Diagnostic request identifier.",
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "description": "Seconds to wait before retrying; optional for 503.",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/transactions/{id}": {
      "get": {
        "operationId": "getTransaction",
        "summary": "Query processing status",
        "description": "Included does not establish finality. After a reorganization the record can return to submitted with inclusion null. Records are scoped to the integration key.",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Current submission state",
            "headers": {
              "X-Request-ID": {
                "description": "Diagnostic request identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TransactionStatus"
                }
              }
            }
          },
          "401": {
            "description": "unauthorized",
            "headers": {
              "X-Request-ID": {
                "description": "Diagnostic request identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "transaction_not_found",
            "headers": {
              "X-Request-ID": {
                "description": "Diagnostic request identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited",
            "headers": {
              "X-Request-ID": {
                "description": "Diagnostic request identifier.",
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "description": "Seconds to wait before retrying; optional for 503.",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "internal_error",
            "headers": {
              "X-Request-ID": {
                "description": "Diagnostic request identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "temporarily_unavailable",
            "headers": {
              "X-Request-ID": {
                "description": "Diagnostic request identifier.",
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "description": "Seconds to wait before retrying; optional for 503.",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Placeholder integration API key, scoped to allowed networks."
      }
    },
    "schemas": {
      "Network": {
        "type": "string",
        "enum": [
          "base",
          "robinhood",
          "arbitrum",
          "optimism",
          "unichain",
          "monad"
        ]
      },
      "SubmitTransaction": {
        "type": "object",
        "required": [
          "network",
          "signedTransaction"
        ],
        "properties": {
          "network": {
            "$ref": "#/components/schemas/Network"
          },
          "signedTransaction": {
            "type": "string",
            "pattern": "^0x[0-9a-fA-F]+$",
            "description": "Serialized signed EVM transaction. The chain must match network."
          },
          "clientReference": {
            "type": "string",
            "maxLength": 128
          }
        }
      },
      "AcceptedTransaction": {
        "type": "object",
        "required": [
          "id",
          "network",
          "status",
          "transactionHash",
          "receivedAt",
          "requestId"
        ],
        "properties": {
          "id": {
            "type": "string",
            "example": "mtx_example_001"
          },
          "network": {
            "$ref": "#/components/schemas/Network"
          },
          "status": {
            "type": "string",
            "enum": [
              "received"
            ]
          },
          "transactionHash": {
            "type": "string",
            "pattern": "^0x[0-9a-fA-F]{64}$"
          },
          "clientReference": {
            "type": [
              "string",
              "null"
            ]
          },
          "receivedAt": {
            "type": "string",
            "format": "date-time"
          },
          "requestId": {
            "type": "string"
          }
        }
      },
      "TransactionStatus": {
        "type": "object",
        "required": [
          "id",
          "network",
          "status",
          "transactionHash",
          "receivedAt",
          "updatedAt",
          "inclusion",
          "failure",
          "requestId"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "network": {
            "$ref": "#/components/schemas/Network"
          },
          "status": {
            "type": "string",
            "enum": [
              "received",
              "processing",
              "submitted",
              "included",
              "rejected",
              "expired"
            ]
          },
          "transactionHash": {
            "type": "string",
            "pattern": "^0x[0-9a-fA-F]{64}$"
          },
          "clientReference": {
            "type": [
              "string",
              "null"
            ]
          },
          "receivedAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "inclusion": {
            "type": [
              "object",
              "null"
            ],
            "required": [
              "blockNumber",
              "blockHash",
              "executionStatus"
            ],
            "properties": {
              "blockNumber": {
                "type": "string",
                "pattern": "^[0-9]+$"
              },
              "blockHash": {
                "type": "string",
                "pattern": "^0x[0-9a-fA-F]{64}$"
              },
              "executionStatus": {
                "type": "string",
                "enum": [
                  "success",
                  "reverted"
                ]
              }
            }
          },
          "failure": {
            "type": [
              "object",
              "null"
            ],
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            }
          },
          "requestId": {
            "type": "string"
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "error",
          "requestId"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "field": {
                "type": "string"
              }
            }
          },
          "requestId": {
            "type": "string"
          }
        }
      }
    }
  }
}
