Skip to content

Remove a line from an invoice

Open .md

DELETE/v2/api/store/{team_slug}/v2/invoice/item/{unique_key}

v2Operation ID v2_public_invoice_item_destroy

Removes one line from an invoice and recalculates it. Returns the action envelope (DELETED). Removing a line that is already gone succeeds with NONE.

Permission

Needs permission to edit the invoice's sales order: the team owner, a role whose Manage Sales Orders permission is "update all", or "update assigned" when you created the order or are assigned to it, or, on a draft order, its creator when their role can create sales orders. Otherwise 403 user_is_not_authorized. Reading needs only team membership.

Business rules

  • On an Auto Invoice invoice you can't remove its sales order lines, shipping fees or discounts ("You cannot delete order Item for an auto managed invoice" and similar).
  • Lines synced from an external system can't be removed: "Cannot delete external object from API."

Side effects

  • Recalculates the invoice: line totals, subtotal, shipping, discounts, tax and total.
  • Updates the sales order's invoiced totals and each line's invoiced status (not invoiced, partly, fully, or over-invoiced), and automatically redistributes (reallocates) recorded payments across the order's invoices to match updated totals (funds frozen by an open dispute or review stay where they are).
  • When the team syncs to QuickBooks Online automatically and the order is published, the order is synced again about 3 minutes later (not after a change of position only).
  • Open Admin Portal pages refresh, and so do Customer Portal pages the order's customer has open. No webhook or email is sent.

Path parameters

  • team_slugstringrequired

    Your team slug, shown as Team ID next to your API key in Profile.

    • Example your-team
  • unique_keystringrequired

    The invoice line's id (a hash id), as its answers show it. Its unique key (ordinvitm_...) also works, but API answers don't include it.

    • Example nhsGsn84PyJBvK

Request body

This operation takes no request body.

Response

200Successful response.

  • dataobjectrequired

    What happened, and the line.

    Child fields (5)
      • Always "invoice_item"
    • NONE when nothing changed.

      • One of: "CREATED", "UPDATED", "DELETED", "NONE"
    • itemobject

      An invoice line.

      Child fields (15)
      • _metaobject

        Read-only: id, type, invoice_id, lock_version, from_legacy, position_hash.

      • YoPrint manages this line (Auto Invoice).

      • external_idsarray of objects

        Links to external systems; empty for lines made in YoPrint.

      • external_typestring | null
      • idstring

        The invoice line.

      • The invoice.

      • Send it back on Update an invoice line to detect a concurrent change.

      • positioninteger
      • pricingobject

        Absent on tax and discount lines. system (sales order lines): _meta.unit_price is the price copied from the sales order line and _meta.subtotal is that price × this line's quantity. fee (shipping fees): product.total is the fee. Prices come at the stored scale (6 decimal places); _meta.subtotal at the combined scale of price × quantity (compacted when large). Always read dp.

        Child fields (1)
        • typestring
          • One of: "system", "fee"
      • productobject
        Child fields (3)
        • _metaobject

          Read-only details, always an object (with editable_fields_on_update); for order_item, parent describes the sales order line.

        • The kind's fields; for order_item, id is the sales order line. A discount's percentage or amount comes back as total (you send it as rate).

        • typestring
          • One of: "order_item", "shipment_fee", "invoice_discount", "user_tax", "override_tax", "auto_tax", "invoice_surcharge"
      • quantityobject

        Absent on tax and discount lines.

        Child fields (2)
        • typestring
          • Always "unit"
        • totaldecimal pair

          The quantity. A decimal pair: the amount is value ÷ 10^dp ({ "value": 1250, "dp": 2 } is 12.50). Read dp every time: it can differ between fields and records.

      • taxobject

        Absent on tax and discount lines. YoPrint adds it by default only to sales order lines (taxable); other lines have it only when it was sent.

        Child fields (1)
        • typestring
          • One of: "taxable", "non_taxable"
      • typestring

        Same as product.type.

    • Lock versions after the change.

      Child fields (2)
      • invoiceobject

        The invoice's lock versions: invoice_item_lock_version, invoice_lock_version.

      • orderobject

        The order's lock versions: job_lock_version, invoice_lock_version, order_item_lock_version, shipment_lock_version, payment_lock_version, order_lock_version.

  • statusintegerrequired
  • successbooleanrequired

Errors

  • 401The API key is missing or wrong (unauthenticated).

  • 403You are not allowed to do this. api_access_not_in_plan: your team's plan doesn't include API access (Pro and above, with an active subscription or trial), so every request answers this until the team upgrades. When your role lacks the permission the operation needs, the body is only {"message": "Insufficient Permission"}. Other refusals use the error envelope, with unauthorized or user_is_not_authorized.

    When
    Your role can't edit this order.
    Fix
    Ask the team owner to adjust your role or assign you to the order.
  • 404Not found. page_not_found: the team slug is unknown, you are not a member of the team, or an id in the path is not one of this team's. code: null, with a message that starts "No query results for": there is no record with that id.

    When
    The line isn't your team's.
    Fix
    Check the line id.
  • 422The request was refused and changed nothing. validation_failed lists what to fix in error.fields; other codes name a business rule, explained in error.message. A few checks answer with only {"message": "..."}. An operation that calls another service (a payment provider, a carrier, an accounting app) can answer connect_timeout ("Please retry again") when that service does not answer in time: the change may or may not have happened there, so read the record back before you retry.

    When
    An Auto Invoice or external line (validation_error).
    Fix
    Change the sales order instead, or turn off Auto Invoice on the invoice in the web app.