loops_sdk 2.4.0 → 2.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 26e2946fb1c882b535762d964ef73b0c79c7631315527f3b967aeaab5fe9cb13
4
- data.tar.gz: f44c32833e2191a6565541c87ed6242580e2cd5e01ca023f6b4444c706a6c6f0
3
+ metadata.gz: 38e9951d94773ecbe15f45265e8a9f165db7515791ac01e420563ed863a26f50
4
+ data.tar.gz: 41128ec37890abc5f7e61a5ae8c5ec9feb7d28782bff9f46eb654d996ba11f60
5
5
  SHA512:
6
- metadata.gz: fcbedd17d573585d04d0e474fc5f2f2d712dd7c3da76fae62675df80d1277aafbcfc3ab9992cd764208e8a1ebd0295ee72a4c5b5bd4b9d522e1cca5ab53cdbd2
7
- data.tar.gz: 64048aaf770aa228250d012a6fd83747c0f62ec2f3c75e531426fd6982c882b4488bbea92a945ac4a2f8cfb6c8cae445d601dcb2bd96f61163c82ed90a5c15f9
6
+ metadata.gz: 4a4a15c19cee615df6b1f3cecdfc94d1c0528c68822048a1b908f61bdec682c158c578daaab99f25fa79e156662d9f66072dfaabab8d44a9a778ea2f428159d0
7
+ data.tar.gz: 108fee098145bf52e79b3e6dd55d46618044c61f6aa3a4f6865e80529f1914e54c7fdef8a27b932d81808a1027ac3b8c08ac9b64e067902e01874bd8a047da7d
data/README.md CHANGED
@@ -120,6 +120,7 @@ You can use custom contact properties in API calls. Please make sure to [add cus
120
120
  - [Transactional.update()](#transactionalupdate)
121
121
  - [Transactional.ensure_draft()](#transactionalensure_draft)
122
122
  - [Transactional.publish()](#transactionalpublish)
123
+ - [Transactional.metrics()](#transactionalmetrics)
123
124
  - [Transactional.send()](#transactionalsend)
124
125
  - [DedicatedSendingIps.list()](#dedicatedsendingipslist)
125
126
  - [Themes.list()](#themeslist)
@@ -134,10 +135,15 @@ You can use custom contact properties in API calls. Please make sure to [add cus
134
135
  - [Campaigns.create()](#campaignscreate)
135
136
  - [Campaigns.get()](#campaignsget)
136
137
  - [Campaigns.update()](#campaignsupdate)
138
+ - [Campaigns.metrics()](#campaignsmetrics)
137
139
  - [CampaignGroups.list()](#campaigngroupslist)
138
140
  - [CampaignGroups.create()](#campaigngroupscreate)
139
141
  - [CampaignGroups.get()](#campaigngroupsget)
140
142
  - [CampaignGroups.update()](#campaigngroupsupdate)
143
+ - [WorkflowGroups.list()](#workflowgroupslist)
144
+ - [WorkflowGroups.create()](#workflowgroupscreate)
145
+ - [WorkflowGroups.get()](#workflowgroupsget)
146
+ - [WorkflowGroups.update()](#workflowgroupsupdate)
141
147
  - [AudienceSegments.list()](#audiencesegmentslist)
142
148
  - [AudienceSegments.get()](#audiencesegmentsget)
143
149
  - [AudienceSegments.create()](#audiencesegmentscreate)
@@ -145,12 +151,15 @@ You can use custom contact properties in API calls. Please make sure to [add cus
145
151
  - [Workflows.create()](#workflowscreate)
146
152
  - [Workflows.get()](#workflowsget)
147
153
  - [Workflows.update()](#workflowsupdate)
154
+ - [Workflows.delete()](#workflowsdelete)
148
155
  - [Workflows.change_mailing_list()](#workflowschange_mailing_list)
149
156
  - [Workflows.get_node()](#workflowsget_node)
157
+ - [Workflows.get_node_metrics()](#workflowsget_node_metrics)
150
158
  - [Workflows.create_node()](#workflowscreate_node)
151
159
  - [Workflows.update_node()](#workflowsupdate_node)
152
160
  - [Workflows.delete_node()](#workflowsdelete_node)
153
161
  - [Workflows.add_branch()](#workflowsadd_branch)
162
+ - [Workflows.reroute_node()](#workflowsreroute_node)
154
163
  - [Workflows.delete_node_recursive()](#workflowsdelete_node_recursive)
155
164
  - [EventPatterns.list()](#eventpatternslist)
156
165
  - [EventPatterns.get()](#eventpatternsget)
@@ -158,6 +167,7 @@ You can use custom contact properties in API calls. Please make sure to [add cus
158
167
  - [EmailMessages.get()](#emailmessagesget)
159
168
  - [EmailMessages.update()](#emailmessagesupdate)
160
169
  - [EmailMessages.preview()](#emailmessagespreview)
170
+ - [EmailMessages.render()](#emailmessagesrender)
161
171
  - [EmailMessages.run_guardian()](#emailmessagesrun_guardian)
162
172
  - [TransactionalGroups.list()](#transactionalgroupslist)
163
173
  - [TransactionalGroups.create()](#transactionalgroupscreate)
@@ -771,10 +781,11 @@ List transactional emails, most recently created first.
771
781
 
772
782
  #### Parameters
773
783
 
774
- | Name | Type | Required | Notes |
775
- | --------- | ------- | -------- | ----------------------------------------------------------------------------------------------------------------------------- |
776
- | `perPage` | integer | No | How many results to return per page. Must be between 10 and 50. Defaults to 20 if omitted. |
777
- | `cursor` | string | No | A cursor, to return a specific page of results. Cursors can be found from the `pagination.nextCursor` value in each response. |
784
+ | Name | Type | Required | Notes |
785
+ | -------------------------- | ------- | -------- | ----------------------------------------------------------------------------------------------------------------------------- |
786
+ | `perPage` | integer | No | How many results to return per page. Must be between 10 and 50. Defaults to 20 if omitted. |
787
+ | `cursor` | string | No | A cursor, to return a specific page of results. Cursors can be found from the `pagination.nextCursor` value in each response. |
788
+ | `transactional_group_id` | string | No | Only return transactional emails in this transactional group. An ID that matches no group returns an empty list. |
778
789
 
779
790
  #### Example
780
791
 
@@ -782,6 +793,8 @@ List transactional emails, most recently created first.
782
793
  response = LoopsSdk::Transactional.list
783
794
 
784
795
  response = LoopsSdk::Transactional.list(perPage: 15, cursor: "cursor_value")
796
+
797
+ response = LoopsSdk::Transactional.list(transactional_group_id: "clg7n5p3q1r9s7t5u3v1w9y7")
785
798
  ```
786
799
 
787
800
  #### Response
@@ -998,6 +1011,38 @@ response = LoopsSdk::Transactional.publish(transactional_id: "clfq6dinn000yl70fg
998
1011
 
999
1012
  ---
1000
1013
 
1014
+ ### Transactional.metrics()
1015
+
1016
+ Get all-time delivery metrics for a transactional email.
1017
+
1018
+ [API Reference](https://loops.so/docs/api-reference/get-transactional-email-metrics)
1019
+
1020
+ #### Parameters
1021
+
1022
+ | Name | Type | Required | Notes |
1023
+ | ------------------ | ------ | -------- | ----- |
1024
+ | `transactional_id` | string | Yes | |
1025
+
1026
+ #### Example
1027
+
1028
+ ```ruby
1029
+ response = LoopsSdk::Transactional.metrics(transactional_id: "clfq6dinn000yl70fgwwyp82l")
1030
+ ```
1031
+
1032
+ #### Response
1033
+
1034
+ ```json
1035
+ {
1036
+ "sends": 4210,
1037
+ "deliveries": 4175,
1038
+ "spamReports": 1,
1039
+ "hardBounces": 9,
1040
+ "softBounces": 13
1041
+ }
1042
+ ```
1043
+
1044
+ ---
1045
+
1001
1046
  ### Transactional.send()
1002
1047
 
1003
1048
  Send a transactional email to a contact. [Learn about sending transactional email](https://loops.so/docs/transactional/guide)
@@ -1432,15 +1477,18 @@ List campaigns.
1432
1477
 
1433
1478
  #### Parameters
1434
1479
 
1435
- | Name | Type | Required | Notes |
1436
- | --------- | ------- | -------- | ----------------------------------------------------------------------------------------------------------------------------- |
1437
- | `perPage` | integer | No | How many results to return per page. Must be between 10 and 50. Defaults to 20 if omitted. |
1438
- | `cursor` | string | No | A cursor, to return a specific page of results. Cursors can be found from the `pagination.nextCursor` value in each response. |
1480
+ | Name | Type | Required | Notes |
1481
+ | -------------------- | ------- | -------- | ----------------------------------------------------------------------------------------------------------------------------- |
1482
+ | `perPage` | integer | No | How many results to return per page. Must be between 10 and 50. Defaults to 20 if omitted. |
1483
+ | `cursor` | string | No | A cursor, to return a specific page of results. Cursors can be found from the `pagination.nextCursor` value in each response. |
1484
+ | `campaign_group_id` | string | No | Only return campaigns in this campaign group. An ID that matches no group returns an empty list. |
1439
1485
 
1440
1486
  #### Example
1441
1487
 
1442
1488
  ```ruby
1443
1489
  response = LoopsSdk::Campaigns.list
1490
+
1491
+ response = LoopsSdk::Campaigns.list(campaign_group_id: "cln4o7p9q0110msw5ekjtmv78")
1444
1492
  ```
1445
1493
 
1446
1494
  #### Response
@@ -1612,6 +1660,40 @@ response = LoopsSdk::Campaigns.update(
1612
1660
 
1613
1661
  ---
1614
1662
 
1663
+ ### Campaigns.metrics()
1664
+
1665
+ Get all-time engagement metrics for a campaign.
1666
+
1667
+ [API Reference](https://loops.so/docs/api-reference/get-campaign-metrics)
1668
+
1669
+ #### Parameters
1670
+
1671
+ | Name | Type | Required | Notes |
1672
+ | ------------- | ------ | -------- | ----- |
1673
+ | `campaign_id` | string | Yes | |
1674
+
1675
+ #### Example
1676
+
1677
+ ```ruby
1678
+ response = LoopsSdk::Campaigns.metrics(campaign_id: "cln4o7p9q0110msw5ekjtmv78")
1679
+ ```
1680
+
1681
+ #### Response
1682
+
1683
+ ```json
1684
+ {
1685
+ "sends": 4210,
1686
+ "opens": 1922,
1687
+ "clicks": 301,
1688
+ "unsubscribes": 12,
1689
+ "spamReports": 1,
1690
+ "hardBounces": 9,
1691
+ "softBounces": 13
1692
+ }
1693
+ ```
1694
+
1695
+ ---
1696
+
1615
1697
  ### EmailMessages.get()
1616
1698
 
1617
1699
  Get an email message, including its LMX content.
@@ -1746,6 +1828,40 @@ response = LoopsSdk::EmailMessages.preview(
1746
1828
 
1747
1829
  ---
1748
1830
 
1831
+ ### EmailMessages.render()
1832
+
1833
+ Render an email message as HTML without sending it. The HTML matches a preview email body. Accepted variable fields depend on the parent type.
1834
+
1835
+ [API Reference](https://loops.so/docs/api-reference/render-email-message)
1836
+
1837
+ #### Parameters
1838
+
1839
+ | Name | Type | Required | Notes |
1840
+ | -------------------- | ------ | -------- | ------------------------------------------------------------------------------- |
1841
+ | `email_message_id` | string | Yes | The ID of the email message. |
1842
+ | `contact_properties` | object | No | Contact property values to render. Accepted for campaign and workflow emails. |
1843
+ | `event_properties` | object | No | Event property values to render. Accepted for workflow emails only. |
1844
+ | `data_variables` | object | No | Transactional data variables to render. Accepted for transactional emails only. |
1845
+
1846
+ #### Example
1847
+
1848
+ ```ruby
1849
+ response = LoopsSdk::EmailMessages.render(
1850
+ email_message_id: "cly8k3m0n0044jpx2bghepq45",
1851
+ contact_properties: { firstName: "Alex" }
1852
+ )
1853
+ ```
1854
+
1855
+ #### Response
1856
+
1857
+ ```json
1858
+ {
1859
+ "html": "<html><body>Hello, Alex!</body></html>"
1860
+ }
1861
+ ```
1862
+
1863
+ ---
1864
+
1749
1865
  ### EmailMessages.run_guardian()
1750
1866
 
1751
1867
  Run Guardian content validation on an email message and return errors and warnings.
@@ -1931,6 +2047,155 @@ response = LoopsSdk::CampaignGroups.update(
1931
2047
 
1932
2048
  ---
1933
2049
 
2050
+ ### WorkflowGroups.list()
2051
+
2052
+ List workflow groups.
2053
+
2054
+ [API Reference](https://loops.so/docs/api-reference/list-workflow-groups)
2055
+
2056
+ #### Parameters
2057
+
2058
+ | Name | Type | Required | Notes |
2059
+ | --------- | ------- | -------- | ----------------------------------------------------------------------------------------------------------------------------- |
2060
+ | `perPage` | integer | No | How many results to return per page. Must be between 10 and 50. Defaults to 20 if omitted. |
2061
+ | `cursor` | string | No | A cursor, to return a specific page of results. Cursors can be found from the `pagination.nextCursor` value in each response. |
2062
+
2063
+ #### Example
2064
+
2065
+ ```ruby
2066
+ response = LoopsSdk::WorkflowGroups.list
2067
+ ```
2068
+
2069
+ #### Response
2070
+
2071
+ ```json
2072
+ {
2073
+ "pagination": {
2074
+ "totalResults": 1,
2075
+ "returnedResults": 1,
2076
+ "perPage": 20,
2077
+ "totalPages": 1,
2078
+ "nextCursor": null,
2079
+ "nextPage": null
2080
+ },
2081
+ "data": [
2082
+ {
2083
+ "id": "clg7n5p3q1r9s7t5u3v1w9y7",
2084
+ "name": "Onboarding",
2085
+ "description": "Signup and activation flows",
2086
+ "createdAt": "2025-06-29T07:47:39.370Z",
2087
+ "updatedAt": "2025-06-29T07:47:39.370Z"
2088
+ }
2089
+ ]
2090
+ }
2091
+ ```
2092
+
2093
+ ---
2094
+
2095
+ ### WorkflowGroups.create()
2096
+
2097
+ Create a workflow group.
2098
+
2099
+ [API Reference](https://loops.so/docs/api-reference/create-workflow-group)
2100
+
2101
+ #### Parameters
2102
+
2103
+ | Name | Type | Required | Notes |
2104
+ | ------------- | ------ | -------- | --------------------------------------- |
2105
+ | `name` | string | Yes | Cannot be the reserved name "Unsorted". |
2106
+ | `description` | string | No | An optional description for the group. |
2107
+
2108
+ #### Example
2109
+
2110
+ ```ruby
2111
+ response = LoopsSdk::WorkflowGroups.create(name: "Onboarding", description: "Signup flows")
2112
+ ```
2113
+
2114
+ #### Response
2115
+
2116
+ ```json
2117
+ {
2118
+ "id": "clg7n5p3q1r9s7t5u3v1w9y7",
2119
+ "name": "Onboarding",
2120
+ "description": "Signup flows",
2121
+ "createdAt": "2025-06-29T07:47:39.370Z",
2122
+ "updatedAt": "2025-06-29T07:47:39.370Z"
2123
+ }
2124
+ ```
2125
+
2126
+ ---
2127
+
2128
+ ### WorkflowGroups.get()
2129
+
2130
+ Get a workflow group by ID.
2131
+
2132
+ [API Reference](https://loops.so/docs/api-reference/get-workflow-group)
2133
+
2134
+ #### Parameters
2135
+
2136
+ | Name | Type | Required | Notes |
2137
+ | ------------------- | ------ | -------- | ----- |
2138
+ | `workflow_group_id` | string | Yes | |
2139
+
2140
+ #### Example
2141
+
2142
+ ```ruby
2143
+ response = LoopsSdk::WorkflowGroups.get(workflow_group_id: "clw8x0y2z0300ycc1lrstvw78")
2144
+ ```
2145
+
2146
+ #### Response
2147
+
2148
+ ```json
2149
+ {
2150
+ "id": "clg7n5p3q1r9s7t5u3v1w9y7",
2151
+ "name": "Onboarding",
2152
+ "description": "Signup and activation flows",
2153
+ "createdAt": "2025-06-29T07:47:39.370Z",
2154
+ "updatedAt": "2025-06-29T07:47:39.370Z"
2155
+ }
2156
+ ```
2157
+
2158
+ ---
2159
+
2160
+ ### WorkflowGroups.update()
2161
+
2162
+ Update a workflow group's name or description.
2163
+
2164
+ [API Reference](https://loops.so/docs/api-reference/update-workflow-group)
2165
+
2166
+ #### Parameters
2167
+
2168
+ | Name | Type | Required | Notes |
2169
+ | ------------------- | ------ | -------- | --------------------------------------- |
2170
+ | `workflow_group_id` | string | Yes | |
2171
+ | `name` | string | No | Cannot be the reserved name "Unsorted". |
2172
+ | `description` | string | No | |
2173
+
2174
+ At least one field must be provided.
2175
+
2176
+ #### Example
2177
+
2178
+ ```ruby
2179
+ response = LoopsSdk::WorkflowGroups.update(
2180
+ workflow_group_id: "clw8x0y2z0300ycc1lrstvw78",
2181
+ name: "Updated name"
2182
+ )
2183
+ ```
2184
+
2185
+ #### Response
2186
+
2187
+ ```json
2188
+ {
2189
+ "id": "clg7n5p3q1r9s7t5u3v1w9y7",
2190
+ "name": "Updated name",
2191
+ "description": "Signup and activation flows",
2192
+ "createdAt": "2025-06-29T07:47:39.370Z",
2193
+ "updatedAt": "2025-06-29T07:47:39.370Z"
2194
+ }
2195
+ ```
2196
+
2197
+ ---
2198
+
1934
2199
  ### AudienceSegments.list()
1935
2200
 
1936
2201
  List audience segments.
@@ -2076,15 +2341,18 @@ List workflows.
2076
2341
 
2077
2342
  #### Parameters
2078
2343
 
2079
- | Name | Type | Required | Notes |
2080
- | --------- | ------- | -------- | ----------------------------------------------------------------------------------------------------------------------------- |
2081
- | `perPage` | integer | No | How many results to return per page. Must be between 10 and 50. Defaults to 20 if omitted. |
2082
- | `cursor` | string | No | A cursor, to return a specific page of results. Cursors can be found from the `pagination.nextCursor` value in each response. |
2344
+ | Name | Type | Required | Notes |
2345
+ | -------------------- | ------- | -------- | ----------------------------------------------------------------------------------------------------------------------------- |
2346
+ | `perPage` | integer | No | How many results to return per page. Must be between 10 and 50. Defaults to 20 if omitted. |
2347
+ | `cursor` | string | No | A cursor, to return a specific page of results. Cursors can be found from the `pagination.nextCursor` value in each response. |
2348
+ | `workflow_group_id` | string | No | Only return workflows in this workflow group. An ID that matches no group returns an empty list. |
2083
2349
 
2084
2350
  #### Example
2085
2351
 
2086
2352
  ```ruby
2087
2353
  response = LoopsSdk::Workflows.list
2354
+
2355
+ response = LoopsSdk::Workflows.list(workflow_group_id: "clw8x0y2z0300ycc1lrstvw78")
2088
2356
  ```
2089
2357
 
2090
2358
  #### Response
@@ -2102,7 +2370,9 @@ response = LoopsSdk::Workflows.list
2102
2370
  "data": [
2103
2371
  {
2104
2372
  "id": "clw1a3b5c7d9e1f3g5h7i9j1",
2373
+ "url": "https://app.loops.so/workflows/clw1a3b5c7d9e1f3g5h7i9j1",
2105
2374
  "name": "Onboarding",
2375
+ "workflowGroupId": "clg7n5p3q1r9s7t5u3v1w9y7",
2106
2376
  "createdAt": "2025-06-29T07:47:39.370Z",
2107
2377
  "updatedAt": "2025-06-29T07:47:39.370Z"
2108
2378
  }
@@ -2120,11 +2390,12 @@ Create a draft workflow with a blank trigger and exit node.
2120
2390
 
2121
2391
  #### Parameters
2122
2392
 
2123
- | Name | Type | Required | Notes |
2124
- | ----------------- | ------ | -------- | ---------------------------------------------- |
2125
- | `name` | string | Yes | |
2126
- | `description` | string | No | |
2127
- | `mailing_list_id` | string | No | The mailing list the workflow sends to. |
2393
+ | Name | Type | Required | Notes |
2394
+ | -------------------- | ------ | -------- | ---------------------------------------------------------------------------------------------- |
2395
+ | `name` | string | Yes | |
2396
+ | `description` | string | No | |
2397
+ | `mailing_list_id` | string | No | The mailing list the workflow sends to. |
2398
+ | `workflow_group_id` | string | No | The workflow group to create this workflow in. Defaults to the team's Unsorted group when omitted. |
2128
2399
 
2129
2400
  #### Example
2130
2401
 
@@ -2139,6 +2410,7 @@ response = LoopsSdk::Workflows.create(name: "Welcome series")
2139
2410
  "id": "clw1a3b5c7d9e1f3g5h7i9j1",
2140
2411
  "status": "Draft",
2141
2412
  "name": "Welcome series",
2413
+ "workflowGroupId": "clg7n5p3q1r9s7t5u3v1w9y7",
2142
2414
  "mailingListId": null,
2143
2415
  "rootNodeId": "cf16k73gq014h3mmj5b6jdi9r",
2144
2416
  "workflowRevisionId": "clrev0w0r1k2f3l4o5w6",
@@ -2182,6 +2454,7 @@ response = LoopsSdk::Workflows.get(workflow_id: "cls9t2u4v0210rx20jpuary23")
2182
2454
  "id": "clw1a3b5c7d9e1f3g5h7i9j1",
2183
2455
  "status": "Draft",
2184
2456
  "name": "Onboarding",
2457
+ "workflowGroupId": "clg7n5p3q1r9s7t5u3v1w9y7",
2185
2458
  "mailingListId": null,
2186
2459
  "rootNodeId": "cf16k73gq014h3mmj5b6jdi9r",
2187
2460
  "workflowRevisionId": "clrev0w0r1k2f3l4o5w6",
@@ -2214,8 +2487,9 @@ Update a workflow's display properties. To change the mailing list, use `Workflo
2214
2487
  | `expected_revision_id` | string | Yes | The `workflowRevisionId` from the latest read or mutation. Pass `nil` for older workflows. |
2215
2488
  | `name` | string | No | |
2216
2489
  | `description` | string | No | |
2490
+ | `workflow_group_id` | string | No | The workflow group to move this workflow into. |
2217
2491
 
2218
- At least one of `name` or `description` must be provided.
2492
+ At least one of `name`, `description`, or `workflow_group_id` must be provided.
2219
2493
 
2220
2494
  #### Example
2221
2495
 
@@ -2234,6 +2508,7 @@ response = LoopsSdk::Workflows.update(
2234
2508
  "id": "clw1a3b5c7d9e1f3g5h7i9j1",
2235
2509
  "status": "Draft",
2236
2510
  "name": "Updated name",
2511
+ "workflowGroupId": "clg7n5p3q1r9s7t5u3v1w9y7",
2237
2512
  "mailingListId": null,
2238
2513
  "rootNodeId": "cf16k73gq014h3mmj5b6jdi9r",
2239
2514
  "workflowRevisionId": "clrev0w0r1k2f3l4o5w6",
@@ -2252,6 +2527,42 @@ response = LoopsSdk::Workflows.update(
2252
2527
 
2253
2528
  ---
2254
2529
 
2530
+ ### Workflows.delete()
2531
+
2532
+ Delete a workflow. Successful deletion returns no content (`nil`). If the workflow is currently sending or has queued contacts, the API returns `409 Conflict` — retry with `confirm_delete: true` to delete the workflow, stop sending, and cancel queued contacts.
2533
+
2534
+ [API Reference](https://loops.so/docs/api-reference/delete-workflow)
2535
+
2536
+ #### Parameters
2537
+
2538
+ | Name | Type | Required | Notes |
2539
+ | ---------------------- | ------- | -------- | ---------------------------------------------------------------------------------------------- |
2540
+ | `workflow_id` | string | Yes | |
2541
+ | `expected_revision_id` | string | Yes | The `workflowRevisionId` from the latest read or mutation. Pass `nil` for older workflows. |
2542
+ | `confirm_delete` | boolean | No | Set to `true` after a confirmation-required `409` to confirm deleting a sending workflow or a workflow with queued contacts. |
2543
+
2544
+ #### Example
2545
+
2546
+ ```ruby
2547
+ LoopsSdk::Workflows.delete(
2548
+ workflow_id: "cls9t2u4v0210rx20jpuary23",
2549
+ expected_revision_id: "rev_123"
2550
+ )
2551
+
2552
+ # After a 409 confirming a sending or queued workflow:
2553
+ LoopsSdk::Workflows.delete(
2554
+ workflow_id: "cls9t2u4v0210rx20jpuary23",
2555
+ expected_revision_id: "rev_123",
2556
+ confirm_delete: true
2557
+ )
2558
+ ```
2559
+
2560
+ #### Response
2561
+
2562
+ `nil` (HTTP `204 No Content`)
2563
+
2564
+ ---
2565
+
2255
2566
  ### Workflows.change_mailing_list()
2256
2567
 
2257
2568
  Dry run or apply a workflow mailing list change. If queued contacts would be removed, the API returns `"status": "queuedContactsFound"` — retry with `queued_contact_policy: "discard"` to apply.
@@ -2287,7 +2598,25 @@ response = LoopsSdk::Workflows.change_mailing_list(
2287
2598
  "mailingListId": "cm06f5v0e45nf0ml5754o9cix",
2288
2599
  "workflowRevisionId": "clrev0w0r1k2f3l4o5w6",
2289
2600
  "queuedContactCount": 0,
2290
- "queuedContactLimitReached": false
2601
+ "workflow": {
2602
+ "id": "clw1a3b5c7d9e1f3g5h7i9j1",
2603
+ "status": "Draft",
2604
+ "name": "Welcome series",
2605
+ "workflowGroupId": "clg7n5p3q1r9s7t5u3v1w9y7",
2606
+ "mailingListId": "cm06f5v0e45nf0ml5754o9cix",
2607
+ "rootNodeId": "cln8p0q2r4s6t8u0v2w4x6z8",
2608
+ "workflowRevisionId": "clrev0w0r1k2f3l4o5w6",
2609
+ "nodes": {
2610
+ "cln8p0q2r4s6t8u0v2w4x6z8": {
2611
+ "typeName": "BlankTrigger",
2612
+ "nextNodeIds": ["cln1a3b5c7d9e1f3g5h7i9j1"]
2613
+ },
2614
+ "cln1a3b5c7d9e1f3g5h7i9j1": {
2615
+ "typeName": "ExitAction",
2616
+ "nextNodeIds": []
2617
+ }
2618
+ }
2619
+ }
2291
2620
  }
2292
2621
  ```
2293
2622
 
@@ -2328,9 +2657,52 @@ response = LoopsSdk::Workflows.get_node(workflow_id: "cls9t2u4v0210rx20jpuary23"
2328
2657
 
2329
2658
  ---
2330
2659
 
2660
+ ### Workflows.get_node_metrics()
2661
+
2662
+ Get all-time engagement metrics for a workflow email node.
2663
+
2664
+ [API Reference](https://loops.so/docs/api-reference/get-workflow-node-metrics)
2665
+
2666
+ #### Parameters
2667
+
2668
+ | Name | Type | Required | Notes |
2669
+ | ------------- | ------ | -------- | ----- |
2670
+ | `workflow_id` | string | Yes | |
2671
+ | `node_id` | string | Yes | |
2672
+
2673
+ #### Example
2674
+
2675
+ ```ruby
2676
+ response = LoopsSdk::Workflows.get_node_metrics(
2677
+ workflow_id: "cls9t2u4v0210rx20jpuary23",
2678
+ node_id: "clt0u3v5w0232sy31kqvbzs34"
2679
+ )
2680
+ ```
2681
+
2682
+ #### Response
2683
+
2684
+ ```json
2685
+ {
2686
+ "sends": 4210,
2687
+ "opens": 1922,
2688
+ "clicks": 301,
2689
+ "unsubscribes": 12,
2690
+ "spamReports": 1,
2691
+ "hardBounces": 9,
2692
+ "softBounces": 13
2693
+ }
2694
+ ```
2695
+
2696
+ ---
2697
+
2331
2698
  ### Workflows.create_node()
2332
2699
 
2333
- Create a new default workflow node. Use `insert_mode: "between"` with `from_node_id`/`to_node_id`, or `insert_mode: "before"` with `before_node_id`.
2700
+ Create a new default workflow node.
2701
+
2702
+ Use `insert_mode` to choose placement:
2703
+ - `between` — insert between `from_node_id` and `to_node_id`
2704
+ - `before` — insert before `to_node_id`
2705
+ - `after` — insert after `from_node_id` (source must have exactly one outgoing connection)
2334
2706
 
2335
2707
  [API Reference](https://loops.so/docs/api-reference/create-workflow-node)
2336
2708
 
@@ -2340,11 +2712,11 @@ Create a new default workflow node. Use `insert_mode: "between"` with `from_node
2340
2712
  | ---------------------- | ------ | -------- | ---------------------------------------------------------------------------------------------- |
2341
2713
  | `workflow_id` | string | Yes | |
2342
2714
  | `expected_revision_id` | string | Yes | Pass `nil` for older workflows. |
2343
- | `insert_mode` | string | Yes | `between` or `before`. |
2715
+ | `insert_mode` | string | Yes | `between`, `before`, or `after`. |
2344
2716
  | `node_type_name` | string | Yes | One of `AudienceFilter`, `BranchNode`, `ExperimentBranchNode`, `TimerAction`, `SendEmailAction`, `VariantNode`. |
2345
- | `from_node_id` | string | No | Required when `insert_mode` is `between`. |
2346
- | `to_node_id` | string | No | Required when `insert_mode` is `between`. |
2347
- | `before_node_id` | string | No | Required when `insert_mode` is `before`. |
2717
+ | `from_node_id` | string | Cond. | Required for `between` and `after`. Not permitted for `before`. |
2718
+ | `to_node_id` | string | Cond. | Required for `between`. For `before`, provide this or `before_node_id` (not both). Not permitted for `after`. |
2719
+ | `before_node_id` | string | Cond. | Deprecated. For `before`, provide this or `to_node_id` (not both). |
2348
2720
 
2349
2721
  #### Example
2350
2722
 
@@ -2357,6 +2729,22 @@ response = LoopsSdk::Workflows.create_node(
2357
2729
  from_node_id: "node_a",
2358
2730
  to_node_id: "node_b"
2359
2731
  )
2732
+
2733
+ response = LoopsSdk::Workflows.create_node(
2734
+ workflow_id: "cls9t2u4v0210rx20jpuary23",
2735
+ expected_revision_id: "rev_123",
2736
+ insert_mode: "after",
2737
+ node_type_name: "TimerAction",
2738
+ from_node_id: "node_a"
2739
+ )
2740
+
2741
+ response = LoopsSdk::Workflows.create_node(
2742
+ workflow_id: "cls9t2u4v0210rx20jpuary23",
2743
+ expected_revision_id: "rev_123",
2744
+ insert_mode: "before",
2745
+ node_type_name: "TimerAction",
2746
+ to_node_id: "node_b"
2747
+ )
2360
2748
  ```
2361
2749
 
2362
2750
  #### Response
@@ -2375,6 +2763,7 @@ response = LoopsSdk::Workflows.create_node(
2375
2763
  "id": "clw1a3b5c7d9e1f3g5h7i9j1",
2376
2764
  "status": "Draft",
2377
2765
  "name": "Welcome series",
2766
+ "workflowGroupId": "clg7n5p3q1r9s7t5u3v1w9y7",
2378
2767
  "mailingListId": null,
2379
2768
  "rootNodeId": "node_a",
2380
2769
  "workflowRevisionId": "clrev0w0r1k2f3l4o5w6",
@@ -2436,7 +2825,28 @@ response = LoopsSdk::Workflows.update_node(
2436
2825
  "nextNodeIds": ["cf16k73gq014h3mmj5b4jdifg"],
2437
2826
  "amount": 2,
2438
2827
  "unit": "d",
2439
- "workflowRevisionId": "clrev0w0r1k2f3l4o5w6"
2828
+ "workflowRevisionId": "clrev0w0r1k2f3l4o5w6",
2829
+ "workflow": {
2830
+ "id": "clw1a3b5c7d9e1f3g5h7i9j1",
2831
+ "status": "Draft",
2832
+ "name": "Welcome series",
2833
+ "workflowGroupId": "clg7n5p3q1r9s7t5u3v1w9y7",
2834
+ "mailingListId": null,
2835
+ "rootNodeId": "cln8p0q2r4s6t8u0v2w4x6z8",
2836
+ "workflowRevisionId": "clrev0w0r1k2f3l4o5w6",
2837
+ "nodes": {
2838
+ "cln8p0q2r4s6t8u0v2w4x6z8": {
2839
+ "typeName": "TimerAction",
2840
+ "nextNodeIds": ["cf16k73gq014h3mmj5b4jdifg"],
2841
+ "amount": 2,
2842
+ "unit": "d"
2843
+ },
2844
+ "cf16k73gq014h3mmj5b4jdifg": {
2845
+ "typeName": "ExitAction",
2846
+ "nextNodeIds": []
2847
+ }
2848
+ }
2849
+ }
2440
2850
  }
2441
2851
  ```
2442
2852
 
@@ -2477,7 +2887,25 @@ response = LoopsSdk::Workflows.delete_node(
2477
2887
  "nodeIds": ["clt0u3v5w0232sy31kqvbzs34"],
2478
2888
  "workflowRevisionId": "clrev0w0r1k2f3l4o5w6",
2479
2889
  "queuedContactCount": 0,
2480
- "queuedContactLimitReached": false
2890
+ "workflow": {
2891
+ "id": "clw1a3b5c7d9e1f3g5h7i9j1",
2892
+ "status": "Draft",
2893
+ "name": "Welcome series",
2894
+ "workflowGroupId": "clg7n5p3q1r9s7t5u3v1w9y7",
2895
+ "mailingListId": null,
2896
+ "rootNodeId": "cln8p0q2r4s6t8u0v2w4x6z8",
2897
+ "workflowRevisionId": "clrev0w0r1k2f3l4o5w6",
2898
+ "nodes": {
2899
+ "cln8p0q2r4s6t8u0v2w4x6z8": {
2900
+ "typeName": "BlankTrigger",
2901
+ "nextNodeIds": ["cln1a3b5c7d9e1f3g5h7i9j1"]
2902
+ },
2903
+ "cln1a3b5c7d9e1f3g5h7i9j1": {
2904
+ "typeName": "ExitAction",
2905
+ "nextNodeIds": []
2906
+ }
2907
+ }
2908
+ }
2481
2909
  }
2482
2910
  ```
2483
2911
 
@@ -2522,6 +2950,7 @@ response = LoopsSdk::Workflows.add_branch(
2522
2950
  "id": "clw1a3b5c7d9e1f3g5h7i9j1",
2523
2951
  "status": "Draft",
2524
2952
  "name": "Welcome series",
2953
+ "workflowGroupId": "clg7n5p3q1r9s7t5u3v1w9y7",
2525
2954
  "mailingListId": null,
2526
2955
  "rootNodeId": "clt0u3v5w0232sy31kqvbzs34",
2527
2956
  "workflowRevisionId": "clrev0w0r1k2f3l4o5w6",
@@ -2541,6 +2970,66 @@ response = LoopsSdk::Workflows.add_branch(
2541
2970
 
2542
2971
  ---
2543
2972
 
2973
+ ### Workflows.reroute_node()
2974
+
2975
+ Reroute a source node's outgoing connection to another valid target node. The source node must have exactly one outgoing connection. Branch and experiment branch nodes cannot be rerouted with this endpoint.
2976
+
2977
+ [API Reference](https://loops.so/docs/api-reference/reroute-node-connection)
2978
+
2979
+ #### Parameters
2980
+
2981
+ | Name | Type | Required | Notes |
2982
+ | ---------------------- | ------ | -------- | ------------------------------------------ |
2983
+ | `workflow_id` | string | Yes | |
2984
+ | `node_id` | string | Yes | The source node whose connection to move. |
2985
+ | `expected_revision_id` | string | Yes | Pass `nil` for older workflows. |
2986
+ | `new_target_node_id` | string | Yes | The node that should receive the connection. |
2987
+
2988
+ #### Example
2989
+
2990
+ ```ruby
2991
+ response = LoopsSdk::Workflows.reroute_node(
2992
+ workflow_id: "cls9t2u4v0210rx20jpuary23",
2993
+ node_id: "clt0u3v5w0232sy31kqvbzs34",
2994
+ expected_revision_id: "rev_123",
2995
+ new_target_node_id: "cln3c5d7e9f1g3h5i7j9k1l3"
2996
+ )
2997
+ ```
2998
+
2999
+ #### Response
3000
+
3001
+ ```json
3002
+ {
3003
+ "id": "cln8p0q2r4s6t8u0v2w4x6z8",
3004
+ "typeName": "SignupTrigger",
3005
+ "nextNodeIds": ["cln3c5d7e9f1g3h5i7j9k1l3"],
3006
+ "workflowRevisionId": "clx7a3b5c7d9e1f3g5h7i9j2",
3007
+ "workflow": {
3008
+ "id": "clw1a3b5c7d9e1f3g5h7i9j1",
3009
+ "workflowRevisionId": "clx7a3b5c7d9e1f3g5h7i9j2",
3010
+ "status": "Draft",
3011
+ "name": "Welcome series",
3012
+ "workflowGroupId": "clg7n5p3q1r9s7t5u3v1w9y7",
3013
+ "mailingListId": "clm2k8j4h6g0f8d6s4a2b0z8",
3014
+ "rootNodeId": "cln8p0q2r4s6t8u0v2w4x6z8",
3015
+ "nodes": {
3016
+ "cln8p0q2r4s6t8u0v2w4x6z8": {
3017
+ "typeName": "SignupTrigger",
3018
+ "nextNodeIds": ["cln3c5d7e9f1g3h5i7j9k1l3"]
3019
+ },
3020
+ "cln3c5d7e9f1g3h5i7j9k1l3": {
3021
+ "typeName": "SendEmailAction",
3022
+ "nextNodeIds": [],
3023
+ "emailMessageId": "cle5f7g9h1i3j5k7l9m1n3p5",
3024
+ "subject": "Welcome to Acme!"
3025
+ }
3026
+ }
3027
+ }
3028
+ }
3029
+ ```
3030
+
3031
+ ---
3032
+
2544
3033
  ### Workflows.delete_node_recursive()
2545
3034
 
2546
3035
  Delete a node and its downstream subtree.
@@ -2579,7 +3068,25 @@ response = LoopsSdk::Workflows.delete_node_recursive(
2579
3068
  ],
2580
3069
  "workflowRevisionId": "clrev0w0r1k2f3l4o5w6",
2581
3070
  "queuedContactCount": 0,
2582
- "queuedContactLimitReached": false
3071
+ "workflow": {
3072
+ "id": "clw1a3b5c7d9e1f3g5h7i9j1",
3073
+ "status": "Draft",
3074
+ "name": "Welcome series",
3075
+ "workflowGroupId": "clg7n5p3q1r9s7t5u3v1w9y7",
3076
+ "mailingListId": null,
3077
+ "rootNodeId": "cln8p0q2r4s6t8u0v2w4x6z8",
3078
+ "workflowRevisionId": "clrev0w0r1k2f3l4o5w6",
3079
+ "nodes": {
3080
+ "cln8p0q2r4s6t8u0v2w4x6z8": {
3081
+ "typeName": "BlankTrigger",
3082
+ "nextNodeIds": ["cln1a3b5c7d9e1f3g5h7i9j1"]
3083
+ },
3084
+ "cln1a3b5c7d9e1f3g5h7i9j1": {
3085
+ "typeName": "ExitAction",
3086
+ "nextNodeIds": []
3087
+ }
3088
+ }
3089
+ }
2583
3090
  }
2584
3091
  ```
2585
3092
 
@@ -9,6 +9,8 @@ module LoopsSdk
9
9
  case response.status
10
10
  when 200, 201
11
11
  JSON.parse(response.body)
12
+ when 204
13
+ nil
12
14
  when 429
13
15
  limit = response.headers["x-ratelimit-limit"]
14
16
  remaining = response.headers["x-ratelimit-remaining"]
@@ -3,8 +3,10 @@
3
3
  module LoopsSdk
4
4
  class Campaigns < Base
5
5
  class << self
6
- def list(perPage: 20, cursor: nil)
7
- make_request(method: :get, path: "v1/campaigns", params: { perPage: perPage, cursor: cursor })
6
+ def list(perPage: 20, cursor: nil, campaign_group_id: nil)
7
+ params = { perPage: perPage, cursor: cursor }
8
+ params[:campaignGroupId] = campaign_group_id if campaign_group_id
9
+ make_request(method: :get, path: "v1/campaigns", params: params)
8
10
  end
9
11
 
10
12
  def create(name:, campaign_group_id: nil, mailing_list_id: nil, audience_segment_id: nil, audience_filter: nil, scheduling: nil)
@@ -34,6 +36,10 @@ module LoopsSdk
34
36
  }.compact
35
37
  make_request(method: :post, path: "v1/campaigns/#{campaign_id}", body: body)
36
38
  end
39
+
40
+ def metrics(campaign_id:)
41
+ make_request(method: :get, path: "v1/campaigns/#{campaign_id}/metrics")
42
+ end
37
43
  end
38
44
  end
39
45
  end
@@ -53,6 +53,15 @@ module LoopsSdk
53
53
  make_request(method: :post, path: "v1/email-messages/#{email_message_id}/preview", body: body)
54
54
  end
55
55
 
56
+ def render(email_message_id:, contact_properties: nil, event_properties: nil, data_variables: nil)
57
+ body = {
58
+ contactProperties: contact_properties,
59
+ eventProperties: event_properties,
60
+ dataVariables: data_variables
61
+ }.compact
62
+ make_request(method: :post, path: "v1/email-messages/#{email_message_id}/render", body: body)
63
+ end
64
+
56
65
  def run_guardian(email_message_id:)
57
66
  make_request(method: :get, path: "v1/email-messages/#{email_message_id}/guardian")
58
67
  end
@@ -3,8 +3,10 @@
3
3
  module LoopsSdk
4
4
  class Transactional < Base
5
5
  class << self
6
- def list(perPage: 20, cursor: nil)
7
- make_request(method: :get, path: "v1/transactional-emails", params: { perPage: perPage, cursor: cursor })
6
+ def list(perPage: 20, cursor: nil, transactional_group_id: nil)
7
+ params = { perPage: perPage, cursor: cursor }
8
+ params[:transactionalGroupId] = transactional_group_id if transactional_group_id
9
+ make_request(method: :get, path: "v1/transactional-emails", params: params)
8
10
  end
9
11
 
10
12
  def create(name:, transactional_group_id: nil)
@@ -29,6 +31,10 @@ module LoopsSdk
29
31
  make_request(method: :post, path: "v1/transactional-emails/#{transactional_id}/publish")
30
32
  end
31
33
 
34
+ def metrics(transactional_id:)
35
+ make_request(method: :get, path: "v1/transactional-emails/#{transactional_id}/metrics")
36
+ end
37
+
32
38
  def send(transactional_id:, email:, add_to_audience: false, data_variables: {}, attachments: [], headers: {})
33
39
  attachments = attachments.map do |attachment|
34
40
  attachment.transform_keys { |key| key == :content_type ? :contentType : key }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LoopsSdk
4
- VERSION = "2.4.0"
4
+ VERSION = "2.7.0"
5
5
  end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LoopsSdk
4
+ class WorkflowGroups < Base
5
+ class << self
6
+ def list(perPage: 20, cursor: nil)
7
+ make_request(method: :get, path: "v1/workflow-groups", params: { perPage: perPage, cursor: cursor })
8
+ end
9
+
10
+ def create(name:, description: nil)
11
+ body = { name: name, description: description }.compact
12
+ make_request(method: :post, path: "v1/workflow-groups", body: body)
13
+ end
14
+
15
+ def get(workflow_group_id:)
16
+ make_request(method: :get, path: "v1/workflow-groups/#{workflow_group_id}")
17
+ end
18
+
19
+ def update(workflow_group_id:, name: nil, description: nil)
20
+ body = { name: name, description: description }.compact
21
+ make_request(method: :post, path: "v1/workflow-groups/#{workflow_group_id}", body: body)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -3,15 +3,18 @@
3
3
  module LoopsSdk
4
4
  class Workflows < Base
5
5
  class << self
6
- def list(perPage: 20, cursor: nil)
7
- make_request(method: :get, path: "v1/workflows", params: { perPage: perPage, cursor: cursor })
6
+ def list(perPage: 20, cursor: nil, workflow_group_id: nil)
7
+ params = { perPage: perPage, cursor: cursor }
8
+ params[:workflowGroupId] = workflow_group_id if workflow_group_id
9
+ make_request(method: :get, path: "v1/workflows", params: params)
8
10
  end
9
11
 
10
- def create(name:, description: nil, mailing_list_id: nil)
12
+ def create(name:, description: nil, mailing_list_id: nil, workflow_group_id: nil)
11
13
  body = {
12
14
  name: name,
13
15
  description: description,
14
- mailingListId: mailing_list_id
16
+ mailingListId: mailing_list_id,
17
+ workflowGroupId: workflow_group_id
15
18
  }.compact
16
19
  make_request(method: :post, path: "v1/workflows", body: body)
17
20
  end
@@ -20,17 +23,28 @@ module LoopsSdk
20
23
  make_request(method: :get, path: "v1/workflows/#{workflow_id}")
21
24
  end
22
25
 
23
- def update(workflow_id:, expected_revision_id:, name: nil, description: nil)
26
+ def update(workflow_id:, expected_revision_id:, name: nil, description: nil, workflow_group_id: nil)
24
27
  body = {
25
28
  expectedRevisionId: expected_revision_id,
26
29
  name: name,
27
- description: description
30
+ description: description,
31
+ workflowGroupId: workflow_group_id
28
32
  }.compact
29
33
  # expectedRevisionId may be null for older workflows; always include it
30
34
  body[:expectedRevisionId] = expected_revision_id
31
35
  make_request(method: :post, path: "v1/workflows/#{workflow_id}", body: body)
32
36
  end
33
37
 
38
+ def delete(workflow_id:, expected_revision_id:, confirm_delete: nil)
39
+ body = {
40
+ expectedRevisionId: expected_revision_id,
41
+ confirmDelete: confirm_delete
42
+ }.compact
43
+ # expectedRevisionId may be null for older workflows; always include it
44
+ body[:expectedRevisionId] = expected_revision_id
45
+ make_request(method: :delete, path: "v1/workflows/#{workflow_id}", body: body)
46
+ end
47
+
34
48
  def change_mailing_list(workflow_id:, expected_revision_id:, mailing_list_id:, dry_run: nil, queued_contact_policy: nil)
35
49
  body = {
36
50
  expectedRevisionId: expected_revision_id,
@@ -48,6 +62,10 @@ module LoopsSdk
48
62
  make_request(method: :get, path: "v1/workflows/#{workflow_id}/nodes/#{node_id}")
49
63
  end
50
64
 
65
+ def get_node_metrics(workflow_id:, node_id:)
66
+ make_request(method: :get, path: "v1/workflows/#{workflow_id}/nodes/#{node_id}/metrics")
67
+ end
68
+
51
69
  def create_node(
52
70
  workflow_id:,
53
71
  expected_revision_id:,
@@ -60,12 +78,36 @@ module LoopsSdk
60
78
  body = {
61
79
  expectedRevisionId: expected_revision_id,
62
80
  insertMode: insert_mode,
63
- nodeTypeName: node_type_name,
64
- fromNodeId: from_node_id,
65
- toNodeId: to_node_id,
66
- beforeNodeId: before_node_id
67
- }.compact
68
- body[:expectedRevisionId] = expected_revision_id
81
+ nodeTypeName: node_type_name
82
+ }
83
+
84
+ case insert_mode
85
+ when "between"
86
+ raise ArgumentError, "from_node_id and to_node_id are required when insert_mode is \"between\"." if from_node_id.nil? || to_node_id.nil?
87
+ raise ArgumentError, "before_node_id is not permitted when insert_mode is \"between\"." unless before_node_id.nil?
88
+
89
+ body[:fromNodeId] = from_node_id
90
+ body[:toNodeId] = to_node_id
91
+ when "before"
92
+ raise ArgumentError, "from_node_id is not permitted when insert_mode is \"before\"." unless from_node_id.nil?
93
+ raise ArgumentError, "Provide either to_node_id or before_node_id when insert_mode is \"before\", not both." if !to_node_id.nil? && !before_node_id.nil?
94
+ raise ArgumentError, "to_node_id or before_node_id is required when insert_mode is \"before\"." if to_node_id.nil? && before_node_id.nil?
95
+
96
+ if !to_node_id.nil?
97
+ body[:toNodeId] = to_node_id
98
+ else
99
+ body[:beforeNodeId] = before_node_id
100
+ end
101
+ when "after"
102
+ raise ArgumentError, "from_node_id is required when insert_mode is \"after\"." if from_node_id.nil?
103
+ raise ArgumentError, "to_node_id is not permitted when insert_mode is \"after\"." unless to_node_id.nil?
104
+ raise ArgumentError, "before_node_id is not permitted when insert_mode is \"after\"." unless before_node_id.nil?
105
+
106
+ body[:fromNodeId] = from_node_id
107
+ else
108
+ raise ArgumentError, "insert_mode must be \"between\", \"before\", or \"after\"."
109
+ end
110
+
69
111
  make_request(method: :post, path: "v1/workflows/#{workflow_id}/nodes", body: body)
70
112
  end
71
113
 
@@ -92,6 +134,14 @@ module LoopsSdk
92
134
  make_request(method: :post, path: "v1/workflows/#{workflow_id}/nodes/#{node_id}/add-branch", body: body)
93
135
  end
94
136
 
137
+ def reroute_node(workflow_id:, node_id:, expected_revision_id:, new_target_node_id:)
138
+ body = {
139
+ expectedRevisionId: expected_revision_id,
140
+ newTargetNodeId: new_target_node_id
141
+ }
142
+ make_request(method: :post, path: "v1/workflows/#{workflow_id}/nodes/#{node_id}/reroute", body: body)
143
+ end
144
+
95
145
  def delete_node_recursive(workflow_id:, node_id:, expected_revision_id:, dry_run: nil, queued_contact_policy: nil)
96
146
  body = {
97
147
  expectedRevisionId: expected_revision_id,
data/lib/loops_sdk.rb CHANGED
@@ -20,6 +20,7 @@ require_relative "loops_sdk/email_messages"
20
20
  require_relative "loops_sdk/uploads"
21
21
  require_relative "loops_sdk/audience_segments"
22
22
  require_relative "loops_sdk/workflows"
23
+ require_relative "loops_sdk/workflow_groups"
23
24
  require_relative "loops_sdk/event_patterns"
24
25
  require_relative "loops_sdk/transactional_groups"
25
26
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: loops_sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Rowden
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-08-04 00:00:00.000000000 Z
11
+ date: 2026-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -53,6 +53,7 @@ files:
53
53
  - lib/loops_sdk/transactional_groups.rb
54
54
  - lib/loops_sdk/uploads.rb
55
55
  - lib/loops_sdk/version.rb
56
+ - lib/loops_sdk/workflow_groups.rb
56
57
  - lib/loops_sdk/workflows.rb
57
58
  homepage: https://loops.so/docs/api-reference
58
59
  licenses: