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

# Create Working Time

> Creates a new working time record in your COR instance

Creates a new working time record in your COR instance through the integrations service.

<Warning>
  Working time records **cannot be updated** once created. If you need to modify a record, you must delete it and create a new one.
</Warning>

## Request Body Requirements

<ParamField body="metadata" type="object" required>
  <Expandable title="properties">
    <ParamField body="source" type="string" required>
      Integration source identifier
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="id" type="string" required>
  External working time record ID from your source system
</ParamField>

<ParamField body="user_id" type="string" required>
  External user ID. The user must have been previously created through the integrations API.
</ParamField>

<ParamField body="is_active" type="boolean">
  Whether the record is active (default: true)
</ParamField>

<ParamField body="source" type="string">
  Source system identifier
</ParamField>

<ParamField body="destination" type="string">
  Destination system identifier
</ParamField>

<ParamField body="status" type="string">
  Working time status
</ParamField>

<Note>
  The `companyId` is automatically set from the authenticated user's company context.
</Note>

## Known Errors

* `ValidationError` — Missing required fields
* `UserNotFoundError` — The specified user does not exist in the integration mappings
* `DuplicateExternalIdError` — A working time record with this external ID already exists

<RequestExample>
  ```bash cURL theme={null}
  curl --location 'https://integrations.projectcor.com/v2/integrations/working-time' \
  --header 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
    "metadata": {
      "source": "SAP"
    },
    "id": "SAP-WT-12345",
    "user_id": "SAP-USER-67890",
    "is_active": true,
    "status": "active"
  }'
  ```

  ```python Python theme={null}
  import requests

  url = "https://integrations.projectcor.com/v2/integrations/working-time"

  payload = {
      "metadata": {
          "source": "SAP"
      },
      "id": "SAP-WT-12345",
      "user_id": "SAP-USER-67890",
      "is_active": True,
      "status": "active"
  }

  headers = {
      "Authorization": "Bearer YOUR_ACCESS_TOKEN",
      "Content-Type": "application/json"
  }

  response = requests.post(url, json=payload, headers=headers)
  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    'https://integrations.projectcor.com/v2/integrations/working-time',
    {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        metadata: {
          source: 'SAP'
        },
        id: 'SAP-WT-12345',
        user_id: 'SAP-USER-67890',
        is_active: true,
        status: 'active'
      })
    }
  );

  const data = await response.json();
  console.log(data);
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "id": 50001,
    "user_id": 8546,
    "company_id": 1234,
    "is_active": true,
    "status": "active",
    "created_at": "2025-01-10T14:30:00Z"
  }
  ```

  ```json 404 theme={null}
  {
    "error": "UserNotFoundError",
    "message": "User with external ID 'SAP-USER-67890' not found",
    "code": "ZC004"
  }
  ```
</ResponseExample>
