> ## 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.

# Crear o reemplazar un perfil de límite prioritario de ubicación

> Crea un perfil de límite de potencia con ventana de tiempo para una
ubicación en la prioridad indicada. Si ya existe un perfil en esa
prioridad para esta ubicación, se reemplaza. El límite efectivo se
recalcula inmediatamente y se aplica a la ubicación.




## OpenAPI

````yaml /api-reference/energy-management/openapi.es.yaml POST /locations/{locationId}/schedules
openapi: 3.1.0
info:
  title: RiDERgy Energy Management API
  version: '1.0'
  license:
    name: Proprietary
    identifier: LicenseRef-Proprietary
  description: |
    Control programático de los límites de potencia de carga en ubicaciones,
    cargadores individuales, organizaciones y clústeres entre ubicaciones.

    ## Autenticación
    Todos los endpoints excepto `GET /health` requieren una cabecera
    `x-api-key`. La clave determina tu tenant — nunca se lee del cuerpo de la
    solicitud ni de ninguna otra cabecera, por lo que una clave de un tenant no
    puede acceder a los datos de otro tenant.

    Tu tenant debe tener habilitada la función Energy Management API; de lo
    contrario, las solicitudes fallarán con `403 FEATURE_NOT_ENABLED`. Contacta
    con RiDERgy para habilitarla.

    ## Modelo de prioridad
    Los límites de ubicación y de cargador se controlan mediante **perfiles con
    ventanas de prioridad**:

    - Las prioridades van de **0 (la más baja) a 10 (la más alta)**, al estilo
      de la pila OCPP.
    - Un objetivo (ubicación o conector de cargador) puede tener hasta 11
      perfiles, uno por nivel de prioridad, cada uno con su propia ventana
      `[startTime, endTime)`.
    - En cualquier momento, el **límite efectivo** es el `limitKw` del perfil
      de mayor prioridad cuya ventana esté actualmente activa.
    - Si no hay ningún perfil activo, una ubicación recurre a su
      `permanentLimitKw`.
    - Enviar un perfil con una prioridad que ya tiene uno para ese objetivo lo
      **reemplaza**.
    - Los perfiles se aplican y revierten automáticamente en su
      `startTime`/`endTime` — no se necesitan más llamadas a la API una vez
      creado un perfil. Los registros de perfiles nunca se eliminan, por lo que
      el historial sigue siendo consultable.

    ## Errores
    Todos los errores comparten esta forma:

    ```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: Comprobación de estado del servicio sin autenticación.
  - name: Locations
    description: >-
      Consultar y establecer límites de potencia y perfiles de prioridad a nivel
      de ubicación.
  - name: Chargers
    description: >-
      Bloquear conectores de cargadores individuales a un límite de potencia
      fijo durante una ventana de tiempo.
  - name: Organizations
    description: >-
      Perfiles de límite a nivel de organización (solo se registran; la
      aplicación aún no está activa).
  - name: Clusters
    description: >-
      Agrupar ubicaciones bajo un límite de kW compartido y aplicar horarios
      entre ellas.
paths:
  /locations/{locationId}/schedules:
    post:
      tags:
        - Locations
      summary: Create or replace a location priority limit profile
      description: |
        Crea un perfil de límite de potencia con ventana de tiempo para una
        ubicación en la prioridad indicada. Si ya existe un perfil en esa
        prioridad para esta ubicación, se reemplaza. El límite efectivo se
        recalcula inmediatamente y se aplica a la ubicación.
      operationId: createLocationSchedule
      parameters:
        - $ref: '#/components/parameters/LocationId'
      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: Perfil creado/reemplazado
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LocationScheduleResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/FeatureNotEnabled'
        '404':
          description: Ubicación no encontrada
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                locationNotFound:
                  value:
                    error:
                      code: LOCATION_NOT_FOUND
                      message: Location 123 was not found for the provided tenant
                      requestId: b1f6e6b0-1234-4abc-9def-000000000000
components:
  parameters:
    LocationId:
      name: locationId
      in: path
      required: true
      schema:
        type: string
      example: '3632155'
  schemas:
    LimitProfileRequest:
      type: object
      required:
        - startTime
        - endTime
        - limitKw
      properties:
        startTime:
          type: string
          format: date-time
          description: Marca de tiempo UTC en formato ISO-8601. Obligatorio.
          example: '2026-06-12T08:00:00Z'
        endTime:
          type: string
          format: date-time
          description: >-
            Marca de tiempo UTC en formato ISO-8601. Debe ser posterior a
            `startTime` y futura. Obligatorio.
          example: '2026-06-12T18:00:00Z'
        limitKw:
          type: number
          format: float
          exclusiveMinimum: 0
          description: Límite de potencia en kW. Debe ser mayor que 0. Obligatorio.
          example: 50
        priority:
          type: integer
          minimum: 0
          maximum: 10
          default: 0
          description: |
            Nivel de prioridad al estilo de la pila OCPP, de 0 (la más baja) a
            10 (la más alta). Enviar un perfil con una prioridad que ya existe
            para este objetivo lo reemplaza.
          example: 5
    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
    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
    ProfileStatus:
      type: string
      enum:
        - SCHEDULED
        - ACTIVE
        - EXPIRED
  responses:
    BadRequest:
      description: Cuerpo de la solicitud no válido o el objetivo está inactivo
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            invalidBody:
              summary: INVALID_REQUEST_BODY
              value:
                error:
                  code: INVALID_REQUEST_BODY
                  message: limitKw must be a positive number
                  requestId: b1f6e6b0-1234-4abc-9def-000000000000
            targetInactive:
              summary: TARGET_INACTIVE
              value:
                error:
                  code: TARGET_INACTIVE
                  message: Location 123 is not active
                  requestId: b1f6e6b0-1234-4abc-9def-000000000000
    Unauthorized:
      description: Clave de API ausente, no válida o expirada
      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: El tenant no tiene habilitada la Energy Management API
      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
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        Clave de API por tenant. El tenant se deriva de la clave — nunca de la
        solicitud.

````