communications-mining
latest
false
Communications Mining Developer Guide
Last updated Oct 3, 2024

Comments

Add or update comments

/api/v1/sources/<project>/<source_name>/sync

Permissions required: Edit messages.

Important:

Billable operation

You will be charged 1 AI unit per created comment, or per updated comment (based on its unique ID) if its text was modified.

  • Bash
    curl -X POST 'https://<my_api_endpoint>/api/v1/sources/<project>/<source>/sync' \
        -H "Authorization: Bearer $REINFER_TOKEN" \
        -H "Content-Type: application/json" \
        -d '{
      "comments": [
        {
          "id": "0123456789abcdef",
          "messages": [
            {
              "body": {
                "text": "Alice,\n\nHere are the figures for today.\n\nRegards,\nBob"
              },
              "from": "bob@organisation.org",
              "sent_at": "2011-12-11T11:05:10.000000+00:00",
              "subject": {
                "text": "Today'"'"'s figures"
              },
              "to": [
                "alice@company.com"
              ]
            }
          ],
          "timestamp": "2011-12-11T11:05:10.000000+00:00",
          "user_properties": {
            "string:Recipient Domain": "company.com",
            "string:Sender Domain": "organisation.org"
          }
        },
        {
          "id": "abcdef0123456789",
          "messages": [
            {
              "body": {
                "text": "Hi Bob,\n\nI think these are the wrong numbers - could you check?\n\nThanks again,\nAlice"
              },
              "from": "alice@company.com",
              "sent_at": "2011-12-11T11:18:43.000000+00:00",
              "subject": {
                "text": "Today'"'"'s figures"
              },
              "to": [
                "bob@organisation.org"
              ]
            }
          ],
          "timestamp": "2011-12-11T11:18:43.000000+00:00",
          "user_properties": {
            "string:Recipient Domain": "organisation.org",
            "string:Sender Domain": "company.com"
          }
        }
      ]
    }'curl -X POST 'https://<my_api_endpoint>/api/v1/sources/<project>/<source>/sync' \
        -H "Authorization: Bearer $REINFER_TOKEN" \
        -H "Content-Type: application/json" \
        -d '{
      "comments": [
        {
          "id": "0123456789abcdef",
          "messages": [
            {
              "body": {
                "text": "Alice,\n\nHere are the figures for today.\n\nRegards,\nBob"
              },
              "from": "bob@organisation.org",
              "sent_at": "2011-12-11T11:05:10.000000+00:00",
              "subject": {
                "text": "Today'"'"'s figures"
              },
              "to": [
                "alice@company.com"
              ]
            }
          ],
          "timestamp": "2011-12-11T11:05:10.000000+00:00",
          "user_properties": {
            "string:Recipient Domain": "company.com",
            "string:Sender Domain": "organisation.org"
          }
        },
        {
          "id": "abcdef0123456789",
          "messages": [
            {
              "body": {
                "text": "Hi Bob,\n\nI think these are the wrong numbers - could you check?\n\nThanks again,\nAlice"
              },
              "from": "alice@company.com",
              "sent_at": "2011-12-11T11:18:43.000000+00:00",
              "subject": {
                "text": "Today'"'"'s figures"
              },
              "to": [
                "bob@organisation.org"
              ]
            }
          ],
          "timestamp": "2011-12-11T11:18:43.000000+00:00",
          "user_properties": {
            "string:Recipient Domain": "organisation.org",
            "string:Sender Domain": "company.com"
          }
        }
      ]
    }'
    
  • Node
    const request = require("request");
    
    request.post(
      {
        url: "https://<my_api_endpoint>/api/v1/sources/<project>/<source>/sync",
        headers: {
          Authorization: "Bearer " + process.env.REINFER_TOKEN,
        },
        json: true,
        body: {
          comments: [
            {
              id: "0123456789abcdef",
              messages: [
                {
                  body: {
                    text: "Alice,\n\nHere are the figures for today.\n\nRegards,\nBob",
                  },
                  from: "bob@organisation.org",
                  sent_at: "2011-12-11T11:05:10.000000+00:00",
                  subject: { text: "Today's figures" },
                  to: ["alice@company.com"],
                },
              ],
              timestamp: "2011-12-11T11:05:10.000000+00:00",
              user_properties: {
                "string:Recipient Domain": "company.com",
                "string:Sender Domain": "organisation.org",
              },
            },
            {
              id: "abcdef0123456789",
              messages: [
                {
                  body: {
                    text: "Hi Bob,\n\nI think these are the wrong numbers - could you check?\n\nThanks again,\nAlice",
                  },
                  from: "alice@company.com",
                  sent_at: "2011-12-11T11:18:43.000000+00:00",
                  subject: { text: "Today's figures" },
                  to: ["bob@organisation.org"],
                },
              ],
              timestamp: "2011-12-11T11:18:43.000000+00:00",
              user_properties: {
                "string:Recipient Domain": "organisation.org",
                "string:Sender Domain": "company.com",
              },
            },
          ],
        },
      },
      function (error, response, json) {
        // digest response
        console.log(JSON.stringify(json, null, 2));
      }
    );const request = require("request");
    
    request.post(
      {
        url: "https://<my_api_endpoint>/api/v1/sources/<project>/<source>/sync",
        headers: {
          Authorization: "Bearer " + process.env.REINFER_TOKEN,
        },
        json: true,
        body: {
          comments: [
            {
              id: "0123456789abcdef",
              messages: [
                {
                  body: {
                    text: "Alice,\n\nHere are the figures for today.\n\nRegards,\nBob",
                  },
                  from: "bob@organisation.org",
                  sent_at: "2011-12-11T11:05:10.000000+00:00",
                  subject: { text: "Today's figures" },
                  to: ["alice@company.com"],
                },
              ],
              timestamp: "2011-12-11T11:05:10.000000+00:00",
              user_properties: {
                "string:Recipient Domain": "company.com",
                "string:Sender Domain": "organisation.org",
              },
            },
            {
              id: "abcdef0123456789",
              messages: [
                {
                  body: {
                    text: "Hi Bob,\n\nI think these are the wrong numbers - could you check?\n\nThanks again,\nAlice",
                  },
                  from: "alice@company.com",
                  sent_at: "2011-12-11T11:18:43.000000+00:00",
                  subject: { text: "Today's figures" },
                  to: ["bob@organisation.org"],
                },
              ],
              timestamp: "2011-12-11T11:18:43.000000+00:00",
              user_properties: {
                "string:Recipient Domain": "organisation.org",
                "string:Sender Domain": "company.com",
              },
            },
          ],
        },
      },
      function (error, response, json) {
        // digest response
        console.log(JSON.stringify(json, null, 2));
      }
    );
  • Python
    import json
    import os
    
    import requests
    
    response = requests.post(
        "https://<my_api_endpoint>/api/v1/sources/<project>/<source>/sync",
        headers={"Authorization": "Bearer " + os.environ["REINFER_TOKEN"]},
        json={
            "comments": [
                {
                    "id": "0123456789abcdef",
                    "timestamp": "2011-12-11T11:05:10.000000+00:00",
                    "messages": [
                        {
                            "from": "bob@organisation.org",
                            "to": ["alice@company.com"],
                            "sent_at": "2011-12-11T11:05:10.000000+00:00",
                            "subject": {"text": "Today's figures"},
                            "body": {
                                "text": "Alice,\n\nHere are the figures for today.\n\nRegards,\nBob"
                            },
                        }
                    ],
                    "user_properties": {
                        "string:Sender Domain": "organisation.org",
                        "string:Recipient Domain": "company.com",
                    },
                },
                {
                    "id": "abcdef0123456789",
                    "timestamp": "2011-12-11T11:18:43.000000+00:00",
                    "messages": [
                        {
                            "from": "alice@company.com",
                            "to": ["bob@organisation.org"],
                            "sent_at": "2011-12-11T11:18:43.000000+00:00",
                            "subject": {"text": "Today's figures"},
                            "body": {
                                "text": "Hi Bob,\n\nI think these are the wrong numbers - could you check?\n\nThanks again,\nAlice"
                            },
                        }
                    ],
                    "user_properties": {
                        "string:Sender Domain": "company.com",
                        "string:Recipient Domain": "organisation.org",
                    },
                },
            ]
        },
    )
    
    print(json.dumps(response.json(), indent=2, sort_keys=True))import json
    import os
    
    import requests
    
    response = requests.post(
        "https://<my_api_endpoint>/api/v1/sources/<project>/<source>/sync",
        headers={"Authorization": "Bearer " + os.environ["REINFER_TOKEN"]},
        json={
            "comments": [
                {
                    "id": "0123456789abcdef",
                    "timestamp": "2011-12-11T11:05:10.000000+00:00",
                    "messages": [
                        {
                            "from": "bob@organisation.org",
                            "to": ["alice@company.com"],
                            "sent_at": "2011-12-11T11:05:10.000000+00:00",
                            "subject": {"text": "Today's figures"},
                            "body": {
                                "text": "Alice,\n\nHere are the figures for today.\n\nRegards,\nBob"
                            },
                        }
                    ],
                    "user_properties": {
                        "string:Sender Domain": "organisation.org",
                        "string:Recipient Domain": "company.com",
                    },
                },
                {
                    "id": "abcdef0123456789",
                    "timestamp": "2011-12-11T11:18:43.000000+00:00",
                    "messages": [
                        {
                            "from": "alice@company.com",
                            "to": ["bob@organisation.org"],
                            "sent_at": "2011-12-11T11:18:43.000000+00:00",
                            "subject": {"text": "Today's figures"},
                            "body": {
                                "text": "Hi Bob,\n\nI think these are the wrong numbers - could you check?\n\nThanks again,\nAlice"
                            },
                        }
                    ],
                    "user_properties": {
                        "string:Sender Domain": "company.com",
                        "string:Recipient Domain": "organisation.org",
                    },
                },
            ]
        },
    )
    
    print(json.dumps(response.json(), indent=2, sort_keys=True))
    
  • Response
    {
      "new": 2,
      "status": "ok",
      "unchanged": 0,
      "updated": 0
    }{
      "new": 2,
      "status": "ok",
      "unchanged": 0,
      "updated": 0
    }

A comment's ID uniquely identifies it within a source. If the provided comment ID does not exist in the source, a new comment is created. Otherwise, an existing comment is updated.

NAMETYPEREQUIREDDESCRIPTION
commentsarray<Cmment>yesA batch of maximum 16384 comments, in the format described in the Comment Reference. Larger batches are faster (per comment) than smaller ones.

ASSIGNED GENERAL FIELDS

Assigned general fields will be preserved, unless the text changed significantly. Assigned labels are never discarded.

LARGE REQUESTS

For large requests, this endpoint may take longer to respond. You should increase your client timeout.

Add or update comments from raw emails

/api/v1/sources/<project>/<source_name>/sync-raw-emails

Permissions required: Edit messages

Important:

BILLABLE OPERATION

You will be charged 1 AI unit per created comment, or per updated comment (based on the email's Message ID) if its text was modified.

  • Bash
    curl -X POST 'https://<my_api_endpoint>/api/v1/sources/<project>/<source>/sync-raw-emails' \
        -H "Authorization: Bearer $REINFER_TOKEN" \
        -H "Content-Type: application/json" \
        -d '{
      "documents": [
        {
          "raw_email": {
            "body": {
              "plain": "Hi Bob,\n\nCould you send me today'"'"'s figures?\n\nThanks,\nAlice"
            },
            "headers": {
              "parsed": {
                "Date": "Thu, 09 Jan 2020 16:34:45 +0000",
                "From": "alice@company.com",
                "Message-ID": "abcdef@company.com",
                "References": "<01234@company.com> <56789@company.com>",
                "Subject": "Figures Request",
                "To": "bob@organisation.org"
              }
            }
          },
          "user_properties": {
            "number:Deal Value": 12000,
            "string:City": "London"
          }
        }
      ],
      "include_comments": true,
      "transform_tag": "name.0.ABCD1234"
    }'curl -X POST 'https://<my_api_endpoint>/api/v1/sources/<project>/<source>/sync-raw-emails' \
        -H "Authorization: Bearer $REINFER_TOKEN" \
        -H "Content-Type: application/json" \
        -d '{
      "documents": [
        {
          "raw_email": {
            "body": {
              "plain": "Hi Bob,\n\nCould you send me today'"'"'s figures?\n\nThanks,\nAlice"
            },
            "headers": {
              "parsed": {
                "Date": "Thu, 09 Jan 2020 16:34:45 +0000",
                "From": "alice@company.com",
                "Message-ID": "abcdef@company.com",
                "References": "<01234@company.com> <56789@company.com>",
                "Subject": "Figures Request",
                "To": "bob@organisation.org"
              }
            }
          },
          "user_properties": {
            "number:Deal Value": 12000,
            "string:City": "London"
          }
        }
      ],
      "include_comments": true,
      "transform_tag": "name.0.ABCD1234"
    }'
    
  • Node
    const request = require("request");
    
    request.post(
      {
        url: "https://<my_api_endpoint>/api/v1/sources/<project>/<source>/sync-raw-emails",
        headers: {
          Authorization: "Bearer " + process.env.REINFER_TOKEN,
        },
        json: true,
        body: {
          documents: [
            {
              raw_email: {
                body: {
                  plain:
                    "Hi Bob,\n\nCould you send me today's figures?\n\nThanks,\nAlice",
                },
                headers: {
                  parsed: {
                    Date: "Thu, 09 Jan 2020 16:34:45 +0000",
                    From: "alice@company.com",
                    "Message-ID": "abcdef@company.com",
                    References: "<01234@company.com> <56789@company.com>",
                    Subject: "Figures Request",
                    To: "bob@organisation.org",
                  },
                },
              },
              user_properties: {
                "number:Deal Value": 12000,
                "string:City": "London",
              },
            },
          ],
          include_messages: true,
          transform_tag: "name.0.ABCD1234",
        },
      },
      function (error, response, json) {
        // digest response
        console.log(JSON.stringify(json, null, 2));
      }
    );const request = require("request");
    
    request.post(
      {
        url: "https://<my_api_endpoint>/api/v1/sources/<project>/<source>/sync-raw-emails",
        headers: {
          Authorization: "Bearer " + process.env.REINFER_TOKEN,
        },
        json: true,
        body: {
          documents: [
            {
              raw_email: {
                body: {
                  plain:
                    "Hi Bob,\n\nCould you send me today's figures?\n\nThanks,\nAlice",
                },
                headers: {
                  parsed: {
                    Date: "Thu, 09 Jan 2020 16:34:45 +0000",
                    From: "alice@company.com",
                    "Message-ID": "abcdef@company.com",
                    References: "<01234@company.com> <56789@company.com>",
                    Subject: "Figures Request",
                    To: "bob@organisation.org",
                  },
                },
              },
              user_properties: {
                "number:Deal Value": 12000,
                "string:City": "London",
              },
            },
          ],
          include_messages: true,
          transform_tag: "name.0.ABCD1234",
        },
      },
      function (error, response, json) {
        // digest response
        console.log(JSON.stringify(json, null, 2));
      }
    );
  • Python
    import json
    import os
    
    import requests
    
    response = requests.post(
        "https://<my_api_endpoint>/api/v1/sources/<project>/<source>/sync-raw-emails",
        headers={"Authorization": "Bearer " + os.environ["REINFER_TOKEN"]},
        json={
            "transform_tag": "name.0.ABCD1234",
            "documents": [
                {
                    "raw_email": {
                        "headers": {
                            "parsed": {
                                "Message-ID": "abcdef@company.com",
                                "Date": "Thu, 09 Jan 2020 16:34:45 +0000",
                                "Subject": "Figures Request",
                                "From": "alice@company.com",
                                "To": "bob@organisation.org",
                                "References": "<01234@company.com> <56789@company.com>",
                            }
                        },
                        "body": {
                            "plain": "Hi Bob,\n\nCould you send me today's figures?\n\nThanks,\nAlice"
                        },
                    },
                    "user_properties": {
                        "string:City": "London",
                        "number:Deal Value": 12000,
                    },
                }
            ],
            "include_comments": True,
        },
    )
    
    print(json.dumps(response.json(), indent=2, sort_keys=True))import json
    import os
    
    import requests
    
    response = requests.post(
        "https://<my_api_endpoint>/api/v1/sources/<project>/<source>/sync-raw-emails",
        headers={"Authorization": "Bearer " + os.environ["REINFER_TOKEN"]},
        json={
            "transform_tag": "name.0.ABCD1234",
            "documents": [
                {
                    "raw_email": {
                        "headers": {
                            "parsed": {
                                "Message-ID": "abcdef@company.com",
                                "Date": "Thu, 09 Jan 2020 16:34:45 +0000",
                                "Subject": "Figures Request",
                                "From": "alice@company.com",
                                "To": "bob@organisation.org",
                                "References": "<01234@company.com> <56789@company.com>",
                            }
                        },
                        "body": {
                            "plain": "Hi Bob,\n\nCould you send me today's figures?\n\nThanks,\nAlice"
                        },
                    },
                    "user_properties": {
                        "string:City": "London",
                        "number:Deal Value": 12000,
                    },
                }
            ],
            "include_comments": True,
        },
    )
    
    print(json.dumps(response.json(), indent=2, sort_keys=True))
    
  • Response
    {
      "comments": [
        {
          "attachments": [],
          "id": "61626364656640636f6d70616e792e636f6d",
          "messages": [
            {
              "body": {
                "text": "Hi Bob,\n\nCould you send me today's figures?"
              },
              "from": "alice@company.com",
              "sent_at": "2020-01-09T16:34:45Z",
              "signature": {
                "text": "Thanks,\nAlice"
              },
              "subject": {
                "text": "Figures Request"
              },
              "to": ["bob@organisation.org"]
            }
          ],
          "source_id": "c1fb849b855841de",
          "text_format": "plain",
          "thread_id": "3c303132333440636f6d70616e792e636f6d3e",
          "timestamp": "2020-01-09T16:34:45Z",
          "uid": "c1fb849b855841de.61626364656640636f6d70616e792e636f6d",
          "user_properties": {
            "number:Deal Value": 12000,
            "number:Participant Count": 2,
            "number:Position in Thread": 3,
            "number:Recipient Count": 1,
            "string:City": "London",
            "string:Has Signature": "Yes",
            "string:Message ID": "abcdef@company.com",
            "string:Sender": "alice@company.com",
            "string:Sender Domain": "company.com",
            "string:Thread": "<01234@company.com>"
          }
        }
      ],
      "new": 1,
      "status": "ok",
      "unchanged": 0,
      "updated": 0
    }{
      "comments": [
        {
          "attachments": [],
          "id": "61626364656640636f6d70616e792e636f6d",
          "messages": [
            {
              "body": {
                "text": "Hi Bob,\n\nCould you send me today's figures?"
              },
              "from": "alice@company.com",
              "sent_at": "2020-01-09T16:34:45Z",
              "signature": {
                "text": "Thanks,\nAlice"
              },
              "subject": {
                "text": "Figures Request"
              },
              "to": ["bob@organisation.org"]
            }
          ],
          "source_id": "c1fb849b855841de",
          "text_format": "plain",
          "thread_id": "3c303132333440636f6d70616e792e636f6d3e",
          "timestamp": "2020-01-09T16:34:45Z",
          "uid": "c1fb849b855841de.61626364656640636f6d70616e792e636f6d",
          "user_properties": {
            "number:Deal Value": 12000,
            "number:Participant Count": 2,
            "number:Position in Thread": 3,
            "number:Recipient Count": 1,
            "string:City": "London",
            "string:Has Signature": "Yes",
            "string:Message ID": "abcdef@company.com",
            "string:Sender": "alice@company.com",
            "string:Sender Domain": "company.com",
            "string:Thread": "<01234@company.com>"
          }
        }
      ],
      "new": 1,
      "status": "ok",
      "unchanged": 0,
      "updated": 0
    }

Each raw email will be converted to a Communications Mining comment. Communications Mining will generate the comment's ID based on the email's "Message-ID" header. If a comment with this comment ID does not exist in the source, a new comment will be created. Otherwise, an existing comment will be updated.

When converting a raw email to a comment, Communications Mining will clean the email body and generate metadata from email headers. You can set include_comments to true to include the generated comments in the response. The comments will be returned in the format described in the Comment Reference.
NAMETYPEREQUIREDDESCRIPTION
transform_tagstringyesA tag identifying the email integration sending the data. You should have received this tag during integration configuration setup.
documentsarray<Document>yesA batch of maximum 16384 documents in the format described below. Larger batches are faster (per document) than smaller ones.
include_commentsbooleannoIf set to true, the comments parsed from the emails will be returned in the response body.
override_user_propertiesarray<string>noUser properties supplied in documents will override auto-generated user properties if their names appear in this list. The user property names in this list should be specified without the type prefix, e.g. as My Property and not string:My Property.

Where Document has the following format:

NAMETYPEREQUIREDDESCRIPTION
raw_emailRawEmailyesEmail data, in the format described in the Comment Reference.
comment_idstringnoUniquely identifies a comment. If no comment ID is provided, Communications Mining will generate the comment ID from the email's message ID. The format is described in the Comment Reference.
user_propertiesmap<string, string | number>noAny user-defined metadata that applies to the comment. The format is described in the Comment Reference.
Note: Some user properties are generated based on the email content. If these conflict with uploaded user properties, the request will fail with 422 Unprocessable Entity.
Warning:

ASSIGNED GENERAL FIELDS

Communications Mining will generate the contents of the comment's "messages" from the raw email body and a subset of the raw email headers, taking into account the specified transform tag. Assigned general fields will be preserved, unless the text changed significantly. Assigned labels are never discarded.

Important:

LARGE REQUESTS

For large requests, this endpoint may take longer to respond. You should increase your client timeout.

Delete comments

/api/v1/sources/<project>/<source_name>/comments?id=<comment_id0>[&id=<comment_id1>...]

Permissions required: Edit messages

  • Bash
    curl -X DELETE 'https://<my_api_endpoint>/api/v1/sources/<project>/<source_name>/comments?id=abcdef0123456789' \
        -H "Authorization: Bearer $REINFER_TOKEN"curl -X DELETE 'https://<my_api_endpoint>/api/v1/sources/<project>/<source_name>/comments?id=abcdef0123456789' \
        -H "Authorization: Bearer $REINFER_TOKEN"
    
  • Node
    const request = require("request");
    
    request.delete(
      {
        url: "https://<my_api_endpoint>/api/v1/sources/<project>/<source_name>/comments?id=abcdef0123456789",
        headers: {
          Authorization: "Bearer " + process.env.REINFER_TOKEN,
        },
      },
      function (error, response, json) {
        // digest response
        console.log(JSON.stringify(json, null, 2));
      }
    );const request = require("request");
    
    request.delete(
      {
        url: "https://<my_api_endpoint>/api/v1/sources/<project>/<source_name>/comments?id=abcdef0123456789",
        headers: {
          Authorization: "Bearer " + process.env.REINFER_TOKEN,
        },
      },
      function (error, response, json) {
        // digest response
        console.log(JSON.stringify(json, null, 2));
      }
    );
  • Python
    import json
    import os
    
    import requests
    
    response = requests.delete(
        "https://<my_api_endpoint>/api/v1/sources/<project>/<source_name>/comments?id=abcdef0123456789",
        headers={"Authorization": "Bearer " + os.environ["REINFER_TOKEN"]},
    )
    
    print(json.dumps(response.json(), indent=2, sort_keys=True))import json
    import os
    
    import requests
    
    response = requests.delete(
        "https://<my_api_endpoint>/api/v1/sources/<project>/<source_name>/comments?id=abcdef0123456789",
        headers={"Authorization": "Bearer " + os.environ["REINFER_TOKEN"]},
    )
    
    print(json.dumps(response.json(), indent=2, sort_keys=True))
    
  • Response
    {
      "status": "ok"
    }{
      "status": "ok"
    }

Individual comments can be deleted from a source, using the ID provided when the comment was added.

All data associated with this comment will be permanently deleted.

Get a comment by id

/api/v1/sources/<project>/<source_name>/comments/<comment_id>

Permissions required: View sources

  • Bash
    curl -X GET 'https://<my_api_endpoint>/api/v1/sources/<project>/<source>/comments/0123456789abcdef' \
        -H "Authorization: Bearer $REINFER_TOKEN"curl -X GET 'https://<my_api_endpoint>/api/v1/sources/<project>/<source>/comments/0123456789abcdef' \
        -H "Authorization: Bearer $REINFER_TOKEN"
    
  • Node
    const request = require("request");
    
    request.get(
      {
        url: "https://<my_api_endpoint>/api/v1/sources/<project>/<source>/comments/0123456789abcdef",
        headers: {
          Authorization: "Bearer " + process.env.REINFER_TOKEN,
        },
      },
      function (error, response, json) {
        // digest response
        console.log(JSON.stringify(json, null, 2));
      }
    );const request = require("request");
    
    request.get(
      {
        url: "https://<my_api_endpoint>/api/v1/sources/<project>/<source>/comments/0123456789abcdef",
        headers: {
          Authorization: "Bearer " + process.env.REINFER_TOKEN,
        },
      },
      function (error, response, json) {
        // digest response
        console.log(JSON.stringify(json, null, 2));
      }
    );
  • Python
    import json
    import os
    
    import requests
    
    response = requests.get(
        "https://<my_api_endpoint>/api/v1/sources/<project>/<source>/comments/0123456789abcdef",
        headers={"Authorization": "Bearer " + os.environ["REINFER_TOKEN"]},
    )
    
    print(json.dumps(response.json(), indent=2, sort_keys=True))import json
    import os
    
    import requests
    
    response = requests.get(
        "https://<my_api_endpoint>/api/v1/sources/<project>/<source>/comments/0123456789abcdef",
        headers={"Authorization": "Bearer " + os.environ["REINFER_TOKEN"]},
    )
    
    print(json.dumps(response.json(), indent=2, sort_keys=True))
    
  • Response
    {
      "comment": {
        "context": "1596721237668",
        "created_at": "2020-08-06T13:20:28.531000Z",
        "id": "0123456789abcdef",
        "last_modified": "2020-08-06T13:40:37.668000Z",
        "messages": [
          {
            "body": {
              "text": "Alice,\n\nHere are the figures for today.\n\nRegards,\nBob"
            },
            "from": "bob@organisation.org",
            "sent_at": "2011-12-11T11:05:10Z",
            "subject": {
              "text": "Today's figures"
            },
            "to": ["alice@company.com"]
          }
        ],
        "source_id": "47194279497e141e",
        "text_format": "plain",
        "timestamp": "2011-12-11T11:05:10Z",
        "uid": "47194279497e141e.0123456789abcdef",
        "user_properties": {
          "string:Recipient Domain": "company.com",
          "string:Sender Domain": "organisation.org"
        }
      },
      "status": "ok"
    }{
      "comment": {
        "context": "1596721237668",
        "created_at": "2020-08-06T13:20:28.531000Z",
        "id": "0123456789abcdef",
        "last_modified": "2020-08-06T13:40:37.668000Z",
        "messages": [
          {
            "body": {
              "text": "Alice,\n\nHere are the figures for today.\n\nRegards,\nBob"
            },
            "from": "bob@organisation.org",
            "sent_at": "2011-12-11T11:05:10Z",
            "subject": {
              "text": "Today's figures"
            },
            "to": ["alice@company.com"]
          }
        ],
        "source_id": "47194279497e141e",
        "text_format": "plain",
        "timestamp": "2011-12-11T11:05:10Z",
        "uid": "47194279497e141e.0123456789abcdef",
        "user_properties": {
          "string:Recipient Domain": "company.com",
          "string:Sender Domain": "organisation.org"
        }
      },
      "status": "ok"
    }

The comment will be returned in the format described in the Comment Reference.

Get comments by thread id

/api/v1/sources/<project>/<source_name>/threads?id=<thread_id0>[&id=<thread_id1>...]

Permissions required: View sources

  • Bash
    curl -X GET 'https://<my_api_endpoint>/api/v1/sources/<project>/<source>/threads?id=185521538102&id=81745162' \
        -H "Authorization: Bearer $REINFER_TOKEN"curl -X GET 'https://<my_api_endpoint>/api/v1/sources/<project>/<source>/threads?id=185521538102&id=81745162' \
        -H "Authorization: Bearer $REINFER_TOKEN"
    
  • Node
    const request = require("request");
    
    request.get(
      {
        url: "https://<my_api_endpoint>/api/v1/sources/<project>/<source>/threads?id=185521538102&id=81745162",
        headers: {
          Authorization: "Bearer " + process.env.REINFER_TOKEN,
        },
      },
      function (error, response, json) {
        // digest response
        console.log(JSON.stringify(json, null, 2));
      }
    );const request = require("request");
    
    request.get(
      {
        url: "https://<my_api_endpoint>/api/v1/sources/<project>/<source>/threads?id=185521538102&id=81745162",
        headers: {
          Authorization: "Bearer " + process.env.REINFER_TOKEN,
        },
      },
      function (error, response, json) {
        // digest response
        console.log(JSON.stringify(json, null, 2));
      }
    );
  • Python
    import json
    import os
    
    import requests
    
    response = requests.get(
        "https://<my_api_endpoint>/api/v1/sources/<project>/<source>/threads?id=185521538102&id=81745162",
        headers={"Authorization": "Bearer " + os.environ["REINFER_TOKEN"]},
    )
    
    print(json.dumps(response.json(), indent=2, sort_keys=True))import json
    import os
    
    import requests
    
    response = requests.get(
        "https://<my_api_endpoint>/api/v1/sources/<project>/<source>/threads?id=185521538102&id=81745162",
        headers={"Authorization": "Bearer " + os.environ["REINFER_TOKEN"]},
    )
    
    print(json.dumps(response.json(), indent=2, sort_keys=True))
    
  • Response
    {
      "status": "ok",
      "threads": [
        {
          "messages": ["4321dcba.1234", "4321dcba.2345", "4321dcba.3456"],
          "thread_id": "185521538102"
        },
        {
          "messages": [],
          "thread_id": "81745162"
        }
      ]
    }{
      "status": "ok",
      "threads": [
        {
          "messages": ["4321dcba.1234", "4321dcba.2345", "4321dcba.3456"],
          "thread_id": "185521538102"
        },
        {
          "messages": [],
          "thread_id": "81745162"
        }
      ]
    }
For each specified thread ID, the response will contain a list of comment UIDs (in the format of source_id.comment_id) that belong to that thread. Note that you will not get an error if you provide a thread ID that does not exist; instead the corresponding list of comments in the response will be empty.

Was this page helpful?

Get The Help You Need
Learning RPA - Automation Courses
UiPath Community Forum
Uipath Logo White
Trust and Security
© 2005-2024 UiPath. All rights reserved.