Create DM
    • Dark
      Light
    • PDF

    Create DM

    • Dark
      Light
    • PDF

    Article summary

    Post
    /api/v1/im.create

    Create a direct message session with another user or more than one user.

    Change Log

    VersionDescription
    0.59.0Added
    3.1.0Added usernames fields
    3.18.0Added excludeSelf option
    Header parameters
    X-Auth-Token
    stringRequired

    The authToken of the authenticated user.

    ExampleRScctEHSmLGZGywfIhWyRpyofhKOiMoUIpimhvheU3f
    X-User-Id
    stringRequired

    The userId of the authenticated user.

    ExamplerbAXPnMktTFbNpwtJ
    Body parameters
    Example
    {
      "username": "kim.dok",
      "excludeSelf": true
    }
    object
    username
    string

    The username to open a direct message session. This parameter is required if the usernames parameter is not provided

    usernames
    string

    List of usernames to open a multiple direct message session. This parameter is required if the username parameter is not provided

    excludeSelf
    boolean

    Creates the direct message session excluding the current authenticated user. The session will only be opened if the current user has the view-room-administration permission

    Responses
    200

    OK

    Example 1
    {
      "room": {
        "t": "d",
        "rid": "PMrDaS4axRqkjY7errocket.cat",
        "usernames": [
          "g1",
          "rocket.cat"
        ]
      },
      "success": true
    }
    Expand All
    object
    room
    object
    t
    string
    rid
    string
    usernames
    Array of string
    string
    success
    boolean
    400

    Bad Request

    Example 1
    {
      "success": false,
      "error": "must have required property 'usernames'\n must have required property 'username'\n must match exactly one schema in oneOf [invalid-params]",
      "errorType": "invalid-params"
    }
    Example 2
    {
      "success": false,
      "error": "Invalid user [error-invalid-user]",
      "errorType": "error-invalid-user",
      "details": {
        "method": "createDirectMessage"
      }
    }
    object
    success
    boolean
    error
    string
    errorType
    string
    401

    Unauthorized

    Authorization Error
    {
      "status": "error",
      "message": "You must be logged in to do this."
    }
    object
    status
    string
    message
    string

    Was this article helpful?

    What's Next
    Changing your password will log you out immediately. Use the new password to log back in.
    First name must have atleast 2 characters. Numbers and special characters are not allowed.
    Last name must have atleast 1 characters. Numbers and special characters are not allowed.
    Enter a valid email
    Enter a valid password
    Your profile has been successfully updated.