You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: api-reference/auto-monitor-setups/bulk-upsert-auto-monitor-setups.mdx
+42-41Lines changed: 42 additions & 41 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,11 +13,11 @@ Each item is upserted independently using the same semantics as [Update by Exter
13
13
See [Authentication](/api-reference/introduction) for details.
14
14
</Note>
15
15
16
-
## Partial Success Semantics
16
+
## Atomic Semantics
17
17
18
-
The endpoint returns **`207 Multi-Status`**when the batch is accepted, even if some items inside fail. Each item carries its own `status` (`ok` or `error`) — you must iterate the response array to check per-item results.
18
+
The batch is applied **atomically**— it either fully succeeds or nothing is written. If any item fails validation, or the database write fails, **no** setups are persisted. On success the endpoint returns **`200 OK`** with the full list of upserted setups.
19
19
20
-
Request-level errors (empty batch, more than 100 items, duplicate `external_id` within the batch, missing `external_id` on any item) reject the **entire** batch with `400 Bad Request`. No items are written.
20
+
Because the batch is all-or-nothing, there are no per-item status flags: every item in the response was written successfully. Failures are surfaced as a single request-level error (`400` or `500`) identifying the first offending item.
21
21
22
22
## Request Body
23
23
@@ -61,61 +61,60 @@ curl -X POST https://api.traceloop.com/v2/auto-monitor-setups/bulk \
61
61
62
62
## Response
63
63
64
-
### 207 Multi-Status
64
+
### 200 OK
65
65
66
-
Returned when the batch is accepted. The `setups` array contains one entry per input item, in the **same order** as the request.
67
-
68
-
Each entry has:
69
-
70
-
| Field | Type | Description |
71
-
|-------|------|-------------|
72
-
|`external_id`| string | The `external_id` of the input item. |
73
-
|`status`| string |`ok` if the item was upserted, `error` if it failed. |
74
-
|`result`| object | Present when `status` is `ok`. The full upserted setup, matching the [Create](/api-reference/auto-monitor-setups/create-an-auto-monitor-setup) response shape. |
75
-
|`error`| string | Present when `status` is `error`. Human-readable message prefixed with the item index, e.g. `setups[1]: unknown evaluator slug "..."`. Internal errors are reported as `setups[N]: internal error` — the underlying cause is logged server-side but not returned to the client. |
66
+
Returned when the entire batch is upserted successfully. The `setups` array contains one entry per input item, in the **same order** as the request. Each entry is a full setup object, matching the [Create](/api-reference/auto-monitor-setups/create-an-auto-monitor-setup) response shape.
Returned when the batch is rejected without writing any items. Causes:
111
+
Returned when the batch is rejected without writing any items. The `error` message identifies the first offending item by index. Causes:
114
112
115
-
- Empty `setups` array
116
-
- More than 100 items
117
-
- Any item missing `external_id`
118
-
- Two items in the batch share the same `external_id`
113
+
- Empty `setups` array — `setups must contain at least 1 item`
114
+
- More than 100 items — `setups exceeds max of 100`
115
+
- Any item missing `external_id` — `setups[N]: external_id is required`
116
+
- Two items in the batch share the same `external_id` — `setups[N]: duplicate external_id "..." (also at setups[M])`
117
+
- Any item fails validation — e.g. an unknown evaluator slug, an invalid selector, or an invalid evaluator config, prefixed with the item index: `setups[N]: evaluators[0]: unknown evaluator slug "..."`
119
118
120
119
```json
121
120
{
@@ -125,8 +124,10 @@ Returned when the batch is rejected without writing any items. Causes:
125
124
126
125
### 500 Internal Server Error
127
126
127
+
Returned when the database write fails. No items are persisted. The underlying cause is logged server-side and not returned to the client.
0 commit comments