####################################################################################################
##
## tradias GmbH REST API
##
openapi: 3.1.0

info:
  title: tradias GmbH API
  version: v2.2.4
  license:
    identifier: Proprietary
    name: tradias API License
  contact:
    name: tradias API Support
    url: "https://www.tradias.de"
    email: "info-api@tradias.de"
  description: |
    For integration inquiries,
    please contact us at [info-api@tradias.de](mailto:info-api@tradias.de).

servers:
  - url: "https://api.preprod.tradias.app/api"
    description: PREPROD environment

tags:
  - name: Instruments
    description: |
      The *Get List of tradeable Instruments* endpoint returns a list of all instruments an API user
      can trade on the system. The result contains aside of the instrument name information about
      the instrument (e.g. the type of instrument, its legs and tenor) and the trading limits and
      precisions.
  - name: Risk Figures
    description: |
      Trading is facilitated according to your agreed risk limits. Orders that breach this limit
      will be rejected with a message asking you to increase your collateral. In order to avoid such
      situations, it may be useful to check your risk figures in regular intervals to see how much
      of the margin has already been used. This functionality is provided through the *Get Risk
      Figures* endpoint.<br><br>

      The tradias system calculates the exposure of an API user in real-time. The exposure is
      measured in euro. The field *exposure_in_eur* contains the actual value. It is the total of
      all trades of an API user in euro minus the settled trades.<br><br>
      The *maximum_allowed_exposure* is the maximal allowed exposure in euro which is covered by the
      actual collateral. The *margin_usage* is the actual utilization of the margin
      (*exposure_in_eur* / *maximum_allowed_exposure*).<br><br>
      The field *margin_requirement* is the *exposure_in_eur* multiplied by the agreed margin, and
      expresses the actual collateral usage in euro.<br><br>

      **In order to assure the possibility to keep trading, verify that your trades do not cause
      the margin_usage to get too close to 1!**
  - name: Order Entry
    description: |
      The Order endpoint serves to allow order entry through the REST API. Orders will get
      immediately processed by our system, which means that they will be checked against the risk
      limits and and executed if they are marketable.
      The response to the order request is either a rejection of the order including the reason
      for the rejection or an execution report (Trade).
  - name: Order History
    description: |
      In order to read out the history of your orders, you can call our Order History REST-API.
      As is described below, there are multiple ways you can filter your orders to find the exact
      order(s) you are looking for. Filters can be applied in combination, in which case only orders
      where all filters apply will be returned.
  - name: Trade History
    description: |
      In order to read out the history of your trades, you can call our Trade History REST-API.
      As is described below, there are multiple ways you can filter your trades to find the exact
      trade(s) you are looking for. Filters can be applied in combination, in which case only trades
      where all filters apply will be returned.<br><br>
      The purpose of the Trade history API is to provide an easy and multifunctional access to your
      trade history that can fit multiple purposes. Reconciliation of trades, computing balances or
      communication between separate parts of your application may be among them.
  - name: Settlement Request
    description: |
      The Settlement Request and Transactions endpoints both serve to automate settlement and
      simplify the reconciliation. Before using the endpoints, make sure that the addresses for the
      currencies (fiat __and__ crypto) that have to be settled are sent to tradias and are
      whitelisted. In general, the user flow for the settlement and transactions API looks as
      follows:

        * Send an order through the WebSocket.
        * Get the trade_id, amount and the total_amount, either from the executions channel or the
          trades history endpoint.
        * Post a settlement request: this is done via the POST settlement request endpoint. In the
          req_header, it is possible to pass a value for the req_id, this will have an idempotency
          property which holds for one hour. The response of this endpoint will contain the
          settlement_request_id, which can be used to query the GET settlement request endpoint and
          can be used in the PATCH transactions endpoint.
        * Get the status of the settlement request: the response will give some information on the
          settlement request, including the status, which is either 'ready' or 'not ready'. This
          status only refers to whether or not the settlement request is processed by our system or
          not, it does not mean that it is settled yet. For example, a rejected settlement request
          will have status 'ready'.
        * Get the settlement request by passing the settlement_request_id: this is done via the GET
          settlement request endpoint. The response will show all information on the settlement
          request, e.g., which amounts are settled or why a settlement request was rejected.
        * Both you and tradias will do the transactions required for settlement. The transaction
          __from__ tradias __to__ you will automatically be mapped to the proper request_amount.
          However, you will have to map your transactions, i.e., the transaction __from__ you
          __to__ tradias, to the settlement request of your choice.
        * Get the transactions: using the GET transactions endpoint, all transactions and the
          corresponding transaction_id can be viewed.
        * Patch transactions with settlement request amount: using this endpoint, an amount from a
          transaction can be mapped to a settlement request. This amount does not have to be
          precisely the amount in the transaction, nor does it have to be exactly the amount in the
          settlement request. However, the amount can of course not exceed the amount in the
          transaction, nor the amount in the settlement request.
  - name: Transaction
    description:
      There are two endpoints concerning transactions. The GET Transactions endpoint can be used to
      see the transactions and information on the transactions that are in the tradias system and
      belong to the client that queries the endpoint. The PATCH Transactions by transaction_id
      endpoint can be used to map (part of) the amount belonging to the transaction to an existing
      settlement request (amount).


####################################################################################################
##
## Instruments
##
paths:
  /instruments:
    get:
      tags:
        - Instruments
      summary: Get List of tradeable Instruments
      operationId: get_instrument_list
      description:
        This endpoint can be used to get an overview of the tradeable
        instruments, together with their precision and maximal tradeable
        quantity.

      x-codeSamples:
        - lang: Python
          label: Python (requests)
          source: |-
            import requests
            import json

            PROTOCOL = "https"
            ENV = "preprod"
            MY_TOKEN = "ENTER TOKEN HERE"
            URL = f"{PROTOCOL}://api.{ENV}.tradias.app/api/instruments"

            rest_api_header = {
                "Authorization": "Bearer " + MY_TOKEN
            }

            tradeable_instruments = requests.get(url=URL, headers=rest_api_header)
            print(json.dumps(tradeable_instruments.json(), indent=4))

      responses:
        "200":
          description: List of tradeable Instruments
          content:
            application/json:
              schema:
                description: List of tradeable Instruments
                type: object
                required:
                  - instrument_list
                additionalProperties: false
                properties:
                  instrument_list:
                    description: Array of tradeable Instruments
                    type: array
                    minItems: 1
                    maxItems: 9999
                    uniqueItems: true
                    items:
                      type: object
                      required:
                        - instrument
                        - leg_1_asset
                        - leg_2_asset
                        - maximum_order_quantity
                      additionalProperties: false
                      properties:
                        instrument:
                          $ref: "dict.yml#/components/schemas/instrument_type"
                        leg_1_asset:
                          $ref: "dict.yml#/components/schemas/asset_type"
                        leg_2_asset:
                          $ref: "dict.yml#/components/schemas/asset_type"
                        tenor:
                          $ref: "dict.yml#/components/schemas/asset_tenor_type"
                        maximum_order_quantity:
                          description:
                            The maximal order quantity possible expressed in the unit of the
                            leg_1 asset.
                          $ref: "dict.yml#/components/schemas/quantity_type"
                examples:
                  - instrument_list:
                      - instrument: "ALGO-EUR"
                        leg_1_asset:
                          name: "Algorand"
                          code: "ALGO"
                          precision: 6
                        leg_2_asset:
                          name: "Euro"
                          code: "EUR"
                          precision: 2
                        maximum_order_quantity: "290000.0"
                      - instrument: "AMP-EUR"
                        leg_1_asset:
                          name: "Amp"
                          code: "AMP"
                          precision: 18
                        leg_2_asset:
                          name: "Euro"
                          code: "EUR"
                          precision: 2
                        maximum_order_quantity: "2400000.0"
                      - instrument: "BTC-EUR"
                        leg_1_asset:
                          name: "Bitcoin"
                          code: "BTC"
                          precision: 8
                        leg_2_asset:
                          name: "Euro"
                          code: "EUR"
                          precision: 2
                        maximum_order_quantity: "36.0"
        "401":
          $ref: "dict.yml#/components/responses/response_401_type"
        "500":
          $ref: "dict.yml#/components/responses/response_500_type"
        "default":
          $ref: "dict.yml#/components/responses/default_response_type"




####################################################################################################
##
## Risk Figures
##
  /v1/riskfigures/report:
    get:
      tags:
        - Risk Figures
      summary: Get Risk Figures
      operationId: get_risk_figures
      description:
        Trading is facilitated according to your agreed risk limits. Orders
        that breach this limit will be rejected with a message asking you to
        increase your collateral. In order to avoid such situations, it may be
        useful to check your risk figures in regular intervals to see how much
        of the margin has already been used. This functionality is provided
        through the risk figures endpoint.<br><br>

        <b>In order to assure the possibility to keep trading, verify that your
        trades do not cause the margin_usage to get too close to 1!</b>

      x-codeSamples:
        - lang: Python
          label: Python (requests)
          source: |-
            import requests
            import json

            PROTOCOL = "https"
            ENV = "preprod"
            MY_TOKEN = "ENTER YOUR TOKEN HERE"

            URL = f"{PROTOCOL}://api.{ENV}.tradias.app/api/v1/riskfigures/report"
            rest_api_header = {
              "Authorization": "Bearer " + MY_TOKEN
            }

            risk_figures_response = requests.get(url=URL, headers=rest_api_header)

            print(json.dumps(risk_figures_response.json(), indent=4))

      responses:
        "200":
          description: Risk Figures Response
          content:
            application/json:
              schema:
                title: Risk Figures Response
                type: object
                required:
                  - exposure_in_eur
                  - maximum_exposure
                  - margin_requirement
                  - margin_usage
                additionalProperties: false
                properties:
                  exposure_in_eur:
                    $ref: "dict.yml#/components/schemas/fiat_amount_type"
                  maximum_exposure:
                    summary: Maximal Allowed Margin Requirement
                    description: The maximal allowed margin requirement
                    $ref: "dict.yml#/components/schemas/fiat_amount_type"
                  margin_requirement:
                    summary: Actual Margin Requirement
                    description: The collateral currently in use to secure your exposure.
                    $ref: "dict.yml#/components/schemas/fiat_amount_type"
                  margin_usage:
                    summary: Current Margin Usage
                    description: The usage of your margin as a fraction.
                    $ref: "dict.yml#/components/schemas/fraction_type"
                examples:
                  - exposure_in_eur: 123456.78
                    maximum_exposure: 1000000.0
                    margin_requirement: 12345.68
                    margin_usage: 0.1456
        "401":
          $ref: "dict.yml#/components/responses/response_401_type"
        "500":
          $ref: "dict.yml#/components/responses/response_500_type"
        "default":
          $ref: "dict.yml#/components/responses/default_response_type"


####################################################################################################
##
## Orders
##
  /orders:

####################################################################################################
##
## Single Orders
##
    post:
      summary: Single Orders
      tags:
        - Order Entry
      operationId: create_single_order
      description: |
        This post endpoint allows order entry through the REST API. Orders will get immediately
        processed by our system, which means that they will be checked against the risk limits and
        executed if they are marketable. The response to the order request is either a rejection of
        the order including the reason for the rejection or an execution report (Trade).
      requestBody:
        content:
          application/json:
            schema:
              title: Single Order Request
              type: object
              required:
                - order_ref
                - instrument
                - side
                - amount
              additionalProperties: false
              properties:
                order_ref:
                  $ref: "dict.yml#/components/schemas/external_ref_type"
                req_header:
                  $ref: "dict.yml#/components/schemas/req_header_type"
                order_type:
                  $ref: "dict.yml#/components/schemas/order_type_type"
                instrument:
                  $ref: "dict.yml#/components/schemas/instrument_type"
                side:
                  $ref: "dict.yml#/components/schemas/side_type"
                amount:
                  $ref: "dict.yml#/components/schemas/order_amount_type"
                counter_leg_precision:
                  $ref: "dict.yml#/components/schemas/asset_precision_type"
                  description:
                    This optional parameter defines the precision of execution of the counter leg
                    (leg 2) of the instrument. If not given, the default precision of the asset is
                    used.
                time_in_force:
                  $ref: "dict.yml#/components/schemas/time_in_force_type"
                  description:
                    This optional parameter defines how long a limit order is valid.
                limit_price:
                  $ref: "dict.yml#/components/schemas/price_type"
      responses:
        "200":
          description: Single Order Execution Response
          content:
            application/json:
              schema:
                title: Get Orders Response
                type: object
                required:
                  - order_id
                  - seq_number
                  - arrived_at
                  - order_ref
                  - order_status
                  - order_type
                  - instrument
                  - side
                  - amount
                additionalProperties: false
                properties:
                  order_id:
                    $ref: "dict.yml#/components/schemas/internal_ref_type"
                  seq_number:
                    $ref: "dict.yml#/components/schemas/sequence_type"
                  arrived_at:
                    $ref: "dict.yml#/components/schemas/timestamp_type"
                  order_ref:
                    $ref: "dict.yml#/components/schemas/external_ref_type"
                  req_header:
                    $ref: "dict.yml#/components/schemas/req_header_type"
                  order_type:
                    $ref: "dict.yml#/components/schemas/order_type_type"
                  instrument:
                    $ref: "dict.yml#/components/schemas/instrument_type"
                  side:
                    $ref: "dict.yml#/components/schemas/side_type"
                  amount:
                    $ref: "dict.yml#/components/schemas/order_amount_type"
                  limit_price:
                    $ref: "dict.yml#/components/schemas/price_type"
                  time_in_force:
                    $ref: "dict.yml#/components/schemas/time_in_force_type"
                    description: |
                      This parameter defines how long the order is valid.
                  order_status:
                    $ref: "dict.yml#/components/schemas/order_status_type"
                  execution:
                    type: object
                    description: |
                      The block _execution_ only exists if the order has been executed.
                      It contains the execution details of the order.
                    required:
                      - trade_id
                      - seq_number
                      - executed_at
                    additionalProperties: false
                    properties:
                      trade_id:
                        $ref: "dict.yml#/components/schemas/internal_ref_type"
                      seq_number:
                        $ref: "dict.yml#/components/schemas/sequence_type"
                      executed_at:
                        $ref: "dict.yml#/components/schemas/timestamp_type"
                      leg_1_executed_amount:
                        $ref: "dict.yml#/components/schemas/quantity_type"
                      leg_2_executed_amount:
                        $ref: "dict.yml#/components/schemas/quantity_type"
                      execution_price:
                        $ref: "dict.yml#/components/schemas/price_type"
                  rejection:
                    type: object
                    description: |
                      The block _rejection_ only exists if the order has not been executed, but
                      rejected. It contains details about the rejection.
                    required:
                      - rejection_reason
                      - rejection_text
                    additionalProperties: false
                    properties:
                      rejection_reason:
                        $ref: "dict.yml#/components/schemas/rejection_reason_type"
                      rejection_text:
                        $ref: "dict.yml#/components/schemas/error_text_type"
        "400":
          description: Unauthorized
          $ref: "dict.yml#/components/responses/response_401_type"
        "409":
          description: Duplicate Request
          $ref: "dict.yml#/components/responses/response_409_type"
        "422":
          description: Unprocessable Entity
          $ref: "dict.yml#/components/responses/response_422_type"
        "503":
          description: Service Unavailable
          $ref: "dict.yml#/components/responses/response_500_type"
        "default":
          $ref: "dict.yml#/components/responses/default_response_type"


####################################################################################################
##
## Order History
##
    get:
      summary: Get Orders
      tags:
        - Order History
      operationId: get_orders
      description: |
        This endpoint can be used to get an overview of your orders that have been
        placed at tradias. You can filter the orders by different parameters, e.g.,
        by time range, side, type, status, instrument or order id. Multiple filters
        can be combined, in which case only orders that match all filters will be
        returned.<br><br>

        The orders are returned in chronological order, starting with the oldest
        order that matches the given filters.<br><br>

        <b>Note:</b> The time range defined by from_datetime and to_datetime is
        inclusive, meaning that orders that arrived exactly at the from_datetime or
        to_datetime will also be included in the response.
      parameters:
        - name: from_datetime
          description: Select orders which arrived at tradias after the here given timestamp
          in: query
          required: true
          schema:
            $ref: "dict.yml#/components/schemas/timestamp_type"
        - name: to_datetime
          description: Select orders which arrived at tradias before the here given timestamp
          in: query
          required: true
          schema:
            $ref: "dict.yml#/components/schemas/timestamp_type"
        - name: side
          description: Select only orders from the given side
          in: query
          required: false
          schema:
            $ref: "dict.yml#/components/schemas/side_type"
        - name: type
          description: Select only orders of the given order type
          in: query
          required: false
          schema:
            $ref: "dict.yml#/components/schemas/order_type_type"
        - name: status
          description: Select only orders which have a given order status
          in: query
          required: false
          schema:
            $ref: "dict.yml#/components/schemas/order_status_type"
        - name: order_id
          description: Select an order which has the given order id (order_id given by tradias to
            the order)
          in: query
          required: false
          schema:
            $ref: "dict.yml#/components/schemas/internal_ref_type"
        - name: order_ref
          description: Select an order which has the given order ref (order_ref given to the order
            by the API user)
          in: query
          required: false
          schema:
            $ref: "dict.yml#/components/schemas/external_ref_type"
        - name: req_id
          description: Select an order which has the given request id (req_id given to the order
            by the API user)
          in: query
          required: false
          schema:
            $ref: "dict.yml#/components/schemas/unique_req_type"
        - name: instrument
          description: Select orders which have the given instrument
          in: query
          required: false
          schema:
            $ref: "dict.yml#/components/schemas/instrument_type"
        - name: limit
          description: Pagination Logic - maximal number of orders returned by this request (page)
          in: query
          required: false
          schema:
            type: integer
            format: int32
            minimum: 10
            maximum: 9999
            default: 100
        - name: skip
          description: Pagination Logic - number of pages to skip. 0 is the first page (no skip)
          in: query
          required: false
          schema:
            title: Skip
            type: integer
            format: int32
            minimum: 0
            default: 0

      x-codeSamples:
        - lang: Python
          label: Python (requests)
          source: |-
            import requests
            import json

            PROTOCOL = "https"
            ENV = "preprod"
            MY_TOKEN = "ENTER YOUR TOKEN HERE"

            URL = f"{PROTOCOL}://api.{ENV}.tradias.app/api/orders"

            headers = {
              "Authorization": "Bearer " + MY_TOKEN
            }

            filter_params = {
                "from_datetime": "2023-10-20T11:20:21.000000Z",
                "to_datetime": "2023-10-20T15:20:21.000000Z",
                "side": "BUY",
                "type": "MARKET"
            }

            get_orders_request = requests.get(url=URL, headers=rest_api_header, params=filter_params)

            print(json.dumps(get_orders_request.json(), indent=4))

      responses:
        "200":
          description: Get Orders Response
          $ref: "dict.yml#/components/responses/response_get_orders_type"
        "401":
          description: Unauthorized
          $ref: "dict.yml#/components/responses/response_401_type"
        "500":
          $ref: "dict.yml#/components/responses/response_500_type"
        "default":
          $ref: "dict.yml#/components/responses/default_response_type"

  /orders/sequence:
    get:
      summary: Get Orders By Sequence Id
      tags:
        - Order History
      operationId: get_orders_by_sequence
      description: |
        This endpoint can be used to get an overview of your orders that have been
        placed at tradias, starting from a given sequence number. This can be used
        to page through all orders in chronological order, by using the sequence
        number of the last order received as the starting point for the next
        request.<br><br>

        The orders are returned in chronological order, starting with the order
        that matches the given sequence number.<br><br>
      parameters:
        - name: seq_number
          description: The sequence number from which to start the list of orders
          in: query
          required: true
          schema:
            $ref: "dict.yml#/components/schemas/sequence_type"
        - name: limit
          description: Pagination Logic - maximal number of orders returned by this request (page)
          in: query
          required: false
          schema:
            type: integer
            format: int32
            minimum: 10
            maximum: 9999
            default: 100

      x-codeSamples:
        - lang: Python
          label: Python (requests)
          source: |-
            import requests
            import json

            PROTOCOL = "https"
            ENV = "preprod"
            MY_TOKEN = "ENTER YOUR TOKEN HERE"

            URL = f"{PROTOCOL}://api.{ENV}.tradias.app/api/orders/sequence"

            rest_api_header = {
              "Authorization": "Bearer " + MY_TOKEN
            }

            params = {"seq_number": 47110815}

            get_order_by_sequence_id_request = requests.get(url=URL, headers=rest_api_header, params=params)

            print(json.dumps(get_order_by_sequence_id_request.json(), indent=4))

      responses:
        "200":
          description: Get Orders Response
          $ref: "dict.yml#/components/responses/response_get_orders_type"
        "401":
          description: Unauthorized
          $ref: "dict.yml#/components/responses/response_401_type"
        "500":
          $ref: "dict.yml#/components/responses/response_500_type"
        "default":
          $ref: "dict.yml#/components/responses/default_response_type"




####################################################################################################
##
## Trade History
##
  /trades:
    get:
      summary: Get Trades
      tags:
        - Trade History
      operationId: get_trades
      description: |
        This endpoint can be used to get an overview of your trades that have been
        executed at tradias. You can filter the trades by different parameters, e.g.,
        by time range, side, instrument, trade id, order id, leg status, price or
        leg amounts. Multiple filters can be combined, in which case only trades
        that match all filters will be returned.<br><br>

        The trades are returned in chronological order, starting with the oldest
        trade that matches the given filters.<br><br>

        <b>Note:</b> The time range defined by from_datetime and to_datetime is
        inclusive, meaning that trades that were executed exactly at the from_datetime
        or to_datetime will also be included in the response.
      parameters:
        - name: from_datetime
          description: Select trades which have been executed after the here given timestamp
          in: query
          required: true
          schema:
            $ref: "dict.yml#/components/schemas/timestamp_type"
        - name: to_datetime
          description: Select trades which have been executed before the here given timestamp
          in: query
          required: true
          schema:
            $ref: "dict.yml#/components/schemas/timestamp_type"
        - name: instrument
          description: Select orders which have the given instrument
          in: query
          required: false
          schema:
            $ref: "dict.yml#/components/schemas/instrument_type"
        - name: side
          description: Select only orders from the given side
          in: query
          required: false
          schema:
            $ref: "dict.yml#/components/schemas/side_type"
        - name: trade_id
          description: Select trades which have the given trade id (trade_id)
          in: query
          required: false
          schema:
            $ref: "dict.yml#/components/schemas/internal_ref_type"
        - name: order_id
          description: Select trades belonging to the order with the given order id (order_id)
          in: query
          required: false
          schema:
            $ref: "dict.yml#/components/schemas/internal_ref_type"
        - name: leg_1_status
          description: The status of the leg_1 part of the trade
          in: query
          required: false
          schema:
            $ref: "dict.yml#/components/schemas/trade_leg_status_type"
        - name: leg_2_status
          description: The status of the leg_2 part of the trade
          in: query
          required: false
          schema:
            $ref: "dict.yml#/components/schemas/trade_leg_status_type"
        - name: price_from
          description: The starting confirmed price for the trades search
          in: query
          required: false
          schema:
            $ref: "dict.yml#/components/schemas/price_type"
        - name: price_to
          description: The ending confirmed price for the trades search
          in: query
          required: false
          schema:
            $ref: "dict.yml#/components/schemas/price_type"
        - name: leg_1_from
          description: The starting leg 1 amount for the trades search
          in: query
          required: false
          schema:
            $ref: "dict.yml#/components/schemas/quantity_type"
        - name: leg_1_to
          description: The ending leg 1 amount for the trades search
          in: query
          required: false
          schema:
            $ref: "dict.yml#/components/schemas/quantity_type"
        - name: leg_2_from
          description: The starting leg 2 amount for the trades search
          in: query
          required: false
          schema:
            $ref: "dict.yml#/components/schemas/quantity_type"
        - name: leg_2_to
          description: The ending leg 2 amount for the trades search
          in: query
          required: false
          schema:
            $ref: "dict.yml#/components/schemas/quantity_type"
        - name: limit
          description: Pagination Logic - maximal number of orders returned by this request (page)
          in: query
          required: false
          schema:
            type: integer
            minimum: 10
            maximum: 9999
            default: 100
        - name: skip
          description: Pagination Logic - number of pages to skip. 0 is the first page (no skip)
          in: query
          required: false
          schema:
            title: Skip
            type: integer
            minimum: 0
            default: 0

      x-codeSamples:
        - lang: Python
          label: Python (requests)
          source: |-
            import requests
            import json

            PROTOCOL = "https"
            ENV = "preprod"
            MY_TOKEN = "ENTER YOUR TOKEN HERE"

            URL = f"{PROTOCOL}://api.{ENV}.tradias.app/api/trades"

            rest_api_header = {
                "Authorization": "Bearer " + MY_TOKEN
            }

            filter_params = {
                "from_datetime": "2023-10-20T11:20:21.000000Z",
                "to_datetime": "2023-10-20T15:20:21.000000Z",
                "side": "SELL",
                "type": "MARKET",
                "instrument": "BTC-EUR/SP",
                "price_from": "24000"
            }

            get_trades_request = requests.get(url=URL, headers=rest_api_header, params=filter_params)

            print(json.dumps(get_trades_request.json(), indent=4))

      responses:
        "200":
          description: Get Trade Response
          $ref: "dict.yml#/components/responses/response_get_trades_type"
        "401":
          description: Unauthorized
          $ref: "dict.yml#/components/responses/response_401_type"
        "500":
          $ref: "dict.yml#/components/responses/response_500_type"
        "default":
          $ref: "dict.yml#/components/responses/default_response_type"

  /trades/sequence:
    get:
      summary: Get Trades By Sequence
      tags:
        - Trade History
      operationId: get_trades_by_sequence
      description: |
        This endpoint can be used to get an overview of your trades that have been
        executed at tradias, starting from a given sequence number. This can be used
        to page through all trades in chronological order, by using the sequence
        number of the last trade received as the starting point for the next
        request.<br><br>

        The trades are returned in chronological order, starting with the trade
        that matches the given sequence number.<br><br>
      parameters:
        - name: seq_number
          description: The sequence number from which to start the list of trades
          in: query
          required: true
          schema:
            $ref: "dict.yml#/components/schemas/sequence_type"
        - name: limit
          description: Pagination Logic - maximal number of orders returned by this request (page)
          in: query
          required: false
          schema:
            $ref: "dict.yml#/components/schemas/pagination_limit_type"

      x-codeSamples:
        - lang: Python
          label: Python (requests)
          source: |-
            import requests
            import json

            PROTOCOL = "https"
            ENV = "preprod"
            MY_TOKEN = "ENTER YOUR TOKEN HERE"

            URL = f"{PROTOCOL}://api.{ENV}.tradias.app/api/trades/sequence"

            rest_api_header = {
                "Authorization": "Bearer " + MY_TOKEN
            }

            params = {"seq_number": 47110815}

            get_trades_by_sequence_id_request = requests.get(url=URL, headers=rest_api_header)

            print(json.dumps(get_trade_by_sequence_id_request.json(), indent=4))

      responses:
        "200":
          description: Get Orders Response
          $ref: "dict.yml#/components/responses/response_get_trades_type"
        "401":
          description: Unauthorized
          $ref: "dict.yml#/components/responses/response_401_type"
        "404":
          description: Not Found
          $ref: "dict.yml#/components/responses/response_404_type"
        "500":
          $ref: "dict.yml#/components/responses/response_500_type"
        "default":
          $ref: "dict.yml#/components/responses/default_response_type"


####################################################################################################
##
## Settlement
##
  /settlement-requests:
    post:
      tags:
        - Settlement Request
      summary: Settlement Request
      operationId: settlement_request
      description: |
        This endpoint allows you to create a settlement request for a set of trades.
        The settlement request contains the list of trade IDs to be settled as well
        as the amounts and addresses for the settlement.<br><br>

        Upon successful submission of the settlement request, a unique settlement
        request ID is returned. You can use this ID to track the status of your
        settlement request via the GET /api/settlement-requests/{settlement_request_id}
        endpoint.
      requestBody:
        content:
          application/json:
            schema:
              title: Settlement Request
              type: object
              required:
                - client_settlement_request_id
                - trade_ids
                - request_amounts
              additionalProperties: false
              properties:
                client_settlement_request_id:
                  $ref: "dict.yml#/components/schemas/external_ref_type"
                trade_ids:
                  title: List of Trades
                  type: array
                  minItems: 1
                  maxItems: 999999
                  uniqueItems: true
                  items:
                    $ref: "dict.yml#/components/schemas/internal_ref_type"
                  description: |
                    List of all trade_ids which net to the settlement amounts contained in
                    the request_amounts field.
                request_amounts:
                  title: Settlement Amounts
                  type: array
                  minItems: 1
                  maxItems: 99
                  description: Array containing the individual net amounts of the settlement
                  items:
                    title: Settlement Amount
                    type: object
                    required:
                      - currency
                      - from_address
                      - to_address
                      - amount
                    properties:
                      currency:
                        $ref: "dict.yml#/components/schemas/asset_code_type"
                        description: The currency to which the request amount applies
                      from_address:
                        summary: From Address
                        $ref: "dict.yml#/components/schemas/address_type"
                      to_address:
                        summary: To Address
                        $ref: "dict.yml#/components/schemas/address_type"
                      amount:
                        summary: Amount to be transferred
                        $ref: "dict.yml#/components/schemas/quantity_type"
              examples:
                - client_settlement_request_id: "6aa21c20-ae4b-11ed-b304-81a12bb57b04"
                  trade_ids:
                    - "2987a674-fa91-4bcb-b480-24934bc4166c"
                    - "a83ceb8f-a7cd-46c6-8322-826a21f56511"
                    - "94f7b459-ae19-4600-8d72-9a21c78b86f4"
                  request_amounts:
                    - currency: "EUR"
                      from_address: "TRADIAS"
                      to_address: "DE89370400440532013000"
                      amount: "12766.04"
                    - currency: "LTC"
                      from_address: "TRADIAS"
                      to_address: "MGxNPPB7eBoWPUaprtX9v9CXJZoD2465zN"
                      amount: "207.606"
                    - currency: "BTC"
                      from_address: "bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq"
                      to_address: "TRADIAS"
                      amount: "1.23"

      x-codeSamples:
        - lang: Python
          label: Python (request)
          source: |-
            import requests
            import json

            PROTOCOL = "https"
            ENV = "preprod"
            MY_TOKEN = "ENTER YOUR TOKEN HERE"

            URL = f"{PROTOCOL}://api.{ENV}.tradias.app/api/settlement-requests"

            rest_api_header = {
                "Authorization": "Bearer " + MY_TOKEN
            }

            payload = {
                "req_header": {
                    "req_id": "ca57eead-b699-11ed-b3ff-cc17d418c9e0",
                    "user_data": [
                        {
                            "tag": "Correlation-Id",
                            "value": "c8d16891-b669-11ed-bc43-f1002b6e6125"
                        },
                        {
                            "tag": "TX-Id",
                            "value": "18955457"
                        }
                    ]
                },
                "settlement_request_ref": "6aa21c20-ae4b-11ed-b304-81a12bb57b04",
                "trade_ids": [
                    "2987a674-fa91-4bcb-b480-24934bc4166c",
                    "a83ceb8f-a7cd-46c6-8322-826a21f56511",
                    "94f7b459-ae19-4600-8d72-9a21c78b86f4"
                ],
                "request_amounts": [
                    {
                        "currency": "EUR",
                        "from_address": "TRADIAS",
                        "to_address": "DE89370400440532013000",
                        "amount": "12766.04"
                    },
                    {
                        "currency": "LTC",
                        "from_address": "TRADIAS",
                        "to_address": "MGxNPPB7eBoWPUaprtX9v9CXJZoD2465zN",
                        "amount": "207.606"
                    },
                    {
                        "currency": "BTC",
                        "from_address": "bc1qar0srrr7xfkvy516431ydnw9re59gtzzwf5mdq",
                        "to_address": "TRADIAS",
                        "amount": "1.23"
                    }
                ]
            }

            post_settlement_request = requests.post(url=URL, json=payload, headers=rest_api_header)
            print(json.dumps(post_settlement_request.json(), indent=4))

      responses:
        "202":
          description: Settlement Request Response
          $ref: "dict.yml#/components/responses/response_settlement_status_short_type"
        "401":
          description: Unauthorized
          $ref: "dict.yml#/components/responses/response_401_type"
        "409":
          description: Duplicate Request
          $ref: "dict.yml#/components/responses/response_409_type"
        "422":
          description: Unprocessable Entity
          $ref: "dict.yml#/components/responses/response_422_type"
        "500":
          description: Internal
          $ref: "dict.yml#/components/responses/response_500_type"
        "default":
          $ref: "dict.yml#/components/responses/default_response_type"

  /settlement-requests/{settlement_request_id}/status:
    get:
      tags:
        - Settlement Request
      summary: Get Settlement Request Status
      operationId: get_settlement_request_status
      description: |
        This endpoint allows you to check the status of a previously created settlement
        request. You can use the settlement_request_id returned by the POST
        /api/settlement-request endpoint to query the status of your settlement
        request.<br><br>

        The response will indicate whether the settlement request is ready to be
        processed or not.
      parameters:
        - name: settlement_request_id
          required: true
          in: path
          schema:
            $ref: "dict.yml#/components/schemas/internal_ref_type"

      x-codeSamples:
        - lang: Python
          label: Python (requests)
          source: |-
            import requests
            import json

            PROTOCOL = "https"
            ENV = "preprod"
            MY_TOKEN = "ENTER YOUR TOKEN HERE"

            settlement_request_id = "13bd7e32-4a43-4112-9002-38c402a2fb11"

            URL = f"{PROTOCOL}://api.{ENV}.tradias.app/api/settlement-requests/{settlement_request_id}/status"

            rest_api_header = {
                "Authorization": "Bearer " + MY_TOKEN
            }

            settlement_request_status = requests.get(url=URL, headers=rest_api_header)
            print(json.dumps(settlement_request_status.json(), indent=4))

      responses:
        "200":
          description: Settlement Request Not Found
          content:
            application/json:
              schema:
                $ref: "dict.yml#/components/schemas/internal_error_type"
              example:
                error: "not ready"
                timestamp: "2023-01-20T14:31:10.012123Z"
        "302":
          description: Settlement Request Found
          content:
            application/json:
              schema:
                $ref: "dict.yml#/components/schemas/internal_error_type"
              example:
                error: "ready"
                timestamp: "2023-01-20T14:31:10.012123Z"
        "401":
          description: Unauthorized
          $ref: "dict.yml#/components/responses/response_401_type"
        "404":
          description: Not Found
          $ref: "dict.yml#/components/responses/response_404_type"
        "500":
          description: Internal Server Error
          $ref: "dict.yml#/components/responses/response_500_type"
        "default":
          $ref: "dict.yml#/components/responses/default_response_type"

  /settlement-requests/{settlement_request_id}:
    get:
      tags:
        - Settlement Request
      summary: Get Settlement Request
      operationId: get_settlement_request
      description: |
        This endpoint allows you to retrieve the details of a previously created
        settlement request. You can use the settlement_request_id returned by the
        POST /api/settlement-request endpoint to query the details of your settlement
        request.<br><br>

        The response will contain information about the settlement request, including
        its status, amounts, and associated trades.
      parameters:
        - name: settlement_request_id
          required: true
          in: path
          schema:
            $ref: "dict.yml#/components/schemas/internal_ref_type"

      x-codeSamples:
        - lang: Python
          label: Python (requests)
          source: |-
            import requests
            import json

            PROTOCOL = "https"
            ENV = "preprod"
            MY_TOKEN = "ENTER YOUR TOKEN HERE"

            settlement_request_id = "13bd7e32-4a43-4112-9002-38c402a2fb11"

            URL = f"{PROTOCOL}://api.{ENV}.tradias.app/api/settlement-requests/{settlement_request_id}/status"

            rest_api_header = {
                "Authorization": "Bearer " + MY_TOKEN
            }

            settlement_request_status = requests.get(url=URL, headers=rest_api_header)
            print(json.dumps(settlement_request_status.json(), indent=4))

      responses:
        "200":
          description: Get Settlement Request
          content:
            application/json:
              schema:
                title: Get Settlement Request
                type: object
                required:
                  - settlement_request_status
                  - settlement_request_id
                  - client_settlement_request_id
                  - request_amounts
                additionalProperties: false
                properties:
                  settlement_request_status:
                    $ref: "dict.yml#/components/schemas/settlement_status_type"
                  settlement_request_id:
                    $ref: "dict.yml#/components/schemas/internal_ref_type"
                  client_settlement_request_id:
                    $ref: "dict.yml#/components/schemas/external_ref_type"
                  request_amounts:
                    title: Settlement Amounts
                    type: array
                    minItems: 1
                    maxItems: 99
                    description: Array containing the individual net amounts of the settlement
                    items:
                      title: Settlement Amount
                      type: object
                      required:
                        - currency
                        - from_address
                        - to_address
                        - amount
                        - expected_amount
                        - status
                        - transactions
                        - settlement_request_amount_id
                      additionalProperties: false
                      properties:
                        currency:
                          $ref: "dict.yml#/components/schemas/asset_code_type"
                          description: The currency to which the request amount applies
                        from_address:
                          summary: From Address
                          $ref: "dict.yml#/components/schemas/checked_address_type"
                        to_address:
                          summary: To Address
                          $ref: "dict.yml#/components/schemas/checked_address_type"
                        amount:
                          summary: Amount to be transferred
                          $ref: "dict.yml#/components/schemas/quantity_type"
                        expected_amount:
                          summary: Expected Amount
                          description:
                            The amount expected by tradias as a result of the trades passed in
                            the corresponding trade list. In order for settlement to go forward,
                            this expected_amount has to agree with the amount field.
                          $ref: "dict.yml#/components/schemas/quantity_type"
                        status:
                          summary: Status
                          description:
                            Settlement status of the respective settlement request amount.
                            In case amount of the settlement request matches with the amount
                            tradias has calculated the value will be "CONFIRMED" and the value
                            switches to "SETTLED", once the transaction has been done.
                            In case tradias receives the amount, the status change will happen
                            upon receipt of the amount, in the case tradias sends the amount,
                            the status change happens upon the sending of the amount.
                          $ref: "dict.yml#/components/schemas/settlement_status_type"
                        transactions:
                          title: Transactions
                          description:
                            A list of transactions that have been made and associated with this
                            settlement request amount
                          type: array
                          minItems: 0
                          maxItems: 99
                          items:
                            title: List of Transactions
                            type: object
                            required:
                              - id
                              - reference
                              - reference_type
                              - used_amount
                            additionalProperties: false
                            properties:
                              id:
                                summary: Transaction Id
                                description: A tradias id of the transaction
                                $ref: "dict.yml#/components/schemas/internal_ref_type"
                              reference:
                                summary: Reference
                                $ref: "dict.yml#/components/schemas/transaction_ref_type"
                              reference_type:
                                summary: Reference Type
                                description:
                                  The type of the reference, e.g. a blockchain transaction hash or
                                  a bank payment reference
                                $ref: "dict.yml#/components/schemas/transaction_ref_type_type"
                              used_amount:
                                summary: Amount transferred
                                $ref: "dict.yml#/components/schemas/quantity_type"
                        settlement_request_amount_id:
                          summary: Settlement Request Amount Id
                          description:
                            Server-side generated unique identifier of the settlement request
                            amount
                          $ref: "dict.yml#/components/schemas/internal_ref_type"
                  trade_ids:
                    title: Lists of Trades in particular states
                    description: |
                      Lists of all trade_ids from the settlement request grouped by their state
                    type: object
                    required:
                      - unknown
                      - conflicting
                      - already_settled
                      - settled
                      - pending
                      - cancelled
                    additionalProperties: false
                    properties:
                      unknown:
                        title: List of unknown Trades
                        description:
                          List of all trade_ids from the settlement request which are not known by
                          tradias
                        type: array
                        minItems: 0
                        maxItems: 999999
                        uniqueItems: true
                        items:
                          $ref: "dict.yml#/components/schemas/internal_ref_type"
                      conflicting:
                        title: List of conflicting Trades
                        description:
                          List of all trade_ids from the settlement request which are in a
                          conflicting state with another settlement request, i.e. in a pending
                          settlement state
                        type: array
                        minItems: 0
                        maxItems: 999999
                        uniqueItems: true
                        items:
                          $ref: "dict.yml#/components/schemas/internal_ref_type"
                      already_settled:
                        title: List of already settled Trades
                        description:
                          List of all trade_ids from the settlement request which have already been
                          settled previously
                        type: array
                        minItems: 0
                        maxItems: 999999
                        uniqueItems: true
                        items:
                          $ref: "dict.yml#/components/schemas/internal_ref_type"
                      settled:
                        title: List of settled Trades
                        description:
                          List of all trade_ids from the settlement request which have been settled
                          with this or a previous settlement request.
                        type: array
                        minItems: 0
                        maxItems: 999999
                        uniqueItems: true
                        items:
                          $ref: "dict.yml#/components/schemas/internal_ref_type"
                      pending:
                        title: List of pending Trades
                        description:
                          List of all trade_ids from the settlement request which are still pending
                          settlement.
                        type: array
                        minItems: 0
                        maxItems: 999999
                        uniqueItems: true
                        items:
                          $ref: "dict.yml#/components/schemas/internal_ref_type"
                      cancelled:
                        title: List of cancelled Trades
                        description:
                          List of all trade_ids from the settlement request which have been
                          cancelled and will not be settled.
                        type: array
                        minItems: 0
                        maxItems: 999999
                        uniqueItems: true
                        items:
                          $ref: "dict.yml#/components/schemas/internal_ref_type"
              example:
                settlement_request_status: "partially"
                settlement_request_id: "92ec4900-8da5-4700-a28c-2c1f2b32b914"
                client_settlement_request_id: "6aa21c20-ae4b-11ed-b304-81a12bb57b04"
                request_amounts:
                  - currency: "LTC"
                    from_address:
                      address: "TRADIAS"
                      valid: true
                    to_address:
                      address: "MGxNPPB7eBoWPUaprtX9v9CXJZoD2465zN"
                      valid: true
                    amount: "207.606"
                    expected_amount: "207.606"
                    status: "settled"
                    transactions:
                      - id: "73b0b7f2-bd94-11ed-bef0-ba16c3846fc3"
                        reference: "d8a8b5c19200417cfad98b30423737cad7a27b40bd19bdec89620e953748f189"
                        reference_type: "on_chain_transaction_id"
                        used_amount: "207.606"
                    settlement_request_amount_id: "99859305-be58-11ed-99a9-ba16c3846fc3"
                  - currency: "EUR"
                    from_address:
                      address: "TRADIAS"
                      valid: true
                    to_address:
                      address: "DE89370400440532013000"
                      valid: true
                    amount: "12766.04"
                    expected_amount: "12766.04"
                    status: "confirmed"
                    transactions:
                      - id: "81a108fc-3181-4e29-a2aa-9464cd77f0fe"
                        reference: "TRX20230901XYZ"
                        reference_type: "sepa_reference"
                        used_amount: "12766.04"
                    settlement_request_amount_id: "81a108fc-3181-4e29-a2aa-9464cd77f0fe"
                  - currency: "BTC"
                    from_address:
                      address: "bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq"
                      valid: true
                    to_address:
                      address: "TRADIAS"
                      valid: true
                    amount: "1.23"
                    expected_amount: "1.23"
                    status: "partially"
                    transactions: []
                    settlement_request_amount_id: "febf879f-11e8-41e1-a909-6438593b154a"
                trade_ids:
                  unknown: []
                  conflicting: []
                  already_settled:
                    - "a83ceb8f-a7cd-46c6-8322-826a21f56511"
                  settled:
                    - "2987a674-fa91-4bcb-b480-24934bc4166c"
                  pending:
                    - "94f7b459-ae19-4600-8d72-9a21c78b86f4"
                  cancelled: []
        "401":
          description: Unauthorized
          $ref: "dict.yml#/components/responses/response_401_type"
        "404":
          description: Not Found
          $ref: "dict.yml#/components/responses/response_404_type"
        "500":
          description: Internal Server Error
          $ref: "dict.yml#/components/responses/response_500_type"
        "default":
          $ref: "dict.yml#/components/responses/default_response_type"


####################################################################################################
##
## Transactions
##
  /transactions:
    get:
      tags:
        - Transaction
      summary: Get Settlement Transactions
      operationId: get_settlement_transactions
      description: |
        This endpoint allows you to retrieve a list of settlement transactions
        associated with your account. You can filter the transactions based on various
        criteria such as date range, amount, currency, and more.<br><br>

        The response will contain a list of transactions that match the specified
        filters, along with relevant details for each transaction.
      parameters:
        - name: from_datetime
          description:
            Select transactions where the settlement has been started after the given timestamp
          in: query
          required: true
          schema:
            $ref: "dict.yml#/components/schemas/timestamp_type"
        - name: to_datetime
          description:
            Select transactions where the settlement has been started before the given timestamp
          in: query
          required: true
          schema:
            $ref: "dict.yml#/components/schemas/timestamp_type"
        - name: min_amount
          description: Select transactions with a transaction amount higher than the given amount
          in: query
          required: false
          schema:
            $ref: "dict.yml#/components/schemas/quantity_type"
        - name: max_amount
          description: Select transactions with a transaction amount lower than the given amount
          in: query
          required: false
          schema:
            $ref: "dict.yml#/components/schemas/quantity_type"
        - name: transaction_id
          description:
            Select transactions with the given transaction id
          in: query
          required: false
          schema:
            $ref: "dict.yml#/components/schemas/internal_ref_type"
        - name: reference
          description:
            Select transactions with the given transaction reference
          in: query
          required: false
          schema:
            $ref: "dict.yml#/components/schemas/external_ref_type"
        - name: currency_code
          description: Select transactions with the given currency
          in: query
          required: false
          schema:
            $ref: "dict.yml#/components/schemas/asset_code_type"
        - name: settlement_request_ids
          description:
            Select transactions with the given settlement ids
          in: query
          required: false
          schema:
            type: array
            minItems: 1
            maxItems: 99
            uniqueItems: true
            items:
              $ref: "dict.yml#/components/schemas/internal_ref_type"
        - name: client_settlement_request_ids
          description:
            Select transactions with the given client settlement ids
          in: query
          required: false
          schema:
            type: array
            minItems: 1
            maxItems: 99
            uniqueItems: true
            items:
              $ref: "dict.yml#/components/schemas/external_ref_type"
        - name: sender_only
          description: Select transactions where the API user is SENDER of the transaction.
          in: query
          required: false
          schema:
            type: boolean
        - name: receiver_only
          description: Select transactions where the API user is RECEIVER of the transaction.
          in: query
          required: false
          schema:
            type: boolean
        - name: limit
          description: Pagination Logic - maximal number of orders returned by this request (page)
          in: query
          required: false
          schema:
            $ref: "dict.yml#/components/schemas/pagination_limit_type"
        - name: skip
          description: Pagination Logic - number of pages to skip. 0 is the first page (no skip)
          in: query
          required: false
          schema:
            $ref: "dict.yml#/components/schemas/pagination_skip_type"

      x-codeSamples:
        - lang: Python
          label: Python (requests)
          source: |-
            import requests
            import json

            PROTOCOL = "https"
            ENV = "preprod"
            MY_TOKEN = "ENTER YOUR TOKEN HERE"

            URL = f"{PROTOCOL}://api.{ENV}.tradias.app/api/transactions"

            rest_api_header = {
                "Authorization": "Bearer " + MY_TOKEN
            }

            params = {
                "from_datetime": "2023-10-20T11:20:21.000000Z",
                "to_datetime": "2023-10-20T15:20:21.000000Z"
            }

            settlement_request_transactions = requests.get(url=URL, headers=rest_api_header, params=params)
            print(json.dumps(settlement_request_transactions.json(), indent=4))

      responses:
        "200":
          description: Successful Response
          $ref: "dict.yml#/components/responses/transactions_response_type"
        "401":
          description: Unauthorized
          $ref: "dict.yml#/components/responses/response_401_type"
        "500":
          description: Internal Server Error
          $ref: "dict.yml#/components/responses/response_500_type"
        "default":
          $ref: "dict.yml#/components/responses/default_response_type"

  /transaction/{transaction_id}:
    patch:
      tags:
        - Transaction
      summary: Map Transaction With Settlement Request Amount
      operationId: map_transaction_with_settlement_request_amount
      description: |
        This endpoint allows you to map an existing transaction to a specific settlement
        request amount. This is useful when you want to associate a transaction with
        a particular settlement request for tracking and reconciliation purposes.<br><br>

        You need to provide the transaction ID in the path parameter and the settlement
        request amount ID along with the amount in the request body.<br><br>

        Upon successful mapping, the response will confirm the association between
        the transaction and the settlement request amount.
      parameters:
        - name: transaction_id
          required: true
          in: path
          schema:
            $ref: "dict.yml#/components/schemas/internal_ref_type"
      requestBody:
        content:
          application/json:
            schema:
              title: Map Transaction With Settlement Request Amount Request
              required:
                - settlement_request_amount_id
              type: object
              properties:
                settlement_request_amount_id:
                  summary: Settlement Request Amount Id
                  description:
                    Server-side generated unique identifier of the settlement request
                    amount
                  $ref: "dict.yml#/components/schemas/internal_ref_type"
                amount:
                  summary: Amount
                  description:
                    The amount to use from the transaction for this settlement request amount.
                  $ref: "dict.yml#/components/schemas/quantity_type"
        required: true

      x-codeSamples:
        - lang: Python
          label: Python (requests)
          source: |-
            import requests
            import json

            PROTOCOL = "https"
            ENV = "preprod"
            MY_TOKEN = "ENTER TOKEN HERE"

            settlement_request_id = "514704a5-848e-4211-a7ce-ec388e122882"

            URL = f"{PROTOCOL}://api.{ENV}.tradias.app/api/transactions/{settlement_request_id}"

            rest_api_header = {
                "Authorization": "Bearer " + MY_TOKEN
            }

            settlement_request_transactions = requests.patch(url=URL, headers=rest_api_header, json={
                "settlement_request_amount_id": "76b8c625-d540-42cc-96e4-ee97658d918b",
                "amount": "1151.01"
            })

            print(json.dumps(settlement_request_transactions.json(), indent=4))

      responses:
        "200":
          description: Successful Response
          $ref: "dict.yml#/components/responses/map_transaction_response_type"
        "401":
          description: Unauthorized
          $ref: "dict.yml#/components/responses/response_401_type"
        "403":
          description: Forbidden
          $ref: "dict.yml#/components/responses/response_403_type"
        "404":
          description: Not Found
          $ref: "dict.yml#/components/responses/response_404_type"
        "409":
          description: Conflict
          content:
            application/json:
              schema:
                $ref: "dict.yml#/components/schemas/internal_error_type"
              example:
                error: "Forbidden"
                timestamp: "2023-01-20T14:31:10.012123Z"
        "422":
          $ref: "dict.yml#/components/responses/response_422_type"
        "500":
          description: Internal Server Error
          $ref: "dict.yml#/components/responses/response_500_type"
        "default":
          $ref: "dict.yml#/components/responses/default_response_type"


####################################################################################################
##
## Security
##
components:
  securitySchemes:
    AuthenticationToken:
      type: http
      scheme: bearer
      bearerFormat: JWT

security:
  - AuthenticationToken: []
