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

# List returns that still need an inbound NF-e (Brazil)

> Brazil only. In Brazil, goods entering Cubbo's warehouse must be covered by an electronic
invoice (NF-e, *Nota Fiscal Eletrônica*). When a returned order is received and is being put
away, your store must issue the inbound NF-e for the return (and, when applicable, for the
stock re-entry) and attach it with `POST /returns/{return_id}/attach-invoice`. This endpoint
lists the returns of a store that are waiting for that document, newest first, so you can
poll it and issue the missing invoices.

A return is listed when all of the following hold:
- its received stock is being put away (the reception has reached the put-away stage),
- the original order has an approved sale (or donation) NF-e, whose access key is given in
  `related_sale_invoice` so you can reference it on the inbound invoice, and
- it is still missing an approved, processing, contingency or pre-approved NF-e for either
  the return itself or its stock re-entry.




## OpenAPI

````yaml /openapi.yaml get /returns/awaiting-invoice
openapi: 3.1.0
info:
  title: Cubbo Clients API
  version: '1.0'
  summary: >-
    Orders, inventory, replenishments, returns, shipping and webhooks for Cubbo
    fulfillment.
  description: >
    The Cubbo Clients API connects your store, ERP or marketplace with Cubbo's
    fulfillment network.

    All endpoints except `POST /auth/token` require a bearer token; see the
    Authentication guide.

    Request and response bodies are JSON. Errors are JSON objects with an
    `error` key.
  contact:
    name: Cubbo integrations
    email: integraciones@cubbo.com
servers:
  - url: https://api.cubbo.com/v1
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Authentication
    description: Exchange client credentials for a bearer token.
  - name: Orders
    description: Create, update, hold, cancel and read sales orders.
  - name: Shipping labels
    description: Read the shipping labels generated for an order.
  - name: Inventory
    description: Products and stock per store.
  - name: Lots
    description: Lot-level inventory for products with expiration or batch tracking.
  - name: Reports
    description: Bulk reports for reconciliation.
  - name: Replenishments
    description: Inbound shipments to the warehouse.
  - name: Returns
    description: Returns and exchanges.
  - name: Stores
    description: Store provisioning and settings.
  - name: Shipping methods
    description: Available shipping methods, coverage and quotes.
  - name: Click and collect
    description: Pickup points and in-store pickup orders.
paths:
  /returns/awaiting-invoice:
    get:
      tags:
        - Returns
      summary: List returns that still need an inbound NF-e (Brazil)
      description: >
        Brazil only. In Brazil, goods entering Cubbo's warehouse must be covered
        by an electronic

        invoice (NF-e, *Nota Fiscal Eletrônica*). When a returned order is
        received and is being put

        away, your store must issue the inbound NF-e for the return (and, when
        applicable, for the

        stock re-entry) and attach it with `POST
        /returns/{return_id}/attach-invoice`. This endpoint

        lists the returns of a store that are waiting for that document, newest
        first, so you can

        poll it and issue the missing invoices.


        A return is listed when all of the following hold:

        - its received stock is being put away (the reception has reached the
        put-away stage),

        - the original order has an approved sale (or donation) NF-e, whose
        access key is given in
          `related_sale_invoice` so you can reference it on the inbound invoice, and
        - it is still missing an approved, processing, contingency or
        pre-approved NF-e for either
          the return itself or its stock re-entry.
      operationId: listReturnsAwaitingInvoice
      parameters:
        - name: store_id
          in: query
          required: true
          description: Id of the store whose returns you want to list.
          schema:
            type: integer
          example: 1234
        - name: page
          in: query
          required: false
          description: Page number, starting at 1.
          schema:
            type: integer
            minimum: 1
            default: 1
          example: 1
        - name: per_page
          in: query
          required: false
          description: Results per page, at most 100.
          schema:
            type: integer
            default: 10
            maximum: 100
          example: 10
      responses:
        '200':
          description: Paginated list of returns awaiting an inbound NF-e.
          content:
            application/json:
              schema:
                type: object
                properties:
                  returns:
                    type: array
                    items:
                      $ref: '#/components/schemas/ReturnAwaitingInvoice'
                  meta:
                    $ref: '#/components/schemas/PaginationMeta'
              example:
                returns:
                  - id: 98765
                    return_type: RETURNED_BY_CARRIER
                    replenishment_id: 77001
                    related_sale_invoice:
                      invoice_key: '00000000000000000000000000000000000000000000'
                    returned_order:
                      id: 445566
                      channel_order_id: '1000123'
                      order_number: ORD-0001
                      integration_details:
                        marketplace: MERCADOLIBRE
                meta:
                  current_page: 1
                  next_page: null
                  prev_page: null
                  total_pages: 1
                  first_page: true
                  last_page: true
                  per_page: 10
                  total_count: 1
        '401':
          $ref: '#/components/responses/Unauthorized'
        '422':
          description: Validation error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                missingStore:
                  value:
                    error: Parameter store_id is required
                storeNotFound:
                  value:
                    error: Couldn't find Store with 'id'=1234
                perPageTooLarge:
                  value:
                    error: Parameter per_page cannot be greater than 100
        '500':
          $ref: '#/components/responses/InternalServerError'
      security:
        - bearerAuth: []
components:
  schemas:
    ReturnAwaitingInvoice:
      type: object
      description: A return that is waiting for its inbound NF-e.
      required:
        - id
        - return_type
        - replenishment_id
        - related_sale_invoice
        - returned_order
      properties:
        id:
          type: integer
          description: >-
            Id of the return; use it with `POST
            /returns/{return_id}/attach-invoice`.
          example: 98765
        return_type:
          $ref: '#/components/schemas/ReturnType'
        replenishment_id:
          type: integer
          description: >-
            Id of the stock re-entry (replenishment) created on reception; the
            `REPLENISHMENT_INVOICE` you attach is linked to it.
          example: 77001
        related_sale_invoice:
          type:
            - object
            - 'null'
          description: >-
            The approved sale (or donation) NF-e of the original order, to
            reference on the inbound invoice.
          properties:
            invoice_key:
              type: string
              description: 44-digit NF-e access key of the sale invoice.
              example: '00000000000000000000000000000000000000000000'
        returned_order:
          type:
            - object
            - 'null'
          description: Summary of the order being returned.
          properties:
            id:
              type: integer
              description: Id of the order.
              example: 445566
            channel_order_id:
              type:
                - string
                - 'null'
              description: Id of the order in the sales channel it came from.
              example: '1000123'
            order_number:
              type: string
              description: Order number.
              example: ORD-0001
            integration_details:
              type: object
              description: Sales-channel details.
              properties:
                marketplace:
                  type:
                    - string
                    - 'null'
                  description: >-
                    Marketplace the order was placed on, when the channel
                    reports it.
                  example: MERCADOLIBRE
    PaginationMeta:
      type: object
      description: Paging information returned next to list results.
      properties:
        current_page:
          type: integer
          example: 1
        next_page:
          type:
            - integer
            - 'null'
          example: 2
        prev_page:
          type:
            - integer
            - 'null'
          example: null
        total_pages:
          type: integer
          example: 7
        first_page:
          type: boolean
          example: true
        last_page:
          type: boolean
          example: false
        per_page:
          type: integer
          example: 50
        total_count:
          type: integer
          example: 312
    Error:
      type: object
      description: Error body returned by every failed request.
      required:
        - error
      properties:
        error:
          type: string
          description: >-
            Human-readable description of the failure. For `401` responses it is
            always `Unauthorized`.
          example: Parameter store_id is required
        message:
          type: string
          description: >-
            Present on `401` responses only; the reason the request was
            rejected.
          example: invalid token
        code:
          type:
            - string
            - 'null'
          description: >-
            Stable machine-readable code, present on some order, return and
            replenishment errors.
          example: ORDER_ALREADY_EXISTS
        context:
          type:
            - object
            - 'null'
          description: >-
            Extra data about the failure when available, for example the id of
            the conflicting order.
          additionalProperties: true
          example:
            order_id: 987654
    ReturnType:
      type: string
      description: >
        What kind of return this is.

        - `TO_BE_DETERMINED`: requested by the customer or by you, not yet
        reviewed; the outcome (simple return, exchange, rejection) is decided
        later.

        - `SIMPLE_RETURN`: the customer sends the goods back; no replacement is
        shipped.

        - `EXCHANGE`: the customer sends the goods back and replacement items
        (`exchange_products`) are reserved to ship once the return arrives.

        - `IMMEDIATE_EXCHANGE`: replacement items ship right away, before the
        return arrives (created from the Cubbo app, not through this API).

        - `RETURNED_BY_CARRIER`: the carrier could not deliver the order and
        brought it back; decide it with `POST /returns/{return_id}/decision`.

        - `UNIDENTIFIED`: a package arrived at the warehouse that could not be
        matched to an order (created by warehouse staff).
      enum:
        - TO_BE_DETERMINED
        - SIMPLE_RETURN
        - EXCHANGE
        - IMMEDIATE_EXCHANGE
        - RETURNED_BY_CARRIER
        - UNIDENTIFIED
      example: TO_BE_DETERMINED
  responses:
    Unauthorized:
      description: >-
        Missing or invalid token, wrong credentials, or no access to the
        requested store.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            invalidToken:
              value:
                error: Unauthorized
                message: invalid token
            noHeader:
              value:
                error: Unauthorized
                message: no authorization header found
            storeNotAllowed:
              value:
                error: Unauthorized
                message: not allowed to show? this Store
    InternalServerError:
      description: >-
        Unexpected error. Retry with backoff; if it persists, send the timestamp
        to Cubbo support.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: 'unexpected error, timestamp: 1760000000'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Token returned by `POST /auth/token`, sent as `Authorization: Bearer
        <token>`.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.