Async batch tasks 2021-01

Batch task creation

Checkout the Async batch Endpoints 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 application

batch_type: address_discount_apply
POST this example json to create Discount application tasks for a batch of batch_type: address_discount_apply

POST /async_batches/:async_batch_id/tasks

{
  "tasks": [
    {
      "body": {
        "address_id": "44459201",
        "discount": {
          "discount_id": 25088194
        }
      }
    }
  ]
}

Discount removal

batch_type: address_discount_remove
POST this example json to create Discount removal tasks for a batch of batch_type: address_discount_remove

🚧

warning on address_discount_remove

address_discount_remove removes any discount on the address

POST /async_batches/:async_batch_id/tasks

{
  "tasks": [
    {
      "body": {
        "address_id": "44459201"
      }
    }
  ]
}

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",
        "duration": "forever",
        "status": "enabled",
        "value": 100
      }
    },
    {
      "body": {
        "code": "compressing",
        "discount_type": "shipping",
        "duration": "forever",
        "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": {
        "code": "Principal",
        "discount_type": "shipping",
        "duration": "forever",
        "status": "enabled",
        "value": 100
      }
    },
    {
      "body": {
        "code": "compressing",
        "discount_type": "shipping",
        "duration": "forever",
        "status": "enabled",
        "value": 100
      }
    }
  ]
}

Product

Product creation

batch_type: product_create
POST this example json to create Product create tasks for a batch of batch_type: product_create

POST /async_batches/:async_batch_id/tasks

{
  "tasks": [
    {
      "body": {
        "discount_amount": 10,
        "discount_type": "percentage",
        "collection_id": 228685,
        "shopify_product_id": 2209241137281,
        "subscription_defaults": {
          "charge_interval_frequency": 1,
          "order_interval_frequency_options": [
            "1"
          ],
          "order_interval_unit": "month",
          "storefront_purchase_options": "subscription_only"
        }
      }
    },
    {
      "body": {
        "discount_amount": 10,
        "discount_type": "percentage",
        "collection_id": 228685,
        "shopify_product_id": 2209241137281,
        "subscription_defaults": {
          "charge_interval_frequency": 1,
          "order_interval_frequency_options": [
            "1"
          ],
          "order_interval_unit": "month",
          "storefront_purchase_options": "subscription_only"
        }
      }
    }
  ]
}

Product update

batch_type: product_update
POST this example json to create Product update tasks for a batch of batch_type: product_update

POST /async_batches/:async_batch_id/tasks

{
  "tasks": [
    {
      "body": {
        "changes": {
          "discount_amount": 15,
          "discount_type": "percentage"
        },
        "product_id": 0
      }
    },
    {
      "body": {
        "changes": {
          "discount_amount": 15,
          "discount_type": "percentage"
        },
        "product_id": 1
      }
    }
  ]
}

Product deletion

batch_type: product_delete
POST this example json to create Product delete tasks for a batch of batch_type: product_delete

POST /async_batches/:async_batch_id/tasks

{
  "tasks": [
    {
      "body": {
        "product_id": 0
      }
    },
    {
      "body": {
        "product_id": 1
      }
    }
  ]
}

Onetime

Onetime creation

batch_type: onetime_create
POST this example json to create Onetime update tasks for a batch of batch_type: onetime_create

POST /async_batches/:async_batch_id/tasks

{
  "tasks": [
    {
      "body": {
        "address_id": 123,
        "onetime": {
          "next_charge_scheduled_at": "2020-08-01",
          "product_title": "Fantastic Concrete",
          "price": 9,
          "quantity": 1,
          "shopify_variant_id": 32638598905988
        }
      }
    },
    {
      "body": {
        "address_id": 456,
        "onetime": {
          "next_charge_scheduled_at": "2020-08-01",
          "product_title": "Unbranded Cotton",
          "price": 9,
          "quantity": 1,
          "shopify_variant_id": 32638598905988
        }
      }
    }
  ]

Onetime deletion

batch_type:onetime_delete
POST this example json to delete Onetime delete tasks for a batch of batch_type: onetime_delete

POST /async_batches/:async_batch_id/tasks

{
  "tasks": [
    {
      "body": {
        "item_id": 14567890
      }
    },
    {
      "body": {
        "item_id": 15498976
      }
    }
  ]
}

Subscriptions

Bulk subscription creation

batch_type:bulk_subscriptions_create
POST this example json to create Subscription create tasks for a batch of batch_type:bulk_subscriptions_create

POST /async_batches/:async_batch_id/tasks

{
  "tasks": [
    {
      "body": {
        "address_id": 123,
        "subscriptions": [
          {
            "charge_interval_frequency": "30",
            "expire_after_specific_number_of_charges": 4,
            "next_charge_scheduled_at": "2020-08-01",
            "order_interval_frequency": "30",
            "order_interval_unit": "day",
            "price": 10.05,
            "properties": [],
            "quantity": 1,
            "shopify_variant_id": 154513843513
          },
          {
            "charge_interval_frequency": "30",
            "expire_after_specific_number_of_charges": 3,
            "next_charge_scheduled_at": "2020-08-01",
            "order_interval_frequency": "30",
            "order_interval_unit": "day",
            "price": 15.32,
            "properties": [],
            "quantity": 1,
            "shopify_variant_id": 5486124654345
          }
        ]
      }
    },
    {
      "body": {
        "address_id": 456,
        "subscriptions": [
          {
            "charge_interval_frequency": "30",
            "expire_after_specific_number_of_charges": 4,
            "next_charge_scheduled_at": "2020-08-01",
            "order_interval_frequency": "30",
            "order_interval_unit": "day",
            "price": 10.05,
            "properties": [],
            "quantity": 1,
            "shopify_variant_id": 154513843513
          }
        ]
      }
    }
  ]
}

Bulk subscription update

batch_type:bulk_subscriptions_update
POST this example json to create Subscription update tasks for a batch of batch_type:bulk_subscriptions_update

POST /async_batches/:async_batch_id/tasks

{
  "tasks": [
    {
      "body": {
        "address_id": 50509756,
        "subscriptions": [
          {
            "id": 91381267,
            "next_charge_scheduled_at": "2020-10-15"
          },
          {
            "id": 91381230,
            "next_charge_scheduled_at": "2020-10-15"
          }
        ]
      }
    },
    {
      "body": {
        "address_id": 50509592,
        "subscriptions": [
          {
            "id": 91380807,
            "next_charge_scheduled_at": "2020-11-16"
          }
        ]
      }
    }
  ]
}

Bulk subscription deletion

batch_type:bulk_subscriptions_delete
POST this example json to delete Subscription tasks for a batch of batch_type:bulk_subscriptions_delete

POST /async_batches/:async_batch_id/tasks

{
  "tasks": [
    {
      "body": {
        "address_id": 123,
        "subscriptions": [
          {
            "id": 71304092
          },
          {
            "id": 71304092
          }
        ]
      }
    },
    {
      "body": {
        "address_id": 123,
        "subscriptions": [
          {
            "id": 71304092
          },
          {
            "id": 71304092
          }
        ]
      }
    }
  ]
}

Subscription cancelation

batch_type:subscription_cancel
POST this example json to cancel Subscriptions for a batch of batch_type:bulk_subscription_cancel

POST /async_batches/:async_batch_id/tasks

 {
    "tasks": [
        {
            "body": {
                "subscription_id": 471485438,
                "send_email": false,
                "cancellation_reason": "This is too expensive.",
                "cancellation_reason_comments": "The costs are too high."
            }
        },
        {
            "body": {
                "subscription_id": 408159374,
                "send_email": false,
                "cancellation_reason": "Other reason.",
                "cancellation_reason_comments": "I have enough of this product."
            }
        }
    ]
}

Change next charge date

batch_type:change_next_charge_date
POST this example json to create Charge next_charge update tasks for a batch of batch_type:change_next_charge_date

POST /async_batches/:async_batch_id/tasks

{
  "tasks": [
    {
      "body": {
        "charge_id": 1234567,
        "next_charge_date": "2021-11-01"
      }
    },
    {
      "body": {
        "charge_id": 2345678,
        "next_charge_date": "2021-11-13"
      }
    }
  ]
}

Suggested Article

Need Help? Contact Us