When it comes to the SOAP Api, it exposes among its headers EmailHeader which can be used to trigger email sent when a case is created via API.

By default, when a case is created via API, the case emails are not sent. However, while the SOAP Api exposes among its headers EmailHeader which can be used to trigger email sent when a case is created via API, there is nothing like that with the REST API.

How to trigger email when creating a case via REST API?

1 Answer 1


The same way you cause emails to be sent when you create a Case through any other Apex, by setting DMLOptions.

There is documentation on setting DMLOptions, but the highlights of that page are...

Database.DMLOptions dml = new Database.DMLOptions();
// For sending emails to the person designated as the Contact for the case
dml.EmailHeader.triggerAutoResponseEmail = true;
// For sending emails to salesforce users of your org
dml.EmailHeader.triggerUserEmail = true;
// For sending emails to addresses outside of your org
dml.EmailHeader.triggerOtherEmail = true;

If you also have auto-assignment rules for cases that are created, you may need to set another DML option AssignmentRuleHeader.useDefaultRule.

If you're only working with a single case, you can use the setOptions() method of the SObject class to actually set the dml options.

Case c = new Case();
Database.DMLOptions dml = new Database.DMLOptions();
insert case;

For lists of SObjects, you'd need to use the database.<dml method>() method instead of just [insert|update] <list of SObject>;. That method only exists for insert and update (not delete, undelete, or upsert)

Database.DMLOptions dml = new Database.DMLOptions();
Database.insert(myCaseList, dml);
  • My question relates to REST API, not Apex Feb 7, 2018 at 15:57
  • 1
    @Edmondo1984 Then it would be good to include that detail in your question. Without further clarification, we can't know if you're using a custom REST endpoint, or xx.x/sobjects/Case and passing the SObject detail in the request body.
    – Derek F
    Feb 7, 2018 at 17:13
  • 2
    @Edmondo1984 Now that you've indicated my answer is not what you were looking for, I took a look at the REST API documentation. There are headers you can set for a REST API call, but no Email header is available. Now it makes more sense what you were asking (again, leaving out details like that leads to getting inaccurate answers). That said, if you want to send emails after creating a case through a REST API, you will need to make a custom rest endpoint, and set dml options as per my existing answer.
    – Derek F
    Feb 7, 2018 at 17:21
  • So you suggest exposing a custom rest endpoint for it, makes sense . I think this is the right answer Feb 7, 2018 at 19:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.