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

# Create Colleague API

> API for creating a new colleague (potential invitee) entry.

## POST `/v1/colleagues-create`

This endpoint is used to create a new colleague entry for potential future invitations.

When it is called, it will create a new colleague record in your organization that can later be invited using the Send Invitation API.

### Endpoint URL

The endpoint URL is `https://api.wazper.com/v1/colleagues-create`

### HTTP Method

`POST`

### Headers

| Header         | Type   | Required | Description                     |
| -------------- | ------ | -------- | ------------------------------- |
| `X-API-Key`    | String | Yes      | Your Wazper API Key.            |
| `Content-Type` | String | Yes      | Must be `application/json`.     |
| `Accept`       | String | No       | Recommended `application/json`. |

### Request Body

The request body must be a JSON object containing colleague information.

```json theme={null}
{
  "name": "string",
  "email": "string",
  "companyName": "string",
  "toBeInvitedById": "string",
  "jobTitle": "string (optional)",
  "website": "string (optional)",
  "team": "integer (optional)",
  "inviteLink": "string (optional)",
  "redirectionLink": "string (optional)"
}
```

**Request Fields:**

| Field             | Type    | Required | Description                                                                                                          |
| ----------------- | ------- | -------- | -------------------------------------------------------------------------------------------------------------------- |
| `name`            | String  | Yes      | The colleague's full name.                                                                                           |
| `email`           | String  | Yes      | The colleague's email address. This will be used for sending invitations.                                            |
| `companyName`     | String  | Yes      | The colleague's company name.                                                                                        |
| `toBeInvitedById` | String  | Yes      | The email address of the user who is creating this colleague entry (the inviter).                                    |
| `jobTitle`        | String  | No       | The colleague's job title.                                                                                           |
| `website`         | String  | No       | The colleague's company website.                                                                                     |
| `team`            | Integer | No       | Team identifier or number.                                                                                           |
| `inviteLink`      | String  | No       | A custom invitation link. If not provided, your organization's default invite link will be used.                     |
| `redirectionLink` | String  | No       | A custom redirection link for after an invite is accepted. If not provided, the default dashboard link will be used. |

### Example Request (cURL)

```bash theme={null}
curl -X POST 'https://api.wazper.com/v1/colleagues-create' \
-H 'X-API-Key: YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
  "name": "Samuel Prospective",
  "email": "samuel.p@example.com",
  "companyName": "Innovate Ltd.",
  "toBeInvitedById": "current.user@example.com",
  "jobTitle": "Marketing Lead",
  "website": "https://innovate.com",
  "team": 2
}'
```

### Success Response (201 Created)

The response contains the newly created colleague entry with all generated fields.

```json theme={null}
{
  "id": "tbi_xyz789",
  "name": "Samuel Prospective",
  "email": "samuel.p@example.com",
  "companyName": "Innovate Ltd.",
  "website": "https://innovate.com",
  "team": 2,
  "wazClientId": "org_abc123xyz",
  "toBeInvitedById": "current.user@example.com",
  "status": "pending",
  "inviteLink": "https://app.wazper.com/invite",
  "redirectionLink": "https://app.wazper.com/dashboard",
  "jobTitle": "Marketing Lead",
  "latestAction": "2023-10-27T10:00:00.000Z",
  "photo": null,
  "createdAt": "2023-10-27T10:00:00.000Z",
  "updatedAt": "2023-10-27T10:00:00.000Z"
}
```

### Error Responses

* **400 Bad Request - Missing Required Fields:**

  ```json theme={null}
  { "error": "Required fields missing: name, email, companyName, and toBeInvitedById are required" }
  ```
* **400 Bad Request - API Key Not Linked:**

  ```json theme={null}
  { "error": "API Key is not linked to a valid organization." }
  ```
* **401 Unauthorized - API Key Required:**

  ```json theme={null}
  { "error": "API Key is required" }
  ```
* **401 Unauthorized - Invalid API Key:**

  ```json theme={null}
  { "error": "Invalid API Key or key not linked to an organization" }
  ```
* **403 Forbidden - Waz Disabled:**

  ```json theme={null}
  { "error": "Waz is currently disabled" }
  ```
* **409 Conflict - Duplicate Email:**

  ```json theme={null}
  { "error": "A colleague with this email (samuel.p@example.com) may already exist for this client or inviter." }
  ```
* **500 Internal Server Error:**

  ```json theme={null}
  { "error": "Internal server error", "details": "The error message from the server." }
  ```

### Notes

* This API does not consume credits from your account.
* This API creates a colleague entry that can later be invited using the Send Invitation API.
* The colleague's initial status will be set to "pending".
* If you don't provide custom invite or redirection links, your organization's default links will be used.
* Each request is logged for tracking and analytics purposes.


## OpenAPI

````yaml POST /v1/colleagues-create
openapi: 3.0.1
info:
  title: Wazper API
  description: >-
    API for Wazper services, including user synchronization and colleague
    management.
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://api.wazper.com
security:
  - ApiKeyAuth: []
paths:
  /v1/colleagues-create:
    post:
      tags:
        - V1 API
      summary: Create Colleague
      description: Creates a new colleague entry in the ToBeInvited table.
      operationId: postV1ColleaguesCreate
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/V1ColleagueCreatePayload'
      responses:
        '201':
          description: Colleague created successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/V1ColleagueRecord'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '500':
          $ref: '#/components/responses/InternalServerError'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    V1ColleagueCreatePayload:
      type: object
      properties:
        name:
          type: string
          description: Full name.
        email:
          type: string
          format: email
          description: Email address.
        companyName:
          type: string
          description: Company name.
        toBeInvitedById:
          type: string
          format: email
          description: Email of the inviter.
        jobTitle:
          type: string
          nullable: true
          description: Job title.
        website:
          type: string
          format: url
          nullable: true
          description: Website.
        team:
          type: integer
          nullable: true
          description: Team ID.
        inviteLink:
          type: string
          format: url
          description: Custom invite link.
          nullable: true
        redirectionLink:
          type: string
          format: url
          nullable: true
          description: Custom redirection link.
      required:
        - name
        - email
        - companyName
        - toBeInvitedById
    V1ColleagueRecord:
      type: object
      properties:
        id:
          type: string
          description: Unique ID of the colleague entry (ToBeInvited table).
        name:
          type: string
          description: Name of the colleague.
        email:
          type: string
          format: email
          description: Email of the colleague.
        jobTitle:
          type: string
          nullable: true
          description: Job title.
        status:
          type: string
          description: Current status (e.g., pending, invited, joined).
        createdAt:
          type: string
          format: date-time
          description: Creation timestamp.
        companyName:
          type: string
          description: Company name.
        website:
          type: string
          format: url
          nullable: true
          description: Website URL.
        inviteLink:
          type: string
          format: url
          nullable: true
          description: Invite link.
        redirectionLink:
          type: string
          format: url
          nullable: true
          description: Redirection link.
        photo:
          type: string
          format: url
          nullable: true
          description: Photo URL.
        team:
          type: integer
          nullable: true
          description: Team identifier.
        wazClientId:
          type: string
          description: Wazper Client ID.
        toBeInvitedById:
          type: string
          format: email
          description: Email of the user who created this entry.
        latestAction:
          type: string
          format: date-time
          description: Timestamp of the last action.
        updatedAt:
          type: string
          format: date-time
          description: Timestamp of last update.
    WazperError:
      type: object
      properties:
        error:
          type: string
      required:
        - error
  responses:
    BadRequestError:
      description: >-
        Bad Request - The request could not be understood by the server due to
        malformed syntax. The client SHOULD NOT repeat the request without
        modifications.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/WazperError'
          examples:
            missingField:
              value:
                error: Field X is required
            invalidFormat:
              value:
                error: Invalid format for field Y
    UnauthorizedError:
      description: >-
        Unauthorized - The request requires user authentication. The client may
        repeat the request with a valid X-Client-ID or other authorization.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/WazperError'
          example:
            error: Invalid client ID
    ForbiddenError:
      description: >-
        Forbidden - The server understood the request, but is refusing to
        fulfill it. Authorization will not help and the request SHOULD NOT be
        repeated.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/WazperError'
          example:
            error: Waz is currently disabled
    InternalServerError:
      description: >-
        Internal Server Error - The server encountered an unexpected condition
        which prevented it from fulfilling the request.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/WazperError'
          example:
            error: Internal server error
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key

````