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

# Update delivery note

> Replace a delivery note's header and lines. Lines with a known id are updated, lines with no id are added, and omitted lines are removed. Closed/cancelled notes are immutable, and a line already matched to a bill cannot be removed or have its received quantity reduced below the matched amount.



## OpenAPI

````yaml put /delivery-notes/{id}
openapi: 3.1.1
info:
  title: Dolfin API
  description: >-
    Dolfin API for AR & AP. Authenticate using the `x-dolfin-api-key` header
    with the API key distributed to your organisation.
  version: v1
servers:
  - url: https://api.dolfinai.co
    description: Production
security:
  - {}
tags:
  - name: Webhooks
  - name: Users
  - name: TaxRates
  - name: Suppliers
  - name: Supplier Credit Notes
  - name: Bills
  - name: SpendCategories
  - name: Payables
  - name: RecurringInvoices
  - name: Receivables
  - name: Purchase Orders
  - name: Products
  - name: Payments
  - name: Invoices
  - name: Organisations
  - name: Members
  - name: MCP
  - name: Matching
  - name: Invoice Reminders
  - name: Industries
  - name: Gmail
  - name: Delivery Notes
  - name: Customers
  - name: Currencies
  - name: Credit Notes
  - name: Clients
  - name: ClientInvites
  - name: BankPayments
  - name: Bank details
  - name: Auth
  - name: ApprovalPolicies
  - name: ApiKeys
  - name: Agent
paths:
  /delivery-notes/{id}:
    put:
      tags:
        - Delivery Notes
      summary: Update delivery note
      description: >-
        Replace a delivery note's header and lines. Lines with a known id are
        updated, lines with no id are added, and omitted lines are removed.
        Closed/cancelled notes are immutable, and a line already matched to a
        bill cannot be removed or have its received quantity reduced below the
        matched amount.
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateDeliveryNoteRequest'
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DeliveryNoteResponse'
        '400':
          description: >-
            DeliveryNote.NumberRequired — a delivery note requires a DN number


            DeliveryNote.NoLines — a delivery note must have at least one line


            DeliveryNote.InvalidLine — a delivery-note line is missing a
            description or a valid quantity


            DeliveryNote.LineNotFound — a referenced delivery-note line does not
            belong to this delivery note
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
        '403':
          description: >-
            Organisation.InsufficientRole — caller's organisation role is below
            the level this action requires
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
        '404':
          description: >-
            DeliveryNote.NotFound — delivery note does not exist or belongs to
            another organisation


            DeliveryNote.SupplierNotFound — the referenced supplier does not
            exist in this organisation
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
        '409':
          description: >-
            DeliveryNote.NotEditable — the delivery note is in a terminal status
            (closed or cancelled) and cannot be edited


            DeliveryNote.LineHasAllocations — a delivery-note line that is
            already matched to a bill cannot be removed


            DeliveryNote.QuantityBelowMatched — quantity received cannot be
            reduced below the quantity already matched to bills
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
components:
  schemas:
    UpdateDeliveryNoteRequest:
      type: object
      properties:
        supplierId:
          type:
            - 'null'
            - string
          description: Supplier the goods were received from. Optional.
          format: uuid
        externalRef:
          type:
            - 'null'
            - string
          description: Caller's own reference for the note. Optional.
        dnNumber:
          type:
            - 'null'
            - string
          description: Human delivery-note number. Required.
        purchaseOrderId:
          type:
            - 'null'
            - string
          description: Loose header link to a purchase order. Optional.
          format: uuid
        receivedAt:
          type:
            - 'null'
            - string
          description: When the goods were received. Optional.
          format: date-time
        lines:
          type: array
          items:
            $ref: '#/components/schemas/UpdateDeliveryNoteLineRequest'
          description: The full set of received lines after the edit.
      description: >-
        Full-representation update of a delivery note and its lines. Lines with
        a known id are updated in place, lines with no id are added, and omitted
        lines are removed. A line already matched to a bill cannot be removed or
        have its received quantity dropped below what is already matched.
    DeliveryNoteResponse:
      required:
        - dnNumber
      type: object
      properties:
        id:
          type: string
          description: Unique identifier of the delivery note.
          format: uuid
        organisationId:
          type: string
          description: The organisation that owns the delivery note.
          format: uuid
        supplierId:
          type:
            - 'null'
            - string
          description: The supplier the goods were received from, if assigned.
          format: uuid
        externalRef:
          type:
            - 'null'
            - string
          description: >-
            Caller's own reference for the note (a reverse pointer to the
            platform's record), if any.
        dnNumber:
          type: string
          description: >-
            Human delivery-note number. Required and unique within the
            organisation.
        purchaseOrderId:
          type:
            - 'null'
            - string
          description: >-
            Loose header link to a purchase order, if one was provided.
            Optional.
          format: uuid
        receivedAt:
          type:
            - 'null'
            - string
          description: When the goods were received, if recorded.
          format: date-time
        status:
          $ref: '#/components/schemas/DeliveryNoteStatus'
          description: >-
            Lifecycle status: Draft, Open, PartiallyMatched, FullyMatched (all
            derived from matching), or the manual terminal states Closed /
            Cancelled.
        lines:
          type: array
          items:
            $ref: '#/components/schemas/DeliveryNoteLineResponse'
          description: The received lines, in display order.
        createdAt:
          type: string
          description: When the delivery note was created.
          format: date-time
        updatedAt:
          type: string
          description: When the delivery note was last updated.
          format: date-time
      description: A delivery note and its received lines.
    ProblemDetails:
      type: object
      properties:
        type:
          type:
            - 'null'
            - string
        title:
          type:
            - 'null'
            - string
        status:
          pattern: ^-?(?:0|[1-9]\d*)$
          type:
            - 'null'
            - integer
            - string
          format: int32
        detail:
          type:
            - 'null'
            - string
        instance:
          type:
            - 'null'
            - string
    UpdateDeliveryNoteLineRequest:
      required:
        - description
      type: object
      properties:
        id:
          type:
            - 'null'
            - string
          description: Existing line id to update in place, or null to create a new line.
          format: uuid
        description:
          type: string
          description: Line description.
        sku:
          type:
            - 'null'
            - string
          description: >-
            Product SKU, used as the exact-match key against bill lines.
            Optional.
        quantityReceived:
          pattern: ^-?(?:0|[1-9]\d*)(?:\.\d+)?$
          type:
            - number
            - string
          description: Quantity received on this line.
          format: double
        unit:
          type:
            - 'null'
            - string
          description: Unit of measure (e.g. each, kg). Optional.
        sortOrder:
          pattern: ^-?(?:0|[1-9]\d*)$
          type:
            - integer
            - string
          description: Display order of the line within the note.
          format: int32
      description: >-
        A line in a delivery-note update. Null id creates a new line; a known id
        updates the existing line in place.
    DeliveryNoteStatus:
      enum:
        - Draft
        - Open
        - PartiallyMatched
        - FullyMatched
        - Closed
        - Cancelled
      description: >-
        Lifecycle status of a delivery note. Draft, Open, PartiallyMatched and
        FullyMatched are derived from matching (and reverse as allocations
        change); Closed and Cancelled are manual terminal states a human sets.
    DeliveryNoteLineResponse:
      required:
        - description
      type: object
      properties:
        id:
          type: string
          description: Unique identifier of the line.
          format: uuid
        description:
          type: string
          description: Line description.
        sku:
          type:
            - 'null'
            - string
          description: >-
            Product SKU, used as the exact-match key against bill lines.
            Optional.
        quantityReceived:
          pattern: ^-?(?:0|[1-9]\d*)(?:\.\d+)?$
          type:
            - number
            - string
          description: Quantity received on this line.
          format: double
        unit:
          type:
            - 'null'
            - string
          description: Unit of measure (e.g. each, kg), if recorded.
        sortOrder:
          pattern: ^-?(?:0|[1-9]\d*)$
          type:
            - integer
            - string
          description: Display order of the line within the note.
          format: int32
        matchedQuantity:
          pattern: ^-?(?:0|[1-9]\d*)(?:\.\d+)?$
          type:
            - 'null'
            - number
            - string
          description: >-
            Total quantity matched against this line across all bills. Null on
            list responses (not computed there); populated on the detail
            (get-by-id) response.
          format: double
        fullyMatched:
          type:
            - 'null'
            - boolean
          description: >-
            True once the matched quantity covers the whole received quantity.
            Null when MatchedQuantity is not computed (list responses) — null
            means 'unknown', not 'unmatched'.
      description: A single received line on a delivery note.

````