From 4b92e71f0d8bb736a7f763a77630f1f8f538acc6 Mon Sep 17 00:00:00 2001 From: Tamas Juhasz Date: Tue, 18 Nov 2025 11:15:55 +0100 Subject: [PATCH 1/2] Enhanced documentation with email and moments examples. --- email.md | 68 +++++++++++++++++++++++++++++ moments.md | 126 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 194 insertions(+) create mode 100644 email.md create mode 100644 moments.md diff --git a/email.md b/email.md new file mode 100644 index 0000000..3fd1511 --- /dev/null +++ b/email.md @@ -0,0 +1,68 @@ +# Email API example + +This example demonstrates how to use the [Infobip Email API](https://www.infobip.com/docs/api/channels/email). You'll learn how to initialize an email client, +send a message, and receive a delivery report. + +Initialize Send Email API client: + +```python +from infobip_api_client.api_client import ApiClient, Configuration + +client_config = Configuration( + host="", + api_key={"APIKeyHeader": ""}, + api_key_prefix={"APIKeyHeader": ""}, +) + +api_client = ApiClient(client_config) +api_instance = EmailApi(api_client) +``` + +Before sending an email message, you need to verify the domain with which you will be sending emails. + +## Send an Email with a file + +Fields `from`, `to`, and `subject` are required. The message must also contain at least one of these: `text`, `html`, or `templateId`. + +--- +**IMPORTANT NOTE** + +Keep in mind the following restrictions while using a trial account: + +- you can only send messages to verified email addresses, +- you can only use your email address with the Infobip test domain in the following form: `YourUserName@selfserviceib.com` + +--- + +```python +file_attachment = open("report.csv", "rb") +file_content = file_attachment.read() + +api_response = api_instance.send_email( + to=["john.smith@somedomain.com"], + var_from="Jane Smith ", + subject="Mail subject text", + text="Test message with a file", + attachment=[file_content], + ) +``` + +## Delivery reports + +For each message that you send out, we can send you a delivery report in real time. +All you need to do is specify your endpoint when sending email in the `notifyUrl` field. + +Additionally, you can use a `messageId` or a `bulkId` autogenerated in a response for troubleshooting and to fetch reports. + +```python +bulk_id = "BULK-ID-123-xyz"; +number_of_reports_limits = 10; + + +api_response = api_instance.get_email_delivery_reports( + bulk_id=bulk_id, limit=number_of_reports_limits +) + +for report in api_response.results: + print(f"{report.message_id} - {report.status.name}") +``` \ No newline at end of file diff --git a/moments.md b/moments.md new file mode 100644 index 0000000..1429166 --- /dev/null +++ b/moments.md @@ -0,0 +1,126 @@ +# Moments quickstart + +This quick guide aims to help you start with [Infobip Moments API](https://www.infobip.com/docs/api/customer-engagement/moments). After reading it, you should know how to use Moments. + +The first step is to create an `ApiClient` instance with some configuration. + +```python +from infobip_api_client.api_client import ApiClient, Configuration + +client_config = Configuration( + host="", + api_key={"APIKeyHeader": ""}, + api_key_prefix={"APIKeyHeader": ""}, +) + +api_client = ApiClient(client_config) +``` + +## Flow API + +You can now create an instance of `FlowApi` which allows you to manage your flows. + +````python +from infobip_api_client.api import FlowApi + +api_instance = FlowApi(api_client) +```` +### Add participants to flow + +To add participants to a flow, you can use the following code: + +````python +from infobip_api_client import ( + FlowAddFlowParticipantsRequest, + FlowParticipant, + FlowPersonUniqueField, + FlowPersonUniqueFieldType, +) + +campaign_id = 200000000000001 + +request = FlowAddFlowParticipantsRequest( + participants=[ + FlowParticipant( + identify_by=FlowPersonUniqueField( + identifier="test@example.com", type=FlowPersonUniqueFieldType.EMAIL + ), + variables={"orderNumber": 1167873391}, + ), + ], + notify_url="https://example.com" + ) + +api_response = api_instance.add_flow_participants(campaign_id, request) +```` + +### Get a report on participants added to flow + +To fetch a report to confirm that all persons have been successfully added to the flow, you can use the following code: + +````python +given_operation_id = "03f2d474-0508-46bf-9f3d-d8e2c28adaea" + +api_response = api_instance.get_flow_participants_added_report(campaign_id, given_operation_id) +```` + +### Remove person from flow + +To remove a person from a flow, you can use the following code: + +````python +external_id = "8edb24b5-0319-48cd-a1d9-1e8bc5d577ab" + +api_response = api_instance.remove_people_from_flow(campaign_id=campaign_id, external_id=external_id) +```` + + +## Forms API + +You can now create an instance of `FormsApi` which allows you to manage your forms. + +````python +from infobip_api_client.api import FormsApi + +api_instance = FormsApi(api_client) +```` + +### Get forms + +To get all forms, you can use the following code: + +````python +api_response = api_instance.get_forms() +```` + +### Get form by ID + +To get a specific form by ID, you can use the following code: + +````python +form_id = "cec5dfd2-4238-48e0-933b-9acbdb2e6f5f" + +api_response = api_instance.get_form(form_id) +```` + +### Increment form view count + +To increase the view counter of a specific form, you can use the following code: + +````python +api_response = api_instance.increment_view_count(form_id) +```` + +### Submit form data + +To submit data to a specific form, you can use the following code: + +````python +form_data_request = { + "first_name": "John", + "last_name": "Doe", + "company": "Infobip", + "email": "info@example.com" +} +api_response = api_instance.submit_form_data(form_id, form_data_request) +```` \ No newline at end of file From 2709df5c7375fd74412b6e9051d17ef3d4f2251a Mon Sep 17 00:00:00 2001 From: Tamas Juhasz Date: Wed, 19 Nov 2025 16:05:34 +0100 Subject: [PATCH 2/2] Readme updated. --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ff08c2c..32aa14e 100644 --- a/README.md +++ b/README.md @@ -192,7 +192,13 @@ Example of webhook implementation using Flask: For 2FA quick start guide please check [these examples](two-factor-authentication.md). #### Calls -For Calls quick start guide please check [these examples](calls.md) +For Calls quick start guide please check [these examples](calls.md). + +#### Email +For Email quick start guide, view [these examples](email.md). + +#### Moments +For Moments quick start guide, view [these examples](moments.md). ## Ask for help