API - Integration with other services

Email This Issue provides two types of API components that makes it possible to integrate it with other addons or external services.

REST API

Send emails

The REST API is a RESTFul service method that will send emails.

Request Body Json

Request Body must be a well formatted Json object with the following structure.

Request Body Json

{
"issue":"BD-1", 
"to":["joe@foocompany.com","admin","g:jira-administrators","r:10000"],
"cc":["mary@anothercompany.com", "o:lead", "o:watchers"],
"bcc":[],
"emailSubject":"This is the email's subject as if the user entered it",
"emailBody":"This is the email body",
"addAttachments":"ALL",
"emailTemplate":"Acknowledge Issue",
"emailOptions":
  {
  "addToWatchers":"true",
  "replyToMe":"true",
  "mailAsMe":"false",
  "addComments":"true",
  "suppressCommentEvent":"true", 
  "emailFormat":"text",
  "commentVisibility":"g:jira-administrators",
  "richHtml":"false"
  },
"payload":{"pay1":"val1"}
} 

Fields in the Json object are the following:

Important: Only the issue field is mandatory.

Request Statistics

The REST API is a RESTFul service method that will return the number of email items from the audit log.

Request Email Items from the Audit Log

The REST API is a RESTFul service method that will return email items from the audit log matching the query parameters.

Response structure

[
{
"issueId": 22900,
"subject": "(IT-349) Új request by customer \"Hello WORLD\"",
"body": <email body>,
"to": <to recipients>,
"cc":<cc recipients>,
"from": <sender email address>,
"format": <email format>,
"actorUserKey": <user key>,
"type": <type of email item>,
"source": <trigger of the email>,
"date": <date and time the email was sent or processed>
},]

Queue Statistics

SINCE 9.0.0

Incoming Queue Statistics

Outgoing Queue Statistics

Mail Generation Queue

OSGi Component API

In case, your Jira add-on wants to use Jira Email This Issue's email capabilities, you can build an integration between your add-on and Email This Issue. In order to do that you have to import the OSGi component Email This Issue publishes and call its methods.

Email Parameters

public class EmailDefinitionApi {
    private String issue;

    private List<String> to; //user keys and email addresses
    private List<String> cc; //user keys and email addresses
    private List<String> bcc; //user keys and email addresses
    private com.metainf.jira.plugin.emailissue.action.EmailOptions emailOptions;
    private String emailBody; //email body (will be injected in the template)
    private String emailSubject; //email subject (will be injected in the subject part of the template)

    private List<String> attachments; //issue attachment IDs
    private String addAttachments;
    private String emailTemplate; //name or ID of the Email template to use
    private Map<String, Object> payload; //arbitrary values that are injected into the Velocity Context in the template
}

public class EmailOptions {
	private boolean addToWatchers; //add recipient users to watchers, default: false
  	private boolean replyToMe; //set the current user as the reply-to address, default: false
  	private boolean mailAsMe; //set the sender address to the current user's email address, default: false
  	private String emailFormat; //email format "text" or "html"
  	private String emailPriority; //HIGH, NORMAL, LOW
}

public class EmailLogQuery {
	private Long issueId;
	private String issueKey;
	private String type; //EmailType
	private String source;
	private int top;
	private Date from;
	private Date to;
}

Last updated