> ## Documentation Index
> Fetch the complete documentation index at: https://developer.energy-hub.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Submit command for vehicle charging schedule

> This endpoint creates an asynchronously executed command request to schedule charging.

<Info>
  Charging Schedules are only supported for **BMW**, **MINI** and **Tesla**
  vehicles.
</Info>


## OpenAPI

````yaml post /v1.0.0/users/{userId}/vehicles/{vehicleId}/commands/charging-schedule
openapi: 3.0.1
info:
  description: A service used for vehicles
  title: vehicle-service
  version: 1.0.0
servers:
  - description: Generated server url
    url: https://api.energy-hub.io
security: []
paths:
  /v1.0.0/users/{userId}/vehicles/{vehicleId}/commands/charging-schedule:
    post:
      tags:
        - User Vehicle Controller
      summary: Submit command for vehicle charging schedule
      description: >-
        This endpoint creates an asynchronously executed command request to
        schedule charging.
      operationId: setSchedule_1
      parameters:
        - schema:
            format: uuid
            type: string
          in: path
          name: vehicleId
          description: Vehicle ID
          required: true
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChargingScheduleRequest'
        required: true
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubmitCommandResponse'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationErrorMessageDto'
              examples:
                BAD_REQUEST:
                  $ref: '#/components/examples/BAD_REQUEST'
                SCHEDULE_DAYS_NOT_SUPPORTED:
                  $ref: '#/components/examples/SCHEDULE_DAYS_NOT_SUPPORTED'
                ONLY_ONE_SCHEDULE_ALLOWED:
                  $ref: '#/components/examples/ONLY_ONE_SCHEDULE_ALLOWED'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessageDto'
              examples:
                UNAUTHORIZED:
                  $ref: '#/components/examples/UNAUTHORIZED'
        '404':
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessageDto'
              examples:
                VEHICLE_NOT_FOUND:
                  $ref: '#/components/examples/VEHICLE_NOT_FOUND'
        '409':
          description: Conflict
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessageDto'
              examples:
                COMMAND_ALREADY_SUBMITTED:
                  $ref: '#/components/examples/COMMAND_ALREADY_SUBMITTED'
                COMMAND_TYPE_NOT_ALLOWED:
                  $ref: '#/components/examples/COMMAND_TYPE_NOT_ALLOWED'
        '501':
          description: Not implemented
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessageDto'
              examples:
                COMMAND_REQUEST_NOT_IMPLEMENTED:
                  $ref: '#/components/examples/COMMAND_REQUEST_NOT_IMPLEMENTED'
      security:
        - API_Key: []
components:
  schemas:
    ChargingScheduleRequest:
      description: New schedule be to set. UTC expected.
      type: object
      required:
        - schedules
      properties:
        schedules:
          description: The list of schedule events.
          type: array
          items:
            $ref: '#/components/schemas/ChargingScheduleEvent'
    SubmitCommandResponse:
      type: object
      required:
        - createdAt
        - deviceId
        - id
        - state
        - type
        - userId
      properties:
        createdAt:
          format: date-time
          description: The timestamp when command is created.
          type: string
        id:
          format: uuid
          description: The ID of the command.
          type: string
        state:
          $ref: '#/components/schemas/CommandState'
        type:
          description: The name of the command type to execute.
          type: string
          enum:
            - CHARGING_START
            - CHARGING_STOP
            - SET_CHARGING_CURRENT
            - SET_CHARGING_SCHEDULE
        userId:
          description: The ID of the user.
          type: string
          example: 896f9d5a-b618-48a2-98ae-957059bf1bc9
        deviceId:
          format: uuid
          description: The ID of the vehicle.
          type: string
    ValidationErrorMessageDto:
      allOf:
        - $ref: '#/components/schemas/ErrorMessageDto'
        - type: object
          properties:
            errorCode:
              description: The error code
              type: string
              example: EXAMPLE_ERROR_CODE
            validationErrors:
              description: List of validation errors
              type: array
              items:
                $ref: '#/components/schemas/ValidationError'
            id:
              format: uuid
              description: The error identifier
              type: string
              example: 7958818d-64d2-4ede-b12b-4786dd2f348b
            message:
              description: The error message
              type: string
              example: Example error message
      type: object
      required:
        - errorCode
        - id
        - message
    ErrorMessageDto:
      type: object
      required:
        - errorCode
        - id
        - message
      properties:
        errorCode:
          description: The error code
          type: string
          example: EXAMPLE_ERROR_CODE
        id:
          format: uuid
          description: The error identifier
          type: string
          example: 7958818d-64d2-4ede-b12b-4786dd2f348b
        message:
          description: The error message
          type: string
          example: Example error message
    ChargingScheduleEvent:
      description: The list of schedule events.
      type: object
      required:
        - end
        - start
      properties:
        chargeRateMax:
          format: int32
          description: Maximum charge rate to use.
          type: integer
          example: 12
        start:
          description: Start time
          type: string
          example: '08:00'
        days:
          uniqueItems: true
          description: >-
            The list of days when schedule is active. If empty or null its for
            every day.
          type: array
          items:
            description: >-
              The list of days when schedule is active. If empty or null its for
              every day.
            type: string
            enum:
              - MONDAY
              - TUESDAY
              - WEDNESDAY
              - THURSDAY
              - FRIDAY
              - SATURDAY
              - SUNDAY
        location:
          $ref: '#/components/schemas/ChargingCoordinate'
        end:
          description: End time
          type: string
          example: '12:00'
        stateOfChargeTarget:
          format: int32
          maximum: 100
          description: Target charge state.
          type: integer
          minimum: 1
          example: 80
        type:
          description: Type of charging.
          type: string
          enum:
            - CHARGE
            - PRECONDITION
            - REDUCED_CHARGING
          example: CHARGE
    CommandState:
      description: |
        The state of the command.
        * `PENDING` - Command is waiting to be executed.
        * `FAILED` - Execution of command has failed.
        * `EXECUTED` - Command has been executed successfully.
      type: string
      enum:
        - PENDING
        - EXECUTED
        - FAILED
    ValidationError:
      type: object
      properties:
        field:
          description: Affected field
          type: string
        message:
          description: Validation message
          type: string
    ChargingCoordinate:
      description: Location of the charging
      type: object
      properties:
        latitude:
          format: double
          description: Latitude
          type: number
          example: 52.2726
        longitude:
          format: double
          description: Longitude
          type: number
          example: 8.0498
  examples:
    BAD_REQUEST:
      value:
        errorCode: BAD_REQUEST
        validationErrors:
          - field: Affected field
            message: Validation message
        id: cae58230-364d-45ca-b67d-08a57653c59f
        message: Bad request
    SCHEDULE_DAYS_NOT_SUPPORTED:
      value:
        errorCode: SCHEDULE_DAYS_NOT_SUPPORTED
        id: cae58230-364d-45ca-b67d-08a57653c59f
        message: '[BMW] Scheduling days not supported'
    ONLY_ONE_SCHEDULE_ALLOWED:
      value:
        errorCode: ONLY_ONE_SCHEDULE_ALLOWED
        id: cae58230-364d-45ca-b67d-08a57653c59f
        message: '[BMW] Only one schedule allowed'
    UNAUTHORIZED:
      value:
        errorCode: UNAUTHORIZED
        id: cae58230-364d-45ca-b67d-08a57653c59f
        message: Unauthorized
    VEHICLE_NOT_FOUND:
      value:
        errorCode: VEHICLE_NOT_FOUND
        id: cae58230-364d-45ca-b67d-08a57653c59f
        message: '[VEHICLE] Requested Vehicle not found'
    COMMAND_ALREADY_SUBMITTED:
      value:
        errorCode: COMMAND_ALREADY_SUBMITTED
        id: cae58230-364d-45ca-b67d-08a57653c59f
        message: '[VEHICLE] Command has already been submitted'
    COMMAND_TYPE_NOT_ALLOWED:
      value:
        errorCode: COMMAND_TYPE_NOT_ALLOWED
        id: cae58230-364d-45ca-b67d-08a57653c59f
        message: '[VEHICLE] Command type for this vehicle is not allowed'
    COMMAND_REQUEST_NOT_IMPLEMENTED:
      value:
        errorCode: COMMAND_REQUEST_NOT_IMPLEMENTED
        id: cae58230-364d-45ca-b67d-08a57653c59f
        message: '[VEHICLE] Submitting command request is not implemented'
  securitySchemes:
    API_Key:
      in: header
      name: X-API-KEY
      description: API key used for authorization and authentication.
      type: apiKey

````