latestOpenAPI 3.0.02026-08-19265791.1 MB

32c70b809354

Campaigns

Publish

Publish missions of a campaign to automatically create one mission per targeted site or per targeted user. The result is the number of newly created missions and the mission ids.

Important The mission must be assigned before booking: error message: "Mission must have an assigned user before it can be booked. Please call the assign endpoint prior to booking the mission."

  • Only campaigns of type memo, form and workflow are supported (quick tasks not supported)

  • Memos cannot be personalised by site (the message is sent as configured in the YOOBIC app)

  • If campaign audience is set by site: not possible to specify user_ids for publication

  • If campaign audience is set by user: not possible to specify store_ids for publication

  • If store_ids specified: missions published to all sites specified OR that match the campaign audience (store_ids that do not match the campaign audience criteria are added)

  • If user_ids specified: missions published to all users specified AND that match the campaign audience (user_ids that do not match the campaign audience criteria are ignored)

  • If no store_ids specified: missions published to all sites in the audience of the campaign (if the audience is not null)

  • If no user_ids specified: missions published to all users in the audience of the campaign (if the audience is not null)

Example:

For a form campaign by site with an audience of 5 sites:

  • if no store_ids, store_client_ids, store_type_ids is specified in the request:

Request - Body:

{}

Response - Body:

{
  "count": 5,
  "mission_ids": [
    "5bf166a4e44684a31c7a5f86",
    "5bf166a4e44684a31c7a5f87",
    "5bf166a4e44684a31c7a5f88",
    "5bf166a4e44684a31c7a5f89",
    "5bf166a4e44684a31c7a5f8a"
  ]
}
  • if store_ids is specified in the request:

Request - Body:

{
  "store_ids": [
    "674843fbf7b5a0004845026b"
  ]
}

Response - Body:

{
  "count": 1,
  "mission_ids": [
    "5bf166a4e44684a31c7a5f8c"
  ]
}

Fields

FieldFormatRequiredDescription
store_idsarrayUnique store ids
store_client_idsarrayExternal unique ids of the stores as it may exists in your Information System
store_type_idsarrayThe ids of the store types
user_idsarrayUnique user ids
skip_when_availablebooleanSkip publishing for a store if there is already an unbooked mission of the same campaign on that store
skip_when_existsbooleanSkip publishing for a store if there is already a mission of the same campaign on that store (regardless of status)
valid_fromdateMake a mission visible from the specified date
valid_untildateArchive an available or ongoing mission after the specified date & time. (Script is run every hour)
due_datedateDue date in UTC
mission_titlestringIf exists, it replaces the default campaign title. See below for further details
answersarrayDefault values for the published missions. Only simple field types are supported — see the list below
notifybooleanif true will send a notification at publication. More information on who receives the notification in this article. If false or not specified, no notification is sent.

mission_title has two placeholders you can add:

  • {campaign_title} if supplied, will be replaced with the original campaign title.

  • {date_now} if supplied, today's date will be added to the mission title.

So i.e. a mission_title could look like -
"{CAMPAIGN_TITLE} - {DATE_NOW_TEMPLATE} - URGENT" => "HQ Store Visit - 01/03/2020 - URGENT".

The answers field is defined as an array of:

FieldFormatRequiredDescription
question_idstringxUnique id of the question
question_typestringThe type of the question
questionstringxThe title of the question
page_numbernumberxThe number of the page the question appears in
answeranyThe value of the answer

One of either options is required for the each answer object:

  • question_id

  • question, page_number

Important
Only simple field types can be prefilled through the answers array when publishing. This list is specific to the publish action and differs from the field types supported on the campaign itself. Below is the list of the supported types:

question_typeTypeDescription
textstringSupports basic HTML formatting when used as readonly
textareastringSupports basic HTML formatting when used as readonly
numbernumber
photoURLExternal image URL only (binary upload not supported)
multiphotosarray of URLsExternal image URLs only (binary upload not supported)
selectstringSingle value chosen from the values defined in the campaign's form
selectmultiarrayMultiple values chosen from the values defined in the campaign's form
selectbuttonsarrayMultiple values chosen from the values defined in the campaign's form
checkboxboolean
toggleboolean

Only the types listed above are supported; any other type is unsupported at publish, including User, Site, Table, Dataset, Formula & advanced formula, Action, Catalogue, Learn and Information fields, as well as any newly added field type not explicitly listed here.

There are two ways to publish a campaign of type mission:

  • If you have a specific store or list of stores to target, you can specify in the body of the request one of the following:

    • store_ids

    • store_client_ids

    • store_type_ids

  • If you have already configured the campaign’s audience in the Campaign’s menu from the user interface, it is possible to publish the campaign on all the stores of the audience, only the stores where a mission from this campaign is not available (skip_when_available: true), or only the stores where no mission from this campaign exisits (skip_when_exists: true).

Important
It is required to have either:

  • At least one active filter with the "Select all" function activated to publish on the selection.

  • At least one store manually selected.

If nothing is selected in the Campaign’s configuration (filters or manual selection) and no stores were specified in the request’s body, then an error will be returned.

post/public/api/campaigns/{id}/publish

Headers

Acceptstring

e.g. application/json

Request body

store_client_idsstring[]

Example request

{
  "store_client_ids": [
    "client_100",
    "client_101",
    "client_102"
  ],
  "answers": [
    {
      "question_id": "8d6d072d-4dcc-42e5-9243-be149b5ef9bb",
      "question_type": "selectmulti",
      "question": "Multiple choice",
      "page_number": 1,
      "answer": [
        "2"
      ]
    },
    {
      "question_type": "number",
      "question": "Number",
      "page_number": 3,
      "answer": 9
    }
  ]
}

Response

OK

countnumber
mission_idsstring[]

Example response

{
  "count": 6,
  "mission_ids": [
    "5bf166a4e44684a31c7a5f86",
    "5bf166a4e44684a31c7a5f87",
    "5bf166a4e44684a31c7a5f88",
    "5bf166a4e44684a31c7a5f89",
    "5bf166a4e44684a31c7a5f8a",
    "5bf166a4e44684a31c7a5f8b",
    "5bf166a4e44684a31c7a5f8c"
  ]
}