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

# Applica una programmazione a tutte le posizioni di un cluster

> Applica lo stesso `LimitProfileRequest` a ogni location del cluster
(equivalente a chiamare `POST /locations/{locationId}/schedules` per
ciascun membro).




## OpenAPI

````yaml /api-reference/energy-management/openapi.it.yaml POST /clusters/{clusterId}/schedules
openapi: 3.1.0
info:
  title: RiDERgy Energy Management API
  version: '1.0'
  license:
    name: Proprietary
    identifier: LicenseRef-Proprietary
  description: |
    Controllo programmatico dei limiti di potenza di ricarica su location,
    singoli charger, organizzazioni e cluster cross-location.

    ## Autenticazione
    Ogni endpoint, eccetto `GET /health`, richiede un header `x-api-key`. La
    chiave determina il tenant — non viene mai letta dal corpo della richiesta
    né da altri header, quindi una chiave di un tenant non può accedere ai
    dati di un altro tenant.

    Il tuo tenant deve avere abilitata la funzionalità Energy Management API,
    altrimenti le richieste falliscono con `403 FEATURE_NOT_ENABLED`. Contatta
    RiDERgy per abilitarla.

    ## Modello di priorità
    I limiti di location e charger sono controllati tramite **profili con
    finestre di priorità**:

    - Le priorità vanno da **0 (più bassa) a 10 (più alta)**, in stile stack
      OCPP.
    - Un target (location o connettore del charger) può avere fino a 11
      profili, uno per livello di priorità, ciascuno con la propria finestra
      `[startTime, endTime)`.
    - In ogni momento, il **limite effettivo** è il `limitKw` del profilo a
      priorità più alta la cui finestra è attualmente attiva.
    - Se nessun profilo è attivo, una location ricade sul proprio
      `permanentLimitKw`.
    - L'invio di un profilo a una priorità che ne ha già uno per quel target
      lo **sostituisce**.
    - I profili vengono applicati e ripristinati automaticamente in base a
      `startTime`/`endTime` — una volta creato un profilo non sono necessarie
      ulteriori chiamate API. I record dei profili non vengono mai eliminati,
      quindi la cronologia rimane interrogabile.

    ## Errori
    Tutti gli errori condividono questa struttura:

    ```json
    {
      "error": {
        "code": "LOCATION_NOT_FOUND",
        "message": "Location 123 was not found for the provided tenant",
        "requestId": "b1f6e6b0-..."
      }
    }
    ```
servers:
  - url: https://api.ridergy.com/v1
    description: Production
security:
  - ApiKeyAuth: []
tags:
  - name: Health
    description: Controllo dello stato del servizio non autenticato.
  - name: Locations
    description: >-
      Leggi e imposta i limiti di potenza e i profili di priorità a livello di
      location.
  - name: Chargers
    description: >-
      Blocca singoli connettori del charger su un limite di potenza fisso per
      una finestra temporale.
  - name: Organizations
    description: >-
      Profili di cap a livello di tenant (solo registrati — l'enforcement non è
      ancora attivo).
  - name: Clusters
    description: >-
      Raggruppa location sotto un cap kW condiviso e applica schedulazioni su di
      esse.
paths:
  /clusters/{clusterId}/schedules:
    post:
      tags:
        - Clusters
      summary: Apply a schedule to every location in a cluster
      description: |
        Applica lo stesso `LimitProfileRequest` a ogni location del cluster
        (equivalente a chiamare `POST /locations/{locationId}/schedules` per
        ciascun membro).
      operationId: applyClusterSchedule
      parameters:
        - $ref: '#/components/parameters/ClusterId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LimitProfileRequest'
            examples:
              example:
                value:
                  startTime: '2026-06-12T08:00:00Z'
                  endTime: '2026-06-12T18:00:00Z'
                  limitKw: 50
                  priority: 5
      responses:
        '200':
          description: Schedulazione applicata ad almeno una location
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ClusterScheduleResponse'
        '400':
          description: >-
            Il cluster è inattivo, vuoto, oppure il corpo della richiesta non è
            valido
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                clusterInactive:
                  summary: CLUSTER_INACTIVE
                  value:
                    error:
                      code: CLUSTER_INACTIVE
                      message: Cluster clst_20260612_a1b2c3d4 is inactive
                      requestId: b1f6e6b0-1234-4abc-9def-000000000000
                clusterEmpty:
                  summary: CLUSTER_EMPTY
                  value:
                    error:
                      code: CLUSTER_EMPTY
                      message: Cluster has no locations
                      requestId: b1f6e6b0-1234-4abc-9def-000000000000
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/FeatureNotEnabled'
        '404':
          $ref: '#/components/responses/ClusterNotFound'
components:
  parameters:
    ClusterId:
      name: clusterId
      in: path
      required: true
      schema:
        type: string
      example: clst_20260612_a1b2c3d4
  schemas:
    LimitProfileRequest:
      type: object
      required:
        - startTime
        - endTime
        - limitKw
      properties:
        startTime:
          type: string
          format: date-time
          description: Timestamp UTC ISO-8601. Obbligatorio.
          example: '2026-06-12T08:00:00Z'
        endTime:
          type: string
          format: date-time
          description: >-
            Timestamp UTC ISO-8601. Deve essere successivo a `startTime` e nel
            futuro. Obbligatorio.
          example: '2026-06-12T18:00:00Z'
        limitKw:
          type: number
          format: float
          exclusiveMinimum: 0
          description: Limite di potenza in kW. Deve essere maggiore di 0. Obbligatorio.
          example: 50
        priority:
          type: integer
          minimum: 0
          maximum: 10
          default: 0
          description: |
            Livello di priorità in stile stack OCPP, da 0 (più bassa) a 10
            (più alta). L'invio di un profilo a una priorità già esistente
            per questo target lo sostituisce.
          example: 5
    ClusterScheduleResponse:
      type: object
      properties:
        clusterId:
          type: string
          example: clst_20260612_a1b2c3d4
        applied:
          type: array
          items:
            allOf:
              - type: object
                properties:
                  locationId:
                    type: string
              - $ref: '#/components/schemas/LocationScheduleResponse'
        errors:
          type: array
          items:
            type: object
            properties:
              locationId:
                type: string
              error:
                $ref: '#/components/schemas/Error'
        totalLocations:
          type: integer
          example: 2
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              example: LOCATION_NOT_FOUND
            message:
              type: string
              example: Location 123 was not found for the provided tenant
            requestId:
              type: string
              format: uuid
    LocationScheduleResponse:
      type: object
      properties:
        locationId:
          type: string
          example: '3632155'
        priority:
          type: integer
          example: 5
        limitKw:
          type: number
          example: 50
        startTime:
          type: string
          format: date-time
        endTime:
          type: string
          format: date-time
        status:
          $ref: '#/components/schemas/ProfileStatus'
        permanentLimitKw:
          type:
            - number
            - 'null'
          example: 100
        effectiveLimitKw:
          type:
            - number
            - 'null'
          example: 50
    ProfileStatus:
      type: string
      enum:
        - SCHEDULED
        - ACTIVE
        - EXPIRED
  responses:
    Unauthorized:
      description: Chiave API mancante, non valida o scaduta
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            unauthorized:
              value:
                error:
                  code: UNAUTHORIZED
                  message: Invalid or inactive API key
                  requestId: b1f6e6b0-1234-4abc-9def-000000000000
    FeatureNotEnabled:
      description: Il tenant non ha l'Energy Management API abilitata
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            featureNotEnabled:
              value:
                error:
                  code: FEATURE_NOT_ENABLED
                  message: >-
                    The Energy Management API is not enabled for your account.
                    Contact RiDERgy to enable this feature.
                  requestId: b1f6e6b0-1234-4abc-9def-000000000000
    ClusterNotFound:
      description: Cluster non trovato
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            clusterNotFound:
              value:
                error:
                  code: CLUSTER_NOT_FOUND
                  message: Cluster clst_20260612_a1b2c3d4 not found
                  requestId: b1f6e6b0-1234-4abc-9def-000000000000
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        Chiave API per-tenant. Il tenant viene derivato dalla chiave — mai dalla
        richiesta.

````