Before anything, this questions is from a beginner in the API environment, so any feedback is greatly welcome.

I have a request to create an invitation URL for customers to leave a service review on Trustpilot. This URL generated by Trustpilot will be used as the link in an email, which will be sent to a Data Extension.

I managed to generate the URL in Postman for an individual contact, as in below:

POST /v1/private/product-reviews/business-units/123456789abcd/invitation-links HTTP/1.1
Host: api.trustpilot.com
Content-Type: application/json
Authorization: Bearer hdsjahdSKDJKJSJDkkd
User-Agent: PostmanRuntime/7.19.0
Accept: */*
Cache-Control: no-cache
Postman-Token: 76a6b8db-4a4c-4082-be0a-3473ef4f7fc9,c511b743-35f9-4256-b8ca-087f3d9af977
Host: api.trustpilot.com
Accept-Encoding: gzip, deflate
Content-Length: 584
Connection: keep-alive
cache-control: no-cache

  "referenceId": "InviteTest",
  "locale": "en-ie",
  "products": [
      "sku": "4121",
      "name": "T-shirt",
      "mpn": "4121",
      "imageUrl": "https://www.brand.com/product/image.jpg",
      "productUrl": "https://www.brand.com/theproduct",
      "gtin": "01234567890",
      "brand": "Brand"
  "consumer": {
    "email": "consumeremail@gmail.com",
    "name": "Luiz Fernando"
  "redirectUri": "https://www.brand.com"

But this is for one email only and it's in Postman, so now I need to bring it to the 'real world'. Email and Name should be updated dynamically based on the Data Extension, so that each subscriber gets a unique URL.

I have a bit of AMPScript that gets Name and Email address from the Sendable Data Extension.


/* Get the PersonContactID field from the email - client doesn't use SubscrikerKey */ 
SET @PersonContactID = AttributeValue("Email")

/* Look up Sign Up Data Extension */
SET @rows = LookupRows("CRM Sign Up","Email",@PersonContactId)

IF RowCount(@rows) > 0 THEN
 /* Set the row to reference */
  SET @row = Row(@rows,1)
  SET @ReviewerEmail = Field(@row,"Email")
  SET @ReviewerFirstName = Field(@row,"FirstName")
  SET @ReviewerLastName = Field(@row,"Surname")
  SET @ReviewerFullName = Concat(@ReviewerFirstName, " ", @ReviewerLastName)

Now, how can I actually generate these URLs in Marketing Cloud, so that the payload fetchs name and email from the AMPScript and then generate the unique URL?

Am I even going the right direction here?

  • I don't get, that your first API call is to Trustpilot API, and you want to send an email with Ampscript? How are those two systems interlinked? – Lukas Lunow Nov 13 '19 at 15:08
  • Hi Lukas. Sure, sorry it wasn't clear. So, the API call to TrustPilot is only to generate the unique URL , and then this URL will be used as a link in the email sent from Marketing Cloud. I will rephrase my question to make it clearer. – Luiz Fernando Xavier Nov 13 '19 at 15:24
  • 2
    I would do this outside of the email. Perhaps via a Script Activity prior to send. Putting API calls inside of an email is opening up many risks that could affect your sending including time-outs or delayed sends – Gortonington Nov 13 '19 at 17:00
  • Thanks @Gortonington, that makes sense. I've found another thread that goes alongside what you suggested so I will try it using a script activity. salesforce.stackexchange.com/questions/224218/… – Luiz Fernando Xavier Nov 13 '19 at 17:47