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

# Approve a timesheet

> Approve once the timesheet referenced by its ID, and any timesheets before it pending approval belonging to the same timesheet owner.

For example, if timesheets of `ownerid=123` of April 2024 (`id=1`), May 2024 (`id=2`), and June 2024 (`id=3`) are pending approval, and you approve the timesheet `id=2` : both April 2024 and May 2024 timesheets will be approved once, and the June 2024 timesheet will be untouched.

Approbation can only be performed with a `pending` status, and it only performs a single approbation step for each timesheet. If a timesheet require several manual approbation steps, the endpoint must be called several times.

<Info>
  If you want to edit the original Transfer, send a new Transfer with the new duration. 
  To cancel a transfer, send a Transfer with a duration of `PT0S`. To keep the same 
  original transfer, send an empty array.
</Info>



## OpenAPI

````yaml /openapi-specs/timmi-timesheet.yaml post /timmi-timesheet/api/timesheets/{id}/approve
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/api/timesheets/{id}/approve:
    parameters:
      - $ref: '#/components/parameters/Authorization'
      - schema:
          type: integer
        name: id
        in: path
        required: true
        description: timesheet id
    post:
      tags:
        - Workflow
      summary: Approve a timesheet
      description: >-
        Approve once the timesheet referenced by its ID, and any timesheets
        before it pending approval belonging to the same timesheet owner.


        For example, if timesheets of `ownerid=123` of April 2024 (`id=1`), May
        2024 (`id=2`), and June 2024 (`id=3`) are pending approval, and you
        approve the timesheet `id=2` : both April 2024 and May 2024 timesheets
        will be approved once, and the June 2024 timesheet will be untouched.


        Approbation can only be performed with a `pending` status, and it only
        performs a single approbation step for each timesheet. If a timesheet
        require several manual approbation steps, the endpoint must be called
        several times.


        <Info>
          If you want to edit the original Transfer, send a new Transfer with the new duration. 
          To cancel a transfer, send a Transfer with a duration of `PT0S`. To keep the same 
          original transfer, send an empty array.
        </Info>
      operationId: post-timmi-timesheet-api-timesheet-approve
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                transfers:
                  type: array
                  description: >-
                    If you want to edit the original Transfer, send a new
                    Transfer with the new duration. To cancel a transfer, send a
                    Transfer with a duration of `PT0S`. To keep the same
                    original transfer, send an empty array.
                  items:
                    $ref: '#/components/schemas/Transfer.V4'
            examples: {}
          application/xml:
            schema:
              type: object
              properties:
                comment:
                  type: string
          multipart/form-data:
            schema:
              type: object
              properties: {}
        description: ''
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/WorkflowItem'
              examples: {}
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                type: object
              examples: {}
            application/xml:
              schema:
                type: object
                properties: {}
            multipart/form-data:
              schema:
                type: object
                properties: {}
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                type: object
              examples: {}
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
  schemas:
    Transfer.V4:
      title: Transfer v4
      type: object
      description: >-
        Define the amount to be transferred from the debited account to the
        credited account of referenced transferAuthorization.


        Two Timesheet accounts can be linked with a transfer authorization,
        allowing upon timesheet submission or approval workflow steps to adjust
        a certain duration amount from the to-be-debited account to the
        to-be-credited account.


        Such transfer authorization must be setup at the statute level. 
      properties:
        transferAuthorizationId:
          type: integer
          minimum: 1
          description: Unique identifier of the transfer authorization.
        amount:
          $ref: '#/components/schemas/Duration'
          description: >-
            Duration to be transferred from the debited account to the credited
            account.
        comment:
          type: string
          description: >-
            A comment to add business context to the transfer action. Visible on
            the Lucca Timesheet user interface.
    WorkflowItem:
      title: WorkflowItem
      type: object
      description: >-
        A WorkflowItem is an individual workflow action performed by a user.


        The expectedNextActor object is a User. [See API
        reference.](reference/Directory-v3.yaml/components/schemas/User)
      properties:
        id:
          type: integer
          description: Unique id of the WorkflowItem.
        exceptionMessage:
          type: string
          description: Any human readable error message.
        startsOn:
          type: string
          pattern: yyyy-MM-dd
          format: date
          description: >-
            The Timesheet the WorkflowItem is related on starting date
            (included).
        endsOn:
          type: string
          format: date
          pattern: yyyy-MM-dd
          description: The Timesheet the WorkflowItem is related on ending date (excluded).
        expectedNextActor:
          type: object
          description: A Directory 'User'. See API reference for up-to-date attributes.
        status:
          type: string
          description: >-
            - "success" for a succesfull workflow operation.

            - "error" if any error was met, and therefore an excetion message is
            set.

            - "noAction" if the workflow operation was not performed. 
    Duration:
      title: Duration
      type: object
      properties:
        iso:
          type: string
          format: duration
          description: ISO-8601 formatted duration.
          example: PT7H30M
        unit:
          type: string
          enum:
            - day
            - hour
      description: ''

````