# Messages

GraphQL interface for messages.

```graphql
enum MESSAGE_SENT_BY {
  ADMIN
  CANDIDATE
}

type MessageAttachment {
  id: String
  name: String
  resourcePath: String
  type: String
  size: Int
}

type Message {
  id: String
  candidateId: String
  sentBy: MESSAGE_SENT_BY
  userId: String
  text: String
  user: User
  replyToMessageId: String
  isRead: Boolean
  attachments: [MessageAttachment]
}

input MessageFilterPaging {
  filter: MessageFilter
  paging: GraphPaging
  sort: GraphSorting
}

input MessageFilter {
  candidateId: String
  contactId: String
  listingId: String
}

type Query {
  messages(input: MessageFilterPaging): [Message]
}

```

Usage of Query:

{% tabs %}
{% tab title="GraphQL" %}

```graphql
query message($candidateId: String, $contactId: String, $listingId: String) {
    messages(
      input: {
        filter: {
          candidateId: $candidateId
          contactId: $contactId
          listingId: $listingId
        }
      }
    ) {
      id
      candidateId
      sentBy
      text
      isRead
      attachments {
        id
        name
        resourcePath
        type
        size
      }
    }
  }
```

**Variables:**

Using either of these 3 should give an error if no variables not given.

```
{
"candidateId": "a50ddf78-c792-4461-b77e-c36ec444ddb5", 
"contactId": "6aec3680-a1de-4e5b-b3d9-67cb4b4727f6",
"listingId": "1840826c-08aa-419c-9779-c0a0dfcbd190"
}

```

{% endtab %}

{% tab title="CURL" %}

```shell
curl --location --request POST 'https://acme-qa.everreal-dev.co/api/reporting/graphql' \
--header 'Authorization: Bearer ....' \
--header 'Content-Type: application/json' \
--data-raw '{"query":"query message($candidateId: String, $contactId: String, $externalContactId: String, $listingId: String) {\n    messages(\n      input: {\n        filter: {\n          candidateId: $candidateId\n          contactId: $contactId\n          externalContactId: $externalContactId\n          listingId: $listingId\n        }\n      }\n    ) {\n      id\n      candidateId\n      sentBy\n      text\n      isRead\n      attachments {\n        id\n        name\n        resourcePath\n        type\n        size\n      }\n    }\n  }","variables":{"candidateId":"a50ddf78-c792-4461-b77e-c36ec444ddb5","contactId":"6aec3680-a1de-4e5b-b3d9-67cb4b4727f6","listingId":"1840826c-08aa-419c-9779-c0a0dfcbd190"}}'
```

{% endtab %}

{% tab title="Javascript" %}

```javascript
var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer ....");
myHeaders.append("Content-Type", "application/json");

var graphql = JSON.stringify({
  query: "query message($candidateId: String, $contactId: String, $externalContactId: String, $listingId: String) {\n    messages(\n      input: {\n        filter: {\n          candidateId: $candidateId\n          contactId: $contactId\n          externalContactId: $externalContactId\n          listingId: $listingId\n        }\n      }\n    ) {\n      id\n      candidateId\n      sentBy\n      text\n      isRead\n      attachments {\n        id\n        name\n        resourcePath\n        type\n        size\n      }\n    }\n  }",
  variables: {"candidateId":"a50ddf78-c792-4461-b77e-c36ec444ddb5","contactId":"6aec3680-a1de-4e5b-b3d9-67cb4b4727f6","listingId":"1840826c-08aa-419c-9779-c0a0dfcbd190"}
})
var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: graphql,
  redirect: 'follow'
};

fetch("https://acme-qa.everreal-dev.co/api/reporting/graphql", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://api-docs.everreal.co/endpoints/messages.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
