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

> Creates a new user in your COR instance with external ID mapping

Creates a new user in your COR instance through the integrations service. The user is mapped to an external ID from your identity provider or HR system.

## Request Body Requirements

<ParamField body="metadata" type="object" required>
  <Expandable title="properties">
    <ParamField body="source" type="string" required>
      Integration source identifier. Must be one of: `JIRA`, `SALESFORCE`, `ADVERTMIND`, `QUICKBOOKS`, `ZAPIER`, `OKTA`, `MICROSOFT_DYNAMICS`, `GITHUB`, `MICROSOFT_TEAMS`, `VBS`, `SAP`, `GLOBANT`
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="id" type="string" required>
  External user ID from your source system (e.g., Okta user ID, SAP employee ID)
</ParamField>

<ParamField body="email" type="string" required>
  User's email address
</ParamField>

<ParamField body="first_name" type="string" required>
  User's first name
</ParamField>

<ParamField body="last_name" type="string" required>
  User's last name
</ParamField>

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

<ParamField body="position" type="string">
  Job position/title
</ParamField>

<ParamField body="department" type="string">
  Department name
</ParamField>

<ParamField body="role_id" type="number">
  COR role ID: `1` (C-Level), `2` (Director), `3` (Project Manager), `4` (Collaborator), `5` (Freelancer), `6` (Client)
</ParamField>

<ParamField body="daily_hours" type="number">
  Daily working hours capacity (default: 8)
</ParamField>

<ParamField body="user_position_id" type="string">
  External position ID. The position must have been previously created through the integrations API. Assigns the user to this position.
</ParamField>

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

## Known Errors

* `ValidationError` — Missing required fields
* `DuplicateEmailError` — A user with this email already exists
* `DuplicateExternalIdError` — A user with this external ID already exists for this source
* `InvalidRoleError` — The `role_id` is not a valid COR role

<RequestExample>
  ```bash cURL theme={null}
  curl --location 'https://integrations.projectcor.com/v2/integrations/users' \
  --header 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
    "metadata": {
      "source": "OKTA"
    },
    "id": "OKTA-USER-12345",
    "email": "john.doe@company.com",
    "first_name": "John",
    "last_name": "Doe",
    "phone": "+1 555-0100",
    "position": "Senior Developer",
    "department": "Engineering",
    "role_id": 4,
    "daily_hours": 8,
    "user_position_id": "external-user-position-1",
    "seniority_id": "external_seniority_id_10"
  }'
  ```

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

  url = "https://integrations.projectcor.com/v2/integrations/users"

  payload = {
      "metadata": {
          "source": "OKTA"
      },
      "id": "OKTA-USER-12345",
      "email": "john.doe@company.com",
      "first_name": "John",
      "last_name": "Doe",
      "phone": "+1 555-0100",
      "position": "Senior Developer",
      "department": "Engineering",
      "role_id": 4,
      "daily_hours": 8,
      "user_position_id": "external-user-position-1",
      "seniority_id": "external_seniority_id_10"
  }

  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/users',
    {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        metadata: {
          source: 'OKTA'
        },
        id: 'OKTA-USER-12345',
        email: 'john.doe@company.com',
        first_name: 'John',
        last_name: 'Doe',
        phone: '+1 555-0100',
        position: 'Senior Developer',
        department: 'Engineering',
        role_id: 4,
        daily_hours: 8
      })
    }
  );

  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": 4,
    "daily_hours": 8,
    "company_id": 1234,
    "created_at": "2025-01-10T14:30:00Z",
    "updated_at": "2025-01-10T14:30:00Z"
  }
  ```

  ```json 400 theme={null}
  {
    "error": "DuplicateEmailError",
    "message": "A user with email 'john.doe@company.com' already exists",
    "code": "ZC002"
  }
  ```
</ResponseExample>
