Conversation management
Guides contents

source_app

Some Twitter accounts may make use of more than one application to send Direct Messages — such as when a human social care app is used alongside a separate bot app to manage the same account. In these cases, it can be helpful for developers to know which app was used to send a given message.

The new source_app object will return this information for all DMs sent by an account. This object is included in the JSON payload for webhooks and REST endpoints. It is relevant on the read path only — Twitter automatically adds this information based on the app authentication used to post a DM. This value will not be returned in the response for POST events/new.json.

Note: This same pattern exists with Tweets with the source property, however the JSON structure is different. Please also note that this object will not be included for DMs received by an authenticating user and is only included for DMs sent by the authenticating user.

source_app object

id The ID of the Twitter app used by the authenticating user to send the DM.
name The name of the Twitter app used by the authenticating user to send the DM.
url The URL of the Twitter app used by the authenticating user to send the DM.

Example for GET direct_messages/events/list

      {
  "event": {
    "type": "message_create",
    "id": "854103000570187779",
    "created_timestamp": "1492468998459",
    "message_create": {
      "target": {
        "recipient_id": "3340250004"
      },
      "sender_id": "51378538",
      "source_app_id": "268278",
      "message_data": {
        "text": "Hello",
        "entities": {
          "hashtags": [],
          "symbols": [],
          "user_mentions": [],
          "urls": []
        }
      }
    }
  }
  "apps": {
    "268278": {
      "id": "268278",
      "name": "Twitter Web Client",
      "url": "http://twitter.com"
    }
  }
}
    

Example for GET direct_messages/events/show

      {
  "events": [
    {
      "type": "message_create",
      "id": "854103000570187779",
      "created_timestamp": "1492468998459",
      "message_create": {
        "target": {
          "recipient_id": "3340250004"
        },
        "sender_id": "51378538",
        "source_app_id": "268278",
        "message_data": {
          "text": "Hello",
          "entities": {
            "hashtags": [],
            "symbols": [],
            "user_mentions": [],
            "urls": []
          }
        }
      }
    },
    {
      "type": "message_create",
      "id": "867807494898188291",
      "created_timestamp": "1495736404524",
      "message_create": {
        "target": {
          "recipient_id": "3340250004"
        },
        "sender_id": "51378538",
        "source_app_id": "9206597",
        "message_data": {
          "text": "World",
          "entities": {
            "hashtags": [],
            "symbols": [],
            "user_mentions": [],
            "urls": []
          }
        }
      }
    },
  ],
  "apps": {
    "9206597": {
      "id": "9206597",
      "name": "BeeToSeaBiz TestApp Awesome",
      "url": "https://twitter.com/beetoseabiz"
    },
    "268278": {
      "id": "268278",
      "name": "Twitter Web Client",
      "url": "http://twitter.com"
    }
  }
}
    
Was this document helpful?
Thank you

Thank you for the feedback. We’re really glad we could help!

Thank you for the feedback. How could we improve this document?
Thank you for the feedback. Your comments will help us improve our documents in the future.