Vision 6

editBatch

Updates the state of a Batch.

editBatch

Updates the state of a Batch.

Top ↑

Syntax

bool editBatch(
    string api_key,
    int batch_id,
    string command,
  [ int send_time ] 
);

Parameters

api_key (string)

The Key required to access the API. See Getting Started for more information

batch_id (int)

The ID of the Batch to edit. Please note that this is not the same as the Queue ID.

command (string)

The change to make to the state of the Batch. These changes can be made at any point after the Batch is sent to the Queue. Valid values are:

  • pause - Pause a Batch that is currently in the sending process.
  • unpause - Unpause a Batch that you have paused. Sending will restart at the point where it was paused.
  • cancel - Stop a Batch and remove it from the sending process. You must call addBatch or addBatchByContactSearch to begin the sending process again.
  • reschedule - Change the send_time value which determines when a scheduled Batch is sent (See addBatch).
send_time (int - optional)

Timestamp of the new send time for the "reschedule" command.

Return Value

Returns true upon success.

Examples

Pause the Batch

PHP

$api = new Api($url, 'YOURAPIKEY');

$batch_id = 1879999;

$result = $api->invokeMethod('editBatch', $batch_id, 'pause');

JSON Request

{
    "id": 1,
    "method": "editBatch",
    "params": [
        "YOURAPIKEY",
        1879999,
        "pause"
    ]
}

JSON Response

{
    "id": 1,
    "result": true,
    "error": null
}

Resume the Batch

PHP

$api = new Api($url, 'YOURAPIKEY');

$batch_id = 1879999;

$result = $api->invokeMethod('editBatch', $batch_id, 'unpause');

JSON Request

{
    "id": 1,
    "method": "editBatch",
    "params": [
        "YOURAPIKEY",
        1879999,
        "unpause"
    ]
}

JSON Response

{
    "id": 1,
    "result": true,
    "error": null
}

Reschedule the Batch:

PHP

$api = new Api($url, 'YOURAPIKEY');

$batch_id = 1879999;

$result = $api->invokeMethod('editBatch', $batch_id, 'reschedule', time() + 86400);

JSON Request

{
    "id": 1,
    "method": "editBatch",
    "params": [
        "YOURAPIKEY",
        1879999,
        "reschedule",
        1360469900
    ]
}

JSON Response

{
    "id": 1,
    "result": true,
    "error": null
}

Error Codes

This method may return the following error codes in addition to the standard error codes:

Code Error Description
308 Unable to load Batch The Batch ID is incorrect.
302 You cannot pause a send that is not sending or ready to send You cannot pause a Batch in its current state.
302 You cannot unpause a Batch that is not paused. You attempted to unpause a Batch that is not paused.
302 Batches that are completed or previously cancelled cannot be cancelled again You cannot cancel the Batch in its current state.
302 You can not re-schedule a Batch that is not pending or paused You cannot reschedule the Batch in its current State. Pausing the Batch may correct the problem.
310 Invalid command Refer to the command parameter above for correct usage.

See Also