Skip to main content

Task Object

The Task Object represents a single batch operation request. Each task defines what operation will be executed (POST, GET, PATCH, or DELETE), which objects are affected, and how they should be updated.

Task execution and results are tracked through the task status attribute and operation counters (processed, success, failure, and total).

When a task reaches the completed status, whether executed directly or after being reviewed and approved, CarrierX sends a callback identified as batch_task_completed. This callback is configured by the partner by setting the callbacks attribute on the Partner object.

Task Object Attributes​

These fields and values make up the JSON object that gets returned with successful requests.

AttributeData TypeDescription
dataarray of objects

The payload containing data for bulk creation or modification. Must be empty for DELETE operations.

date_created
read only
string

The date and time when the batch task was created.

date_modified
read only
string

The date and time when the batch task was modified.

entriesarray

List of existing record identifiers to be modified or deleted. This is based on field. Must be empty for POST requests.

failure
read only
integer

Number of failed operations within the batch.

fieldstring

The field used to locate the existing entries during PATCH and DELETE operations. Must be empty for POST. The allowed values depend on the task type. Refer to Object Task Types and DID Settings Task Types.

methodstring

The HTTP method applied to the batch request: POST, GET, PATCH, or DELETE. The GET method exports the selected objects to a CSV file.

partner_sid
read only
string

The secure ID of the partner associated with the batch task.

processed
read only
integer

Number of operations already processed in the batch task.

reviewboolean

Indicates whether this task requires manual reviewing before execution.

results_emailstring

The email address that gets a summary when the task completes. The summary contains the task type, method, the total, success, and failure counters, and the link to the results file. This attribute can be set only when the task is created.

results_url
read only
string

The public link to the CSV file with the task results. CarrierX sets this link when the task completes. Refer to Results File for details.

statusstring

Current execution status of the batch task. Refer to the table below for a comprehensive list of statuses.

success
read only
integer

Number of successfully executed operations.

task_sid
read only
string

The task secure ID.

total
read only
integer

Total number of operations queued in the batch.

typestring

The type of task: phonenumber, prefix, lrn_prefix, file, sms_enablement, line_information, or emergency. For the phonenumber, prefix, lrn_prefix, and file types, refer to Object Task Types. For the sms_enablement, line_information, and emergency types, refer to DID Settings Task Types.

status​

ValueDescription
approvedThe task has been approved and will execute.
cancelledThe task has been cancelled and will not execute.
completedThe task is completed.
createdThe batch of objects has been created.
pending_reviewThe task is pending review and has not been executed.
queuedThe task is in queue.
runningThe task is currently running.

Object Task Types​

The phonenumber, prefix, lrn_prefix, and file task types create, update, or delete objects of the matching type. The data field contains the fields of this object.

Task TypeObjectMethodsfield Values
phonenumberDIDPOST, GET, PATCH, DELETEphonenumber, phonenumber_sid, filter
prefixPrefixPOST, PATCH, DELETEprefix, prefix_sid, filter
lrn_prefixLRN PrefixPOST, PATCH, DELETEprefix, lrn_prefix_sid, filter
fileFilePATCH, DELETEfile_sid, filter

For filter, each entry is a result filter expression.

GET tasks export the selected DIDs to a CSV file. Refer to Create Task for details.

DID Settings Task Types​

The sms_enablement, line_information, and emergency task types apply the same settings to many DIDs in one task. Each item of the task works like a single request for one DID, so the same validation rules apply.

Task TypeMethodsSingle DID Request
sms_enablementPATCHEnable or Disable SMS/MMS Messaging for DID
line_informationPATCH, DELETEUpdate DID Line Information, Delete DID Line Information
emergencyPATCH, DELETEUpdate DID Emergency, Delete DID Emergency

For sms_enablement tasks, use the PATCH method. The single DID request uses POST, but a batch task with the POST method creates new objects.

To select the DIDs, set field to phonenumber, phonenumber_sid, or filter, and put the matching values in entries. For filter, each entry is a result filter expression, for example, did_group_sid eq d9b2e4a5-9d6c-4c1a-8e2f-3f7b6a5c4d21. The task applies the same data object to every selected DID. For DELETE tasks, data must be empty.

The data object accepts only the following fields:

Task TypeAllowed data Fields
sms_enablementenabled (required), type, campaign_sid, campaign_sub_id, p2p_nnid
line_informationcaller_name, class_of_service, enabled, extended_business_name, extended_first_name, extended_last_name, privacy, screening
emergencycaller_name, enabled, locations

Refer to the DID Messaging Enablement, DID Line Information, and DID Emergency objects for the descriptions of these fields.

These task types work as follows:

  • sms_enablement tasks do not use the force query argument of the single DID request. It is always false. If a DID already has messaging enabled with different settings, the item for this DID fails.
  • An emergency task with the PATCH method and {"enabled": false} in data removes the emergency information of the DIDs, the same as a DELETE task.
  • If a selected DID cannot get the settings, only the item for this DID fails, and the task continues. For example, the item fails if the DID is not assigned to the partner. Such errors appear in the task error details.
  • If a DID is changed after the review and before the task runs, the item for this DID fails with a version mismatch error.
  • In the review items, the old value of each field is always null. The locations field of emergency tasks shows an empty new value.

Results File​

When a task completes, CarrierX creates a CSV file with the task results and sets its link in the results_url attribute. The link does not need authentication. The file is kept for 7 days and then deleted automatically. Deleting the task does not delete the file.

The content of the file depends on the method of the task:

  • For GET tasks, the file contains the exported objects, one row for each object. The columns are the object fields, in the same order as in the object. Use include_fields or exclude_fields in data to select the columns. Refer to Create Task for details. If a GET task finds no objects, no file is created, and results_url stays null.
  • For POST, PATCH, and DELETE tasks, the file contains one row for each item of the task, with the following columns:
ColumnDescription
commentsThe error details for a failed item.
entryFor PATCH and DELETE tasks, the secure ID of the object. For POST tasks, the submitted data row.
statusThe processing status of the item, for example, complete.

Sample Task object​

{
"data": {
"trunk_group_sid": "b30a3dbb-3708-41f0-a9ca-5cf365dcc4d4"
},
"date_created": "2024-10-30T20:47:32.517Z",
"date_modified": "2024-10-30T20:47:32.517Z",
"entries": [
"18053355112",
"18053355280"
],
"error_details": [],
"failure": null,
"field": "phonenumber",
"method": "PATCH",
"partner_sid": "923840ce-0b63-44a9-b4ce-09dc4181fb9d",
"processed": null,
"results_email": null,
"results_url": null,
"review": true,
"status": "created",
"success": null,
"task_sid": "2d9e546e-634b-4f6b-97ca-c2158163540c",
"total": null,
"type": "phonenumber"
}