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

# Add Employee



## OpenAPI

````yaml /openapi.yaml post /v1/employees
openapi: 3.1.0
info:
  title: Trackpilots API & Webhooks
  version: 1.1.0
  description: >
    Trackpilots REST APIs and Webhook events.

    Webhooks are sent by the Trackpilots desktop agent to customer-configured
    endpoints.

    Clients only send `secret_key`. All other fields are generated by the
    server.
servers:
  - url: https://api.trackpilots.com
    description: Production server
security: []
tags:
  - name: Teams
    description: Team management APIs
  - name: Desktop Events
    description: Desktop agent webhook events
paths:
  /v1/employees:
    post:
      tags:
        - Manage Employees
      summary: Add Employee
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AddEmployeeViaManualRequest'
      responses:
        '200':
          description: User added successfully.
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/200AddedEmployeeViaManuallySuccessResponse
        '400':
          description: Request validation failed
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/400AddEmployeeManualValidationErrorResponse
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '409':
          description: Employee email ID is already associated with another organization.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/409AddEmployeeDuplicateErrorResponse'
        '422':
          $ref: '#/components/responses/422AddEmployeeUnprocessableErrorResponse'
        '500':
          $ref: '#/components/responses/InternalServerError'
      security:
        - BearerAuth: []
components:
  schemas:
    AddEmployeeViaManualRequest:
      type: object
      required:
        - userName
        - emailId
        - roleId
        - teamId
        - workMode
        - password
      properties:
        userName:
          type: string
          minLength: 2
          maxLength: 100
          example: Jagatheesan M
        emailId:
          type: string
          format: email
          example: mjagatheesan.g@gmail.com
        password:
          type: string
          format: password
          minLength: 8
          maxLength: 128
          description: >
            Must contain at least 1 uppercase letter, 1 lowercase letter, 1
            number, and 1 special character.
          pattern: ^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^A-Za-z\d]).{8,128}$
          example: Strong@123
        roleId:
          type: string
          format: uuid
          example: 271e6693-2130-4ea9-b02d-e6d57516186d
        teamId:
          type: array
          minItems: 1
          items:
            type: string
            format: uuid
          example:
            - 5f6fe61c-15c6-47b7-899d-dba99da2464c
        workMode:
          type: string
          enum:
            - remote
            - office
            - hybrid
          example: remote
    200AddedEmployeeViaManuallySuccessResponse:
      type: object
      properties:
        success:
          type: boolean
          example: true
        statusCode:
          type: integer
          format: int32
          example: 200
        statusMessage:
          type: string
          example: User added successfully
        error:
          nullable: true
          example: null
        response:
          type: object
          properties:
            userName:
              type: string
              example: Jagatheesan M
            emailId:
              type: string
              format: email
              example: mjagatheesan.g@gmail.com
            userId:
              type: string
              format: uuid
              example: 7f9a0d29-c3a3-419a-87f6-11c34948cf7e
    400AddEmployeeManualValidationErrorResponse:
      type: object
      properties:
        success:
          type: boolean
          example: false
        statusCode:
          type: integer
          example: 400
        statusMessage:
          type: string
          example: Failed to add user
        data:
          type: object
          nullable: true
          example: null
        error:
          type: object
          properties:
            message:
              type: string
              example: Request body is not valid
            code:
              type: string
              example: REQUEST_VALIDATION_FAILED
            details:
              type: array
              items:
                type: object
                properties:
                  path:
                    type: array
                    items:
                      type: string
                    example:
                      - userName
                  message:
                    type: string
                    example: 'Invalid input: expected string, received undefined'
    409AddEmployeeDuplicateErrorResponse:
      type: object
      properties:
        success:
          type: boolean
          example: false
        statusCode:
          type: integer
          example: 409
        statusMessage:
          type: string
          example: Employee email ID is already associated with another organization
        error:
          type: object
          properties:
            message:
              type: string
              example: duplicate key value violates unique constraint `unique_email_id`
            code:
              type: string
              example: DUPLICATE_EMAIL_ID
        data:
          type: object
          nullable: true
          example: null
    ErrorResponse:
      type: object
      properties:
        success:
          type: boolean
          example: false
        statusCode:
          type: integer
          format: int32
          example: 401
        statusMessage:
          type: string
          example: Authentication failed
        data:
          nullable: true
          example: null
        error:
          type: object
          properties:
            message:
              type: string
              example: Authorization header is missing
            code:
              type: string
              enum:
                - AUTHORIZATION_HEADER_MISSING
                - INVALID_API_KEY_SCHEMA
                - API_KEY_MISSING
                - INVALID_API_KEY
                - PLAN_EXPIRED
              example: AUTHORIZATION_HEADER_MISSING
    422CreateEmployeeSendInviteUnprocessableErrorSchema:
      type: object
      properties:
        success:
          type: boolean
          example: false
        statusCode:
          type: integer
          format: int32
          example: 422
        statusMessage:
          type: string
          example: Invalid roleId
        response:
          nullable: true
          example: null
        error:
          type: object
          properties:
            message:
              type: string
              example: Provided roleId does not exist for this organisation
            code:
              type: string
              enum:
                - INVALID_ROLE_ID
                - INVALID_TEAM_ID
              example: INVALID_ROLE_ID
    InternalServerError:
      allOf:
        - $ref: '#/components/schemas/BaseError'
        - type: object
          properties:
            statusCode:
              example: 500
            statusMessage:
              example: Internal server error
            error:
              type: object
              properties:
                message:
                  example: Some technical error has occurred !!
                code:
                  example: UNKNOWN_SERVER_ERROR
    BaseError:
      type: object
      properties:
        success:
          type: boolean
          example: false
        statusCode:
          type: integer
        statusMessage:
          type: string
        data:
          nullable: true
          example: null
        error:
          type: object
          properties:
            message:
              type: string
            code:
              type: string
  responses:
    UnauthorizedError:
      description: Authentication & Authorization errors
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            authorizationHeaderMissing:
              summary: Authorization header missing
              value:
                success: false
                statusCode: 401
                statusMessage: Authentication token header is missing
                data: null
                error:
                  message: Authorization header is missing
                  code: AUTHORIZATION_HEADER_MISSING
            invalidAuthorizationScheme:
              summary: Invalid authorization scheme
              value:
                success: false
                statusCode: 401
                statusMessage: Invalid authentication token schema
                data: null
                error:
                  message: Authorization header must start with 'Bearer'
                  code: INVALID_API_KEY_SCHEMA
            apiKeyMissing:
              summary: API key missing
              value:
                success: false
                statusCode: 401
                statusMessage: Authentication token is missing
                data: null
                error:
                  message: API key value is missing
                  code: API_KEY_MISSING
            invalidApiKey:
              summary: Invalid or inactive API key
              value:
                success: false
                statusCode: 401
                statusMessage: Authentication failed
                data: null
                error:
                  message: Provided API key is invalid or inactive
                  code: INVALID_API_KEY
            planExpired:
              summary: Upgrade required
              value:
                success: false
                statusCode: 401
                statusMessage: Upgrade required
                data: null
                error:
                  message: Upgrade required to use Trackpilots APIs
                  code: PLAN_EXPIRED
    422AddEmployeeUnprocessableErrorResponse:
      description: Unprocessable Entity – Invalid roleId or teamIds
      content:
        application/json:
          schema:
            $ref: >-
              #/components/schemas/422CreateEmployeeSendInviteUnprocessableErrorSchema
          examples:
            invalidRoleId:
              summary: Invalid roleId
              value:
                success: false
                statusCode: 422
                statusMessage: Invalid roleId
                response: null
                error:
                  message: Provided roleId does not exist for this organisation
                  code: INVALID_ROLE_ID
            invalidTeamId:
              summary: Invalid teamId
              value:
                success: false
                statusCode: 422
                statusMessage: Invalid teamId
                response: null
                error:
                  message: One or more teamIds are invalid for this organisation
                  code: INVALID_TEAM_ID
    InternalServerError:
      description: Internal server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/InternalServerError'
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````