---
schema_version: "1"
id: c962818255ababc67443fe68b3173818a752f51896dbdced4855e1f673c126b3
title: MessagingSession
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/object_reference/sforce_api_objects_messagingsession.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_messagingsession.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 984c6fbd3334db5cafe2335e21729ea9589e0848b9604c9e9b40ef12b463aa7f
description: Represents a session on a Messaging channel. This object is available in API version 47.0 and later.
---
# MessagingSession

Represents a session on a Messaging channel. This object is available in API version 47.0 and later.

## Supported Calls

create(), delete(), describeLayout(), describeSObjects(), getDeleted(), getUpdated(), query(), retrieve(), search(), undelete(), update(), upsert()

## Fields

| Field | Details |
| --- | --- |
| AcceptTime | 
Type

dateTime

Properties

Create, Filter, Nillable, Sort, Update

Description

The time when an agent accepts an incoming Messaging session.



 |
| AgentMessageCount | 

Type

int

Properties

Nillable

Description

The number of messages sent by the agent during the session.



 |
| AgentType | 

Type

picklist

Properties

Create, Defaulted on create, Filter, Group, Nillable, Restricted picklist, Sort

Description

The type of agent that is assigned to the Messaging session. Possible values are:

- Agent
- Bot
- BotToAgent—Bot & Agent
- System—Used for triggered outbound messages





 |
| CampaignId | 

Type

reference

Properties

Create, Filter, Group, Nillable, Sort, Update

Description

The ID of the related campaign. Available in API version 67.0 and later.

This field is a relationship field.

Relationship Name

Campaign

Relationship Type

Lookup

Refers To

Campaign



 |
| CaseId | 

Type

reference

Properties

Create, Filter, Group, Nillable, Sort, Update

Description

The ID of the case associated with this Messaging session.



 |
| ChannelEndUserFormula | 

Type

string

Properties

Filter, Group, idLookup, Nillable, Sort

Description

A concatenation of the Messaging channel and Messaging user.



 |
|  |  |
|  |  |
| ChannelKey | 

Type

string

Properties

Filter, Group, Nillable, Sort

Description

The unique identifier for the associated Messaging channel.



 |
| ChannelLocale | 

Type

string

Properties

Create, Filter, Group, Nillable, Sort, Update

Description

The locale of the associated Messaging channel.



 |
| ChannelName | 

Type

string

Properties

Filter, Group, Nillable, Sort

Description

The name of the associated Messaging channel.



 |
| ChannelType | 

Type

picklist

Properties

Filter, Group, Nillable, Restricted picklist, Sort

Description

The type of the associated Messaging channel. Possible values are:

- Alexa
- AppleBusinessChat—Represents Apple Messages for Business.
- Email
- EmbeddedMessaging—Available in API version 55.0 and later.
- Facebook
- GoogleHome
- Line
- Omega
- Phone
- Text
- Voice
- WeChat
- WebChat
- WhatsApp





 |
| ConversationId | 

Type

reference

Properties

Create, Filter, Group, Nillable, Sort

Description

The ID of the related conversation. Available in API version 55.0 and later.

This field is a relationship field.

Relationship Name

Conversation

Relationship Type

Lookup

Refers To

Conversation



 |
| EndedByType | 

Type

picklist

Properties

Create, Filter, Group, Nillable, Restricted picklist, Sort

Description

Who or what ended the enhanced messaging session. Possible values are:

- Agent
- Bot
- EndUser
- System:
    - The session is inactive for a while, so the session ends.
    - An automation ends the session.
    - The session ended because of an error.





 |
| EndTime | 

Type

dateTime

Properties

Create, Filter, Nillable, Sort

Description

The time when the Messaging session ended.



 |
| EndUserAccountId | 

Type

reference

Properties

Filter, Group, Nillable, Sort

Description

The ID of the end user's account record.

This is a relationship field.

Relationship Name

EndUserAccount

Relationship Type

Lookup

Refers To

Account



 |
| EndUserContactId | 

Type

reference

Properties

Filter, Group, Nillable, Sort

Description

The ID of the end user's contact record.

This is a relationship field.

Relationship Name

EndUserContact

Relationship Type

Lookup

Refers To

Contact



 |
| EndUserLanguage | 

Type

picklist

Properties

Create, Filter, Group, Nillable, Restricted picklist, Sort, Update

Description

The preferred language of the messaging user who participated in the messaging session.



 |
| EndUserMessageCount | 

Type

int

Properties

Nillable

Description

The number of messages sent by the Messaging end user.



 |
| LastReferencedDate | 

Type

dateTime

Properties

Filter, Nillable, Sort

Description

The timestamp for when the current user last viewed a record related to this record.



 |
| LastViewedDate | 

Type

dateTime

Properties

Filter, Nillable, Sort

Description

The timestamp for when the current user last viewed this record. If this value is null, this record might only have been referenced (LastReferencedDate) and not viewed.



 |
| LeadId | 

Type

reference

Properties

Create, Filter, Group, Nillable, Sort, Update

Description

The ID of the Lead associated with this Messaging session.



 |
| MessagingChannelId | 

Type

reference

Properties

Create, Filter, Group, Sort

Description

The ID of the Messaging channel associated with this Messaging session.

This is a relationship field.

Relationship Name

MessagingChannel

Relationship Type

Lookup

Refers To

MessagingChannel



 |
| MessagingEndUserId | 

Type

reference

Properties

Create, Filter, Group, Sort

Description

The ID of the Messaging end user associated with this Messaging session.

This is a relationship field.

Relationship Name

MessagingEndUser

Relationship Type

Lookup

Refers To

MessagingEndUser



 |
| Name | 

Type

string

Properties

Autonumber, Defaulted on create, Filter, idLookup, Sort

Description

The name of this Messaging session.



 |
| OpportunityId | 

Type

reference

Properties

Create, Filter, Group, Nillable, Sort, Update

Description

The ID of the opportunity record associated with this Messaging session.



 |
| Origin | 

Type

picklist

Properties

Create, Defaulted on create, Filter, Group, Restricted picklist, Sort

Description

The origin of this Messaging session. Possible values are:

- AgentInitiated
- ConversationClose—Messaging user deleted the conversation in Apple Messages
- ConversationControlLost—Third-party bot resumes control from Salesforce bot or agent
- Help
- InboundInitiated
- OptIn—Opt In Status Change
- OptOut—Opt Out Status Change
- TriggeredOutbound

Messaging sessions can’t be created using Apex code. They can be created only through customer initiation or by using Process Builder, flows, or the Start Conversation action.



 |
| OwnerId | 

Type

reference

Properties

Create, Defaulted on create, Filter, Group, Sort, Update

Description

The ID of the owner associated with this Messaging session.

This is a polymorphic relationship field.

Relationship Name

Owner

Relationship Type

Lookup

Refers To

Group, User



 |
| PreviewDetails | 

Type

string

Properties

Nillable

Description

The preview shown to an agent for this Messaging session.



 |
| SessionKey | 

Type

string

Properties

Create, Filter, Group, Nillable, Sort

Description

The identifier for the Messaging session.



 |
| StartTime | 

Type

dateTime

Properties

Create, Filter, Nillable, Sort

Description

The time when the Messaging session started.



 |
| Status | 

Type

picklist

Properties

Create, Filter, Group, Restricted picklist, Sort

Description

The status of the Messaging session. Possible values are:

- New (standard channels only)
- Active
- Consent (enhanced channels only)
- Waiting
- Paused (enhanced channels only)
- Inactive (enhanced channels only)
- Ended
- Error (enhanced channels only)

To learn more about these statuses, see [Lifecycle of a Messaging Session](https://help.salesforce.com/s/articleView?id=service.messaging_life_cycle.htm&type=5&language=en_US "HTML (New Window)") in Salesforce Help.



 |
| TargetUserId | 

Type

reference

Properties

Create, Filter, Group, Nillable, Sort, Update

Description

The ID of the target user associated with this Messaging session.

This is a relationship field.

Relationship Name

TargetUser

Relationship Type

Lookup

Refers To

User



 |

## Usage

To monitor messaging session activity, report on the MessagingSession and [MessagingSessionMetrics](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_messagingsessionmetrics.htm "Represents a metric gathered about a specific enhanced messaging session, such as average agent response time. This object is available starting in October 2024 in API version 62.0 and later.") objects. MessagingSessionMetrics captures metrics about a messaging session, such as agent and end user response time. See [Report on Messaging Activity in Service Cloud](https://help.salesforce.com/s/articleView?id=service.messaging_reporting.htm&type=5&language=en_US "HTML (New Window)").

## Associated Objects

This object has the following associated objects. Unless noted, they’re available in the same API version as this object.

[MessagingSessionChangeEvent](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_associated_objects_change_event.htm "A ChangeEvent object is available for each object that supports Change Data Capture. You can subscribe to a stream of change events using Change Data Capture to receive data tied to record changes in Salesforce. Changes include record creation, updates to an existing record, deletion of a record, and undeletion of a record. A change event isn’t a Salesforce object—it doesn’t support CRUD operations or queries. It’s included in the object reference so you can discover which Salesforce objects support change events.") (API version 62.0)

Change events are available for the object.

[MessagingSessionFeed](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_associated_objects_feed.htm "StandardObjectNameFeed is the model for all feed objects associated with standard objects. These objects represent the posts and feed-tracked changes of a standard object.")

Feed tracking is available for the object.

[MessagingSessionHistory](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_associated_objects_history.htm "StandardObjectNameHistory is the model for all history objects associated with standard objects. These objects represent the history of changes to the values in the fields of a standard object.")

History is available for tracked fields of the object.

[MessagingSessionOwnerSharingRule](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_associated_objects_ownersharingrule.htm "StandardObjectNameOwnerSharingRule is the model for all owner sharing rule objects associated with standard objects. These objects represent a rule for sharing a standard object with users other than the owner.")

Sharing rules are available for the object.

[MessagingSessionShare](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_associated_objects_share.htm "StandardObjectNameShare is the model for all share objects associated with standard objects. These objects represent a sharing entry on the standard object.")

Sharing is available for the object.