Skip to main content

Creating a simple target

Mindbaz target

A simple target allows you to target the subscribers of your MINDBAZ database. You can use them to send a test bat, a campaign or define an export. A target is composed of several criteria called "filter".

There are several types of filters:

  • declarative filters (e.g. > postal code, address, opt-in type, webmail, etc),
  • behavioural filters (e.g. > opened / clicked on a campaign),
  • geolocation filters
  • file filters (selects emails present in a file)
  • etc.

A target must first be created with the Targets api and then filters are assigned to it with the targetFilters api.

combined targets

In the interface, it is also possible to create combined targets. This type of target combines several targets by making a union, intersection or subtraction between them. The targets api does not currently allow the creation of this type of target.

Creating a simple target

First, let's create our first target by calling POST api/{idsite}/Targets.

The parameters to specify in the url are the following:

NameDescriptionTypeAdditional information
idsiteMindBaz site identifierIntegerMandatory

In the query body, the parameters to be passed in the form "application/json, text/json " are as follows:

NameDescriptionTypeAdditional information
nameName of the target (255 carac max)StringMandatory
isTestTargettrue if it is a target for BATBooleanNone
pctSelectPercentage of the target to select (100 by default).IntegerNone
maxSelectMaximum number of emails to be selected by the target (if defined, maxSelect replaces pctSelect).
isRandomModeTrue to activate the random mode (useful with a percentage lower than 100). Caution: only for standard targets Caution: do not exclude a target that is in random mode because the excluded population will be different for each calculation**BooleanNone
excludedTargetsList of target ids to exclude from the target.Integer CollectionNone
isAutomationtrue if it is an Automation TargetBooleanDeprecated

Example

Here is an example to create a target that randomly selects 10 emails after excluding the result of target id 1 and 2.

[
{
"name": "sample string 1",
"isTestTarget": false,
"maxSelect": 10,
"isRandomMode": true,
"excludedTargets": [
1,
2
]
}
]

In return for the call, I get the information of the newly created target:

{
"success": true,
"data": {
"id": 183813,
"parameters": {
"name": "sample string 1",
"isTestTarget": false,
"pctSelect": 100,
"maxSelect": 10,
"isRandomMode": true,
"excludedTargets": [1,2],
"isAutomation": false
},
"creationDate": "2021-08-25T11:29:41.961503+02:00",
"lastUpdateDate": "2021-08-25T11:29:41.961503+02:00",
"targetType": 1,
"hasFieldFilter": false,
"hasGeolocFilter": false,
"hasSqlFilter": false,
"hasEmailPressureFilter": false,
"hasBehaviourFilter": false,
"hasReactivityFilter": false,
"hasSendingFilter": false,
"hasFileFilter": false,
"hasThematicFilter": false
},
"error": null,
"typeName": "Target"
}

Codeline of a simple target

string token = ""; //Valeur du token récupéré pour l'authentification
string idSite = ""; //Valeur de l'identifiant du site
var client = new RestClient("https://api.mindbaz.com/api/" + idSite + "/targets/");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer " + token);
request.AddHeader("Content-Type", "application/json");
var body = @"{""name"": ""sample string 1"",""isTestTarget"": false,""maxSelect"": 10,""isRandomMode"": true,""excludedTargets"": [1,2]}";
request.AddParameter("application/json", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);

At this point, we have created a target but no filter is defined. At this step, the target is not yet usable and cannot appear in the target manager in the interface. For the target to be valid, it must have at least one filter.

Creating a filter

Our target needs at least one filter to work. To create one, you can use the call corresponding to the desired filter type:

caution

A single target can only have one filter of each type.

Filter by field

For the example, we will create a filter by field:

The parameters to be specified in the url are as follows:

NameDescriptionTypeAdditional information
idsiteMindBaz site identifierIntegerMandatory

In the query body, the parameters to be passed in the form "application/json, text/json " are as follows:

NameDescriptionTypeAdditional information
idTargettarget identifierintegerMandatory
isEnabledtrue if filter is enabledBooleanNone
filtersList of field filters (operations) to be applied to each field. Note that an idField cannot have more than one filter at a time!Collection of FieldFilterNone

The FieldFilter type is a collection of fields representing the following:

NameDescriptionTypeAdditional information
idFieldField identifier (0 = id, 1 =email...).
The list of fields can be retrieved here.
Click here for more information.
IntegerMandatory
operatorOperator to useEOperatorRequired
valueValue of the field to be used with the operator.
For the Date type, the format dd/MM/yyyy must be used.
For the List type, the id corresponding to the desired value must be used. For example, to make "subscriber status" = "subscriber". You must use { idField=7, operator=3,value=0}
ObjectRequired

The EOperator type is of type Enum:

  1. "HasValue"
  2. "NoValue
  3. "Equals"
  4. "DifferentThan"
  5. "LessThan" (for Number and Date type only)
  6. "MoreThan" (for Number and Date type only)
  7. "Between" (for Number and Date type only)
  8. "DatePast" (for type Date only)
  9. "DateFuture" (for Date type only) 10.
  10. "NbDaysMoreThan" (for Date type only)
  11. "NbDaysLessThan" (for type Date only)
  12. "AgeGreaterThan" (for type Date only)
  13. "AgeLesserThan" (for type Date only)
  14. "AgeBetween" (for type Date only)
info

For the operators "Equals" and "DifferentThan", you can combine several values by separating them with a ";". A logical OR will be applied between the values.

You can for example create a test target with a field filter on the email by passing several emails separated by ";". As the length of the field is limited, if you have a lot of values to include, it will be better to use a filter by file.

Example

We will add email address informed and subscriber status equal to unsubscribed.

{
"idTarget": 183813,
"isEnabled": true,
"filters": [
{
"idField": 1,
"operator": 1
},
{
"idField": 7,
"operator": 3,
"value": "1"
}
]
}

The return code is as follows:

{
"success": true,
"data": true,
"error": null,
"typeName": "Boolean"
}

Codeline of a filter by field

string token = ""; //Value of the token recovered for the authentication
string idSite = ""; //Value of the site identifier
var client = new RestClient("https://api.mindbaz.com/api/" + idSite + "/targetfilters/field");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer " + token);
request.AddHeader("Content-Type", "application/json");
var body = @"{""idTarget"": 183813,""isEnabled"": true,""filters"": [{""idField"": 1,""operator"": 1},{""idField"": 7,""operator"": 3,""value"": ""1""}]}";
request.AddParameter("application/json", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);