Skip to main content

Add or update comments#

POST/api/v1/sources/<organisation>/<source_name>/sync
Permissions required: Edit verbatims
curl -X POST 'https://reinfer.io/api/v1/sources/<organisation>/<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"
}
}
]
}'

A comment's ID uniquely identifies it within a source. If the provided comment ID does not exist in the source, a new comment will be created. Otherwise, an existing comment will be updated. (When a comment is updated, any assigned labels will still apply, while any assigned entities will be discarded).

NameTypeRequiredDescription
commentsarray<Comment>yesA batch of at most 1024 comments, in the format described in the Comment Reference. Larger batches are faster (per comment) that smaller ones.

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

Add or update comments from raw emails#

POST/api/v1/sources/<organisation>/<source_name>/sync-raw-emails
Permissions required: Edit verbatims
curl -X POST 'https://reinfer.io/api/v1/sources/<organisation>/<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",
"Subject": "Figures Request",
"To": "bob@organisation.org"
}
}
},
"user_properties": {
"number:Deal Value": 12000,
"string:City": "London"
}
}
],
"include_comments": true,
"transform_tag": "name.0.ABCD1234"
}'

You should use this endpoint if you want to upload raw emails into Re:infer. Re:infer will automatically clean the email bodies, convert the emails to comments, enrich them with additional metadata, and assign them a unique ID.

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 recieved this tag during integration configuration setup.
documentsarray<Document>yesA batch of at most 4096 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 below.
comment_idstringnoIdentifies a comment uniquely. If no comment ID is provided, Re:infer 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.

Where RawEmail has the following format:

NameTypeRequiredDescription
headersHeadersyesAn object containing the headers of the email.
bodyBodyyesAn object containing the main body of the email.

Where Headers has the following format:

NameTypeRequiredDescription
rawstringnoOne of raw and parsed is required. The raw email headers, given as a single string, with each header on its own line.
parsedmap<string, string | array<string>>noOne of raw and parsed is required. The parsed email headers, given as an object with string keys and string or array<string> values. Each key represents one email header. Lists of values will be concatenated with , before being set as a single header value.

If you require duplicate header keys, please use raw instead.

Where Body has the following format:

NameTypeRequiredDescription
plainstringnoAt least one of plain and html is required. The plaintext content of the email.
htmlstringnoAt least one of plain and html is required. The HTML content of the email.

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

Delete comments#

DELETE/api/v1/sources/<organisation>/<source_name>/comments?ids=<comment_id0>[,<comment_id1>,...]
Permissions required: Edit verbatims
curl -X DELETE 'https://reinfer.io/api/v1/sources/<organisation>/<source_name>/comments?ids=abcdef0123456789' \
-H "Authorization: Bearer $REINFER_TOKEN"

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#

GET/api/v1/sources/<organisation>/<source_name>/comments/<comment_id>
Permissions required: View sources
curl -X GET 'https://reinfer.io/api/v1/sources/<organisation>/<source>/comments/0123456789abcdef' \
-H "Authorization: Bearer $REINFER_TOKEN"

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