Team room messages

Last Update: 12/5/2016

api-version = 1.0

If you haven't already, look at the information on getting started with these APIs.

Create a message

POST https://{instance}/DefaultCollection/_apis/chat/rooms/{roomId}/messages?api-version={version}
Content-Type: application/json
{
  content: {message}
}
Parameter Type Notes
URL
instance string VS Team Services account ({account}.visualstudio.com) or TFS server ({server:port}).
roomId int ID of the team room.
Query
api-version string Version of the API to use.
Body
content string Message to post to the team room.

Sample request

POST https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/chat/rooms/305/messages?api-version=1.0
Content-Type: application/json
{
  "content": "Here's a new message"
}

Sample response

Status code: 201
{
  "id": 118943,
  "content": "Here's a new message",
  "messageType": "normal",
  "postedTime": "2014-10-27T16:42:06.073Z",
  "postedRoomId": 305,
  "postedBy": {
    "id": "d6245f20-2af8-44f4-9451-8107cb2767db",
    "displayName": "Normal Paulk",
    "url": "https://fabrikam-fiber-inc.vssps.visualstudio.com/_apis/Identities/d6245f20-2af8-44f4-9451-8107cb2767db",
    "imageUrl": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_api/_common/identityImage?id=d6245f20-2af8-44f4-9451-8107cb2767db"
  }
}

Get a list of messages

GET https://{instance}/DefaultCollection/_apis/chat/rooms/{roomId}/messages?api-version={version}
Parameter Type Notes
URL
instance string VS Team Services account ({account}.visualstudio.com) or TFS server ({server:port}).
roomId int ID of the team room.
Query
api-version string Version of the API to use.
$filter string OData filter can be applied to the PostedTime field to return messages from a different timespan. The timespan can be up to 30 days. No more than 100,000 messages will be returned. If no filter is applied, messages from the last 24 hours are returned.

Sample request

GET https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/chat/rooms/305/messages?api-version=1.0

Sample response

Status code: 200
{
  "count": 2,
  "value": [
    {
      "id": 118940,
      "content": "Normal Paulk entered the room",
      "messageType": "system",
      "postedTime": "2014-10-27T16:36:02.28Z",
      "postedRoomId": 305,
      "postedBy": {
        "id": "47d25e84-de54-49ce-8f3d-351c77422775",
        "displayName": "[DefaultCollection]\\Project Collection Service Accounts",
        "url": "https://fabrikam-fiber-inc.vssps.visualstudio.com/_apis/Identities/47d25e84-de54-49ce-8f3d-351c77422775",
        "imageUrl": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_api/_common/identityImage?id=47d25e84-de54-49ce-8f3d-351c77422775"
      }
    },
    {
      "id": 118942,
      "content": "My second message!",
      "messageType": "normal",
      "postedTime": "2014-10-27T16:41:42.28Z",
      "postedRoomId": 305,
      "postedBy": {
        "id": "d6245f20-2af8-44f4-9451-8107cb2767db",
        "displayName": "Normal Paulk",
        "url": "https://fabrikam-fiber-inc.vssps.visualstudio.com/_apis/Identities/d6245f20-2af8-44f4-9451-8107cb2767db",
        "imageUrl": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_api/_common/identityImage?id=d6245f20-2af8-44f4-9451-8107cb2767db"
      }
    }
  ]
}

In a date range

Sample request

GET https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/chat/rooms/305/messages?$filter=PostedTime ge 10/25/2014 and PostedTime lt 10/28/2014&api-version=1.0

Sample response

Status code: 200
{
  "count": 2,
  "value": [
    {
      "id": 118940,
      "content": "Normal Paulk entered the room",
      "messageType": "system",
      "postedTime": "2014-10-27T16:36:02.28Z",
      "postedRoomId": 305,
      "postedBy": {
        "id": "47d25e84-de54-49ce-8f3d-351c77422775",
        "displayName": "[DefaultCollection]\\Project Collection Service Accounts",
        "url": "https://fabrikam-fiber-inc.vssps.visualstudio.com/_apis/Identities/47d25e84-de54-49ce-8f3d-351c77422775",
        "imageUrl": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_api/_common/identityImage?id=47d25e84-de54-49ce-8f3d-351c77422775"
      }
    },
    {
      "id": 118942,
      "content": "My second message!",
      "messageType": "normal",
      "postedTime": "2014-10-27T16:41:42.28Z",
      "postedRoomId": 305,
      "postedBy": {
        "id": "d6245f20-2af8-44f4-9451-8107cb2767db",
        "displayName": "Normal Paulk",
        "url": "https://fabrikam-fiber-inc.vssps.visualstudio.com/_apis/Identities/d6245f20-2af8-44f4-9451-8107cb2767db",
        "imageUrl": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_api/_common/identityImage?id=d6245f20-2af8-44f4-9451-8107cb2767db"
      }
    }
  ]
}

Get a message

GET https://{instance}/DefaultCollection/_apis/chat/rooms/{roomId}/messages/{messageId}?api-version={version}
Parameter Type Notes
URL
instance string VS Team Services account ({account}.visualstudio.com) or TFS server ({server:port}).
roomId int ID of the team room.
messageId int ID of the message.
Query
api-version string Version of the API to use.

Sample request

GET https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/chat/rooms/305/messages/118943?api-version=1.0

Sample response

Status code: 200
{
  "id": 118943,
  "content": "Updated message",
  "messageType": "normal",
  "postedTime": "2014-10-27T16:42:06.073Z",
  "postedRoomId": 305,
  "postedBy": {
    "id": "d6245f20-2af8-44f4-9451-8107cb2767db",
    "displayName": "Normal Paulk",
    "url": "https://fabrikam-fiber-inc.vssps.visualstudio.com/_apis/Identities/d6245f20-2af8-44f4-9451-8107cb2767db",
    "imageUrl": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_api/_common/identityImage?id=d6245f20-2af8-44f4-9451-8107cb2767db"
  }
}

Update message

PATCH https://{instance}/DefaultCollection/_apis/chat/rooms/{roomId}/messages/{messageId}?api-version={version}
Content-Type: application/json
{
  content: {message}
}
Parameter Type Notes
URL
instance string VS Team Services account ({account}.visualstudio.com) or TFS server ({server:port}).
roomId int ID of the team room.
messageId int ID of the message.
Query
api-version string Version of the API to use.
Body
content string Message to post to the team room.

Sample request

PATCH https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/chat/rooms/305/messages/118943?api-version=1.0
Content-Type: application/json
{
  "content": "Updated message"
}

Sample response

Status code: 200
{
  "id": 118943,
  "content": "Updated message",
  "messageType": "normal",
  "postedTime": "2014-10-27T16:42:06.073Z",
  "postedRoomId": 305,
  "postedBy": {
    "id": "d6245f20-2af8-44f4-9451-8107cb2767db",
    "displayName": "Normal Paulk",
    "url": "https://fabrikam-fiber-inc.vssps.visualstudio.com/_apis/Identities/d6245f20-2af8-44f4-9451-8107cb2767db",
    "imageUrl": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_api/_common/identityImage?id=d6245f20-2af8-44f4-9451-8107cb2767db"
  }
}

Delete message

DELETE https://{instance}/DefaultCollection/_apis/chat/rooms/{roomId}/messages/{messageId}?api-version={version}
Parameter Type Notes
URL
instance string VS Team Services account ({account}.visualstudio.com) or TFS server ({server:port}).
roomId int ID of the team room.
messageId int ID of the message.
Query
api-version string Version of the API to use.

Sample request

DELETE https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/chat/rooms/305/messages/118943?api-version=1.0

Sample response

Status code: 200