Share via


Team room messages

TFS 2017 | TFS 2015 | TFS 2013

Note

Looking for REST APIS that support TFS 2018 or later versions? See the Azure DevOps REST API Reference.

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 TFS server name ({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://mytfsserver/DefaultCollection/_apis/chat/rooms/305/messages?api-version=1.0
{
  "content": "Here's a new message"
}

Sample response

{
  "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://mytfsserver/DefaultCollection/_apis/Identities/d6245f20-2af8-44f4-9451-8107cb2767db",
    "imageUrl": "https://mytfsserver/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 TFS server name ({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://mytfsserver/DefaultCollection/_apis/chat/rooms/305/messages?api-version=1.0

Sample response

{
  "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://mytfsserver/DefaultCollection/_apis/Identities/47d25e84-de54-49ce-8f3d-351c77422775",
        "imageUrl": "https://mytfsserver/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://mytfsserver/DefaultCollection/_apis/Identities/d6245f20-2af8-44f4-9451-8107cb2767db",
        "imageUrl": "https://mytfsserver/DefaultCollection/_api/_common/identityImage?id=d6245f20-2af8-44f4-9451-8107cb2767db"
      }
    }
  ]
}

In a date range

Sample request

GET https://mytfsserver/DefaultCollection/_apis/chat/rooms/305/messages?$filter=PostedTime ge 10/25/2014 and PostedTime lt 10/28/2014&api-version=1.0

Sample response

{
  "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://mytfsserver/DefaultCollection/_apis/Identities/47d25e84-de54-49ce-8f3d-351c77422775",
        "imageUrl": "https://mytfsserver/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://mytfsserver/DefaultCollection/_apis/Identities/d6245f20-2af8-44f4-9451-8107cb2767db",
        "imageUrl": "https://mytfsserver/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 TFS server name ({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://mytfsserver/DefaultCollection/_apis/chat/rooms/305/messages/118943?api-version=1.0

Sample response

{
  "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://mytfsserver/DefaultCollection/_apis/Identities/d6245f20-2af8-44f4-9451-8107cb2767db",
    "imageUrl": "https://mytfsserver/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 TFS server name ({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://mytfsserver/DefaultCollection/_apis/chat/rooms/305/messages/118943?api-version=1.0
{
  "content": "Updated message"
}

Sample response

{
  "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://mytfsserver/DefaultCollection/_apis/Identities/d6245f20-2af8-44f4-9451-8107cb2767db",
    "imageUrl": "https://mytfsserver/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 TFS server name ({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://mytfsserver/DefaultCollection/_apis/chat/rooms/305/messages/118943?api-version=1.0