1

We're currently looking into sending a welcome email from SFMC. I know this is possible but I don't know where to even start doing this. I'm fairly new to APIs in general, the most I have done so far is send an API call to our Events system from SFMC using server-side javascript to fill a data extension which we could then send emails to, and most of this was written from scratch by a consultant we were working with.

Ideally, our events system would send an API call to SFMC every time someone registers for an event, and this would trigger an email just to this one person.

Can someone give me an indication of what I need to set up for this - I've created a User-Intiated send, but I'm not even sure if this is the right way.

I'd also like to know if there's an easy way to test this - our new events platform is still under development so in the meantime I would like to be able to test sending the call from elsewhere, such as Postman.

Got this far with Postman - getting an Access Token

enter image description here

  • 1
    Have you looked at the SFMC Postman collection on Github? – Adam Spriggs Aug 8 '17 at 13:51
  • Thanks - didn't know I needed to do this, it's not mentioned in any of the guides. – TCassa Aug 9 '17 at 13:37
  • You don't need to do it, but it will help as you develop your REST calls. It's not a complete set of examples. – Adam Spriggs Aug 9 '17 at 13:50
3

You need to create a triggered send definition and send a post-request to the REST-API. There is very good documentation on this, that you can find here:

Creating a triggered send:

In order to create a triggered send definition you need to perform the following steps in Email Studio:

  1. Click Interactions
  2. Click Messages
  3. Click Email
  4. Click Triggered
  5. Click Create
  6. Create Triggered Send
  7. Complete Properties (described in Create a Triggered Email Message Interaction)

Sending the triggered email using the REST-API

The call to the REST-API could look like this in the example below. The URL you post the request to needs to be adapted, as cust_key needs to be replaced by the customer/external key of your triggered send definition (the one you created using the explanation in the triggered emails guide.

Before you can initiate that request, you need to get an API key/secret using App Center, as this is necessary for obtaining the access token, that needs to be sent in the header of your subsequent requests (the one triggering the email send for example). These steps are described in the following documentation articles:

The access token retrieval can be handled by the SDK you use for making the requests. This depends on the setup you have (programming language, etc.). These are available for C#, PHP, Node.js, Java, etc. and are listed in the documentation article "Introduction to SDKs".

Request-Header:

Host: https://www.exacttargetapis.com
POST /messaging/v1/messageDefinitionSends/key:cust_key/send
Content-Type: application/json
Authorization: Bearer YOUR_ACCESS_TOKEN

Request-Body:

{
    "From": {
        "Address": "code@exacttarget.com",
        "Name": "Code@"
    },
    "To": {
        "Address": "example@example.com",
        "SubscriberKey": "example@example.com",
        "ContactAttributes": {
            "SubscriberAttributes": {
                "Region": "West",
                "City": "Indianapolis",
                "State": "IN"
            }
        }
    },
    "OPTIONS": {
        "RequestType": "ASYNC"
    }
}
|improve this answer|||||
  • Thank you, very helpful reply - I've got as far as requesting an access token but have got a little stuck. I'm using Postman to send the POST call to get the token but get a bad request every time. I'm choosing POST as type, using auth.exacttargetapis.com/v1/requestToken as the URL and Content-Type application/json as a header, and pasted my clientId and Secret in the body. It looks a bit like this (clientId and Secret obscured - see image in OP) – TCassa Aug 8 '17 at 12:02
  • 1
    @TCassa - Your request appears to be 100% correct. Check to see if your user has API permissions in admin tab. Without that, you will always get a "Bad Request" or "Not Authorized" error. If user has API capability, this may be a support ticket to see if there is some 'back end' permission that is not turned on – Gortonington Aug 8 '17 at 12:48
  • Thanks - but if this is to be an API which will be triggered externally, how does it account for which user it is? Postman doesn't know it is me that is making the API call. – TCassa Aug 8 '17 at 13:02
  • 1
    @TCassa the problem in your request is a missing comma after the first value, so your payload should be {"clientId": "here", "clientSecret": "here"} – Markus Slabina Aug 8 '17 at 13:05
  • 1
    You can find this information in my answer to another question: salesforce.stackexchange.com/a/149322/36218 – Markus Slabina Aug 9 '17 at 9:47

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