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

# Gets targets for a site

> returns the targets for a siteId



## OpenAPI

````yaml /api-reference/targets.yaml get /v2/sites/{siteId}/targets
openapi: 3.0.3
info:
  title: Targets lifecycle
  description: >
    Target key concepts:

    - A target is applicable for 12 months and spans from the start of the year
    to its end.

    - A target can either be a cost in euros or a consumption in kWh. The value
    of the target can be updated but not its unit type.
  termsOfService: TODO
  contact:
    email: api@datanumia.com
  version: 2.0.0
servers:
  - url: https://api.home.datanumia.com/api
    description: Production Server
security: []
paths:
  /v2/sites/{siteId}/targets:
    get:
      tags:
        - targets
      summary: Gets targets for a site
      description: returns the targets for a siteId
      operationId: getTargets
      parameters:
        - name: siteId
          in: path
          required: true
          schema:
            type: string
          example: d8a9b286-d7c0-493c-9610-403747687023_01
        - name: type
          in: query
          description: fluid type
          required: false
          schema:
            type: array
            enum:
              - ELEC
              - CARBON
        - name: onlyActive
          in: query
          description: >-
            YES or NO (the target is active if the current date is before the
            endDate)
          required: false
          example: 'TRUE'
          schema:
            type: boolean
        - name: onlyLast
          in: query
          description: YES or NO (YES to get only the most recent target)
          required: false
          example: 'FALSE'
          schema:
            type: boolean
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetTargets'
        '400':
          description: |
            Functional Error. Error cases:
            - SITE_NOT_FOUND when the site referenced in the path doesn't exist
            - NO_TARGETS_FOUND when there is no target associated with the site
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                errorCode: SITE_NOT_FOUND
                errorDescription: Unknown site
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseUnauthorized'
        '403':
          description: Forbidden
          content: {}
        '404':
          description: Not Found
          content: {}
        '500':
          description: Server error
          content: {}
      security:
        - Bearer:
            - home:consumption-targets:targets:read
components:
  schemas:
    GetTargets:
      type: object
      properties:
        targets:
          type: array
          items:
            $ref: '#/components/schemas/TargetDTO'
    ErrorResponse:
      required:
        - errorCode
        - errorDescription
      type: object
      properties:
        errorCode:
          description: The error code.
          type: string
          example: SITE_NOT_FOUND
        errorDescription:
          type: string
          description: The error description
          example: Unknown site
      description: ErrorResponse
    ErrorResponseUnauthorized:
      required:
        - errorCode
        - errorDescription
      type: object
      properties:
        errorCode:
          description: The error code.
          type: string
          example: INVALID_AUTHORIZATION_HEADER_VALUE
        errorDescription:
          type: string
          description: The error description
          example: The Authorization header is invalid
      description: ErrorResponse
    TargetDTO:
      type: object
      required:
        - targetId
        - generationTs
        - beginDate
        - endDate
        - type
        - unit
        - targetValue
        - targetValueEquivalent
        - defaultTargetValue
        - defaultTargetValueEquivalent
        - isActive
        - notificationChannels
        - notificationType
        - name
      properties:
        targetId:
          description: Target id
          type: string
          example: 2FD7EADA83E24121C5EC0CFCBBEBCF819E08BDD845163E1C9D451737CC12BCFC
        generationTs:
          description: The generation timestamp for the target
          type: string
          format: date-time
          example: '2021-07-21T22:00:00Z'
        beginDate:
          description: The timestamp at which the target period starts
          type: string
          format: date-time
          example: '2021-12-31T23:00:00Z'
        endDate:
          description: The timestamp at which the target period ends
          type: string
          format: date-time
          example: '2022-12-31T23:00:00Z'
        type:
          description: The fluid type for the target (ELEC or CARBON)
          type: string
          example: ELEC
          enum:
            - ELEC
            - CARBON
        unit:
          description: >-
            The designated unit type for the target, which can be either EURO or
            KWH
          type: string
          example: EURO
          enum:
            - EURO
            - KWH
        targetValue:
          description: The yearly value for the target
          type: integer
          example: 3000
        targetValueEquivalent:
          description: The yearly value for the target, once converted to the other unit
          type: integer
          example: 12000
        defaultTargetValue:
          description: >-
            The yearly default value for the target; the reference value based
            on similar homes or past consumptions
          type: integer
          example: 3300
        defaultTargetValueEquivalent:
          description: >-
            The yearly default value for the target, once converted to the other
            unit
          type: integer
          example: 13200
        isActive:
          description: Flag set to true when the target period is ongoing
          type: boolean
          example: true
        notificationChannels:
          description: |
            The channels used to send notifications (EMAIL, SMS, both or none)
          type: array
          items:
            type: string
          example: []
        notificationType:
          description: >
            The condition that defines whether a notification should be sent or
            not
          type: string
          enum:
            - NONE
            - ON_DIST_INDEX_RECEPTION
            - THRESHOLD_OVERRUN
          example: NONE
        name:
          description: The target's name
          type: string
          example: My target
  securitySchemes:
    Bearer:
      type: http
      scheme: bearer

````