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

# Create widget transaction and redirect to frontend

> Accepts either `widgetId` or `widget_id` as the widget identifier and redirects to the frontend transaction link after creating a pending transaction.




## OpenAPI

````yaml /OPENAPI.yaml get /api/widgets
openapi: 3.0.3
info:
  title: Redf Backend API
  version: 1.0.0
  description: >
    OpenAPI specification for the current HTTP backend exposed by the Phoenix
    router. The spec reflects the routes and controller behaviour currently
    implemented in `blockchain_app/lib/blockchain_app_web/router.ex`.
servers:
  - url: http://localhost:4000
    description: Local development
security: []
tags:
  - name: Health
  - name: Networks
  - name: Projects
  - name: Transactions
  - name: Widgets
paths:
  /api/widgets:
    get:
      tags:
        - Widgets
      summary: Create widget transaction and redirect to frontend
      description: >
        Accepts either `widgetId` or `widget_id` as the widget identifier and
        redirects to the frontend transaction link after creating a pending
        transaction.
      operationId: widgetRedirect
      parameters:
        - in: query
          name: widgetId
          schema:
            type: integer
            minimum: 1
          description: Widget identifier. Use this or `widget_id`.
        - in: query
          name: widget_id
          schema:
            type: integer
            minimum: 1
          description: Widget identifier. Use this or `widgetId`.
        - in: query
          name: amount
          required: true
          schema:
            $ref: '#/components/schemas/DecimalInput'
          description: Requested payment amount
      responses:
        '302':
          description: Redirect to frontend payment page
          headers:
            Location:
              $ref: '#/components/headers/Location'
        '400':
          description: Invalid widget id or amount
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Widget not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: Transaction creation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    DecimalInput:
      description: Decimal amount accepted by the backend
      oneOf:
        - type: string
          example: '10.50'
        - type: integer
          example: 10
        - type: number
          example: 10.5
    ErrorResponse:
      type: object
      description: >
        Generic error payload used by the API. Some handlers return `error`,
        while validation and internal checker failures may return only `errors`
        or `reason`.
      required:
        - status
      properties:
        status:
          type: string
          enum:
            - error
        error:
          type: string
          example: invalid_request
        reason:
          type: string
          nullable: true
        detail:
          type: string
          nullable: true
        field:
          oneOf:
            - type: string
            - type: integer
          nullable: true
        currency:
          type: string
          nullable: true
        missing:
          type: array
          items:
            type: string
        errors:
          $ref: '#/components/schemas/ValidationErrors'
        message:
          type: string
          nullable: true
        constraint:
          type: string
          nullable: true
        tx_status:
          type: string
          nullable: true
        project_uid:
          type: string
          nullable: true
        widget_id:
          oneOf:
            - type: string
            - type: integer
          nullable: true
        expected:
          type: object
          additionalProperties: true
      additionalProperties: true
    ValidationErrors:
      type: object
      description: Map of field names to validation error messages
      additionalProperties:
        type: array
        items:
          type: string
  headers:
    Location:
      description: Redirect target URL
      schema:
        type: string
        format: uri

````