{
  "openapi": "3.0.0",
  "info": {
    "version": "v2.0.0",
    "title": "Crypto payouts API",
    "description": "API for managing crypto payouts in the Rio platform"
  },
  "servers": [
    {
      "url": "https://app.sandbox.rio.trade"
    }
  ],
  "paths": {
    "/api/payouts/crypto/bulk": {
      "post": {
        "summary": "Create bulk crypto payout",
        "description": "Creates a bulk crypto payout container to group multiple order payouts into a single consolidated payout.",
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/responseCreateBulkCryptoPayoutSchema"
                }
              }
            },
            "description": "Created"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/unauthorizedSchema"
                }
              }
            },
            "description": "Unauthorized"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/createBulkCryptoPayoutSchema"
              }
            }
          }
        }
      }
    },
    "/api/payouts/crypto/bulk/{id}": {
      "get": {
        "summary": "Get bulk crypto payout",
        "description": "Retrieves the details and status of a bulk crypto payout.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Id of the bulk crypto payout"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/responseBulkCryptoPayoutSchema"
                }
              }
            },
            "description": "OK"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/unauthorizedSchema"
                }
              }
            },
            "description": "Unauthorized"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/notFoundSchema"
                }
              }
            },
            "description": "Not Found"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "unauthorizedSchema": {
        "type": "object",
        "properties": {
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "code": {
                  "type": "number",
                  "example": 19
                },
                "message": {
                  "type": "string",
                  "example": "Not authorized"
                }
              }
            }
          }
        }
      },
      "notFoundSchema": {
        "type": "object",
        "properties": {
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "code": {
                  "type": "number",
                  "example": 4
                },
                "message": {
                  "type": "string",
                  "example": "Bulk crypto payout not found"
                }
              }
            }
          }
        }
      },
      "createBulkCryptoPayoutSchema": {
        "type": "object",
        "required": [
          "payoutAddressId",
          "country"
        ],
        "properties": {
          "payoutAddressId": {
            "type": "string",
            "description": "The ID of the crypto address where the payout will be sent.",
            "example": "65ba521a4b3e1bd9eb6a5107"
          },
          "country": {
            "type": "string",
            "enum": [
              "MX",
              "PE",
              "CO"
            ],
            "description": "The country of the operation."
          }
        }
      },
      "responseCreateBulkCryptoPayoutSchema": {
        "type": "object",
        "properties": {
          "createdAt": {
            "type": "string",
            "description": "The date and time the bulk payout was created.",
            "example": "2025-01-04T00:24:28.658Z"
          },
          "userId": {
            "type": "string",
            "description": "The unique identifier of the user.",
            "example": "6757546b4c5d19bf3cd7b09c"
          },
          "orderIds": {
            "type": "array",
            "description": "List of order IDs associated with this bulk payout.",
            "items": {
              "type": "string"
            },
            "example": []
          },
          "amount": {
            "type": "number",
            "description": "The total payout amount across all orders.",
            "example": 0
          },
          "asset": {
            "type": "string",
            "enum": [
              "USDC",
              "USDCe",
              "EURC",
              "USDT"
            ],
            "description": "Stablecoin the bulk payout sends, taken from the payout address.",
            "example": "USDC"
          },
          "network": {
            "type": "string",
            "enum": [
              "ethereum",
              "polygon",
              "solana",
              "stellar",
              "base",
              "tempo",
              "tron",
              "bsc"
            ],
            "description": "Network the bulk payout settles on, taken from the payout address.",
            "example": "solana"
          },
          "payoutAddressId": {
            "type": "string",
            "description": "The ID of the destination crypto address.",
            "example": "65ba521a4b3e1bd9eb6a5107"
          },
          "blockchainAddress": {
            "type": "string",
            "description": "The blockchain address where funds will be sent.",
            "example": "0x1234567890abcdef1234567890abcdef12345678"
          },
          "country": {
            "type": "string",
            "enum": [
              "MX",
              "PE",
              "CO"
            ],
            "description": "The country of the operation."
          },
          "status": {
            "type": "string",
            "enum": [
              "awaitingOrders",
              "awaitingPaymentForOrders",
              "awaitingPayoutRequest",
              "awaitingPayout",
              "awaitingAsyncPayout",
              "awaitingAsyncPayoutRequest",
              "checkingLiquidity",
              "sourcingLiquidity",
              "liquiditySourced",
              "complete",
              "failed",
              "cancelled"
            ],
            "description": "The current status of the bulk crypto payout.",
            "example": "awaitingOrders"
          },
          "id": {
            "type": "string",
            "description": "The unique identifier of the bulk crypto payout.",
            "example": "677890d5d520f9ecb10e9c33"
          }
        }
      },
      "responseBulkCryptoPayoutSchema": {
        "type": "object",
        "properties": {
          "createdAt": {
            "type": "string",
            "description": "The date and time the bulk payout was created.",
            "example": "2025-01-04T00:24:28.658Z"
          },
          "userId": {
            "type": "string",
            "description": "The unique identifier of the user.",
            "example": "6757546b4c5d19bf3cd7b09c"
          },
          "orderIds": {
            "type": "array",
            "description": "List of order IDs associated with this bulk payout.",
            "items": {
              "type": "string"
            },
            "example": [
              "677880bab7a7c5e821c9f56f",
              "67788100b7a7c5e821c9fc0f",
              "6778811fb7a7c5e821c9fef5"
            ]
          },
          "amount": {
            "type": "number",
            "description": "The total payout amount across all orders.",
            "example": 15000
          },
          "asset": {
            "type": "string",
            "enum": [
              "USDC",
              "USDCe",
              "EURC",
              "USDT"
            ],
            "description": "Stablecoin the bulk payout sends, taken from the payout address.",
            "example": "USDC"
          },
          "network": {
            "type": "string",
            "enum": [
              "ethereum",
              "polygon",
              "solana",
              "stellar",
              "base",
              "tempo",
              "tron",
              "bsc"
            ],
            "description": "Network the bulk payout settles on, taken from the payout address.",
            "example": "solana"
          },
          "payoutAddressId": {
            "type": "string",
            "description": "The ID of the destination crypto address.",
            "example": "65ba521a4b3e1bd9eb6a5107"
          },
          "blockchainAddress": {
            "type": "string",
            "description": "The blockchain address where funds will be sent.",
            "example": "0x1234567890abcdef1234567890abcdef12345678"
          },
          "country": {
            "type": "string",
            "enum": [
              "MX",
              "PE",
              "CO"
            ],
            "description": "The country of the operation."
          },
          "status": {
            "type": "string",
            "enum": [
              "awaitingOrders",
              "awaitingPaymentForOrders",
              "awaitingPayoutRequest",
              "awaitingPayout",
              "awaitingAsyncPayout",
              "awaitingAsyncPayoutRequest",
              "checkingLiquidity",
              "sourcingLiquidity",
              "liquiditySourced",
              "complete",
              "failed",
              "cancelled"
            ],
            "description": "The current status of the bulk crypto payout.",
            "example": "awaitingOrders"
          },
          "payoutsSent": {
            "type": "array",
            "description": "Details of individual payouts within this bulk payout.",
            "items": {
              "type": "object",
              "properties": {
                "amount": {
                  "type": "number",
                  "description": "Amount of this individual payout."
                },
                "blockchainTxId": {
                  "type": "string",
                  "description": "The blockchain transaction ID."
                },
                "sentAt": {
                  "type": "string",
                  "description": "Date and time the payout was sent.",
                  "example": "2025-01-04T12:30:00.000Z"
                }
              }
            }
          },
          "id": {
            "type": "string",
            "description": "The unique identifier of the bulk crypto payout.",
            "example": "677890d5d520f9ecb10e9c33"
          }
        }
      }
    },
    "securitySchemes": {
      "apiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key"
      }
    }
  },
  "security": [
    {
      "apiKeyAuth": []
    }
  ]
}
