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

# Send Invitation API

> API for sending an email invitation to a colleague.

## POST `/v1/send-invitation`

This endpoint is used to send an email invitation to a colleague who has been previously created.

When it is called, it will send an invitation email to the specified colleague and update their status to "invited".

### Endpoint URL

The endpoint URL is `https://api.wazper.com/v1/send-invitation`

### 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 the colleague ID.

```json theme={null}
{
  "colleagueId": "string"
}
```

**Request Fields:**

| Field         | Type   | Required | Description                                     |
| ------------- | ------ | -------- | ----------------------------------------------- |
| `colleagueId` | String | Yes      | The unique ID of the colleague entry to invite. |

### Example Request (cURL)

```bash theme={null}
curl -X POST 'https://api.wazper.com/v1/send-invitation' \
-H 'X-API-Key: YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
  "colleagueId": "tbi_xyz789"
}'
```

### Success Response (200 OK)

The response indicates whether the invitation was successfully sent and processed.

```json theme={null}
{
  "success": true,
  "requestId": "req_clx0p...",
  "invite": {
    "id": "tbi_xyz789",
    "name": "Samuel Prospective",
    "email": "samuel.p@example.com",
    "status": "invited",
    "latestAction": "2023-10-27T12: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-27T12:00:00.000Z"
  },
  "emailSent": true,
  "emailResult": {
    "id": "email_id_123..."
  }
}
```

### Error Responses

* **400 Bad Request - Missing Colleague ID:**

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

  ```json theme={null}
  { "error": "Invalid or already processed colleague ID" }
  ```
* **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 requires the colleague to have been previously created by the algorithm (when calling user-sync) or using the Create Colleague API.
* The colleague's status is updated to "invited".
* The invitation email is sent using your organization's branding and template settings.


## OpenAPI

````yaml POST /v1/send-invitation
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/send-invitation:
    post:
      tags:
        - V1 API
      summary: Send Invitation
      description: Sends an invitation email to a specified colleague.
      operationId: postV1SendInvitation
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/V1SendInvitationPayload'
      responses:
        '200':
          description: Invitation process initiated.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/V1SendInvitationResponse'
        '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:
    V1SendInvitationPayload:
      type: object
      properties:
        colleagueId:
          type: string
          description: ID of the ToBeInvited entry.
      required:
        - colleagueId
    V1SendInvitationResponse:
      type: object
      properties:
        success:
          type: boolean
        requestId:
          type: string
          description: ID of the request log.
        invite:
          $ref: '#/components/schemas/V1ColleagueRecord'
        emailSent:
          type: boolean
          description: Whether the email was dispatched.
        emailResult:
          type: object
          nullable: true
          properties:
            id:
              type: string
              description: ID of the sent email from Resend.
        emailError:
          type: string
          nullable: true
          description: Error message if email sending failed.
    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

````