Developer Guide: Queuing Tasks

In this guide you'll learn about the queuing mechanism used to process tasks submitted to the Media Strategies API, and how to submit tasks to that queue.

Asynchronous task queue

Similar to analysis tasks, strategy tasks submitted via the Media Strategies API are appended to a queue and processed in a First-In-First-Out pattern when processing capacity is available.

Submitting a task

Strategy tasks are submitted by calling the POST /pylon/{service}/task endpoint with the POST method.

For example to submit a strategy task for the top_urls strategy:

# POST /pylon/linkedin/task
{
  "type": "strategy",
  "subscription_id": "cd99abbc812f646c77bfd8ddf767a134f0b91e84",
  "name": "Top urls for cloud",
  "parameters": {
    "strategy": "top_urls",
    "version": 1,
    "parameters": {
      "keywords": {
        "any": ["cloud", "azure", "aws", "google cloud", "vmware"]
      },
      "comparison_audience": "global"
    }
  }
}

If a task is successfully submitted, the API will return an id for the task which you use to monitor and retrieve results for the task:

{
  "id": "b39746f8b4837623b528c793ef7fb84b61998ddd"
}

Full API documentation for task submission can be found in the POST /pylon/{service}/task REST API endpoint documentation.

API response headers

Upon successfully submitting a new strategy task, you should expect to receive the following headers containing information about your queue:

  • X-Strategy-Tasks-Queued - the number of strategy tasks you currently have queued
  • X-Strategy-Tasks-Queue-Limit - the maximum number of strategy tasks you can queue

Queue limits

Queue limits and allowances are described in full in the Platform Allowances documentation.