0

I'm trying to use the Transactional Messaging API (https://developer.salesforce.com/docs/atlas.en-us.noversion.mc-apis.meta/mc-apis/transactional-messaging-api.htm) to create a password reset e-mail that could be triggered by an API call from outside SFMC. I managed to successfully create a send definition for a simple e-mail and trigger it, but I'm having trouble with something more complex.

According to https://developer.salesforce.com/docs/atlas.en-us.mc-apis.meta/mc-apis/sendMessageSingleRecipient.htm, it is possible to pass recipient attributes in an API call. ("Information used to personalize the message for the recipient. Written as key:value pairs. The attributes match profile attributes, content attributes, or triggered send data extension attributes.") How to actually use this information to personalize the message? If I want to pass values like:

"attributes": {
  "user_code": "value"
}

How do I actually use "user_code" in the e-mail? Putting in %%user_code%% in the content makes my create send definition POST request (https://developer.salesforce.com/docs/atlas.en-us.mc-apis.meta/mc-apis/createSendDefinition.htm) fail with MCMS_UTM_Validation_email_does_not_pass_validation.

2

You are on the right track. Your payload should look more or less like this:

{
  "recipient": {
    "to": "user@example.com",
    "contactKey": "123456",
    "attributes": {
      "attrib1": "foo",
      "attrib2": "bar",
      "attrib3": "42"
    }
  },
  "definitionKey": "MyEmail"
}

And referencing the above attributes in email can be done using AttributeValue function, as per:

SET @fish = AttributeValue("attrib1")
SET @horse = AttributeValue("attrib2")
SET @bird = AttributeValue("attrib3")
2
  • 1
    Thank you! My payload was more or less the same, but the AttributeValue part was crucial, it now works as I envisioned. – bst Jul 3 '20 at 10:57
  • 1
    you're welcome @bst - I have also provided an answer to one of your older questions – Lukas Lunow Jul 3 '20 at 11:08

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.