Async batch tasks 2021-11

Batch task creation

Checkout the API Refs to create a batch. This step is required prior to creating batch Tasks to be processed by the batch.

Batch task creation examples

Discounts

Discount creation

batch_type: discount_create
POST this example JSON to create Discount creation tasks for a batch of batch_type: discount_create

POST /async_batches/:async_batch_id/tasks

{
  "tasks": [
    {
      "body": {
        "code": "Principal",
        "discount_type": "shipping",
        "status": "enabled",
        "value": 100
      }
    },
    {
      "body": {
        "code": "compressing",
        "discount_type": "shipping",
        "status": "enabled",
        "value": 100
      }
    }
  ]
}

Discount deletion

batch_type: discount_delete
POST this example JSON to create Discount deletion tasks for a batch of batch_type: discount_delete

POST /async_batches/:async_batch_id/tasks

{
  "tasks": [
    {
      "body": {
        "discount_id": 045613
      }
    },
    {
      "body": {
        "discount_id": 148434
      }
    }
  ]
}

Discount update

batch_type: discount_update
POST this example JSON to create Discount update tasks for a batch of batch_type: discount_update

POST /async_batches/:async_batch_id/tasks

{
    "tasks": [
        {
            "body": {
                "discount_id": 92469011,
                "changes": {
                    "value": 5,
                    "discount_type": "shipping",
                    "duration": "forever",
                    "status": "enabled"
                }
            }
        }
    ]
}

Bulk plans

Bulk plan creation

batch_type: bulk_plans_create
POST this example JSON to create bulk_plans creation tasks for a batch of batch_type: bulk_plans_create

POST /async_batches/:async_batch_id/tasks

{
  "tasks": [
    {
      "body": {
        "external_product_id": {
          "ecommerce": "123456798238"
          }
        "plans": [
          { 
            "channel_settings": {
              "api": {
                "display": true
              },
              "checkout_page": {
                "display": true
              },
              "customer_portal": {
                "display": true
              },
              "merchant_portal": {
                "display": true
              }
            },
          "discount": "10",
          "discount_type": "percentage",
          "sort_order": 1,
          "subscription_preferences": {
              "charge_interval_frequency": 14,
              "expire_after_specific_number_of_charges": 6,
              "interval_unit": "day",
              "order_day_of_month": 1,
              "order_interval_frequency": 14
    },
          "title": "White socks",
          "type": "subscription"
          },
          {
            "channel_settings": {
              "api": {
                "display": true
              },
              "checkout_page": {
                "display": true
              },
              "customer_portal": {
                "display": true
              },
              "merchant_portal": {
                "display": true
              }
            },
          "discount": "10",
          "discount_type": "percentage",
          "sort_order": 2,
          "subscription_preferences": {
              "charge_interval_frequency": 21,
              "expire_after_specific_number_of_charges": 6,
              "interval_unit": "day",
              "order_day_of_month": 1,
              "order_interval_frequency": 21
          },
          "title": "White socks",
          "type": "subscription"
        }
      ]
   },
   {
    "body": {
        "external_product_id": {
            "e-commerce": "99991212288"
            }
        "plans": [
          {
            "channel_settings": {
              "api": {
                "display": true
              },
              "checkout_page": {
                "display": true
              },
              "customer_portal": {
                "display": true
              },
              "merchant_portal": {
                "display": true
              }
            },
          "discount": "20",
          "discount_type": "percentage",
          "sort_order": 1,
          "subscription_preferences": {
              "charge_interval_frequency": 14,
              "expire_after_specific_number_of_charges": 6,
              "interval_unit": "day",
              "order_day_of_month": 1,
              "order_interval_frequency": 14
          },
          "title": "Purple gloves",
          "type": "subscription"
        }
       ]   
    }
  ]
}

Bulk Plans deletion

batch_type: bulk_plans_delete
POST this example JSON to create Bulk Plans deletion tasks for a batch of batch_type: bulk_plans_delete

POST /async_batches/:async_batch_id/tasks

{
  "tasks": [
    {
      "body": {
        "external_product_id": {
          "ecommerce": "12345678"
          },
        "plans": [
          { 
            "id": 1234554
          },
          { 
            "id": 1234555
          },
          { 
            "id": 1234556
          }
      ]
   },
   {
    "body": {
        "external_product_id": {
            "ecommerce": "9999288",
            },
        "plans": [
          { 
            "id": 1788991
          }
       ]   
    }
  ]
}

Bulk Plans update

batch_type: bulk_plans_update
POST this example JSON to create Bulk Plans update tasks for a batch of batch_type: bulk_plans_update

POST /async_batches/:async_batch_id/tasks

{
  "tasks": [
    {
      "body": {
        "external_product_id": {
          "ecommerce": "1234567238",
          },
        "plans": [
          { 
            "id": 1234554,
            "subscription_preferences": {
              "charge_interval_frequency": 3,
              "expire_after_specific_number_of_charges": 6,
              "interval_unit": "month",
              "order_day_of_month": 1,
              "order_interval_frequency": 3
            }
          },
          { 
            "id": 1234555,
            "subscription_preferences": {
              "charge_interval_frequency": 4,
              "expire_after_specific_number_of_charges": 6,
              "interval_unit": "month",
              "order_day_of_month": 1,
              "order_interval_frequency": 4
            }
          }
      ]
   },
   {
      "body": {
        "external_product_id": {
            "ecommerce": "9999282348",
            },
        "plans": [
          { 
            "id": 1837722,
            "subscription_preferences": {
              "charge_interval_frequency": 10,
              "interval_unit": "month",
              "order_interval_frequency": 3
            }
          }
       ]   
    }
  ]
}

Suggested Article

Need Help? Contact Us