> ## Documentation Index
> Fetch the complete documentation index at: https://docs.loopreturns.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Draft Return Totals

> Returns the computed monetary totals for the draft return. Money values are objects with
an integer `amount` in minor units and a `currencyCode`.




## OpenAPI

````yaml draft-returns-hal-forms get /draft-returns/{draft_return_id}/totals
openapi: 3.1.0
info:
  title: Draft Returns API
  version: v1
  description: >
    # Overview


    The Draft Returns API lets you build a complete return-creation flow by
    managing draft

    returns through a state machine. Endpoints allow you to initialize a draft,
    add or remove

    items, set customer and address details, finalize selections, and submit the
    completed return.


    This document describes the unreleased API version. Test via

    `/api/unstable/draft-returns/...`.


    ## Response architecture


    Successful responses include `draft_return`, `context`, `errors`, plus
    hypermedia controls.


    ### `_links`


    An object keyed by relation name. Each value includes `href` and optional
    metadata:


    ```json

    {
      "_links": {
        "self": {
          "href": "https://api.loopreturns.com/api/unstable/draft-returns/123"
        },
        "add-returning-item": {
          "href": "https://api.loopreturns.com/api/unstable/draft-returns/123/returning-items"
        },
        "finalize-items": {
          "href": "https://api.loopreturns.com/api/unstable/draft-returns/123/finalize-items"
        }
      }
    }

    ```


    ### `_templates`


    Each available action is described by a template in the `_templates` object:


    ```json

    {
      "_templates": {
        "add-returning-item": {
          "method": "POST",
          "title": "Add a line item to the return",
          "contentType": "application/json",
          "properties": [
            {
              "name": "order_line_item_id",
              "type": "number",
              "required": true,
              "prompt": "ID of the line item to return"
            }
          ]
        },
        "finalize-items": {
          "method": "POST",
          "title": "Lock in item selections and proceed",
          "contentType": "application/json",
          "properties": []
        }
      }
    }

    ```


    Each template may include:

    - `method`: The HTTP method (`POST`, `DELETE`, etc.)

    - `title`: Human-readable description of the action

    - `contentType`: The request content type (typically `application/json`)

    - `properties`: Array of field descriptors with `name`, `type`, `required`,
      `prompt`, and optionally `options` (for enum-like fields)

    ### `client_application`


    Responses include a `client_application` object describing how the client
    should

    identify itself on subsequent requests.


    ### Content type


    | Header | Value |

    |---|---|

    | `Content-Type` (response) | `application/prs.hal-forms+json` |

    | `Content-Type` (request body) | `application/json` |


    ## State Machine


    ```

    created → finalize-items → items-finalized → submit → submitted
       ↓                              ↓
       ↓← ← unfinalize-items ← ← ← ← ↓
       ↓                              ↓
       └→ cancel → cancelled     expired
    ```


    ### States


    - **created**: Initial state where items are added and customer information
    is set

    - **items-finalized**: Items are locked in; credit type and return method
    can be selected

    - **submitted**: Terminal state — draft has been converted to an actual
    return

    - **cancelled**: Terminal state — draft was explicitly cancelled

    - **expired**: Terminal state — draft timed out due to inactivity


    ### Available Templates by State


    #### Created State


    `_templates` may include:


    - `add-returning-item`: Add an item from the order to the return

    - `remove-returning-item`: Remove an item from the return

    - `set-returning-item-return-reason`: Set why an item is being returned

    - `set-returning-item-return-type`: Set whether the item is for credit or
    exchange

    - `add-returning-item-exchange-item`: Add an exchange product for a
    returning item

    - `add-returning-item-user-input`: Provide additional information requested
    by merchant

    - `remove-cart-item`: Remove an exchange or shop-now item

    - `set-customer`: Set customer email and name

    - `set-address`: Set return shipping address

    - `finalize-items`: Lock in item selections and proceed to return method
    selection

    - `cancel-draft-return`: Cancel this draft return


    #### Items-Finalized State


    `_templates` may include:


    - `set-credit-type`: Choose how to receive the refund

    - `select-return-method`: Select the shipping method for the return

    - `submit-draft-return`: Submit the draft and convert it to an actual return

    - `unfinalize-items`: Go back to add/remove items

    - `cancel-draft-return`: Cancel this draft return


    #### Terminal States


    When a draft return reaches a terminal state (`submitted`, `cancelled`,
    `expired`),

    `_templates` and `_links` will be empty objects.
servers:
  - url: https://api.loopreturns.com/api/v1
security: []
paths:
  /draft-returns/{draft_return_id}/totals:
    get:
      summary: Get Draft Return Totals
      description: >
        Returns the computed monetary totals for the draft return. Money values
        are objects with

        an integer `amount` in minor units and a `currencyCode`.
      operationId: getDraftReturnTotalsHalForms
      parameters:
        - $ref: '#/components/parameters/DraftReturnId'
        - $ref: '#/components/parameters/ShopId'
        - $ref: '#/components/parameters/AcceptHalForms'
      responses:
        '200':
          description: OK
          content:
            application/prs.hal-forms+json:
              schema:
                type: object
                properties:
                  _links:
                    $ref: '#/components/schemas/HalFormsLinks'
                  data:
                    type: object
                    properties:
                      return_total:
                        $ref: '#/components/schemas/DraftReturnMoney'
                      new_item_total:
                        $ref: '#/components/schemas/DraftReturnMoney'
                      total_bonus_offered:
                        $ref: '#/components/schemas/DraftReturnMoney'
                      bonus_used:
                        $ref: '#/components/schemas/DraftReturnMoney'
                      fees:
                        type: object
                        properties:
                          applied:
                            $ref: '#/components/schemas/DraftReturnMoney'
                          refund:
                            $ref: '#/components/schemas/DraftReturnMoney'
                          credit:
                            $ref: '#/components/schemas/DraftReturnMoney'
                          exchange:
                            $ref: '#/components/schemas/DraftReturnMoney'
                      amount_due:
                        $ref: '#/components/schemas/DraftReturnMoney'
                      credit:
                        $ref: '#/components/schemas/DraftReturnMoney'
                      net:
                        $ref: '#/components/schemas/DraftReturnMoney'
                      returning_item_subtotal:
                        $ref: '#/components/schemas/DraftReturnMoney'
                      returning_item_tax:
                        $ref: '#/components/schemas/DraftReturnMoney'
                      purchasing_item_tax:
                        $ref: '#/components/schemas/DraftReturnMoney'
                      settings:
                        type: object
                        properties:
                          stripe_min:
                            type: integer
                      is_difference_covered:
                        type: boolean
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '404':
          description: Not Found
      security:
        - api_key: []
components:
  parameters:
    DraftReturnId:
      name: draft_return_id
      in: path
      description: The unique identifier of the draft return.
      required: true
      schema:
        type: integer
    ShopId:
      name: X-Shop-Id
      in: header
      description: >
        The unique identifier of the shop associated with the draft return.


        This header is not required, as the merchant's shop is identified by the
        API key present in the request.
      schema:
        type: integer
    AcceptHalForms:
      name: Accept
      in: header
      required: false
      description: |
        Optional. Responses use `Content-Type: application/prs.hal-forms+json`.
      schema:
        type: string
        enum:
          - application/prs.hal-forms+json
  schemas:
    HalFormsLinks:
      type: object
      description: >
        HAL `_links` object. Always includes `self`. Other keys are relation
        names

        corresponding to available actions for the current draft return state.
      properties:
        self:
          $ref: '#/components/schemas/HalLink'
      additionalProperties:
        $ref: '#/components/schemas/HalLink'
    DraftReturnMoney:
      type: object
      properties:
        amount:
          type: integer
          description: The monetary amount in minor units (e.g. cents).
        currencyCode:
          type: string
          description: The three-character ISO 4217 currency code.
    HalLink:
      type: object
      properties:
        href:
          type: string
          description: The fully-qualified URL for this link relation.
      required:
        - href
  responses:
    UnauthorizedError:
      description: API key is missing or invalid.
      content:
        application/json:
          schema:
            type: object
            properties:
              errors:
                type: array
                items:
                  type: object
                  properties:
                    code:
                      type: string
                      enum:
                        - unauthorized
                    message:
                      type: string
                      example: Unauthorized.
  securitySchemes:
    api_key:
      type: apiKey
      in: header
      name: X-Authorization

````