openapi: 3.1.0
info:
  title: Meter Energy - Smart Meter Texas Interval Data API
  version: 2.0.0
  description: |
    Pull up to 12 months of 15-minute Smart Meter Texas (SMT) import and
    export data for a Texas smart meter.

    Two steps:

    1. `POST https://meterplan.com/api/v1/request-smt-data` starts a pull and
       waits up to `waitSeconds` (default 20). Most pulls finish in about 20
       seconds and return `status: complete` in the same response.
    2. If it returns `status: pending`, call
       `POST https://meterplan.com/api/v1/get-smt-data` with the `requestId`
       after `checkAfterSeconds`.

    Completed pulls download as files from
    `GET https://meterplan.com/api/v1/smt-data/{requestId}/export`.

    The same tools (`request_smt_data`, `get_smt_data`) are available over MCP
    inside the Texas Electricity app at `https://mcp.meterplan.com/mcp`, and are listed in
    Meter's OpenAPI document, MCP discovery manifest, and `/llms.txt`.

    Data access through SMT is legal customer meter-data access. Only request
    data for a meter you are authorized to access: your own, or a customer's
    with their permission. No API key is required.
  contact:
    name: Meter Energy
    url: https://meterplan.com
    email: tyler@meterplan.com
  termsOfService: https://meterplan.com/terms

servers:
  - url: https://meterplan.com
    description: Production

paths:
  /api/v1/request-smt-data:
    post:
      operationId: requestSmtData
      summary: Start a Smart Meter Texas pull
      description: |
        Start (or reuse) a Smart Meter Texas pull for one meter. Provide
        `esiId` or `address`, plus `meterNumber` and `currentRetailer`.

        A pull completed for the same ESI ID + meter number + provider in the
        last 24 hours is returned (`reused: true`) instead of starting a new
        one; a pull already in progress is joined. Repeating a combination
        Smart Meter Texas rejected in the last 5 minutes returns 422
        `duplicate_failed_combo`.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/RequestSmtDataRequest"
            examples:
              byEsiId:
                summary: ESI ID + meter number
                value:
                  esiId: "10443720012345678"
                  meterNumber: "119026839"
                  currentRetailer: "TXU Energy"
              byAddress:
                summary: Service address
                value:
                  address: "123 Main St, Dallas, TX 75201"
                  meterNumber: "119026839"
                  currentRetailer: "Reliant Energy"
                  waitSeconds: 30
      responses:
        "200":
          description: Pull complete, pending, or failed after it started (see `status`)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SmtDataResult"
        "400":
          $ref: "#/components/responses/InvalidInput"
        "422":
          $ref: "#/components/responses/ToolError"
        "500":
          $ref: "#/components/responses/InternalError"

  /api/v1/get-smt-data:
    post:
      operationId: getSmtData
      summary: Check on or fetch a Smart Meter Texas pull
      description: |
        Read a pull started with `request-smt-data` by its `requestId`.
        Read-only: never starts a new Smart Meter Texas request.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/GetSmtDataRequest"
            examples:
              status:
                summary: Check status
                value:
                  requestId: "7a0f1f22-7cb4-4ef2-bc49-2aa3c6df4f5f"
              withIntervals:
                summary: Last 3 months with raw intervals
                value:
                  requestId: "7a0f1f22-7cb4-4ef2-bc49-2aa3c6df4f5f"
                  includeIntervals: true
                  months: 3
      responses:
        "200":
          description: Current state of the pull (see `status`)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SmtDataResult"
        "400":
          $ref: "#/components/responses/InvalidInput"
        "422":
          $ref: "#/components/responses/ToolError"
        "500":
          $ref: "#/components/responses/InternalError"

  /api/v1/smt-data/{requestId}/export:
    get:
      operationId: exportSmtData
      summary: Download a completed pull as a file
      description: |
        Returns the full year of readings as an attachment. The `requestId`
        is the only credential, so treat export URLs like the data itself.
      parameters:
        - name: requestId
          in: path
          required: true
          schema:
            type: string
            format: uuid
        - name: format
          in: query
          required: false
          schema:
            type: string
            enum: [csv, aurora, opensolar, solargraf]
            default: csv
          description: |
            `csv`: DateTime, Consumption_kWh, Generation_kWh.
            `aurora`: one consumption value per line, for Aurora Solar's paste-in box.
            `opensolar`: OpenSolar CSV import.
            `solargraf`: Solargraf CSV import.
      responses:
        "200":
          description: File download
          headers:
            Content-Disposition:
              schema:
                type: string
              example: attachment; filename="smt-10443720012345678-aurora.txt"
          content:
            text/csv:
              schema:
                type: string
            text/plain:
              schema:
                type: string
        "400":
          description: Invalid requestId or format (`invalid_request_id`, `invalid_format`)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ExportError"
        "404":
          description: No pull for that requestId (`not_found`), or no readings (`no_data`)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ExportError"
        "409":
          description: Pull not complete yet (`not_ready`)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ExportError"

components:
  responses:
    InvalidInput:
      description: Request body failed schema validation
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
                enum: [invalid_json, invalid_input]
              message:
                type: string
              issues:
                type: array
                items:
                  type: object
    ToolError:
      description: Well-formed request the tool could not complete (bad ESI ID, unknown provider, rejected combination, ...)
      content:
        application/json:
          schema:
            type: object
            required: [error, error_code, message]
            properties:
              error:
                type: string
                const: tool_error
              error_code:
                type: [string, "null"]
                description: |
                  One of `validation_missing_fields`, `validation_esi_id`,
                  `validation_meter_number`, `smt_agreement_failed`,
                  `smt_service_error`, `smt_proxy_error`, `database_error`,
                  `duplicate_failed_combo`, `not_found`.
              message:
                type: string
                description: What went wrong and what to fix, safe to show the user.
    InternalError:
      description: Unexpected server error
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
                enum: [internal_error, invalid_output]
              message:
                type: string

  schemas:
    RequestSmtDataRequest:
      type: object
      required: [meterNumber, currentRetailer]
      properties:
        esiId:
          type: string
          description: ESI ID from the bill, 17 or 22 digits (spaces and dashes are fine). Provide this or `address`.
          example: "10443720012345678"
        address:
          type: string
          description: Service address (street, city, ZIP), used to look up the ESI ID. Provide this or `esiId`.
          example: "123 Main St, Dallas, TX 75201"
        meterNumber:
          type: string
          description: Meter number from the bill, 8 to 12 characters. Not the serial printed on the meter.
          example: "119026839"
        currentRetailer:
          type: string
          description: Current electricity provider as named on the bill, or its 5-digit PUCT number.
          example: "TXU Energy"
        waitSeconds:
          type: integer
          minimum: 0
          maximum: 45
          default: 20
          description: How long to wait for Smart Meter Texas before returning `pending`.
      anyOf:
        - required: [esiId]
        - required: [address]

    GetSmtDataRequest:
      type: object
      required: [requestId]
      properties:
        requestId:
          type: string
          format: uuid
        includeIntervals:
          type: boolean
          default: false
          description: Include raw 15-minute readings (the most recent 3,000).
        months:
          type: integer
          minimum: 1
          maximum: 12
          description: Limit returned data to the most recent N calendar months.

    SmtDataResult:
      type: object
      required:
        - status
        - requestId
        - reused
        - step
        - esiId
        - utility
        - serviceAddress
        - dataStart
        - dataEnd
        - readingCount
        - monthlyAggregates
        - avgMonthlyImportKwh
        - avgMonthlyExportKwh
        - peakDemandKw
        - hasSolarExports
        - summary
      properties:
        status:
          type: string
          enum: [pending, complete, error]
        requestId:
          type: string
          format: uuid
        reused:
          type: boolean
          description: True when returned from an earlier pull (last 24 hours) or one already in progress.
        step:
          type: string
        checkAfterSeconds:
          type: integer
          description: Present when `pending`.
        esiId:
          type: [string, "null"]
        utility:
          type: [string, "null"]
          example: Oncor
        serviceAddress:
          type: [string, "null"]
        dataStart:
          type: [string, "null"]
          description: First reading, local Central Time (YYYY-MM-DDTHH:MM:00).
        dataEnd:
          type: [string, "null"]
          description: Last reading, local Central Time (YYYY-MM-DDTHH:MM:00).
        readingCount:
          type: integer
        monthlyAggregates:
          type: array
          items:
            $ref: "#/components/schemas/MonthlyAggregate"
        avgMonthlyImportKwh:
          type: [number, "null"]
        avgMonthlyExportKwh:
          type: [number, "null"]
        peakDemandKw:
          type: [number, "null"]
        hasSolarExports:
          type: [boolean, "null"]
        intervals:
          type: array
          description: Only with `includeIntervals`; the most recent 3,000 readings at most.
          items:
            $ref: "#/components/schemas/IntervalReading"
        intervalsTruncated:
          type: boolean
        exports:
          type: object
          description: Download links, present when `complete`.
          properties:
            csv:
              type: string
              format: uri
            aurora:
              type: string
              format: uri
            opensolar:
              type: string
              format: uri
            solargraf:
              type: string
              format: uri
        errorCode:
          type: string
          description: Present when `error`, for example `smt_agreement_failed`, `smt_email_not_found`, or `no_data`.
        errorMessage:
          type: string
        summary:
          type: string

    IntervalReading:
      type: object
      properties:
        timestamp:
          type: string
          description: Interval start, local Central Time (YYYY-MM-DDTHH:MM:00).
        importKwh:
          type: number
        exportKwh:
          type: number

    MonthlyAggregate:
      type: object
      properties:
        month:
          type: string
          example: "2026-09"
        totalImportsKwh:
          type: number
        totalExportsKwh:
          type: number
        netKwh:
          type: number
        peakDemandKw:
          type: number
        daysOfData:
          type: integer

    ExportError:
      type: object
      properties:
        error:
          type: string
        message:
          type: string
