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

# TimeEntries update service

> ## Before using this service

This service is aimed at updating a given user TimeEntries easily, as it automatically detects and applies changes needed to transform whatever TimeEntries might currently exist to what you send it. It create, edit, or delete TimeEntries. **An algorithm tries to match and update any existing TimeEntries, but it might wipe clean TimeEntries before adding new ones.**

There are different ways to update TimeEntries. Please see [this guide](../docs/Use-cases/Timmi%20Timesheet/Update-time-entries.md) for a guide on how to update TimeEntries the right way depending on your use case.

## How to use

It will create, edit, or delete existing TimeEntries for a given period and owner to match the TimeEntries of the request body.

The request body is an array of 'simplified' TimeEntries, [please see the API reference for a TimeEntry model for additional information and main validation rules](reference/Timmi-Timesheet-v3.yaml/components/schemas/TimeEntry).

Here the TimeEntry `id` field is optional as the matching algorithm does not take it into account.



## OpenAPI

````yaml /openapi-specs/timmi-timesheet.yaml put /timmi-timesheet/services/time-entries
openapi: 3.1.0
info:
  title: Lucca Timesheet API (not v3)
  version: '1.0'
  description: The latest documentation for Lucca Timesheet API.
  contact:
    name: API Support
    url: https://support.lucca.fr
    email: contact@luccasoftware.com
  license:
    name: Unlicensed
    url: https://www.luccasoftware.com
servers:
  - url: https://{host}
    description: Your Lucca account URL.
    variables:
      host:
        default: example.ilucca.net
        description: >-
          The URL of your dedicated Lucca account: `{account}.{env}.{region}`.


          Account reflects your company name. Env indicates the environment.
          Region depends on your server location.


          **Please, use your test or sandbox environments (and not your
          production env.) for testing purposes.**


          **Please, use your test or sandbox environments (and not your
          production env.) for testing purposes.**


          Environments:

          - `ilucca`: production environment for customers.

          - `ilucca-test`: test environment for customers.

          - `ilucca-demo`: demo environment for prospects.


          Regions:

          - `.ch` for Swiss located accounts.

          - `.net` for the others.


          Regarding sandboxes, the pattern differs:
          `https://{account}-{sandboxName}.sandbox.{server}.luccasoftware.com`,
          where:

          - `{sandboxName}` is automatically generated upon creation.

          - `{server}` may be "eu1", "eu2" or "ch1".
security: []
tags:
  - name: TimeEntries
    description: TimeEntries are the actual working hours observed by a user.
  - name: Workflow
    description: All actions regarding the approval process of timesheets.
paths:
  /timmi-timesheet/services/time-entries:
    parameters:
      - $ref: '#/components/parameters/Authorization'
    put:
      tags:
        - TimeEntries
      summary: TimeEntries update service
      description: >-
        ## Before using this service


        This service is aimed at updating a given user TimeEntries easily, as it
        automatically detects and applies changes needed to transform whatever
        TimeEntries might currently exist to what you send it. It create, edit,
        or delete TimeEntries. **An algorithm tries to match and update any
        existing TimeEntries, but it might wipe clean TimeEntries before adding
        new ones.**


        There are different ways to update TimeEntries. Please see [this
        guide](../docs/Use-cases/Timmi%20Timesheet/Update-time-entries.md) for a
        guide on how to update TimeEntries the right way depending on your use
        case.


        ## How to use


        It will create, edit, or delete existing TimeEntries for a given period
        and owner to match the TimeEntries of the request body.


        The request body is an array of 'simplified' TimeEntries, [please see
        the API reference for a TimeEntry model for additional information and
        main validation
        rules](reference/Timmi-Timesheet-v3.yaml/components/schemas/TimeEntry).


        Here the TimeEntry `id` field is optional as the matching algorithm does
        not take it into account.
      operationId: put-timmi-timesheet-services-time-entries
      parameters:
        - schema:
            type: string
            format: date
            pattern: yyyy-MM-dd
          in: query
          name: startsOn
          required: true
          description: >-
            First day (included) of the period you want to update with provided
            TimeEntries.
        - schema:
            type: string
            format: date
            pattern: yyyy-MM-dd
          in: query
          name: endsOn
          required: true
          description: >-
            Last day (included) of the period you want to update with provided
            TimeEntries.
        - schema:
            type: integer
          in: query
          name: ownerId
          required: true
          description: Unique identifier of the TimeEntries owner.
      requestBody:
        content:
          application/json:
            schema:
              type: array
              items:
                type: object
                properties:
                  owner:
                    type: object
                    properties:
                      id:
                        type: integer
                        example: 123
                        description: Unique identifier of the TimeEntries owner.
                  startsAt:
                    type: string
                    format: date-time
                    example: '2023-10-12T12:00:00'
                    description: >-
                      The timeEntry start date and time. Please do NOT send any
                      offset/timezone information ("Z", "+01:00", etc...).
                  unit:
                    type: string
                    enum:
                      - day
                      - duration
                      - time
                    description: |-
                      Unit in which the TimeEntry has been entered.
                      - day: share a of a 24-hour day (e.g. "1/2 day")
                      - duration: number of hours (e.g. "8h15min")
                      - time: accurate time of a day (e.g. "23:45:00")
                  duration:
                    type: object
                    properties:
                      iso:
                        type: string
                        format: duration
                        description: ISO-8601 formatted duration of the TimeEntry.
                        example: PT15M
                  axisSections:
                    type:
                      - array
                      - 'null'
                    description: >-
                      The activities this TimeEntry should be associated with.
                      When not in activity mode, send an empty array, or do not
                      serialize this property.
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                          example: 123
                  timeType:
                    type:
                      - object
                      - 'null'
                    description: >-
                      Optional reference of a configured Time Type. To use only
                      if the timesheet is set up to use Time Types. Null
                      otherwise.
                    properties:
                      id:
                        type: integer
                  timeSource:
                    type: string
                    enum:
                      - manual
                      - import
                      - timer
                    default: manual
                    description: >-
                      Attribute used to identify last modification source :

                      - manual : Manually created or edited (default).

                      - import : Imported from external sources. Is read-only on
                      Lucca Timesheet user interfaces only if Timesheet
                      regulation is in following modes : attendance schedule
                      with clock-in clock-out, and activity-schedule

                      - timer : Entered with Lucca Timesheet clock-in clock-out
                      tool. 
                  comment:
                    type:
                      - string
                      - 'null'
                    description: >-
                      A comment on the TimeEntry, visible on Lucca Timesheet
                      user interface.
                required:
                  - owner
                  - startsAt
                  - unit
                  - duration
            examples:
              Example 1:
                value:
                  - owner:
                      id: 123
                    startsAt: '2024-05-06T00:00:00'
                    duration:
                      iso: PT4H
                    comment: null
                    timeSource: manual
                    unit: duration
                    timeType: null
                    axisSections:
                      - id: 41
                      - id: 127
                      - id: 285
                      - id: 319
                  - owner:
                      id: 123
                    startsAt: '2024-05-06T00:00:00'
                    duration:
                      iso: PT2H
                    comment: null
                    timeSource: manual
                    unit: duration
                    timeType: null
                    axisSections:
                      - id: 41
                      - id: 290
                      - id: 309
                      - id: 311
                  - owner:
                      id: 123
                    startsAt: '2024-05-07T00:00:00'
                    duration:
                      iso: PT7H20M
                    comment: This is a comment
                    timeSource: manual
                    unit: duration
                    timeType: null
                    axisSections:
                      - id: 41
                      - id: 127
                      - id: 285
                      - id: 319
      responses:
        '200':
          description: OK
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                type: object
                properties:
                  title:
                    type: string
                    default: One or more validation errors occured.
                  status:
                    type: integer
                    default: 400
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
              examples:
                Example 1:
                  value:
                    title: One or more validation errors occurred.
                    status: 400
                    errors:
                      $[0]:
                        - >-
                          You cannot create a time entry that spans over two
                          days.
                      $[0].AxisSections:
                        - >-
                          AxisSections must all be active and consistent with
                          the tree structure of their sections
                      $[2]:
                        - >-
                          You cannot create a time entry with a duration that
                          exceeds 24h.
        '500':
          description: Internal Server Error
components:
  parameters:
    Authorization:
      name: Authorization
      required: true
      description: 'API key. Value must be formatted like so: `lucca application={api_key}`.'
      in: header
      schema:
        type: string

````