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

# Update Colleague API

> API for updating an existing colleague (potential invitee) entry.

## PATCH `/v1/colleagues-update`

This endpoint is used to update an existing colleague entry in your organization.

When it is called, it will modify the specified colleague's information, typically to change their status or email address.

### Endpoint URL

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

### HTTP Method

`PATCH`

### 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 the colleague ID and the fields to update.

```json theme={null}
{
  "id": "string",
  "status": "string (optional)",
  "email": "string (optional)"
}
```

**Request Fields:**

| Field    | Type   | Required | Description                                                                                             |
| -------- | ------ | -------- | ------------------------------------------------------------------------------------------------------- |
| `id`     | String | Yes      | The unique ID of the colleague entry to update.                                                         |
| `status` | String | No       | New status for the colleague (e.g., "invited", "deleted", "joined"). Required if email is not provided. |
| `email`  | String | No       | New email address for the colleague. Must be a valid email format. Required if status is not provided.  |

### Example Request (cURL)

```bash theme={null}
curl -X PATCH 'https://api.wazper.com/v1/colleagues-update' \
-H 'X-API-Key: YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
  "id": "tbi_xyz789",
  "status": "invited"
}'
```

### Success Response (200 OK)

The response contains the updated colleague entry with the modified information.

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

### Error Responses

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

  ```json theme={null}
  { "error": "Required fields missing: id and either status or email are required" }
  ```
* **400 Bad Request - Invalid Email Format:**

  ```json theme={null}
  { "error": "Invalid email format" }
  ```
* **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" }
  ```
* **404 Not Found - Colleague Not Found:**

  ```json theme={null}
  { "error": "Colleague with ID tbi_nonexistent not found for client org_abc123xyz." }
  ```
* **409 Conflict - Duplicate Email:**

  ```json theme={null}
  { "error": "A colleague with the new email (new.email@example.com) may already exist." }
  ```
* **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.
* You must provide either a status or email field to update, or both.
* The `latestAction` timestamp is automatically updated when any field is modified.
* When updating the email, it must be in a valid email format.


## OpenAPI

````yaml PATCH /v1/colleagues-update
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-update:
    patch:
      tags:
        - V1 API
      summary: Update Colleague
      description: Updates an existing colleague entry in the ToBeInvited table.
      operationId: patchV1ColleaguesUpdate
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/V1ColleagueUpdatePayload'
      responses:
        '200':
          description: Colleague updated successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/V1ColleagueRecord'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalServerError'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    V1ColleagueUpdatePayload:
      type: object
      properties:
        id:
          type: string
          description: ID of the ToBeInvited entry to update.
        status:
          type: string
          nullable: true
          description: New status.
        email:
          type: string
          format: email
          nullable: true
          description: New email.
      required:
        - id
    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
    NotFoundError:
      description: Not Found - The requested resource could not be found.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/WazperError'
          example:
            error: Resource not found.
    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

````