---
title: entities.messageRelation
description: Read message relation records with the messageRelation repository, and change them with the message relation mutations. Same records as the REST MessageRelations entity.
canonical: https://developers.coevera.com/reference/graphql/message-relation/
section: graphql
verification: schema
generatedFrom: schema f155746 (2026-10-20)
publisher: Coevera
---

# entities.messageRelation

Read message relation records with the messageRelation repository, and change them with the message relation mutations. Same records as the REST MessageRelations entity.

REST: [MessageRelations](https://developers.coevera.com/reference/rest/message-relations.md).

## Queries

- `getById(entityId: ID!): MessageRelationEntity` Returns the record with the given id, or null when there is none. Deleted records are returned as well.
- `getByIds(entityIds: [ID!]!): [MessageRelationEntity!]!` Returns the records with the given ids; ids without a record are left out. Deleted records are returned as well.
- `getAll(limit: Int, offset: Int, filter: MessageRelationFilterInput, orderBy: [MessageRelationOrderByInput!], includeDeleted: Boolean): [MessageRelationEntity!]!` Returns the records that match the filter, paged with limit and offset.
- `getByCriteria(filter: MessageRelationFilterInput, orderBy: [MessageRelationOrderByInput!], includeDeleted: Boolean, before: String, after: String, first: Int, last: Int): MessageRelationEntityConnection` Returns the records that match the filter as a cursor-paginated connection.
- `getChangedFieldsSinceRevision(id: UUID!, revision: Int!): [UUID!]!` Returns the ids of the fields of a record that changed after the given revision. Returns an empty list for entities without change tracking.

## Mutations

- `createMessageRelation(input: CreateMessageRelationInput!, validationLevel: [ValidationLevel!]): CreateMessageRelationPayload` Create one record.
- `updateMessageRelation(input: UpdateMessageRelationInput!, validationLevel: [ValidationLevel!], sessionIdToUpdate: String): UpdateMessageRelationPayload` Update fields.
- `bulkUpdateMessageRelation(input: [CreateOrUpdateMessageRelationInput!]!, deleteInput: [DeleteMessageRelationInput!], validationLevel: [ValidationLevel!], rollbackMethod: RollbackMethod, match: MatchingInput): BulkUpdateMessageRelationPayload` Create or update many; per-item results.
- `deleteMessageRelation(input: DeleteMessageRelationInput!): DeleteMessageRelationPayload` Soft-delete.

## Types

### MessageRelationEntity (object)

Link between a message (email or memo) and a record such as an account, contact, lead or opportunity.

- `isDeleteProtected: Boolean!` True when the record is protected against deletion because it must always exist in the space. Deleting a record that is not protected can still fail on other checks. Read-only.
- `id: ID!` Unique identifier of entity.
- `isDeleted: Boolean` Specifies if the entity is considered deleted.
- `modified: DateTime` Last modification time.
- `created: DateTime` Creation time.
- `account: AccountEntity` Account the message is linked to, or empty when not linked to an account.
- `contact: ContactEntity` Contact the message is linked to, or empty when not linked to a contact.
- `customEntity: CustomEntityEntity` Custom entity record the message is linked to, or empty when not linked.
- `lead: LeadEntity` Lead the message is linked to. Set when leadOpptyId resolves to a Lead; otherwise empty.
- `oppty: OpportunityEntity` Opportunity the message is linked to. Set when leadOpptyId resolves to an Opportunity; otherwise empty.
- `email: EmailEntity` Email side of the link. Set when messageId resolves to an Email; otherwise empty.
- `memo: MemoEntity` Memo side of the link. Set when messageId resolves to a Memo; otherwise empty.
- `project: ProjectEntity` Project the message is linked to, or empty when not linked.
- `quote: QuoteEntity` Quote the message is linked to, or empty when not linked.
- `accountId: ID` Id of the linked account.
- `contactId: ID` Id of the linked contact.
- `customEntityId: ID` Id of the linked custom entity record.
- `leadOpptyId: ID` Id of the lead or opportunity the message is linked to, or empty when not linked.
- `messageId: ID!` Id of the email or memo on this link.
- `projectId: ID` Id of the linked project.
- `quoteId: ID` Id of the linked quote.
- `revision: Int` Revision when entity was lastly changed.
- `instancePermissions: [EntityPermsEnum!]! (1 args)` Permissions the current user has on this record, out of the requested ones.

### MessageRelationEntityConnection (object)

Paginated list of MessageRelation records.

- `pageInfo: PageInfo!` Pagination data for this connection.
- `edges: [MessageRelationEntityEdge]!` Contains the nodes in this connection.
- `totalCount: Int` Total number of items in the connection.

### MessageRelationEntityEdge (object)

A Relay edge containing a `MessageRelationEntity` and its cursor.

- `node: MessageRelationEntity` The item at the end of the edge
- `cursor: String!` A cursor for use in pagination

### MessageRelationFilterInput (input)

Filter conditions for MessageRelation records. Conditions on different fields are combined with AND; use OR, AND and NOT for other combinations.

- `OR: [MessageRelationFilterInput!]` Matches records that meet at least one of the listed filters.
- `AND: [MessageRelationFilterInput!]` Matches records that meet all of the listed filters.
- `NOT: MessageRelationFilterInput` Matches records that do not meet this filter.
- `globalSearchQuery: String` Search term matched against the fields that the global search covers for this entity.
- `id: EntityFilterStringField` Unique identifier of entity.
- `isDeleted: Boolean` Specifies if the entity is considered deleted.
- `modified: EntityFilterDateTimeField` Last modification time.
- `created: EntityFilterDateTimeField` Creation time.
- `accountId: EntityFilterStringField` Id of the linked account.
- `contactId: EntityFilterStringField` Id of the linked contact.
- `customEntityId: EntityFilterStringField` Id of the linked custom entity record.
- `leadOpptyId: EntityFilterStringField` Id of the lead or opportunity the message is linked to, or empty when not linked.
- `messageId: EntityFilterStringField` Id of the email or memo on this link.
- `projectId: EntityFilterStringField` Id of the linked project.
- `quoteId: EntityFilterStringField` Id of the linked quote.
- `revision: EntityFilterNumberField` Revision when entity was lastly changed.
- `account: AccountFilterInput` Account the message is linked to, or empty when not linked to an account. Matches records where a related record meets these conditions.
- `contact: ContactFilterInput` Contact the message is linked to, or empty when not linked to a contact. Matches records where a related record meets these conditions.
- `customEntity: CustomEntityFilterInput` Custom entity record the message is linked to, or empty when not linked. Matches records where a related record meets these conditions.
- `lead: LeadFilterInput` Lead the message is linked to. Set when leadOpptyId resolves to a Lead; otherwise empty. Matches records where a related record meets these conditions.
- `oppty: OpportunityFilterInput` Opportunity the message is linked to. Set when leadOpptyId resolves to an Opportunity; otherwise empty. Matches records where a related record meets these conditions.
- `email: EmailFilterInput` Email side of the link. Set when messageId resolves to an Email; otherwise empty. Matches records where a related record meets these conditions.
- `memo: MemoFilterInput` Memo side of the link. Set when messageId resolves to a Memo; otherwise empty. Matches records where a related record meets these conditions.
- `project: ProjectFilterInput` Project the message is linked to, or empty when not linked. Matches records where a related record meets these conditions.
- `quote: QuoteFilterInput` Quote the message is linked to, or empty when not linked. Matches records where a related record meets these conditions.

### MessageRelationOrderByInput (input)

Sorting of MessageRelation records. Set exactly one field in each item; list several items to sort by more fields, in order of priority.

- `id: OrderByEnum` Unique identifier of entity.
- `isDeleted: OrderByEnum` Specifies if the entity is considered deleted.
- `modified: OrderByEnum` Last modification time.
- `created: OrderByEnum` Creation time.
- `account: [AccountOrderByNestedInput!]` Account the message is linked to, or empty when not linked to an account. Sorts by fields of the related record, listed in order of priority.
- `contact: [ContactOrderByNestedInput!]` Contact the message is linked to, or empty when not linked to a contact. Sorts by fields of the related record, listed in order of priority.
- `customEntity: [CustomEntityOrderByNestedInput!]` Custom entity record the message is linked to, or empty when not linked. Sorts by fields of the related record, listed in order of priority.
- `lead: [LeadOrderByNestedInput!]` Lead the message is linked to. Set when leadOpptyId resolves to a Lead; otherwise empty. Sorts by fields of the related record, listed in order of priority.
- `oppty: [OpportunityOrderByNestedInput!]` Opportunity the message is linked to. Set when leadOpptyId resolves to an Opportunity; otherwise empty. Sorts by fields of the related record, listed in order of priority.
- `email: [EmailOrderByNestedInput!]` Email side of the link. Set when messageId resolves to an Email; otherwise empty. Sorts by fields of the related record, listed in order of priority.
- `memo: [MemoOrderByNestedInput!]` Memo side of the link. Set when messageId resolves to a Memo; otherwise empty. Sorts by fields of the related record, listed in order of priority.
- `project: [ProjectOrderByNestedInput!]` Project the message is linked to, or empty when not linked. Sorts by fields of the related record, listed in order of priority.
- `quote: [QuoteOrderByNestedInput!]` Quote the message is linked to, or empty when not linked. Sorts by fields of the related record, listed in order of priority.
- `accountId: OrderByEnum` Id of the linked account.
- `contactId: OrderByEnum` Id of the linked contact.
- `customEntityId: OrderByEnum` Id of the linked custom entity record.
- `leadOpptyId: OrderByEnum` Id of the lead or opportunity the message is linked to, or empty when not linked.
- `messageId: OrderByEnum` Id of the email or memo on this link.
- `projectId: OrderByEnum` Id of the linked project.
- `quoteId: OrderByEnum` Id of the linked quote.
- `revision: OrderByEnum` Revision when entity was lastly changed.

### CreateMessageRelationInput (input)

Field values of a new MessageRelation record.

- `clientMutationId: String` Optional client-supplied identifier passed on a mutation input and echoed back unchanged on its payload, so a client can correlate the response with its request (Relay convention).
- `modified: DateTime` Last modification time.
- `created: DateTime` Creation time.
- `accountId: ID` Id of the linked account.
- `contactId: ID` Id of the linked contact.
- `customEntityId: ID` Id of the linked custom entity record.
- `leadOpptyId: ID` Id of the lead or opportunity the message is linked to, or empty when not linked.
- `messageId: ID!` Id of the email or memo on this link.
- `projectId: ID` Id of the linked project.
- `quoteId: ID` Id of the linked quote.
- `revision: Int` Revision when entity was lastly changed.

### CreateOrUpdateMessageRelationInput (input)

Field values of a MessageRelation record to create, or to update when its id is set.

- `clientMutationId: String` Optional client-supplied identifier passed on a mutation input and echoed back unchanged on its payload, so a client can correlate the response with its request (Relay convention).
- `id: ID` Unique identifier of entity.
- `modified: DateTime` Last modification time.
- `created: DateTime` Creation time.
- `accountId: ID` Id of the linked account.
- `contactId: ID` Id of the linked contact.
- `customEntityId: ID` Id of the linked custom entity record.
- `leadOpptyId: ID` Id of the lead or opportunity the message is linked to, or empty when not linked.
- `messageId: ID` Id of the email or memo on this link.
- `projectId: ID` Id of the linked project.
- `quoteId: ID` Id of the linked quote.
- `revision: Int` Revision when entity was lastly changed.

### DeleteMessageRelationInput (input)

Id of the MessageRelation record to delete.

- `clientMutationId: String` Optional client-supplied identifier passed on a mutation input and echoed back unchanged on its payload, so a client can correlate the response with its request (Relay convention).
- `id: ID!` Unique identifier of entity.
- `leadOpptyId: ID` Id of the lead or opportunity the message is linked to, or empty when not linked.
- `messageId: ID` Id of the email or memo on this link.

### UpdateMessageRelationInput (input)

Id of a MessageRelation record and the field values to change.

- `clientMutationId: String` Optional client-supplied identifier passed on a mutation input and echoed back unchanged on its payload, so a client can correlate the response with its request (Relay convention).
- `id: ID!` Unique identifier of entity.
- `modified: DateTime` Last modification time.
- `created: DateTime` Creation time.
- `accountId: ID` Id of the linked account.
- `contactId: ID` Id of the linked contact.
- `customEntityId: ID` Id of the linked custom entity record.
- `leadOpptyId: ID` Id of the lead or opportunity the message is linked to, or empty when not linked.
- `messageId: ID` Id of the email or memo on this link.
- `projectId: ID` Id of the linked project.
- `quoteId: ID` Id of the linked quote.
- `revision: Int` Revision when entity was lastly changed.

### BulkUpdateMessageRelationPayload (object)

Result of the bulkUpdateMessageRelation mutation.

- `result: BulkUpdateResults!` Ids of the created, updated and deleted records, and the items that failed.

### CreateMessageRelationPayload (object)

Result of the createMessageRelation mutation.

- `messageRelation: MessageRelationEntity` The created record.
- `clientMutationId: String` Optional client-supplied identifier passed on a mutation input and echoed back unchanged on its payload, so a client can correlate the response with its request (Relay convention).

### DeleteMessageRelationPayload (object)

Result of the deleteMessageRelation mutation.

- `messageRelation: MessageRelationEntity` The deleted record.
- `clientMutationId: String` Optional client-supplied identifier passed on a mutation input and echoed back unchanged on its payload, so a client can correlate the response with its request (Relay convention).

### UpdateMessageRelationPayload (object)

Result of the updateMessageRelation mutation.

- `messageRelation: MessageRelationEntity` The updated record.
- `clientMutationId: String` Optional client-supplied identifier passed on a mutation input and echoed back unchanged on its payload, so a client can correlate the response with its request (Relay convention).

Types several repositories share, such as `PageInfo` and the filter fields, are in the [types index](https://developers.coevera.com/reference/graphql/types.md). The [SDL](https://developers.coevera.com/graphql/schema.graphql) has the whole schema in one file.

## Example

```graphql
query FirstMessageRelations {
  entities {
    messageRelation {
      getByCriteria(first: 3, orderBy: [{ modified: Desc }]) {
        totalCount
        edges { node { id modified } }
      }
    }
  }
}
```

```bash
curl 'https://{region}.api.coevera.com/api/v100/app/space/{space_id}/graphql/public' \
  --user "$COEVERA_API_KEY:$COEVERA_API_SECRET" \
  --header 'Content-Type: application/json' \
  --data '{"query":"query FirstMessageRelations { entities { messageRelation { getByCriteria(first: 3, orderBy: [{ modified: Desc }]) { totalCount edges { node { id modified } } } } } }"}'
```
