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

# Update User

> Updates an existing user in your COR instance using their external ID

Updates an existing user in your COR instance using their external ID. Only provided fields will be updated.

## Path Parameters

<ParamField path="id" type="string" required>
  External user ID that was used when creating the user
</ParamField>

## Request Body Requirements

<ParamField body="metadata" type="object" required>
  <Expandable title="properties">
    <ParamField body="source" type="string" required>
      Integration source identifier. Must match the source used when creating the user.
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="first_name" type="string">
  Updated first name
</ParamField>

<ParamField body="last_name" type="string">
  Updated last name
</ParamField>

<ParamField body="phone" type="string">
  Updated phone number
</ParamField>

<ParamField body="position" type="string">
  Updated job position
</ParamField>

<ParamField body="department" type="string">
  Updated department
</ParamField>

<ParamField body="role_id" type="number">
  Updated COR role ID
</ParamField>

<ParamField body="daily_hours" type="number">
  Updated daily hours capacity
</ParamField>

<ParamField body="user_position_id" type="string">
  External position ID. The position must have been previously created through the integrations API. Updates the user's position assignment.
</ParamField>

<ParamField body="seniority_id" type="string">
  External seniority ID. The seniority must have been previously created through the integrations API. Updates the user's seniority level.
</ParamField>

<ParamField body="salary" type="number">
  Monthly salary amount.
</ParamField>

<ParamField body="salary_from" type="string">
  Month from which the salary becomes effective. Must use MM-YYYY format. Defaults to the current month if salary is provided.
</ParamField>

## Known Errors

* `ZC001` — Entity is not associated (user with the specified external ID not found)
* `UserNotFoundError` — No user found with the specified external ID for this source
* `ValidationError` — Missing required `metadata.source` field
* `InvalidRoleError` — The `role_id` is not a valid COR role
* `ValidationError` — The `salary_from` field must use MM-YYYY format

<RequestExample>
  ```bash cURL theme={null}
  curl --location --request PUT 'https://integrations.projectcor.com/v2/integrations/users/OKTA-USER-12345' \
  --header 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
    "metadata": {
      "source": "OKTA"
    },
    "position": "Lead Developer",
    "role_id": 3,
    "daily_hours": 8,
    "user_position_id": "external-user-position-2",
    "seniority_id": "external_seniority_id_20",
    "salary": 5000,
    "salary_from": "03-2025"
  }'
  ```

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

  url = "https://integrations.projectcor.com/v2/integrations/users/OKTA-USER-12345"

  payload = {
      "metadata": {
          "source": "OKTA"
      },
      "position": "Lead Developer",
      "role_id": 3,
      "daily_hours": 8,
      "user_position_id": "external-user-position-2",
      "seniority_id": "external_seniority_id_20",
      "salary": 5000,
      "salary_from": "03-2025"
  }

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

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

  ```javascript JavaScript theme={null}
  const response = await fetch(
    'https://integrations.projectcor.com/v2/integrations/users/OKTA-USER-12345',
    {
      method: 'PUT',
      headers: {
        'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        metadata: {
          source: 'OKTA'
        },
        position: 'Lead Developer',
        role_id: 3,
        daily_hours: 8,
        salary: 5000,
        salary_from: '03-2025'
      })
    }
  );

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

<ResponseExample>
  ```json 200 theme={null}
  {
    "id": 8546,
    "email": "john.doe@company.com",
    "first_name": "John",
    "last_name": "Doe",
    "phone": "+1 555-0100",
    "role_id": 3,
    "daily_hours": 8,
    "company_id": 1234,
    "created_at": "2025-01-10T14:30:00Z",
    "updated_at": "2025-01-15T10:00:00Z"
  }
  ```

  ```json 404 theme={null}
  {
    "status": "ERROR",
    "code": "ZC001",
    "message": "Entity is not associated"
  }
  ```

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