TalkJS User presence API

Operations related to user presence

GitHub OpenAPI

Operations 2

GET /v1/{appId}/users/{userId}/sessions List sessions for a user #
POST /v1/{appId}/presences List online users #

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/talkjs:talkjs-user-presence-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. By signing up you are subscribing to the APIs.io and API Evangelist newsletters — you can unsubscribe from any issue. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

talkjs-user-presence-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: TalkJS User presence API
  summary: Manage messages, conversations, users, notifications and app metadata
  description: 'The TalkJS REST API allows you to manage messages, conversations, sessions, users and notifications from your backend. The API is REST-based, using HTTP and JSON. The API only accepts authenticated calls over HTTPS, and uses standard HTTP status codes for reporting results. ## Authentication


    Authentication helps keep your chat and user data secure. ### Single-use token authentication


    The TalkJS REST API works with token-based authentication. Because the REST API has read/write access to all data in your TalkJS account, we recommend using single-use tokens. With single-use tokens, your server generates a new token for each REST API request. Single-use tokens allow you to set an extremely short expiry time for a token. That means that even if you accidentally leak a token, the token will expire before anyone can exploit it. The following are example code snippets in different languages to generate a REST API token that expires after 30 seconds.'
  termsOfService: https://talkjs.com/terms/
  contact:
    name: TalkJS team
    url: https://talkjs.com/?chat
    email: hey@talkjs.com
  license:
    name: MIT License
    url: https://mit-license.org
  version: '2024-01-01'
servers:
- url: https://api.talkjs.com
  description: Production server
security:
- JWTAuth: []
- ApiKeyAuth: []
tags:
- name: User presence
  description: Operations related to user presence
paths:
  /v1/{appId}/users/{userId}/sessions:
    summary: Path for operations on sessions for a specific user
    description: 'Use this endpoint to get all sessions for a specific user.

      '
    get:
      tags:
      - User presence
      summary: List sessions for a user
      description: 'Lists all sessions for a specific user.


        If you create a TalkJS session on every page, then a user can have multiple session objects: one for the TalkJS background session, and one for each TalkJS UI that''s in focus.


        ### Examples


        User `alice` is offline:


        ```js

        // request:

        GET https://api.talkjs.com/v1/YOUR_APP_ID/users/alice/sessions


        // response:

        []

        ```


        User `alice` is logged into your site, but doesn''t have a TalkJS UI in focus:


        ```js

        // request:

        GET https://api.talkjs.com/v1/YOUR_APP_ID/users/alice/sessions


        // response:

        [

        {

        "isTyping": false,

        "currentConversationId": null

        }

        ]

        ```


        User `alice` is logged into your site, has a TalkJS UI in focus and is currently typing a message in conversation `1234`:


        ```js

        // request:

        GET https://api.talkjs.com/v1/YOUR_APP_ID/users/alice/sessions


        // response:

        [

        {

        "isTyping": false,

        "currentConversationId": null

        },

        {

        "isTyping": true,

        "currentConversationId": "1234"

        }

        ]

        ```'
      operationId: listSessionsForUser
      deprecated: true
      parameters:
      - $ref: '#/components/parameters/AppID'
      - $ref: '#/components/parameters/UserID'
      responses:
        '200':
          $ref: '#/components/responses/ListSessionsForUserSuccessResponse'
        '400':
          $ref: '#/components/responses/BadRequestResponse'
        '401':
          $ref: '#/components/responses/UnauthorizedResponse'
        '404':
          $ref: '#/components/responses/ResourceNotFoundResponse'
        '429':
          $ref: '#/components/responses/TooManyRequestsResponse'
        '500':
          $ref: '#/components/responses/InternalServerErrorResponse'
  /v1/{appId}/presences:
    summary: Path for operations on user presence
    description: 'Use this endpoint to create a list of online users.

      '
    post:
      tags:
      - User presence
      summary: List online users
      description: 'Lists online users.


        You can programmatically check the online status and current activity of users on your app.


        If you create a TalkJS session on every page—which we recommend—then TalkJS internally stores two sessions: one background session for each user, and one session for each active TalkJS chat UI widget.


        By default, we don''t return users with only a background session. You can change this behavior by passing the `includeBackgroundSessions` option.'
      operationId: listOnlineUsers
      parameters:
      - $ref: '#/components/parameters/AppID'
      requestBody:
        $ref: '#/components/requestBodies/ListOnlineUsersRequestBody'
      responses:
        '200':
          $ref: '#/components/responses/ListOnlineUsersSuccessResponse'
        '400':
          $ref: '#/components/responses/BadRequestResponse'
        '401':
          $ref: '#/components/responses/UnauthorizedResponse'
        '404':
          $ref: '#/components/responses/ResourceNotFoundResponse'
        '415':
          $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
          $ref: '#/components/responses/TooManyRequestsResponse'
        '500':
          $ref: '#/components/responses/InternalServerErrorResponse'
components:
  responses:
    BadRequestResponse:
      description: Bad request
    UnauthorizedResponse:
      description: Authorization information is missing or invalid.
    ResourceNotFoundResponse:
      description: Resource not found
    ListOnlineUsersSuccessResponse:
      description: Online users listed successfully.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/OnlineUserList'
    ListSessionsForUserSuccessResponse:
      description: Sessions for a user listed successfully.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Sessions'
    TooManyRequestsResponse:
      description: Too many requests
    InternalServerErrorResponse:
      description: Internal server error
    UnsupportedMediaTypeResponse:
      description: Unsupported media type
  parameters:
    AppID:
      name: appId
      in: path
      description: 'A unique identifier of your TalkJS app. You can find your app ID on the **Settings** page of your [dashboard](https://talkjs.com/dashboard).

        '
      required: true
      schema:
        type: string
        example: abcd1234
    UserID:
      name: userId
      in: path
      description: 'A unique identifier of a user.

        '
      required: true
      schema:
        type: string
        example: alice
  schemas:
    Session:
      description: 'An array of sessions for an online user.

        '
      type: array
      items:
        description: A session for an online user.
        type: object
        properties:
          custom:
            description: A custom property of a session. Both keys and values must be strings.
            type: object
            additionalProperties:
              type: string
            example:
              priority: high
          selectedConversationId:
            description: A unique identifier of a selected conversation.
            type: string
            example: 0123456789abcdef
          isTyping:
            description: Indicates whether the user is currently typing a message in a conversation in this session.
            type: boolean
            example: false
          hasFocus:
            description: Indicates whether the user currently has this session in focus.
            type: boolean
            example: true
          sessionId:
            description: A unique identifier of a session.
            type: string
            example: 0123456789-0123456789-abcde-abcde
    OnlineUserList:
      description: Online users.
      type: object
      properties:
        data:
          description: A data object that wraps online users.
          type: object
          additionalProperties:
            description: 'Details of sessions for an online user.

              '
            type: object
            properties:
              status:
                description: Indicates whether the user is online or not.
                type: string
                example: online
              backgroundSessions:
                $ref: '#/components/schemas/Session'
              widgets:
                $ref: '#/components/schemas/Session'
          example:
            alice:
              status: online
              backgroundSessions:
              - custom:
                  priority: high
                selectedConversationId: 0123456789abcdef
                isTyping: false
                hasFocus: true
                sessionId: 0123456789-0123456789-abcde-abcde
              widgets:
              - custom:
                  priority: high
                selectedConversationId: 0123456789abcdef
                isTyping: false
                hasFocus: true
                sessionId: 0123456789-0123456789-abcde-abcde
            sebastian:
              status: online
              backgroundSessions:
              - custom:
                  priority: high
                selectedConversationId: 0123456789abcdef
                isTyping: false
                hasFocus: true
                sessionId: 0123456789-0123456789-abcde-abcde
              widgets:
              - custom:
                  priority: high
                selectedConversationId: 0123456789abcdef
                isTyping: false
                hasFocus: false
                sessionId: 0123456789-0123456789-abcde-abcde
    Sessions:
      type: array
      description: 'An array with sessions that a user is part of.

        '
      items:
        description: A single session for a user
        type: object
        properties:
          isTyping:
            description: Indicates whether the user is currently typing a message in this session.
            type: boolean
            example: true
          currentConversationId:
            description: A unique identifier of a conversation.
            type:
            - string
            - 'null'
            example: 0123456789
    OnlineUserListCreateData:
      description: 'Requirements for the list of online users to be created.

        '
      type: object
      properties:
        includeBackgroundSessions:
          description: 'Filter users based on whether they have their TalkJS session in the background or not. The following values are accepted:


            - **false**: Only return users who have a TalkJS UI widget in the foreground.

            - **true**: Return all online users. Users who has their TalkJS UI widget in the background are returned with an empty `widgets` field.

            '
          type: boolean
          example: true
          default: false
        selectedConversationId:
          description: 'Filter users who are online in the selected conversation. Requires passing in a `conversationID`. You can pass an explicit `null` value to filter users who are online but have no conversation selected.


            Omit this field to return online users in all conversations, regardless of whether a conversation is selected.

            '
          type:
          - string
          - 'null'
          example: 0123456789
        hasFocus:
          description: 'Filter users based on whether they have the TalkJS UI in focus or not. Omit this field to get all online users, regardless of whether they have the TalkJS UI in focus.

            '
          type: boolean
          example: true
        isTyping:
          description: 'Only return users who are currently typing in a conversation. Omit this field to get all users, regardless of whether they''re typing.

            '
          type: boolean
          example: true
        userIds:
          description: 'Only show sessions for users with the given user IDs. Omit this option to not filter on user ID.

            '
          type: array
          maxItems: 1000
          items:
            description: A unique identifier of a user.
            type: string
          example:
          - alice
          - sebastian
  requestBodies:
    ListOnlineUsersRequestBody:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/OnlineUserListCreateData'
  securitySchemes:
    JWTAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
    ApiKeyAuth:
      type: http
      scheme: bearer
      bearerFormat: APIKey
externalDocs:
  description: TalkJS documentation
  url: https://talkjs.com/docs