Skip to main content

batches

Creates, updates, deletes, gets or lists a batches resource.

Overview​

Namebatches
TypeResource
Idovh.sms.batches

Fields​

The following fields are returned by SELECT queries:

successful operation

NameDatatypeDescription
idstring (uuid)Batch ID
namestringBatch name
account_idintegerSMS account ID (wire: accountID)
slot_idstringSlot ID (wire: slotID)
created_atstring (date-time)Creation datetime (wire: createdAt)
errorsarrayDetails on error(s) on the batch, if any
estimated_creditsnumberThe estimated cost of the batch in credits (wire: estimatedCredits)
finished_atstring (date-time)Datetime when the batch finished processing SMSs (wire: finishedAt)
fromstringSMS sender
messagestringSMS message
processed_recordsintegerNumber of processed records in this batch (wire: processedRecords)
receiversarraySMS receivers list
sent_atstring (date-time)Datetime when the SMSs of the batch are sent (based on deferred time if exists) (wire: sentAt)
started_atstring (date-time)Datetime when the batch started processing SMSs (wire: startedAt)
statusstringBatch status (CANCELED, CANCELING, COMPLETED, FAILED, INSERTED, INSERTING, PENDING, TO_CANCEL)
total_recordsintegerTotal number of records in this batch (wire: totalRecords)
updated_atstring (date-time)Last update datetime (wire: updatedAt)

Methods​

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectid, service_nameReturns the batch: message, sender, receivers, status, estimated credits and errors.
listselectservice_nameReturns the batches of the SMS account.
createinsertservice_name, messageCreates a batch that sends one message to a list of receivers or to a receiver list. Set a sender, or ask for one that allows replies. Sending can be deferred to a later date.
updateupdateid, service_name, nameUpdates the batch name.
deletedeleteid, service_nameDeletes the batch.
cancelexecid, serviceNameCancels a batch scheduled for later. Only possible if no SMS of the batch has been sent yet.

Parameters​

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
api_hoststringThe OVHcloud API host. Selected by OVH_ENDPOINT (ovh-eu, ovh-ca or ovh-us; default ovh-eu). (default: api.eu.ovhcloud.com, x-stackQL-envVarSelector: {"envVar":"OVH_ENDPOINT","default":"ovh-eu","values":{"ovh-eu":"api.eu.ovhcloud.com","ovh-ca":"api.ca.ovhcloud.com","ovh-us":"api.us.ovhcloud.com"}})
idstring (uuid)Id
serviceNamestringThe internal name of your SMS offer
service_namestringThe internal name of your SMS offer (wire: serviceName)

SELECT examples​

Returns the batch: message, sender, receivers, status, estimated credits and errors.

SELECT
id,
name,
account_id,
slot_id,
created_at,
errors,
estimated_credits,
finished_at,
from,
message,
processed_records,
receivers,
sent_at,
started_at,
status,
total_records,
updated_at
FROM ovh.sms.batches
WHERE id = '{{ id }}' -- required
AND service_name = '{{ service_name }}' -- required
;

INSERT examples​

Creates a batch that sends one message to a list of receivers or to a receiver list. Set a sender, or ask for one that allows replies. Sending can be deferred to a later date.

INSERT INTO ovh.sms.batches (
class,
deferred,
from,
message,
name,
no_stop,
sender_for_response,
slot_id,
tag,
to,
service_name
)
SELECT
'{{ class }}',
'{{ deferred }}',
'{{ from }}',
'{{ message }}' /* required */,
'{{ name }}',
{{ no_stop }},
{{ sender_for_response }},
'{{ slot_id }}',
'{{ tag }}',
'{{ to }}',
'{{ service_name }}'
RETURNING
id,
name,
account_id,
slot_id,
created_at,
errors,
estimated_credits,
finished_at,
from,
message,
processed_records,
receivers,
sent_at,
started_at,
status,
total_records,
updated_at
;

UPDATE examples​

Updates the batch name.

UPDATE ovh.sms.batches
SET
name = '{{ name }}'
WHERE
id = '{{ id }}' --required
AND service_name = '{{ service_name }}' --required
AND name = '{{ name }}' --required
RETURNING
id,
name,
account_id,
slot_id,
created_at,
errors,
estimated_credits,
finished_at,
from,
message,
processed_records,
receivers,
sent_at,
started_at,
status,
total_records,
updated_at;

DELETE examples​

Deletes the batch.

DELETE FROM ovh.sms.batches
WHERE id = '{{ id }}' --required
AND service_name = '{{ service_name }}' --required
;

Lifecycle Methods​

EXEC variables use wire (API) names.

Cancels a batch scheduled for later. Only possible if no SMS of the batch has been sent yet.

EXEC ovh.sms.batches.cancel
@id='{{ id }}' --required,
@serviceName='{{ serviceName }}' --required
;