CometChat Users API

Create and manage app users

OpenAPI Specification

cometchat-users-api-openapi.yml Raw ↑
openapi: 3.0.1
info:
  title: CometChat REST Management Auth Tokens Users API
  description: Server-side REST Management API (v3) for CometChat in-app messaging. Manages users, authentication tokens, groups, group members, messages, conversations, reactions, roles, friends, blocked and banned users, and webhooks for a CometChat app. The API is scoped to a single app and region; the host is derived from your App ID and the region your app is provisioned in (us, eu, in). All requests authenticate with a Rest API Key (fullAccess scope) passed in the `apikey` header. Realtime delivery to end users is handled separately by the CometChat client SDKs over a managed WebSocket layer and is not part of this REST surface.
  termsOfService: https://www.cometchat.com/terms-and-conditions
  contact:
    name: CometChat Support
    url: https://www.cometchat.com/contact-sales
  version: '3.0'
servers:
- url: https://{appId}.api-{region}.cometchat.io/v3
  description: Per-app, per-region CometChat REST Management API host
  variables:
    appId:
      default: APP_ID
      description: Your CometChat App ID from the dashboard
    region:
      default: us
      enum:
      - us
      - eu
      - in
      description: The region your CometChat app is provisioned in
security:
- apiKeyAuth: []
tags:
- name: Users
  description: Create and manage app users
paths:
  /users:
    get:
      operationId: listUsers
      tags:
      - Users
      summary: List users
      parameters:
      - $ref: '#/components/parameters/Page'
      - $ref: '#/components/parameters/PerPage'
      - name: searchKey
        in: query
        schema:
          type: string
        description: Filter users by UID or name.
      - name: status
        in: query
        schema:
          type: string
          enum:
          - online
          - offline
      responses:
        '200':
          description: A paginated list of users.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserList'
    post:
      operationId: createUser
      tags:
      - Users
      summary: Create a user
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateUserRequest'
      responses:
        '200':
          description: The created user.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserResponse'
  /users/{uid}:
    parameters:
    - $ref: '#/components/parameters/Uid'
    get:
      operationId: getUser
      tags:
      - Users
      summary: Get a user
      responses:
        '200':
          description: The requested user.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserResponse'
    put:
      operationId: updateUser
      tags:
      - Users
      summary: Update a user
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateUserRequest'
      responses:
        '200':
          description: The updated user.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserResponse'
    delete:
      operationId: deleteUser
      tags:
      - Users
      summary: Delete a user
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                permanent:
                  type: boolean
                  description: Permanently delete user data when true.
      responses:
        '200':
          description: Deletion acknowledgement.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Acknowledgement'
  /users/{uid}/deactivate:
    parameters:
    - $ref: '#/components/parameters/Uid'
    put:
      operationId: deactivateUser
      tags:
      - Users
      summary: Deactivate a user
      responses:
        '200':
          description: The deactivated user.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserResponse'
  /users/{uid}/reactivate:
    parameters:
    - $ref: '#/components/parameters/Uid'
    put:
      operationId: reactivateUser
      tags:
      - Users
      summary: Reactivate a user
      responses:
        '200':
          description: The reactivated user.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserResponse'
components:
  schemas:
    User:
      type: object
      properties:
        uid:
          type: string
        name:
          type: string
        avatar:
          type: string
        link:
          type: string
        role:
          type: string
        metadata:
          type: object
        status:
          type: string
          enum:
          - online
          - offline
        statusMessage:
          type: string
        hasBlockedMe:
          type: boolean
        blockedByMe:
          type: boolean
        createdAt:
          type: integer
          format: int64
        updatedAt:
          type: integer
          format: int64
        lastActiveAt:
          type: integer
          format: int64
        deactivatedAt:
          type: integer
          format: int64
    UserList:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/User'
        meta:
          type: object
          properties:
            pagination:
              $ref: '#/components/schemas/Pagination'
    CreateUserRequest:
      type: object
      required:
      - uid
      - name
      properties:
        uid:
          type: string
        name:
          type: string
        avatar:
          type: string
        link:
          type: string
        role:
          type: string
        metadata:
          type: object
        withAuthToken:
          type: boolean
          description: Also generate an auth token for the new user.
    UpdateUserRequest:
      type: object
      properties:
        name:
          type: string
        avatar:
          type: string
        link:
          type: string
        role:
          type: string
        metadata:
          type: object
    Pagination:
      type: object
      properties:
        total:
          type: integer
        count:
          type: integer
        per_page:
          type: integer
        current_page:
          type: integer
        total_pages:
          type: integer
    Acknowledgement:
      type: object
      properties:
        data:
          type: object
          properties:
            success:
              type: boolean
            message:
              type: string
    UserResponse:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/User'
  parameters:
    Page:
      name: page
      in: query
      schema:
        type: integer
        default: 1
    PerPage:
      name: perPage
      in: query
      schema:
        type: integer
        default: 25
        maximum: 100
    Uid:
      name: uid
      in: path
      required: true
      schema:
        type: string
      description: Unique user identifier.
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: apikey
      description: Rest API Key with fullAccess scope from the CometChat dashboard. The App ID and region are encoded in the host, not in a header.