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

# Update an invoice

> 
Update an invoice with override fields, line item descriptions, and/or PDF attachments.

| Field | Affects this invoice | Persists to future invoices |
|-------|---------------------|----------------------------|
| `due_at` | ✓ | ✗ |
| `purchase_order` | ✓ | ✓ (if `persist_purchase_order=true`) |
| `billing_address` | ✓ | ✓ (Updates subscription) |
| `company_name` | ✓ | ✓ (Updates subscription) |
| `accounts_payable_emails` | ✓ | ✓ (Updates subscription) |
| `invoice_memo` | ✓ | ✓ (if `persist_memo=true`) |
| `line_item_overrides` | ✓ | ✗ |

Upload PDF attachments as multipart form data using the `pdf_attachments` field.




## OpenAPI

````yaml https://api.salesbricks.com/api/v2/openapi.yaml patch /invoices/{invoice_id}
openapi: 3.0.3
info:
  title: Salesbricks REST API
  version: 2.0.0
  description: API reference for external integrations
servers:
  - url: https://api.salesbricks.com/api/v2
    description: Production
  - url: https://api.staging.salesbricks.com/api/v2
    description: Staging
security:
  - ApiKeyAuth: []
tags:
  - name: Subscriptions
    description: >-
      Operations related to subscription management, including creation,
      updates, and retrieving subscription details. Subscriptions can be
      upgraded to add / remove add-ons by using the POST
      /subscriptions/{subscription_id}/upgrade endpoint and can be recasted for
      replacing the current agreement using the POST
      /subscriptions/{subscription_id}/recast endpoint
  - name: Customers
    description: >-
      Operations related to customer management, including creation, updates,
      and managing customer person objects.
  - name: Invoices
    description: Operations related to subscription's invoicing details.
  - name: Plans
    description: >-
      Operations related to listing and getting plan details including bricks in
      the plan.
  - name: Payment Methods
    description: Operations related to subscription's payment method.
paths:
  /invoices/{invoice_id}:
    patch:
      tags:
        - Invoices
      summary: Update an invoice
      description: >

        Update an invoice with override fields, line item descriptions, and/or
        PDF attachments.


        | Field | Affects this invoice | Persists to future invoices |

        |-------|---------------------|----------------------------|

        | `due_at` | ✓ | ✗ |

        | `purchase_order` | ✓ | ✓ (if `persist_purchase_order=true`) |

        | `billing_address` | ✓ | ✓ (Updates subscription) |

        | `company_name` | ✓ | ✓ (Updates subscription) |

        | `accounts_payable_emails` | ✓ | ✓ (Updates subscription) |

        | `invoice_memo` | ✓ | ✓ (if `persist_memo=true`) |

        | `line_item_overrides` | ✓ | ✗ |


        Upload PDF attachments as multipart form data using the
        `pdf_attachments` field.
      operationId: updateInvoice
      parameters:
        - in: path
          name: invoice_id
          schema:
            type: string
            pattern: ^([a-zA-Z\d\-]+)$
          required: true
      requestBody:
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/PatchedInvoiceUpdateInput'
          application/x-www-form-urlencoded:
            schema:
              $ref: '#/components/schemas/PatchedInvoiceUpdateInput'
          application/json:
            schema:
              $ref: '#/components/schemas/PatchedInvoiceUpdateInput'
            examples:
              UpdateInvoiceRequest:
                value:
                  due_at: '2024-02-15T00:00:00Z'
                  purchase_order: PO-2024-001
                  billing_address:
                    line_1: 123 Main Street
                    line_2: Suite 100
                    city: San Francisco
                    region: CA
                    zip: '94102'
                    country: US
                  company_name: Acme Corporation
                  accounts_payable_emails:
                    - ap@acme.com
                    - billing@acme.com
                  invoice_memo: Net 30 payment terms
                  persist_memo: false
                  send_invoice: true
                  reason_for_updating: Updated billing address per customer request
                summary: Update Invoice Request
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InvoiceUpdateOutput'
          description: ''
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                BadRequestResponse:
                  value:
                    error:
                      code: ERR_BAD_REQUEST
                      message: >-
                        Bad request — the input payload is malformed, missing
                        required fields, or contains invalid data.
                  summary: Bad Request Response
                InvoiceAlreadyPaid:
                  value:
                    error:
                      code: ERR_BAD_REQUEST
                      message: Invoice is already paid and cannot be edited.
                  summary: Invoice Already Paid
          description: ''
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                NotFoundResponse:
                  value:
                    error:
                      code: ERR_NOT_FOUND
                      message: >-
                        Not found — the resource you are looking for does not
                        exist.
                  summary: Not Found Response
          description: ''
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                ServerErrorResponse:
                  value:
                    error:
                      code: ERR_PDF_GENERATION_FAILED
                      message: Failed to generate invoice PDF after update.
                  summary: Server Error Response
          description: ''
components:
  schemas:
    PatchedInvoiceUpdateInput:
      type: object
      description: Input serializer for updating an invoice.
      properties:
        due_at:
          type: string
          format: date
          nullable: true
          description: Override the due date for this invoice. Pass null for no change.
        issued_at:
          type: string
          format: date
          nullable: true
          description: Override the issue date for this invoice. Pass null for no change.
        purchase_order:
          type: string
          nullable: true
          description: >-
            Purchase order with code. Pass null for no change, empty object or
            empty code to clear.
        billing_address:
          type: string
          nullable: true
          description: >-
            Billing address. Pass null for no change. **Changes will reflect in
            the subscription.**
        company_name:
          type: string
          nullable: true
          description: >-
            Company name for the invoice. Pass null for no change, empty string
            to clear. **Changes will reflect in the subscription.**
          maxLength: 255
        accounts_payable_emails:
          type: array
          items:
            type: string
            format: email
          nullable: true
          description: >-
            List of accounts payable contact emails. Pass null for no change,
            empty array to clear. **Changes will reflect in the subscription.**
        invoice_memo:
          type: string
          nullable: true
          description: Memo or notes to appear on the invoice. Pass empty string to clear.
          maxLength: 2000
        reason_for_updating:
          type: string
          nullable: true
          description: Internal reason for updating the invoice (for audit purposes)
          maxLength: 500
        line_item_overrides:
          type: string
          description: >-
            Override descriptions for specific line items. **Only affects this
            invoice, does not persist to future invoices.**
        send_invoice:
          type: boolean
          default: false
          description: >-
            Whether to send the invoice to the customer after updating. Defaults
            to false.
        persist_memo:
          type: boolean
          default: false
          description: >-
            Whether to persist the invoice memo on all future invoices. Defaults
            to false. 
        persist_purchase_order:
          type: boolean
          default: false
          description: >-
            Whether to persist the purchase order number on all future invoices.
            Defaults to false. When true, the PO number will be applied to all
            future invoices for this subscription. When false, the PO number is
            only set for this specific invoice.
        show_brick_descriptions:
          type: boolean
          description: >-
            Whether to show brick descriptions on the invoice PDF. Defaults to
            true if not specified.
        pdf_attachments:
          type: array
          items:
            type: string
            format: uri
          description: PDF files to attach to the invoice.
        pdf_attachments_config:
          type: array
          items:
            type: object
            additionalProperties: {}
          description: >-
            Configuration for managing attachments. Each item specifies either
            an existing attachment to keep (by attachment_id) or a new file to
            add (by new_file_index), along with a 'target' to specify where to
            store it ('invoice' or 'subscription'). The order in this array
            determines the unified order of attachments in the PDF. Existing
            attachments NOT in this list will be DELETED. If omitted,
            pdf_attachments will replace all existing invoice-level attachments.
        tax_id:
          type: string
          nullable: true
          description: >-
            Tax ID for the invoice. **Changes will reflect in the
            subscription.**
          maxLength: 255
        dunning_auto_retries:
          type: boolean
          nullable: true
          description: >-
            Whether to enable automatic retries for failed payments. When
            enabled, failed invoice payments will be retried using saved payment
            methods. Defaults to False.
    InvoiceUpdateOutput:
      type: object
      description: Output serializer for successful invoice update.
      properties:
        invoice_id:
          type: string
          format: uuid
          description: The unique identifier of the updated invoice
        signed_pdf_url:
          type: string
          format: uri
          description: Signed URL to download the updated invoice PDF. Expires in 1 hour.
        attachments:
          type: array
          items:
            $ref: '#/components/schemas/InvoiceAttachmentResponse'
          description: >-
            Current attachments for this invoice as a flat array. Array order
            reflects the PDF merge order (unified across both levels).
      required:
        - invoice_id
        - signed_pdf_url
    ErrorResponse:
      type: object
      description: >-
        Standardizes API error responses with a consistent structure containing
        error code and message.
      properties:
        error:
          $ref: '#/components/schemas/Error'
      required:
        - error
    InvoiceAttachmentResponse:
      type: object
      description: >-
        Serializer for a single attachment in the response.


        Mirrors the input format (pdf_attachments_config) with additional
        read-only fields.

        This allows the frontend to easily pass the data back for updates.
      properties:
        attachment_id:
          type: string
          format: uuid
          description: Unique identifier for this attachment
        target:
          enum:
            - invoice
            - subscription
          type: string
          x-spec-enum-id: 3970fdc4ffe95396
          description: |-
            Where this attachment is stored: 'invoice' or 'subscription'

            * `invoice` - invoice
            * `subscription` - subscription
        file_name:
          type: string
          description: Original filename of the attachment
        created_at:
          type: string
          format: date-time
          description: When this attachment was created
      required:
        - attachment_id
        - created_at
        - file_name
        - target
    Error:
      type: object
      description: >-
        Represents individual error details with a standardized code and
        descriptive message.
      properties:
        code:
          enum:
            - ERR_NOT_FOUND
            - ERR_BAD_REQUEST
            - ERR_SERVER_ERROR
          type: string
          x-spec-enum-id: dc5a5d6feae1b697
          description: >-
            Error code indicating the type of error: NOT_FOUND for missing
            resources, BAD_REQUEST for invalid input, SERVER_ERROR for internal
            server issues


            * `ERR_NOT_FOUND` - ERR_NOT_FOUND

            * `ERR_BAD_REQUEST` - ERR_BAD_REQUEST

            * `ERR_SERVER_ERROR` - ERR_SERVER_ERROR
        message:
          type: string
        error_id:
          type: string
          format: uuid
          description: >-
            Correlation handle for SERVER_ERROR responses — quote this when
            contacting support; it joins to the structured server log line for
            the failure. Not present on 4xx responses.
      required:
        - code
        - message
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-SALESBRICKS-KEY
      description: API key for authentication

````

## Related topics

- [One-Off Invoices](/documentation/one-off-invoices.md)
- [Your email notifications](/documentation/your-email-notifications.md)
- [Update a usage entry](/api-reference/usage/patch.md)
