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

# Complete order fulfillment

> Marks an order as completed and resets all associated equipment to idle state.

This endpoint should be called by a robot or orchestrator after an order has been fulfilled.
It performs the following operations:
1. Updates the order status to 'completed' and rfc_status to 'completed'
2. Marks all order_items as completed (fulfilled_quantity = quantity)
3. Resets all totes associated with the order to 'empty' status and clears their associations
4. Releases all carts assigned to the order (sets order_id to null, location to 'idle')
5. Marks all bags for the order as 'delivered'
6. Marks all pick_list_items and sweep_items as 'picked'/'completed'

The Supabase RPC function 'complete_order_fulfillment' handles the database updates atomically.



## OpenAPI

````yaml api-reference/v1/openapi.yaml post /v1/orders/complete
openapi: 3.1.0
info:
  title: Goods API
  version: 1.0.0
  description: >-
    API for Goods grocery operations - scanner app, admin dashboard, and
    customer features
  contact:
    name: Goods Team
    url: https://goods.app
servers:
  - url: http://localhost:3000
    description: Local development
  - url: https://dev.api.switchyard.run
    description: Development
  - url: https://api.switchyard.run
    description: Production
security: []
tags:
  - name: v1
    description: API v1 - unified domain-based endpoints
  - name: Scanner
    description: Scanner app endpoints for drivers and pickers
  - name: Sweeps
    description: Sweep management - retail store pickup operations
  - name: RFC Picks
    description: Ready-for-checkout picking operations
  - name: Inventory
    description: Inventory management and barcode lookup
  - name: Admin
    description: Admin dashboard endpoints
  - name: Orders
    description: Order management
  - name: Products
    description: Product catalog management
  - name: Notifications
    description: Push, email, SMS, and Slack notification management
paths:
  /v1/orders/complete:
    post:
      tags:
        - Orders
      summary: Complete order fulfillment
      description: >-
        Marks an order as completed and resets all associated equipment to idle
        state.


        This endpoint should be called by a robot or orchestrator after an order
        has been fulfilled.

        It performs the following operations:

        1. Updates the order status to 'completed' and rfc_status to 'completed'

        2. Marks all order_items as completed (fulfilled_quantity = quantity)

        3. Resets all totes associated with the order to 'empty' status and
        clears their associations

        4. Releases all carts assigned to the order (sets order_id to null,
        location to 'idle')

        5. Marks all bags for the order as 'delivered'

        6. Marks all pick_list_items and sweep_items as 'picked'/'completed'


        The Supabase RPC function 'complete_order_fulfillment' handles the
        database updates atomically.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                order_id:
                  type: string
                  description: Order UUID to mark as completed
                  example: a1b2c3d4-e5f6-7890-abcd-ef1234567890
              required:
                - order_id
      responses:
        '200':
          description: Order completed successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  order_id:
                    type: string
                    format: uuid
                  message:
                    type: string
                  reset_summary:
                    type: object
                    properties:
                      totes_reset:
                        type: number
                        description: Number of totes reset to empty status
                      carts_released:
                        type: number
                        description: Number of carts unassigned from order
                      bags_delivered:
                        type: number
                        description: Number of bags marked as delivered
                      order_items_completed:
                        type: number
                        description: Number of order items marked as completed
                      pick_list_items_completed:
                        type: number
                        description: Number of pick list items marked as completed
                      sweep_items_completed:
                        type: number
                        description: Number of sweep items marked as completed
                    required:
                      - totes_reset
                      - carts_released
                      - bags_delivered
                      - order_items_completed
                      - pick_list_items_completed
                      - sweep_items_completed
                required:
                  - success
                  - order_id
                  - message
                  - reset_summary
        '404':
          description: Order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: Error message
                    example: Not found
                required:
                  - error
        '500':
          description: Server error
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: Error message
                    example: Not found
                required:
                  - error

````