{
  "openapi": "3.1.0",
  "info": {
    "title": "SimplePay API",
    "version": "1.0.0",
    "description": "Open, unauthenticated API returning peer-to-peer card transactions for a person by user ID and date range."
  },
  "servers": [
    {
      "url": "https://simplepay.decagon.tools"
    }
  ],
  "paths": {
    "/api/public/transactions": {
      "get": {
        "operationId": "listTransactions",
        "summary": "List a person's transactions",
        "parameters": [
          {
            "name": "user_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The person's string user ID, e.g. usr_toby_tyler_2254. The internal UUID also works."
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "merchant_name",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Case-insensitive partial match on the counterparty/merchant name."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000,
              "default": 500
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Matching transactions",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "user_id": {
                      "type": "string"
                    },
                    "user_name": {
                      "type": "string"
                    },
                    "account_number": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "date_range": {
                      "type": "object",
                      "properties": {
                        "from": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "to": {
                          "type": [
                            "string",
                            "null"
                          ]
                        }
                      }
                    },
                    "merchant_name": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "count": {
                      "type": "integer"
                    },
                    "transactions": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "transaction_id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "amount": {
                            "type": "number"
                          },
                          "date": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "merchant_name": {
                            "type": "string"
                          },
                          "account_type": {
                            "type": "string",
                            "enum": [
                              "business",
                              "merchant"
                            ]
                          },
                          "type": {
                            "type": "string",
                            "enum": [
                              "USD",
                              "crypto"
                            ]
                          },
                          "currency_code": {
                            "type": "string",
                            "enum": [
                              "USD",
                              "BTC",
                              "ETH",
                              "USDC",
                              "SOL"
                            ]
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "pending",
                              "posted",
                              "declined",
                              "refunded"
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Missing user_id"
          },
          "404": {
            "description": "Unknown user_id"
          }
        }
      }
    },
    "/api/public/transactions/{transaction_id}": {
      "get": {
        "operationId": "getTransaction",
        "summary": "Get a single transaction by its transaction ID",
        "parameters": [
          {
            "name": "transaction_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The transaction ID returned by listTransactions."
          }
        ],
        "responses": {
          "200": {
            "description": "The transaction",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "transaction": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "transaction_id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "amount": {
                          "type": "number"
                        },
                        "date": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "merchant_name": {
                          "type": "string"
                        },
                        "account_type": {
                          "type": "string",
                          "enum": [
                            "business",
                            "merchant"
                          ]
                        },
                        "type": {
                          "type": "string",
                          "enum": [
                            "USD",
                            "crypto"
                          ]
                        },
                        "currency_code": {
                          "type": "string",
                          "enum": [
                            "USD",
                            "BTC",
                            "ETH",
                            "USDC",
                            "SOL"
                          ]
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "pending",
                            "posted",
                            "declined",
                            "refunded"
                          ]
                        },
                        "created_at": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "user_id": {
                          "type": "string"
                        },
                        "user_name": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "account_number": {
                          "type": [
                            "string",
                            "null"
                          ]
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid transaction id"
          },
          "404": {
            "description": "Unknown transaction id"
          }
        }
      }
    }
  }
}