Custom Audience API guide

Authentication & Authorization

Sanoma takes the security of its APIs seriously and as such provides tools to ensure your API calls are secure.

Look for this API request in the APIs page (select Sanoma Identity Manager API):
GET /identity/api/login/get-api-access

On-behalf-of Flow Walkthough

As a partner, you may work on behalf of your clients, as such, the On-behalf-of flow allows you to make API calls as if the client themselves were making the API call.

  1. Redirect customer to Login page

  2. Customer is asked to login with their own Sanoma Ad Manager user.

    • Look for this API request in the APIs page (select Sanoma Identity Manager API):
      POST /identity/api/login/renewToken?refreshToken=<refresh token>

  3. If callbackUrl was given, a POST request callback is sent to the address

    • The callback enables the caller to programmatically store/cache the access token and refresh token. The echoed externalUserId can be used to match the token to the correct user.

    • If no callbackUrl was given, the caller can get the access token and refresh token from the query parameters in step 4.

  4. If returnUrl was given, the customer is redirected to the address. The same query parameters listed in step 3 are also appended to the request.

  5. To renew expired access token, send POST request to /identity/api/login/renewToken with query parameter:

    refreshToken = The refresh token received in step 3/4.

Ad Manager Custom Audiences API

Prior to the Ad Manager Custom Audiences API, the advertiser would need to send a message to Sanoma Services to add their audiences to the Data Marketplace. Now advertisers may upload their own list of contacts (Audience) in order to run advertising campaigns.

The Ad Manager Custom Audiences API Product comprises of three separate APIs, you need to work with all three APIs in order to complete the use case:

Identity Manager: In order to use this API you need to ensure that you have a valid access token. Please use the "On-behalf-of" flow in order to obtain a valid token.

Hashing Service: Before storing sensitive information, such as an email address or a phone number in Sanoma, it will first be hashed with a SHA-256 hashing algorithm. This is in accordance with the GDPR directive.

Ad Manager Custom Audiences API

Prerequisites:
In order to use the Ad Manager Custom Audiences API, the customer is required to have completed several steps beforehand. Failure to complete these steps will result in an error on the API Call.

The customer must:

  • Be registered with Sanoma Media i.e. Have a valid AdManager Account and a designated contact person.

  • Subscribe to an Ad Manager Custom Audiences Package.

  • Have accepted the Sanoma Data Agreement.

More information may be found on the Sanoma Media site.

Ad Manager Custom Audiences API


Sanoma Ad Manager Audiences are comprised of the following objects:

Segments
A segment is a client specific collection based upon a set of characteristics that are required for this campaign e.g. Relationship status (Single, Couple, Family with kids), Age (15-17, 18-29, 30-34, 35-49, 50+), etc.

Campaigns
A campaign is a container for the marketing activities and runs for a set amount of time.

Audiences
An audience is a collection of customers to whom you wish to target your campaign. There are different types of audiences:

  • CRM - These are audiences that come from an existing Customer Relationship Management system.

  • Lookalike - Audiences that are similar to an existing audience.

The client with the advertiser account will work with Sanoma to define Segments and Campaigns. After the custom audience has been created with the API, Sanoma will attach the audience to the right campaigns.

How to create a new CRM Audience

To work with CRM Audiences there are dedicated URI's:

  • /audiences/v2/crm_audiences

  • /hashing-service/v1/crm_audiences

All the API calls will require these headers to be set. You can obtain the X-advertiser-ID and the Authorization programmatically during the authorization process:

  • Ocp-Apim-Subscription-Key = api management subscription key

  • X-Advertiser-Id = The customer's advertiser ID.

  • Authorization = Bearer {token}.

Look for this API request in the APIs page (select Custom Audiences API):

POST https://api.sb2b.net/audiences/v1/crm_audiences

1. Create an empty Audience

Create an empty audience - We create an empty audience in order to get a new audience identifier. Simply provide a Name and Description.


Look for this API request in the APIs page (select Custom Audiences API):

POST https://api.sb2b.net/audiences/v1/crm_audiences/<CRM_AUDIENCE_ID>/uploads?salt_source=advertiser

2. Initiate the Upload

In order to upload a CSV file, you first need to obtain an upload identifier "upload_id". You do this by making a request to the uploads controller.

Example CSV File:

email,phone
zinedine.zintonic@gmail.com,+358502222333
tapio.branvinn@hotmail.com,+358501234567
romeo.freesoul@hotmail.com,+358502222339
,+358502227493
max.power@gmail.com,

3. Prepare the CSV File


Prepare the CRM data for upload to Sanoma using the standard Comma Separated convention e.g. email, phone

Fields available for upload are:

  • email

  • phone

Always provide the email/phone values in same order (same fields). If you have records (rows) where you only have either email or phone – then leave the missing value empty in the dedicated field

Sanoma will automatically hash sensitive information using the SHA-256 hashing algorithm.


Look for this API request in the APIs page (select Custom Audiences API):

PUT /hashing-service/v1/crm_audiences/<CRM_AUDIENCE_ID>/uploads/<UPLOAD_ID>?is_last_batch=true

4. Upload CSV

In order to create a new CRM Audience, a POST call is made to the URI:

/hashing-service/v1/crm_audiences/{audienceId}/uploads/{uploadId}

There is a 5MB limit on the CSV file size. As such, the boolean query parameter: is_last_batch may be set in order to process multiple files within an audience.

The body is set to: binary (= csv file from Step 3.)

About the Hashing Service: In order for the matching process to complete successfully, the hashing service will prepend the value of the salt to each customer data item (such as an email address or a phone number) prior to hashing each value using the SHA-256 hashing algorithm.


Look for this API request in the APIs page (select Custom Audiences API):

GET /hashing-service/v1/crm_audiences/<CRM_AUDIENCE_ID>/uploads/<UPLOAD_ID>

5. Query Upload Status

After initiating the upload with the hashing-service, you should check the status to see if the upload/s have completed successfully.