sinch.domains.sms.api.v1 package

class sinch.domains.sms.api.v1.Batches(sinch)[source]

Bases: BaseSms

cancel(
batch_id: str,
**kwargs,
) Annotated[TextResponse | BinaryResponse | MediaResponse, FieldInfo(annotation=NoneType, required=True, discriminator='type')][source]

A batch can be canceled at any point. If a batch is canceled while it’s currently being delivered some messages currently being processed might still be delivered. The delivery report will indicate which messages were canceled and which weren’t.

Canceling a batch scheduled in the future will result in an empty delivery report while canceling an already sent batch would result in no change to the completed delivery report.

Parameters:
  • batch_id (str) – The batch ID you received from sending a message. (required)

  • **kwargs

    Additional parameters for the request.

Returns:

BatchResponse

Return type:

BatchResponse

For detailed documentation, visit https://developers.sinch.com/docs/sms/.

dry_run(
request: DryRunTextRequest | DryRunBinaryRequest | DryRunMediaRequest | None = None,
per_recipient: bool | None = None,
number_of_recipients: int | None = None,
**kwargs,
) DryRunResponse[source]

This operation will perform a dry run of a batch which calculates the bodies and number of parts for all messages in the batch without actually sending any messages.

Parameters:
  • request (Optional[DryRunRequest]) – The request object. (optional)

  • per_recipient (Optional[bool]) – Whether to include per recipient details in the response (optional)

  • number_of_recipients (Optional[int]) – Max number of recipients to include per recipient details for in the response (optional)

  • **kwargs

    Additional parameters for the request.

Returns:

DryRunResponse

Return type:

DryRunResponse

For detailed documentation, visit https://developers.sinch.com/docs/sms/.

dry_run_sms(
to: List[str],
from_: str,
body: str,
per_recipient: bool | None = None,
number_of_recipients: int | None = None,
parameters: Dict[str, Dict[str, str]] | None = None,
delivery_report: Literal['none', 'summary', 'full', 'per_recipient', 'per_recipient_final'] | Annotated[str, Strict(strict=True)] | None = None,
send_at: datetime | None = None,
expire_at: datetime | None = None,
event_destination_target: str | None = None,
client_reference: str | None = None,
feedback_enabled: bool | None = None,
flash_message: bool | None = None,
max_number_of_message_parts: int | None = None,
truncate_concat: bool | None = None,
from_ton: int | None = None,
from_npi: int | None = None,
**kwargs,
) DryRunResponse[source]

This operation will perform a dry run of a batch which calculates the bodies and number of parts for all messages in the batch without actually sending any messages (SMS).

Parameters:
  • to (List[str]) – The list of phone numbers to send the message to. (required)

  • from (str) – The sender phone number. (required)

  • body (str) – The message body. (required)

  • per_recipient (Optional[bool]) – Whether to include per recipient details in the response (optional)

  • number_of_recipients (Optional[int]) – Max number of recipients to include per recipient details for in the response (optional)

  • parameters (Optional[Dict[str, Dict[str, str]]]) – The parameters for the message. (optional)

  • delivery_report (Optional[DeliveryReportType]) – The delivery report type. (optional)

  • send_at (Optional[datetime]) – The time to send the message at. (optional)

  • expire_at (Optional[datetime]) – The time to expire the message at. (optional)

  • event_destination_target (Optional[str]) – The callback URL to receive the delivery report. (optional)

  • client_reference (Optional[str]) – The client reference to identify the message. (optional)

  • feedback_enabled (Optional[bool]) – Whether to enable feedback. (optional)

  • flash_message (Optional[bool]) – Whether to enable flash message. (optional)

  • max_number_of_message_parts (Optional[int]) – The maximum number of message parts. (optional)

  • truncate_concat (Optional[bool]) – Whether to truncate the message if it is too long. (optional)

  • from_ton (Optional[int]) – The type of number for the sender number. (optional)

  • from_npi (Optional[int]) – The number plan indicator for the sender number. (optional)

  • **kwargs

    Additional parameters for the request.

  • from_ (str)

Returns:

DryRunResponse

Return type:

DryRunResponse

For detailed documentation, visit https://developers.sinch.com/docs/sms/.

dry_run_binary(
to: List[str],
from_: str,
body: str,
udh: str,
per_recipient: bool | None = None,
number_of_recipients: int | None = None,
delivery_report: Literal['none', 'summary', 'full', 'per_recipient', 'per_recipient_final'] | Annotated[str, Strict(strict=True)] | None = None,
send_at: datetime | None = None,
expire_at: datetime | None = None,
event_destination_target: str | None = None,
client_reference: str | None = None,
feedback_enabled: bool | None = None,
from_ton: int | None = None,
from_npi: int | None = None,
**kwargs,
) DryRunResponse[source]

This operation will perform a dry run of a batch which calculates the bodies and number of parts for all messages in the batch without actually sending any messages (Binary).

Parameters:
  • to (List[str]) – The list of phone numbers to send the message to. (required)

  • from (str) – The sender phone number. (required)

  • body (str) – The message body. (required)

  • udh (str) – The user data header. (required)

  • per_recipient (Optional[bool]) – Whether to include per recipient details in the response (optional)

  • number_of_recipients (Optional[int]) – Max number of recipients to include per recipient details for in the response (optional)

  • delivery_report (Optional[DeliveryReportType]) – The delivery report type. (optional)

  • send_at (Optional[datetime]) – The time to send the message at. (optional)

  • expire_at (Optional[datetime]) – The time to expire the message at. (optional)

  • event_destination_target (Optional[str]) – The callback URL to receive the delivery report. (optional)

  • client_reference (Optional[str]) – The client reference to identify the message. (optional)

  • feedback_enabled (Optional[bool]) – Whether to enable feedback. (optional)

  • from_ton (Optional[int]) – The type of number for the sender number. (optional)

  • from_npi (Optional[int]) – The number plan indicator for the sender number. (optional)

  • **kwargs

    Additional parameters for the request.

  • from_ (str)

Returns:

DryRunResponse

Return type:

DryRunResponse

For detailed documentation, visit https://developers.sinch.com/docs/sms/.

dry_run_mms(
to: List[str],
from_: str,
body: MediaBodyDict,
per_recipient: bool | None = None,
number_of_recipients: int | None = None,
parameters: Dict[str, Dict[str, str]] | None = None,
delivery_report: Literal['none', 'summary', 'full', 'per_recipient', 'per_recipient_final'] | Annotated[str, Strict(strict=True)] | None = None,
send_at: datetime | None = None,
expire_at: datetime | None = None,
event_destination_target: str | None = None,
client_reference: str | None = None,
feedback_enabled: bool | None = None,
strict_validation: bool | None = None,
**kwargs,
) DryRunResponse[source]

This operation will perform a dry run of a batch which calculates the bodies and number of parts for all messages in the batch without actually sending any messages (MMS).

Parameters:
  • to (List[str]) – The list of phone numbers to send the message to. (required)

  • from (str) – The sender phone number. (required)

  • body (MediaBodyDict) – The message body. (required)

  • per_recipient (Optional[bool]) – Whether to include per recipient details in the response (optional)

  • number_of_recipients (Optional[int]) – Max number of recipients to include per recipient details for in the response (optional)

  • parameters (Optional[Dict[str, Dict[str, str]]]) – The parameters for the message. (optional)

  • delivery_report (Optional[DeliveryReportType]) – The delivery report type. (optional)

  • send_at (Optional[datetime]) – The time to send the message at. (optional)

  • expire_at (Optional[datetime]) – The time to expire the message at. (optional)

  • event_destination_target (Optional[str]) – The callback URL to receive the delivery report. (optional)

  • client_reference (Optional[str]) – The client reference to identify the message. (optional)

  • feedback_enabled (Optional[bool]) – Whether to enable feedback. (optional)

  • strict_validation (Optional[bool]) – Whether to enable strict validation. (optional)

  • **kwargs

    Additional parameters for the request.

  • from_ (str)

Returns:

DryRunResponse

Return type:

DryRunResponse

For detailed documentation, visit https://developers.sinch.com/docs/sms/.

get(
batch_id: str,
**kwargs,
) Annotated[TextResponse | BinaryResponse | MediaResponse, FieldInfo(annotation=NoneType, required=True, discriminator='type')][source]

This operation returns a specific batch that matches the provided batch ID.

Parameters:
  • batch_id (str) – The batch ID you received from sending a message. (required)

  • **kwargs

    Additional parameters for the request.

Returns:

BatchResponse

Return type:

BatchResponse

For detailed documentation, visit https://developers.sinch.com/docs/sms/.

list(
page: int | None = None,
page_size: int | None = None,
start_date: datetime | None = None,
end_date: datetime | None = None,
from_: List[str] | None = None,
client_reference: str | None = None,
**kwargs,
) Paginator[Annotated[TextResponse | BinaryResponse | MediaResponse, FieldInfo(annotation=NoneType, required=True, discriminator='type')]][source]

With the list operation you can list batch messages created in the last 14 days that you have created. This operation supports pagination.

Parameters:
  • page (Optional[int]) – The page number starting from 0. (optional)

  • page_size (Optional[int]) – Determines the size of a page. (optional)

  • start_date (Optional[datetime]) – Only list messages received at or after this date/time. Formatted as [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601): YYYY-MM-DDThh:mm:ss.SSSZ. Default: Now-24 (optional)

  • end_date (Optional[datetime]) – Only list messages received before this date/time. Formatted as [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601): YYYY-MM-DDThh:mm:ss.SSSZ. (optional)

  • from (Optional[List[str]]) – Only list messages sent from this sender number. Multiple originating numbers can be comma separated. Must be phone numbers or short code. (optional)

  • client_reference (Optional[str]) – Client reference to include (optional)

  • **kwargs

    Additional parameters for the request.

  • from_ (List[str] | None)

Returns:

Paginator[BatchResponse]

Return type:

Paginator[BatchResponse]

For detailed documentation, visit https://developers.sinch.com/docs/sms/.

replace(
batch_id: str,
request: ReplaceTextRequest | ReplaceBinaryRequest | ReplaceMediaRequest | None = None,
**kwargs,
) Annotated[TextResponse | BinaryResponse | MediaResponse, FieldInfo(annotation=NoneType, required=True, discriminator='type')][source]

This operation will replace all the parameters of a batch with the provided values. It is the same as cancelling a batch and sending a new one instead.

Parameters:
  • batch_id (str) – The batch ID you received from sending a message. (required)

  • request (Optional[ReplaceBatchRequest]) – The request object. (optional)

  • **kwargs

    Additional parameters for the request.

Returns:

BatchResponse

Return type:

BatchResponse

For additional documentation, see https://www.sinch.com and visit our developer portal.

replace_sms(
batch_id: str,
to: List[str],
from_: str,
body: str,
delivery_report: Literal['none', 'summary', 'full', 'per_recipient', 'per_recipient_final'] | Annotated[str, Strict(strict=True)] | None = None,
send_at: datetime | None = None,
expire_at: datetime | None = None,
event_destination_target: str | None = None,
client_reference: str | None = None,
feedback_enabled: bool | None = None,
flash_message: bool | None = None,
max_number_of_message_parts: int | None = None,
truncate_concat: bool | None = None,
from_ton: int | None = None,
from_npi: int | None = None,
parameters: Dict[str, Dict[str, str]] | None = None,
**kwargs,
) Annotated[TextResponse | BinaryResponse | MediaResponse, FieldInfo(annotation=NoneType, required=True, discriminator='type')][source]

This operation will replace all the parameters of a batch with the provided values. It is the same as cancelling a batch and sending a new one instead (MMS).

Parameters:
  • batch_id (str) – The batch ID you received from sending a message. (required)

  • to (List[str]) – The list of phone numbers to send the message to. (required)

  • from (str) – The sender phone number. (required)

  • body (str) – The message body. (required)

  • delivery_report (Optional[DeliveryReportType]) – The delivery report type. (optional)

  • send_at (Optional[datetime]) – The time to send the message at. (optional)

  • expire_at (Optional[datetime]) – The time to expire the message at. (optional)

  • event_destination_target (Optional[str]) – The callback URL to receive the delivery report. (optional)

  • client_reference (Optional[str]) – The client reference to identify the message. (optional)

  • feedback_enabled (Optional[bool]) – Whether to enable feedback. (optional)

  • flash_message (Optional[bool]) – Whether to enable flash message. (optional)

  • max_number_of_message_parts (Optional[int]) – The maximum number of message parts. (optional)

  • truncate_concat (Optional[bool]) – Whether to truncate the message if it is too long. (optional)

  • from_ton (Optional[int]) – The type of number for the sender number. (optional)

  • from_npi (Optional[int]) – The number plan indicator for the sender number. (optional)

  • parameters (Optional[Dict[str, Dict[str, str]]]) – The parameters for the message. (optional)

  • **kwargs

    Additional parameters for the request.

  • from_ (str)

Returns:

BatchResponse

Return type:

BatchResponse

For additional documentation, see https://www.sinch.com and visit our developer portal.

replace_binary(
batch_id: str,
to: List[str],
from_: str,
body: str,
udh: str,
delivery_report: Literal['none', 'summary', 'full', 'per_recipient', 'per_recipient_final'] | Annotated[str, Strict(strict=True)] | None = None,
send_at: datetime | None = None,
expire_at: datetime | None = None,
event_destination_target: str | None = None,
client_reference: str | None = None,
feedback_enabled: bool | None = None,
from_ton: int | None = None,
from_npi: int | None = None,
**kwargs,
) Annotated[TextResponse | BinaryResponse | MediaResponse, FieldInfo(annotation=NoneType, required=True, discriminator='type')][source]

This operation will replace all the parameters of a batch with the provided values. It is the same as cancelling a batch and sending a new one instead (Binary).

Parameters:
  • batch_id (str) – The batch ID you received from sending a message. (required)

  • to (List[str]) – The list of phone numbers to send the message to. (required)

  • from (str) – The sender phone number. (required)

  • body (str) – The message body. (required)

  • udh (str) – The user data header. (required)

  • delivery_report (Optional[DeliveryReportType]) – The delivery report type. (optional)

  • send_at (Optional[datetime]) – The time to send the message at. (optional)

  • expire_at (Optional[datetime]) – The time to expire the message at. (optional)

  • event_destination_target (Optional[str]) – The callback URL to receive the delivery report. (optional)

  • client_reference (Optional[str]) – The client reference to identify the message. (optional)

  • feedback_enabled (Optional[bool]) – Whether to enable feedback. (optional)

  • from_ton (Optional[int]) – The type of number for the sender number. (optional)

  • from_npi (Optional[int]) – The number plan indicator for the sender number. (optional)

  • **kwargs

    Additional parameters for the request.

  • from_ (str)

Returns:

BatchResponse

Return type:

BatchResponse

For additional documentation, see https://www.sinch.com and visit our developer portal.

replace_mms(
batch_id: str,
to: List[str],
from_: str,
body: MediaBodyDict,
delivery_report: Literal['none', 'summary', 'full', 'per_recipient', 'per_recipient_final'] | Annotated[str, Strict(strict=True)] | None = None,
send_at: datetime | None = None,
expire_at: datetime | None = None,
event_destination_target: str | None = None,
client_reference: str | None = None,
feedback_enabled: bool | None = None,
strict_validation: bool | None = None,
parameters: Dict[str, Dict[str, str]] | None = None,
**kwargs,
) Annotated[TextResponse | BinaryResponse | MediaResponse, FieldInfo(annotation=NoneType, required=True, discriminator='type')][source]

This operation will replace all the parameters of a batch with the provided values. It is the same as cancelling a batch and sending a new one instead (MMS).

Parameters:
  • batch_id (str) – The batch ID you received from sending a message. (required)

  • to (List[str]) – The list of phone numbers to send the message to. (required)

  • from (str) – The sender phone number. (required)

  • body (MediaBodyDict) – The message body. (required)

  • delivery_report (Optional[DeliveryReportType]) – The delivery report type. (optional)

  • send_at (Optional[datetime]) – The time to send the message at. (optional)

  • expire_at (Optional[datetime]) – The time to expire the message at. (optional)

  • event_destination_target (Optional[str]) – The callback URL to receive the delivery report. (optional)

  • client_reference (Optional[str]) – The client reference to identify the message. (optional)

  • feedback_enabled (Optional[bool]) – Whether to enable feedback. (optional)

  • strict_validation (Optional[bool]) – Whether to enable strict validation. (optional)

  • parameters (Optional[Dict[str, Dict[str, str]]]) – The parameters for the message. (optional)

  • **kwargs

    Additional parameters for the request.

  • from_ (str)

Returns:

BatchResponse

Return type:

BatchResponse

For additional documentation, see https://www.sinch.com and visit our developer portal.

send(
request: TextRequest | BinaryRequest | MediaRequest | None = None,
**kwargs,
) Annotated[TextResponse | BinaryResponse | MediaResponse, FieldInfo(annotation=NoneType, required=True, discriminator='type')][source]

Send a message or a batch of messages.

Depending on the length of the body, one message might be split into multiple parts and charged accordingly.

Any groups targeted in a scheduled batch will be evaluated at the time of sending. If a group is deleted between batch creation and scheduled date, it will be considered empty.

Be sure to use the correct [region](/docs/sms/api-reference/#base-url) in the server URL.

Parameters:
  • request (Optional[SendSMSRequest]) – The request object. (optional)

  • **kwargs

    Additional parameters for the request.

Returns:

BatchResponse

Return type:

BatchResponse

For detailed documentation, visit https://developers.sinch.com/docs/sms/.

send_sms(
to: List[str],
from_: str,
body: str,
delivery_report: Literal['none', 'summary', 'full', 'per_recipient', 'per_recipient_final'] | Annotated[str, Strict(strict=True)] | None = None,
send_at: datetime | None = None,
expire_at: datetime | None = None,
event_destination_target: str | None = None,
client_reference: str | None = None,
feedback_enabled: bool | None = None,
flash_message: bool | None = None,
max_number_of_message_parts: int | None = None,
truncate_concat: bool | None = None,
from_ton: int | None = None,
from_npi: int | None = None,
parameters: Dict[str, Dict[str, str]] | None = None,
**kwargs,
) Annotated[TextResponse | BinaryResponse | MediaResponse, FieldInfo(annotation=NoneType, required=True, discriminator='type')][source]

Send a message or a batch of messages (SMS).

Depending on the length of the body, one message might be split into multiple parts and charged accordingly.

Any groups targeted in a scheduled batch will be evaluated at the time of sending. If a group is deleted between batch creation and scheduled date, it will be considered empty.

Be sure to use the correct [region](/docs/sms/api-reference/#base-url) in the server URL.

Parameters:
  • to (List[str]) – The list of phone numbers to send the message to. (required)

  • from (str) – The sender phone number. (required)

  • body (str) – The message body. (required)

  • delivery_report (Optional[DeliveryReportType]) – The delivery report type. (optional)

  • send_at (Optional[datetime]) – The time to send the message at. (optional)

  • expire_at (Optional[datetime]) – The time to expire the message at. (optional)

  • event_destination_target (Optional[str]) – The callback URL to receive the delivery report. (optional)

  • client_reference (Optional[str]) – The client reference to identify the message. (optional)

  • feedback_enabled (Optional[bool]) – Whether to enable feedback. (optional)

  • flash_message (Optional[bool]) – Whether to enable flash message. (optional)

  • max_number_of_message_parts (Optional[int]) – The maximum number of message parts. (optional)

  • truncate_concat (Optional[bool]) – Whether to truncate the message if it is too long. (optional)

  • from_ton (Optional[int]) – The type of number for the sender number. (optional)

  • from_npi (Optional[int]) – The number plan indicator for the sender number. (optional)

  • parameters (Optional[Dict[str, Dict[str, str]]]) – The parameters for the message. (optional)

  • **kwargs

    Additional parameters for the request.

  • from_ (str)

Returns:

BatchResponse

Return type:

BatchResponse

For detailed documentation, visit https://developers.sinch.com/docs/sms/.

send_binary(
to: List[str],
from_: str,
body: str,
udh: str,
delivery_report: Literal['none', 'summary', 'full', 'per_recipient', 'per_recipient_final'] | Annotated[str, Strict(strict=True)] | None = None,
send_at: datetime | None = None,
expire_at: datetime | None = None,
event_destination_target: str | None = None,
client_reference: str | None = None,
feedback_enabled: bool | None = None,
from_ton: int | None = None,
from_npi: int | None = None,
**kwargs,
) Annotated[TextResponse | BinaryResponse | MediaResponse, FieldInfo(annotation=NoneType, required=True, discriminator='type')][source]

Send a message or a batch of messages (Binary).

Depending on the length of the body, one message might be split into multiple parts and charged accordingly.

Any groups targeted in a scheduled batch will be evaluated at the time of sending. If a group is deleted between batch creation and scheduled date, it will be considered empty.

Be sure to use the correct [region](/docs/sms/api-reference/#base-url) in the server URL.

Parameters:
  • to (List[str]) – The list of phone numbers to send the message to. (required)

  • from (str) – The sender phone number. (required)

  • body (str) – The message body. (required)

  • udh (str) – The user data header. (required)

  • delivery_report (Optional[DeliveryReportType]) – The delivery report type. (optional)

  • send_at (Optional[datetime]) – The time to send the message at. (optional)

  • expire_at (Optional[datetime]) – The time to expire the message at. (optional)

  • event_destination_target (Optional[str]) – The callback URL to receive the delivery report. (optional)

  • client_reference (Optional[str]) – The client reference to identify the message. (optional)

  • feedback_enabled (Optional[bool]) – Whether to enable feedback. (optional)

  • from_ton (Optional[int]) – The type of number for the sender number. (optional)

  • from_npi (Optional[int]) – The number plan indicator for the sender number. (optional)

  • **kwargs

    Additional parameters for the request.

  • from_ (str)

Returns:

BatchResponse

Return type:

BatchResponse

For detailed documentation, visit https://developers.sinch.com/docs/sms/.

send_mms(
to: List[str],
from_: str,
body: MediaBodyDict,
delivery_report: Literal['none', 'summary', 'full', 'per_recipient', 'per_recipient_final'] | Annotated[str, Strict(strict=True)] | None = None,
send_at: datetime | None = None,
expire_at: datetime | None = None,
event_destination_target: str | None = None,
client_reference: str | None = None,
feedback_enabled: bool | None = None,
strict_validation: bool | None = None,
parameters: Dict[str, Dict[str, str]] | None = None,
**kwargs,
) Annotated[TextResponse | BinaryResponse | MediaResponse, FieldInfo(annotation=NoneType, required=True, discriminator='type')][source]

Send a message or a batch of messages (MMS).

Depending on the length of the body, one message might be split into multiple parts and charged accordingly.

Any groups targeted in a scheduled batch will be evaluated at the time of sending. If a group is deleted between batch creation and scheduled date, it will be considered empty.

Be sure to use the correct [region](/docs/sms/api-reference/#base-url) in the server URL.

Parameters:
  • to (List[str]) – The list of phone numbers to send the message to. (required)

  • from (str) – The sender phone number. (required)

  • body (MediaBodyDict) – The message body. (required)

  • delivery_report (Optional[DeliveryReportType]) – The delivery report type. (optional)

  • send_at (Optional[datetime]) – The time to send the message at. (optional)

  • expire_at (Optional[datetime]) – The time to expire the message at. (optional)

  • event_destination_target (Optional[str]) – The callback URL to receive the delivery report. (optional)

  • client_reference (Optional[str]) – The client reference to identify the message. (optional)

  • feedback_enabled (Optional[bool]) – Whether to enable feedback. (optional)

  • strict_validation (Optional[bool]) – Whether to enable strict validation. (optional)

  • parameters (Optional[Dict[str, Dict[str, str]]]) – The parameters for the message. (optional)

  • **kwargs

    Additional parameters for the request.

  • from_ (str)

Returns:

BatchResponse

Return type:

BatchResponse

For detailed documentation, visit https://developers.sinch.com/docs/sms/.

send_delivery_feedback(
batch_id: str,
recipients: List[str],
**kwargs,
) None[source]

Send feedback if your system can confirm successful message delivery.

Feedback can only be provided if feedback_enabled was set when batch was submitted.

Batches: It is possible to submit feedback multiple times for the same batch for different recipients. Feedback without specified recipients is treated as successful message delivery to all recipients referenced in the batch. Note that the recipients key is still required even if the value is empty.

Groups: If the batch message was creating using a group ID, at least one recipient is required. Excluding recipients (an empty recipient list) does not work and will result in a failed request.

Parameters:
  • batch_id (str) – The batch ID you received from sending a message. (required)

  • recipients (List[str]) – A list of phone numbers (MSISDNs) that have successfully received the message. The key is required, however, the value can be an empty array ([]) for a batch. If the feedback was enabled for a group, at least one phone number is required. (required)

  • **kwargs

    Additional parameters for the request.

Returns:

None

Return type:

None

For detailed documentation, visit https://developers.sinch.com/docs/sms/.

update(
batch_id: str,
request: UpdateTextRequestWithBatchId | UpdateBinaryRequestWithBatchId | UpdateMediaRequestWithBatchId | None = None,
**kwargs,
) Annotated[TextResponse | BinaryResponse | MediaResponse, FieldInfo(annotation=NoneType, required=True, discriminator='type')][source]

This operation updates all specified parameters of a batch that matches the provided batch ID.

Parameters:
  • batch_id (str) – The batch ID you received from sending a message. (required)

  • request (Optional[UpdateBatchMessageRequest]) – The request object. (optional)

  • **kwargs

    Additional parameters for the request.

Returns:

BatchResponse

Return type:

BatchResponse

For detailed documentation, visit https://developers.sinch.com/docs/sms/.

update_sms(
batch_id: str,
from_: str | None = None,
to_add: List[str] | None = None,
to_remove: List[str] | None = None,
body: str | None = None,
delivery_report: Literal['none', 'summary', 'full', 'per_recipient', 'per_recipient_final'] | Annotated[str, Strict(strict=True)] | None = None,
send_at: datetime | None = None,
expire_at: datetime | None = None,
event_destination_target: str | None = None,
client_reference: str | None = None,
feedback_enabled: bool | None = None,
parameters: Dict[str, Dict[str, str]] | None = None,
from_ton: int | None = None,
from_npi: int | None = None,
max_number_of_message_parts: int | None = None,
truncate_concat: bool | None = None,
flash_message: bool | None = None,
**kwargs,
) Annotated[TextResponse | BinaryResponse | MediaResponse, FieldInfo(annotation=NoneType, required=True, discriminator='type')][source]

This operation updates all specified parameters of a batch that matches the provided batch ID. (SMS)

Parameters:
  • batch_id (str) – The batch ID you received from sending a message. (required)

  • from (Optional[str]) – The sender phone number. (optional)

  • to_add (Optional[List[str]]) – The list of phone numbers to add to the batch. (optional)

  • to_remove (Optional[List[str]]) – The list of phone numbers to remove from the batch. (optional)

  • body (Optional[str]) – The message body. (optional)

  • delivery_report (Optional[DeliveryReportType]) – The delivery report type. (optional)

  • send_at (Optional[datetime]) – The time to send the message at. (optional)

  • expire_at (Optional[datetime]) – The time to expire the message at. (optional)

  • event_destination_target (Optional[str]) – The callback URL to receive the delivery report. (optional)

  • client_reference (Optional[str]) – The client reference to identify the message. (optional)

  • feedback_enabled (Optional[bool]) – Whether to enable feedback. (optional)

  • parameters (Optional[Dict[str, Dict[str, str]]]) – The parameters for the message. (optional)

  • from_ton (Optional[int]) – The type of number for the sender number. (optional)

  • from_npi (Optional[int]) – The number plan indicator for the sender number. (optional)

  • max_number_of_message_parts (Optional[int]) – The maximum number of message parts. (optional)

  • truncate_concat (Optional[bool]) – Whether to truncate the message if it is too long. (optional)

  • flash_message (Optional[bool]) – Whether to enable flash message. (optional)

  • **kwargs

    Additional parameters for the request.

  • from_ (str | None)

Returns:

BatchResponse

Return type:

BatchResponse

For detailed documentation, visit https://developers.sinch.com/docs/sms/.

update_binary(
batch_id: str,
udh: str,
from_: str | None = None,
to_add: List[str] | None = None,
to_remove: List[str] | None = None,
body: str | None = None,
delivery_report: Literal['none', 'summary', 'full', 'per_recipient', 'per_recipient_final'] | Annotated[str, Strict(strict=True)] | None = None,
send_at: datetime | None = None,
expire_at: datetime | None = None,
event_destination_target: str | None = None,
client_reference: str | None = None,
feedback_enabled: bool | None = None,
from_ton: int | None = None,
from_npi: int | None = None,
**kwargs,
) Annotated[TextResponse | BinaryResponse | MediaResponse, FieldInfo(annotation=NoneType, required=True, discriminator='type')][source]

This operation updates all specified parameters of a batch that matches the provided batch ID. (Binary)

Parameters:
  • batch_id (str) – The batch ID you received from sending a message. (required)

  • udh (str) – The user data header. (required)

  • from (Optional[str]) – The sender phone number. (optional)

  • to_add (Optional[List[str]]) – The list of phone numbers to add to the batch. (optional)

  • to_remove (Optional[List[str]]) – The list of phone numbers to remove from the batch. (optional)

  • body (Optional[str]) – The message body. (optional)

  • delivery_report (Optional[DeliveryReportType]) – The delivery report type. (optional)

  • send_at (Optional[datetime]) – The time to send the message at. (optional)

  • expire_at (Optional[datetime]) – The time to expire the message at. (optional)

  • event_destination_target (Optional[str]) – The callback URL to receive the delivery report. (optional)

  • client_reference (Optional[str]) – The client reference to identify the message. (optional)

  • feedback_enabled (Optional[bool]) – Whether to enable feedback. (optional)

  • from_ton (Optional[int]) – The type of number for the sender number. (optional)

  • from_npi (Optional[int]) – The number plan indicator for the sender number. (optional)

  • **kwargs

    Additional parameters for the request.

  • from_ (str | None)

Returns:

BatchResponse

Return type:

BatchResponse

For detailed documentation, visit https://developers.sinch.com/docs/sms/.

update_mms(
batch_id: str,
from_: str | None = None,
to_add: List[str] | None = None,
to_remove: List[str] | None = None,
body: MediaBodyDict | None = None,
delivery_report: Literal['none', 'summary', 'full', 'per_recipient', 'per_recipient_final'] | Annotated[str, Strict(strict=True)] | None = None,
send_at: datetime | None = None,
expire_at: datetime | None = None,
event_destination_target: str | None = None,
client_reference: str | None = None,
feedback_enabled: bool | None = None,
parameters: Dict[str, Dict[str, str]] | None = None,
strict_validation: bool | None = None,
**kwargs,
) Annotated[TextResponse | BinaryResponse | MediaResponse, FieldInfo(annotation=NoneType, required=True, discriminator='type')][source]

This operation updates all specified parameters of a batch that matches the provided batch ID. (MMS)

Parameters:
  • batch_id (str) – The batch ID you received from sending a message. (required)

  • from (Optional[str]) – The sender phone number. (optional)

  • to_add (Optional[List[str]]) – The list of phone numbers to add to the batch. (optional)

  • to_remove (Optional[List[str]]) – The list of phone numbers to remove from the batch. (optional)

  • body (Optional[MediaBodyDict]) – The message body. (optional)

  • delivery_report (Optional[DeliveryReportType]) – The delivery report type. (optional)

  • send_at (Optional[datetime]) – The time to send the message at. (optional)

  • expire_at (Optional[datetime]) – The time to expire the message at. (optional)

  • event_destination_target (Optional[str]) – The callback URL to receive the delivery report. (optional)

  • client_reference (Optional[str]) – The client reference to identify the message. (optional)

  • feedback_enabled (Optional[bool]) – Whether to enable feedback. (optional)

  • parameters (Optional[Dict[str, Dict[str, str]]]) – The parameters for the message. (optional)

  • strict_validation (Optional[bool]) – Whether to enable strict validation. (optional)

  • **kwargs

    Additional parameters for the request.

  • from_ (str | None)

Returns:

BatchResponse

Return type:

BatchResponse

For detailed documentation, visit https://developers.sinch.com/docs/sms/.

class sinch.domains.sms.api.v1.DeliveryReports(sinch)[source]

Bases: BaseSms

get(
batch_id: str,
report_type: str | None = None,
status: List[Literal['QUEUED', 'DISPATCHED', 'ABORTED', 'CANCELLED', 'FAILED', 'DELIVERED', 'EXPIRED', 'REJECTED', 'DELETED', 'UNKNOWN'] | Annotated[str, Strict(strict=True)]] | None = None,
code: List[Literal[400, 401, 402, 403, 404, 405, 406, 407, 408, 410, 411, 412, 413, 414, 415, 416, 417, 418] | Annotated[int, Strict(strict=True)]] | None = None,
client_reference: str | None = None,
**kwargs,
) BatchDeliveryReport[source]

Delivery reports can be retrieved even if no callback was requested. The difference between a summary and a full report is only that the full report contains the phone numbers in [E.164](https://community.sinch.com/t5/Glossary/E-164/ta-p/7537) format for each status code.

Parameters:
  • batch_id (str) – The batch ID you received from sending a message. (required)

  • report_type (Optional[str]) – The type of delivery report. - A summary will count the number of messages sent per status. - A full report give that of a summary report but in addition, lists phone numbers. (optional)

  • status (Optional[List[DeliveryStatusType]]) – Comma separated list of delivery_report_statuses to include (optional)

  • code (Optional[List[DeliveryReceiptStatusCodeType]]) – Comma separated list of delivery_receipt_error_codes to include (optional)

  • client_reference (Optional[str]) – The client identifier of the batch this delivery report belongs to, if set when submitting batch. (optional)

  • **kwargs

    Additional parameters for the request.

Returns:

BatchDeliveryReport

Return type:

BatchDeliveryReport

For detailed documentation, visit https://developers.sinch.com/docs/sms/.

get_for_number(
batch_id: str,
recipient: str,
**kwargs,
) RecipientDeliveryReport[source]

A recipient delivery report contains the message status for a single recipient phone number.

Parameters:
  • batch_id (str) – The batch ID you received from sending a message. (required)

  • recipient (str) – Phone number for which you want to search. (required)

  • **kwargs

    Additional parameters for the request.

Returns:

RecipientDeliveryReport

Return type:

RecipientDeliveryReport

For detailed documentation, visit https://developers.sinch.com/docs/sms/.

list(
page: int | None = None,
page_size: int | None = None,
start_date: datetime | None = None,
end_date: datetime | None = None,
status: List[Literal['QUEUED', 'DISPATCHED', 'ABORTED', 'CANCELLED', 'FAILED', 'DELIVERED', 'EXPIRED', 'REJECTED', 'DELETED', 'UNKNOWN'] | Annotated[str, Strict(strict=True)]] | None = None,
code: List[Literal[400, 401, 402, 403, 404, 405, 406, 407, 408, 410, 411, 412, 413, 414, 415, 416, 417, 418] | Annotated[int, Strict(strict=True)]] | None = None,
client_reference: str | None = None,
**kwargs,
) Paginator[RecipientDeliveryReport][source]

Get a list of finished delivery reports. This operation supports pagination.

Parameters:
  • page (Optional[int]) – The page number starting from 0. (optional)

  • page_size (Optional[int]) – Determines the size of a page. (optional)

  • start_date (Optional[datetime]) – Only list messages received at or after this date/time. Default: 24h ago (optional)

  • end_date (Optional[datetime]) – Only list messages received before this date/time. (optional)

  • status (Optional[List[DeliveryStatusType]]) – Comma separated list of delivery report statuses to include. (optional)

  • code (Optional[List[DeliveryReceiptStatusCodeType]]) – Comma separated list of delivery receipt error codes to include. (optional)

  • client_reference (Optional[str]) – Client reference to include (optional)

  • **kwargs

    Additional parameters for the request.

Returns:

Paginator[RecipientDeliveryReport]

Return type:

Paginator[RecipientDeliveryReport]

For detailed documentation, visit https://developers.sinch.com/docs/sms/.

class sinch.domains.sms.api.v1.Inbounds(sinch)[source]

Bases: BaseSms

get(
inbound_id: str,
**kwargs,
) Annotated[MOTextMessage | MOBinaryMessage | MOMediaMessage, FieldInfo(annotation=NoneType, required=True, discriminator='type')][source]

This operation retrieves a specific inbound message using the provided inbound ID.

Parameters:
  • inbound_id (str) – The inbound ID found when listing inbound messages. (required)

  • **kwargs

    Additional parameters for the request.

Returns:

InboundMessage

Return type:

InboundMessage

For detailed documentation, visit https://developers.sinch.com/docs/sms/.

list(
page: int | None = None,
page_size: int | None = None,
to: List[str] | None = None,
start_date: datetime | None = None,
end_date: datetime | None = None,
client_reference: str | None = None,
**kwargs,
) Paginator[Annotated[MOTextMessage | MOBinaryMessage | MOMediaMessage, FieldInfo(annotation=NoneType, required=True, discriminator='type')]][source]
With the list operation,

you can list all inbound messages that you have received. This operation supports pagination. Inbounds are returned in reverse chronological order.

Parameters:
  • page (Optional[int]) – The page number starting from 0. (optional)

  • page_size (Optional[int]) – Determines the size of a page (optional)

  • to (Optional[List[str]]) – Only list messages sent to this destination. Multiple phone numbers formatted as either [E.164](https://community.sinch.com/t5/Glossary/E-164/ta-p/7537) or short codes can be comma separated. (optional)

  • start_date – Only list messages received at or after this date/time. Formatted as [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601): YYYY-MM-DDThh:mm:ss.SSSZ. Default: Now-24 (optional)

  • client_reference (Optional[str]) – Using a client reference in inbound messages requires additional setup on your account. Contact your [account manager](https://dashboard.sinch.com/settings/account-details) to enable this feature. Only list inbound messages that are in response to messages with a previously provided client reference. (optional)

  • **kwargs

    Additional parameters for the request.

  • end_date (Optional[datetime])

Returns:

Paginator[InboundMessage]

Return type:

Paginator[InboundMessage]

For detailed documentation, visit https://developers.sinch.com/docs/sms/.

class sinch.domains.sms.api.v1.Groups(sinch)[source]

Bases: BaseSms

create(
name: str | None = None,
members: List[str] | None = None,
child_groups: List[str] | None = None,
auto_update: AutoUpdateDict | None = None,
**kwargs,
) GroupResponse[source]

This endpoint allows you to create a group of recipients. A new group must be created with a group name. This is represented by the name field which can be up to 20 characters. In addition, there are a number of optional fields:

  • members field enables groups to be created with an initial list of contacts.

  • auto_update allows customers to auto subscribe to a new group. This contains three fields. The to field contains the group creator’s number. (This number must be provisioned by contacting your account manager.) The add and remove fields are objects containing the keywords that customers need to text to join or leave a group.

Parameters:
  • name (Optional[str]) – Name of the group. Max 20 characters. (optional)

  • members (Optional[List[str]]) – Initial list of phone numbers in E.164 format (MSISDNs) for the group. (optional)

  • child_groups (Optional[List[str]]) – MSISDNs of child groups to include in this group. If present, this group will be auto-populated. Elements must be valid group IDs. (optional)

  • auto_update (Optional[AutoUpdateDict]) – The auto-update settings for the group. (optional)

  • **kwargs

    Additional parameters for the request.

Returns:

GroupResponse

Return type:

GroupResponse

For detailed documentation, visit https://developers.sinch.com/docs/sms/.

list(
page: int | None = None,
page_size: int | None = None,
**kwargs,
) Paginator[GroupResponse][source]

With the list operation you can list all groups that you have created. This operation supports pagination.

Groups are returned in reverse chronological order.

Parameters:
  • page (Optional[int]) – The page number starting from 0. (optional)

  • page_size (Optional[int]) – Determines the size of a page. (optional)

  • **kwargs

    Additional parameters for the request.

Returns:

Paginator[GroupResponse]

Return type:

Paginator[GroupResponse]

For detailed documentation, visit https://developers.sinch.com/docs/sms/.

get(
group_id: str,
**kwargs,
) GroupResponse[source]

This operation retrieves a specific group with the provided group ID.

Parameters:

group_id (str) – ID of a group that you are interested in getting.

Returns:

GroupResponse

Return type:

GroupResponse

For detailed documentation, visit https://developers.sinch.com/docs/sms/.

replace(
group_id: str,
name: str | None = None,
members: List[str] | None = None,
child_groups: List[str] | None = None,
auto_update: AutoUpdateDict | None = None,
**kwargs,
) GroupResponse[source]

The replace operation will replace all parameters, including members, of an existing group with new values.

Replacing a group targeted by a batch message scheduled in the future is allowed and changes will be reflected when the batch is sent.

Parameters:
  • group_id (str) – ID of the group to replace.

  • name (Optional[str]) – Name of the group. Max 20 characters. (optional)

  • members (Optional[List[str]]) – Initial list of phone numbers in E.164 format (MSISDNs) for the group. (optional)

  • child_groups (Optional[List[str]]) – MSISDNs of child groups to include in this group. If present, this group will be auto-populated. Elements must be valid group IDs. (optional)

  • auto_update (Optional[AutoUpdateDict]) – The auto-update settings for the group. (optional)

  • **kwargs

    Additional parameters for the request.

Returns:

GroupResponse

Return type:

GroupResponse

For detailed documentation, visit https://developers.sinch.com/docs/sms/.

update(
group_id: str,
add: List[str] | None = None,
remove: List[str] | None = None,
name: str | None = None,
add_from_group: str | None = None,
remove_from_group: str | None = None,
auto_update: AutoUpdateDict | None = None,
**kwargs,
) GroupResponse[source]

With the update group operation, you can add and remove members in an existing group as well as rename the group.

This method encompasses a few ways to update a group:

  1. By using add and remove arrays containing phone numbers, you control the group movements. Any list of valid numbers in E.164 format can be added.

  2. By using the auto_update object, your customer can add or remove themselves from groups.

  3. You can also add or remove other groups into this group with add_from_group and remove_from_group.

Other group update info:

  • The request will not be rejected for duplicate adds or unknown removes.

  • The additions will be done before the deletions. If a phone number is on both lists, it will not be part of the resulting group.

  • Updating a group targeted by a batch message scheduled in the future is allowed. Changes will be reflected when the batch is sent.

Parameters:
  • group_id (str) – ID of the group to update.

  • add (Optional[List[str]]) – List of phone numbers (MSISDNs) in E.164 format to add to the group. (optional)

  • remove (Optional[List[str]]) – List of phone numbers (MSISDNs) in E.164 format to remove from the group. (optional)

  • name (Optional[str]) – Name of the group. Omit to leave the name unchanged; set explicitly to null to remove the existing name. (optional)

  • add_from_group (Optional[str]) – Copy the members from another group into this group. Must be a valid group ID. (optional)

  • remove_from_group (Optional[str]) – Remove the members in a specified group from this group. Must be a valid group ID. (optional)

  • auto_update (Optional[AutoUpdateDict]) – The auto-update settings for the group. (optional)

  • **kwargs

    Additional parameters for the request.

Returns:

GroupResponse

Return type:

GroupResponse

For detailed documentation, visit https://developers.sinch.com/docs/sms/.

delete(group_id: str, **kwargs) None[source]

This operation deletes the group with the provided group ID.

Parameters:

group_id (str) – ID of the group to delete.

Returns:

None

Return type:

None

For detailed documentation, visit https://developers.sinch.com/docs/sms/.

list_members(group_id: str, **kwargs) Paginator[str][source]

This operation retrieves the members of the group with the provided group ID.

Parameters:

group_id (str) – ID of the group whose members are being retrieved.

Returns:

Paginator[str]

Return type:

Paginator[str]

For detailed documentation, visit https://developers.sinch.com/docs/sms/.