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

# Validate invoice

> Validates an invoice against contract data and optional user-provided consumption data. Performs comprehensive validation including consumption matching, meter reading verification, and check against contract.

**Validation Rules:**
- Meter Reading Logic: Current reading must be ≥ previous reading
- Contract Matching: Invoice date must fall within contract period
- MPAN Matching: At least one MPAN must match between invoice and contract

**Data Sources:**
- Manual uploads from parseInvoice endpoint
- Invoices from Supplier Integration system
- User-provided consumption and meter reading data



## OpenAPI

````yaml post /v1/billValidation/validateInvoice
openapi: 3.0.3
info:
  title: VoltView API
  description: >-
    The VoltView API provides comprehensive energy monitoring and management
    capabilities for multi-site businesses, enabling real-time tracking of
    energy consumption, cost analysis, and environmental impact metrics.


    Our API suite includes:

    - Site Management API - Manage and monitor multiple site locations

    - Energy Consumption API - Access detailed energy usage data

    - Cost Analysis API - Track and analyse energy costs

    - Environmental Metrics API - Monitor carbon emissions and energy efficiency

    - Bill Validation API - Validate and audit utility bills for accuracy

    - Supplier Integration API - Integrate with utility suppliers for automated
    data collection


    ## Getting started guide


    To start using the VoltView API, you need to:


    - Sign up for a VoltView account to receive your API credentials

    - Review our data granularity options (hourly/daily/monthly)

    - Ensure your requests are sent via HTTPS

    - All responses are returned in JSON format


    ## Authentication


    Include your VoltView API key in the `x-api-key` header on every request.


    ### Authentication error response

    If authentication fails, you will receive an HTTP 401 Unauthorised response
    with a detailed error message in the JSON response body.


    ## Data Units

    - Energy Consumption: kWh

    - Power Demand: kW

    - Carbon Emissions: kg CO2e/tonnes CO2e

    - Currency: GBP (£)

    - Time Series: ISO 8601 format

    - Numeric Values: Rounded to 2 decimal places
  version: 1.0.0
  contact:
    email: info@voltview.co.uk
  license:
    name: Proprietary
servers:
  - url: https://api.voltview.co.uk
    description: Production server
security:
  - apiKeyAuth: []
tags:
  - name: Authentication
    description: Endpoints for authentication
  - name: User
    description: User profile management
  - name: Sites
    description: Multi-site management endpoints
  - name: Energy Consumption
    description: Energy consumption data endpoints
  - name: Specific Site
    description: Operations for specific sites
  - name: Meters
    description: Meter lookup and meter readings management
  - name: Emissions
    description: Carbon emissions data endpoints
  - name: LOA Management
    description: >-
      Letter of Authority (LOA) management - create, list, view, and update
      status of LOAs
  - name: Supplier Integration
    description: Utilities integration endpoints
  - name: Billing Insights
    description: Account-level billing insights and bill assurance opportunities
  - name: Bill Validation
    description: Utility bill validation and error detection endpoints
paths:
  /v1/billValidation/validateInvoice:
    post:
      tags:
        - Bill Validation
      summary: Validate invoice
      description: >-
        Validates an invoice against contract data and optional user-provided
        consumption data. Performs comprehensive validation including
        consumption matching, meter reading verification, and check against
        contract.


        **Validation Rules:**

        - Meter Reading Logic: Current reading must be ≥ previous reading

        - Contract Matching: Invoice date must fall within contract period

        - MPAN Matching: At least one MPAN must match between invoice and
        contract


        **Data Sources:**

        - Manual uploads from parseInvoice endpoint

        - Invoices from Supplier Integration system

        - User-provided consumption and meter reading data
      operationId: validateInvoice
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                filePath:
                  type: string
                  description: >-
                    File path to the invoice document to validate. Can be from a
                    manually uploaded invoice (parseInvoice endpoint) or from an
                    invoice retrieved via Supplier Integration endpoints.
                  example: accounts/123456789/invoices/INV2024001.pdf
                userConsumptionData:
                  type: object
                  description: >-
                    Optional user-provided consumption data to validate against
                    the invoice
                  properties:
                    fromDate:
                      type: string
                      format: date-time
                      description: Start date of consumption period (ISO 8601)
                      example: '2024-06-01T00:00:00.000Z'
                    toDate:
                      type: string
                      format: date-time
                      description: End date of consumption period (ISO 8601)
                      example: '2024-07-01T00:00:00.000Z'
                    utilityType:
                      type: string
                      enum:
                        - ELECTRICITY
                        - GAS
                        - BMS
                      description: Type of utility
                    consumption:
                      type: object
                      description: Consumption values for the period
                      properties:
                        activeImportKwh:
                          type: number
                          description: Active energy imported (main consumption) in kWh
                          example: 5223
                        activeExportKwh:
                          type: number
                          description: >-
                            Active energy exported in kWh (for sites with
                            generation)
                        dayConsumption:
                          type: number
                          description: Day/peak consumption in kWh (for dual-rate tariffs)
                        nightConsumption:
                          type: number
                          description: >-
                            Night/off-peak consumption in kWh (for dual-rate
                            tariffs)
                        reactiveImportKvarh:
                          type: number
                          description: Reactive energy imported in kvarh (electricity only)
                        reactiveExportKvarh:
                          type: number
                          description: Reactive energy exported in kvarh (electricity only)
                        apparentKvah:
                          type: number
                          description: >-
                            Apparent energy consumption in kVAh (electricity
                            only)
                    meterReadings:
                      type: object
                      description: Optional meter reading information
                      properties:
                        previousReading:
                          type: number
                          description: Previous meter reading
                          example: 100000
                        currentReading:
                          type: number
                          description: Current meter reading
                          example: 105223
                        previousReadingDate:
                          type: string
                          format: date-time
                          description: Date of previous reading (ISO 8601)
                          example: '2024-06-01T00:00:00.000Z'
                        currentReadingDate:
                          type: string
                          format: date-time
                          description: Date of current reading (ISO 8601)
                          example: '2024-07-01T00:00:00.000Z'
                        previousReadingType:
                          type: string
                          enum:
                            - actual
                            - estimated
                            - customer
                            - smart
                          description: Type of previous reading
                        currentReadingType:
                          type: string
                          enum:
                            - actual
                            - estimated
                            - customer
                            - smart
                          description: Type of current reading
              required:
                - filePath
            examples:
              basicValidation:
                summary: Basic validation without user data
                value:
                  filePath: accounts/123456789/invoices/INV2024001.pdf
              withConsumptionData:
                summary: Validation with consumption data
                value:
                  filePath: accounts/123456789/invoices/INV2024001.pdf
                  userConsumptionData:
                    utilityType: ELECTRICITY
                    consumption:
                      activeImportKwh: 5223
              withMeterReadings:
                summary: Validation with meter readings
                value:
                  filePath: accounts/123456789/invoices/INV2024001.pdf
                  userConsumptionData:
                    utilityType: ELECTRICITY
                    meterReadings:
                      previousReading: 100000
                      currentReading: 105223
                      previousReadingDate: '2024-06-01T00:00:00.000Z'
                      currentReadingDate: '2024-07-01T00:00:00.000Z'
                      previousReadingType: actual
                      currentReadingType: actual
      responses:
        '200':
          description: Validation completed - may return passed, failed, or pending status
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationResult'
              examples:
                validationPassed:
                  summary: Validation Passed
                  value:
                    filePath: accounts/123456789/invoices/INV2024001.pdf
                    status: passed
                    errors: []
                validationFailedSingle:
                  summary: Validation Failed - Single Error
                  value:
                    filePath: accounts/123456789/invoices/INV2024001.pdf
                    status: failed
                    errors:
                      - type: consumptionMismatch
                        description: >-
                          Invoice consumption differs from user-provided
                          consumption
                        expected: 6000 kWh
                        actual: 5223 kWh
                validationFailedMultiple:
                  summary: Validation Failed - Multiple Errors
                  value:
                    filePath: accounts/123456789/invoices/INV2024001.pdf
                    status: failed
                    errors:
                      - type: consumptionMismatch
                        description: >-
                          Invoice consumption differs from user-provided
                          consumption
                        expected: 6000 kWh
                        actual: 5223 kWh
                      - type: consumptionMismatch
                        description: >-
                          Invoice consumption differs from calculated
                          consumption based on meter readings
                        expected: 6033 kWh
                        actual: 5223 kWh
                      - type: rateMismatch
                        description: Unit rate differs from contract rate
                        expected: 25.50p/kWh
                        actual: 28.87p/kWh
                validationPending:
                  summary: Validation Pending - No Contract
                  value:
                    filePath: accounts/123456789/invoices/INV2024001.pdf
                    status: pending
                    errors:
                      - type: other
                        description: >-
                          Cannot validate - please parse a contract document for
                          the corresponding MPAN and date range
                        expected: Contract document with matching MPAN and date range
                        actual: No contract document found
        '400':
          description: Bad Request - Invalid input
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                missingFilePath:
                  summary: Missing filePath
                  value:
                    error: File path is required
                invalidConsumptionData:
                  summary: Invalid consumption data
                  value:
                    error: User-provided consumption cannot be negative
        '401':
          description: Unauthorized - Authentication required
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: Unauthorized
        '404':
          description: Not Found - Invoice not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: Invoice not found at specified file path
components:
  schemas:
    ValidationResult:
      type: object
      properties:
        filePath:
          type: string
          description: File path to the validated invoice document
        status:
          type: string
          enum:
            - passed
            - failed
            - pending
          description: >-
            Validation status - passed means all validations succeeded, failed
            means discrepancies were found, pending means validation could not
            be completed (e.g., missing contract data)
        errors:
          type: array
          items:
            type: object
            properties:
              type:
                type: string
                enum:
                  - consumptionMismatch
                  - rateMismatch
                  - standingChargeError
                  - dayRateMismatch
                  - nightRateMismatch
                  - capacityChargeError
                  - vatError
                  - cclError
                  - dateMismatch
                  - other
                description: Type of validation error detected
              description:
                type: string
                description: Human-readable description of the validation error
              expected:
                type: string
                description: Expected value or condition
              actual:
                type: string
                description: Actual value found that caused the validation error
          description: >-
            Array of validation errors found. Empty array indicates validation
            passed.
    Error:
      type: object
      properties:
        type:
          type: string
          enum:
            - error
          description: Error type indicator
        error:
          type: object
          properties:
            type:
              type: string
              enum:
                - invalid_request_error
              description: Specific error type
            message:
              type: string
              description: Human-readable error message
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: VoltView API key

````