monday_ruby 1.0.0 → 1.2.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 +4 -4
- data/.env +1 -1
- data/.rspec +0 -1
- data/.rubocop.yml +19 -0
- data/.simplecov +1 -0
- data/CHANGELOG.md +49 -0
- data/CONTRIBUTING.md +165 -0
- data/README.md +167 -88
- data/docs/.vitepress/config.mjs +255 -0
- data/docs/.vitepress/theme/index.js +4 -0
- data/docs/.vitepress/theme/style.css +43 -0
- data/docs/README.md +80 -0
- data/docs/explanation/architecture.md +507 -0
- data/docs/explanation/best-practices/errors.md +478 -0
- data/docs/explanation/best-practices/performance.md +1084 -0
- data/docs/explanation/best-practices/rate-limiting.md +630 -0
- data/docs/explanation/best-practices/testing.md +820 -0
- data/docs/explanation/column-values.md +857 -0
- data/docs/explanation/design.md +795 -0
- data/docs/explanation/graphql.md +356 -0
- data/docs/explanation/migration/v1.md +808 -0
- data/docs/explanation/pagination.md +447 -0
- data/docs/guides/advanced/batch.md +1274 -0
- data/docs/guides/advanced/complex-queries.md +1114 -0
- data/docs/guides/advanced/errors.md +818 -0
- data/docs/guides/advanced/pagination.md +934 -0
- data/docs/guides/advanced/rate-limiting.md +981 -0
- data/docs/guides/authentication.md +286 -0
- data/docs/guides/boards/create.md +386 -0
- data/docs/guides/boards/delete.md +405 -0
- data/docs/guides/boards/duplicate.md +511 -0
- data/docs/guides/boards/query.md +530 -0
- data/docs/guides/boards/update.md +453 -0
- data/docs/guides/columns/create.md +452 -0
- data/docs/guides/columns/metadata.md +492 -0
- data/docs/guides/columns/query.md +455 -0
- data/docs/guides/columns/update-multiple.md +459 -0
- data/docs/guides/columns/update-values.md +509 -0
- data/docs/guides/files/add-to-column.md +40 -0
- data/docs/guides/files/add-to-update.md +37 -0
- data/docs/guides/files/clear-column.md +33 -0
- data/docs/guides/first-request.md +285 -0
- data/docs/guides/folders/manage.md +750 -0
- data/docs/guides/groups/items.md +626 -0
- data/docs/guides/groups/manage.md +501 -0
- data/docs/guides/installation.md +169 -0
- data/docs/guides/items/create.md +493 -0
- data/docs/guides/items/delete.md +514 -0
- data/docs/guides/items/query.md +605 -0
- data/docs/guides/items/subitems.md +483 -0
- data/docs/guides/items/update.md +699 -0
- data/docs/guides/updates/manage.md +619 -0
- data/docs/guides/use-cases/dashboard.md +1421 -0
- data/docs/guides/use-cases/import.md +1962 -0
- data/docs/guides/use-cases/task-management.md +1381 -0
- data/docs/guides/workspaces/manage.md +502 -0
- data/docs/index.md +69 -0
- data/docs/package-lock.json +2468 -0
- data/docs/package.json +13 -0
- data/docs/reference/client.md +540 -0
- data/docs/reference/configuration.md +586 -0
- data/docs/reference/errors.md +693 -0
- data/docs/reference/resources/account.md +208 -0
- data/docs/reference/resources/activity-log.md +369 -0
- data/docs/reference/resources/board-view.md +359 -0
- data/docs/reference/resources/board.md +393 -0
- data/docs/reference/resources/column.md +543 -0
- data/docs/reference/resources/file.md +236 -0
- data/docs/reference/resources/folder.md +386 -0
- data/docs/reference/resources/group.md +507 -0
- data/docs/reference/resources/item.md +348 -0
- data/docs/reference/resources/subitem.md +267 -0
- data/docs/reference/resources/update.md +259 -0
- data/docs/reference/resources/workspace.md +213 -0
- data/docs/reference/response.md +560 -0
- data/docs/tutorial/first-integration.md +713 -0
- data/lib/monday/client.rb +41 -2
- data/lib/monday/configuration.rb +13 -0
- data/lib/monday/deprecation.rb +23 -0
- data/lib/monday/error.rb +5 -2
- data/lib/monday/request.rb +19 -1
- data/lib/monday/resources/base.rb +4 -0
- data/lib/monday/resources/board.rb +52 -0
- data/lib/monday/resources/column.rb +6 -0
- data/lib/monday/resources/file.rb +56 -0
- data/lib/monday/resources/folder.rb +55 -0
- data/lib/monday/resources/group.rb +66 -0
- data/lib/monday/resources/item.rb +62 -0
- data/lib/monday/util.rb +33 -1
- data/lib/monday/version.rb +1 -1
- data/lib/monday_ruby.rb +1 -0
- metadata +92 -11
- data/monday_ruby.gemspec +0 -39
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
# Item
|
|
2
|
+
|
|
3
|
+
Access and manage items via the `client.item` resource.
|
|
4
|
+
|
|
5
|
+
::: tip <span style="display: inline-flex; align-items: center; gap: 6px;"><svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="16" x2="12" y2="12"></line><line x1="12" y1="8" x2="12.01" y2="8"></line></svg>Finding Column IDs</span>
|
|
6
|
+
Many item operations require column IDs. These are board-specific. Query your board's columns first:
|
|
7
|
+
|
|
8
|
+
```ruby
|
|
9
|
+
response = client.board.query(
|
|
10
|
+
args: { ids: [1234567890] },
|
|
11
|
+
select: ["id", { columns: ["id", "title", "type"] }]
|
|
12
|
+
)
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
See the [Create Items guide](/guides/items/create#finding-column-ids) for a complete example.
|
|
16
|
+
:::
|
|
17
|
+
|
|
18
|
+
## Methods
|
|
19
|
+
|
|
20
|
+
### query
|
|
21
|
+
|
|
22
|
+
Retrieves items from your account.
|
|
23
|
+
|
|
24
|
+
```ruby
|
|
25
|
+
client.item.query(args: {}, select: DEFAULT_SELECT)
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
**Parameters:**
|
|
29
|
+
|
|
30
|
+
| Name | Type | Default | Description |
|
|
31
|
+
|------|------|---------|-------------|
|
|
32
|
+
| `args` | Hash | `{}` | Query arguments (see [items query](https://developer.monday.com/api-reference/reference/items#queries)) |
|
|
33
|
+
| `select` | Array | `["id", "name", "created_at"]` | Fields to retrieve |
|
|
34
|
+
|
|
35
|
+
**Returns:** `Monday::Response`
|
|
36
|
+
|
|
37
|
+
**Common args:**
|
|
38
|
+
- `ids` - Array of item IDs or single item ID as string
|
|
39
|
+
- `limit` - Number of results (default: 25)
|
|
40
|
+
- `page` - Page number
|
|
41
|
+
- `newest_first` - Boolean, sort by creation date
|
|
42
|
+
|
|
43
|
+
**Example:**
|
|
44
|
+
|
|
45
|
+
```ruby
|
|
46
|
+
response = client.item.query(
|
|
47
|
+
args: { ids: [123456, 789012] },
|
|
48
|
+
select: ["id", "name", "created_at", "state"]
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
items = response.body.dig("data", "items")
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
**GraphQL:** `query { items { ... } }`
|
|
55
|
+
|
|
56
|
+
**See:** [monday.com items query](https://developer.monday.com/api-reference/reference/items#queries)
|
|
57
|
+
|
|
58
|
+
### create
|
|
59
|
+
|
|
60
|
+
Creates a new item.
|
|
61
|
+
|
|
62
|
+
```ruby
|
|
63
|
+
client.item.create(args: {}, select: DEFAULT_SELECT)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**Parameters:**
|
|
67
|
+
|
|
68
|
+
| Name | Type | Default | Description |
|
|
69
|
+
|------|------|---------|-------------|
|
|
70
|
+
| `args` | Hash | `{}` | Creation arguments (required) |
|
|
71
|
+
| `select` | Array | `["id", "name", "created_at"]` | Fields to retrieve |
|
|
72
|
+
|
|
73
|
+
**Required args:**
|
|
74
|
+
- `board_id` - Integer or String
|
|
75
|
+
- `item_name` - String
|
|
76
|
+
|
|
77
|
+
**Optional args:**
|
|
78
|
+
- `group_id` - String - Group to create item in
|
|
79
|
+
- `column_values` - Hash or JSON String - Initial column values
|
|
80
|
+
- `create_labels_if_missing` - Boolean - Auto-create status labels
|
|
81
|
+
|
|
82
|
+
**Returns:** `Monday::Response`
|
|
83
|
+
|
|
84
|
+
**Example:**
|
|
85
|
+
|
|
86
|
+
```ruby
|
|
87
|
+
# Note: Replace column IDs with your board's actual column IDs
|
|
88
|
+
response = client.item.create(
|
|
89
|
+
args: {
|
|
90
|
+
board_id: 123456,
|
|
91
|
+
item_name: "New Task",
|
|
92
|
+
column_values: {
|
|
93
|
+
status: { # Use your board's status column ID
|
|
94
|
+
label: "Done"
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
item = response.body.dig("data", "create_item")
|
|
101
|
+
# => {"id"=>"18273372913", "name"=>"New Task", "created_at"=>"2025-10-27T02:17:50Z"}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
**GraphQL:** `mutation { create_item { ... } }`
|
|
105
|
+
|
|
106
|
+
**See:** [monday.com create_item](https://developer.monday.com/api-reference/reference/items#create-item)
|
|
107
|
+
|
|
108
|
+
### duplicate
|
|
109
|
+
|
|
110
|
+
Duplicates an existing item.
|
|
111
|
+
|
|
112
|
+
```ruby
|
|
113
|
+
client.item.duplicate(board_id, item_id, with_updates, select: DEFAULT_SELECT)
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
**Parameters:**
|
|
117
|
+
|
|
118
|
+
| Name | Type | Default | Description |
|
|
119
|
+
|------|------|---------|-------------|
|
|
120
|
+
| `board_id` | Integer | - | Board ID (required) |
|
|
121
|
+
| `item_id` | Integer | - | Item ID to duplicate (required) |
|
|
122
|
+
| `with_updates` | Boolean | - | Include update threads (required) |
|
|
123
|
+
| `select` | Array | `["id", "name", "created_at"]` | Fields to retrieve |
|
|
124
|
+
|
|
125
|
+
**Returns:** `Monday::Response`
|
|
126
|
+
|
|
127
|
+
**Example:**
|
|
128
|
+
|
|
129
|
+
```ruby
|
|
130
|
+
response = client.item.duplicate(123456, 789012, true)
|
|
131
|
+
|
|
132
|
+
duplicated_item = response.body.dig("data", "duplicate_item")
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
**GraphQL:** `mutation { duplicate_item { ... } }`
|
|
136
|
+
|
|
137
|
+
**See:** [monday.com duplicate_item](https://developer.monday.com/api-reference/reference/items#duplicate-item)
|
|
138
|
+
|
|
139
|
+
### archive
|
|
140
|
+
|
|
141
|
+
Archives an item.
|
|
142
|
+
|
|
143
|
+
```ruby
|
|
144
|
+
client.item.archive(item_id, select: ["id"])
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
**Parameters:**
|
|
148
|
+
|
|
149
|
+
| Name | Type | Default | Description |
|
|
150
|
+
|------|------|---------|-------------|
|
|
151
|
+
| `item_id` | Integer | - | Item ID to archive (required) |
|
|
152
|
+
| `select` | Array | `["id"]` | Fields to retrieve |
|
|
153
|
+
|
|
154
|
+
**Returns:** `Monday::Response`
|
|
155
|
+
|
|
156
|
+
**Example:**
|
|
157
|
+
|
|
158
|
+
```ruby
|
|
159
|
+
response = client.item.archive(123456)
|
|
160
|
+
|
|
161
|
+
archived_item = response.body.dig("data", "archive_item")
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
**GraphQL:** `mutation { archive_item { ... } }`
|
|
165
|
+
|
|
166
|
+
**See:** [monday.com archive_item](https://developer.monday.com/api-reference/reference/items#archive-item)
|
|
167
|
+
|
|
168
|
+
### delete
|
|
169
|
+
|
|
170
|
+
Permanently deletes an item.
|
|
171
|
+
|
|
172
|
+
```ruby
|
|
173
|
+
client.item.delete(item_id, select: ["id"])
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
**Parameters:**
|
|
177
|
+
|
|
178
|
+
| Name | Type | Default | Description |
|
|
179
|
+
|------|------|---------|-------------|
|
|
180
|
+
| `item_id` | Integer | - | Item ID to delete (required) |
|
|
181
|
+
| `select` | Array | `["id"]` | Fields to retrieve |
|
|
182
|
+
|
|
183
|
+
**Returns:** `Monday::Response`
|
|
184
|
+
|
|
185
|
+
::: warning <span style="display: inline-flex; align-items: center; gap: 6px;"><svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"></path><line x1="12" y1="9" x2="12" y2="13"></line><line x1="12" y1="17" x2="12.01" y2="17"></line></svg>Permanent Deletion</span>
|
|
186
|
+
This operation cannot be undone. All item data will be permanently lost.
|
|
187
|
+
:::
|
|
188
|
+
|
|
189
|
+
**Example:**
|
|
190
|
+
|
|
191
|
+
```ruby
|
|
192
|
+
response = client.item.delete(123456)
|
|
193
|
+
|
|
194
|
+
deleted_item = response.body.dig("data", "delete_item")
|
|
195
|
+
# => {"id"=>"123456"}
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
**GraphQL:** `mutation { delete_item { ... } }`
|
|
199
|
+
|
|
200
|
+
**See:** [monday.com delete_item](https://developer.monday.com/api-reference/reference/items#delete-item)
|
|
201
|
+
|
|
202
|
+
### page_by_column_values
|
|
203
|
+
|
|
204
|
+
Retrieves paginated items filtered by column values using cursor-based pagination.
|
|
205
|
+
|
|
206
|
+
```ruby
|
|
207
|
+
client.item.page_by_column_values(
|
|
208
|
+
board_id:,
|
|
209
|
+
columns: nil,
|
|
210
|
+
limit: 25,
|
|
211
|
+
cursor: nil,
|
|
212
|
+
select: DEFAULT_PAGINATED_SELECT
|
|
213
|
+
)
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
**Parameters:**
|
|
217
|
+
|
|
218
|
+
| Name | Type | Default | Description |
|
|
219
|
+
|------|------|---------|-------------|
|
|
220
|
+
| `board_id` | Integer | - | Board ID to query (required) |
|
|
221
|
+
| `columns` | Array | `nil` | Column filtering criteria (mutually exclusive with cursor) |
|
|
222
|
+
| `limit` | Integer | `25` | Items per page (max: 500) |
|
|
223
|
+
| `cursor` | String | `nil` | Pagination cursor (mutually exclusive with columns) |
|
|
224
|
+
| `select` | Array | `["id", "name"]` | Item fields to retrieve |
|
|
225
|
+
|
|
226
|
+
**Column Filter Structure:**
|
|
227
|
+
|
|
228
|
+
Each column filter is a hash with:
|
|
229
|
+
- `column_id` - String - The column identifier
|
|
230
|
+
- `column_values` - Array - Values to match (uses ANY_OF logic)
|
|
231
|
+
|
|
232
|
+
Multiple column filters use AND logic.
|
|
233
|
+
|
|
234
|
+
**Returns:** `Monday::Response`
|
|
235
|
+
|
|
236
|
+
The response contains items and cursor:
|
|
237
|
+
|
|
238
|
+
```ruby
|
|
239
|
+
items_page = response.body.dig("data", "items_page_by_column_values")
|
|
240
|
+
items = items_page["items"]
|
|
241
|
+
cursor = items_page["cursor"]
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
**Supported Column Types:**
|
|
245
|
+
|
|
246
|
+
Checkbox, Country, Date, Dropdown, Email, Hour, Link, Long Text, Numbers, People, Phone, Status, Text, Timeline, World Clock
|
|
247
|
+
|
|
248
|
+
**Example:**
|
|
249
|
+
|
|
250
|
+
```ruby
|
|
251
|
+
# Filter by single column
|
|
252
|
+
# Note: Use your board's actual column IDs (not titles)
|
|
253
|
+
response = client.item.page_by_column_values(
|
|
254
|
+
board_id: 123456,
|
|
255
|
+
columns: [
|
|
256
|
+
{ column_id: "status", column_values: ["Done", "Working on it"] } # Your status column ID
|
|
257
|
+
],
|
|
258
|
+
limit: 50
|
|
259
|
+
)
|
|
260
|
+
|
|
261
|
+
items_page = response.body.dig("data", "items_page_by_column_values")
|
|
262
|
+
items = items_page["items"]
|
|
263
|
+
cursor = items_page["cursor"]
|
|
264
|
+
|
|
265
|
+
# Filter by multiple columns (AND logic)
|
|
266
|
+
response = client.item.page_by_column_values(
|
|
267
|
+
board_id: 123456,
|
|
268
|
+
columns: [
|
|
269
|
+
{ column_id: "status", column_values: ["Done"] }, # Your status column ID
|
|
270
|
+
{ column_id: "text", column_values: ["High Priority"] } # Your text column ID
|
|
271
|
+
]
|
|
272
|
+
)
|
|
273
|
+
|
|
274
|
+
# Next page using cursor
|
|
275
|
+
response = client.item.page_by_column_values(
|
|
276
|
+
board_id: 123456,
|
|
277
|
+
cursor: cursor
|
|
278
|
+
)
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
**GraphQL:** `query { items_page_by_column_values { cursor items { ... } } }`
|
|
282
|
+
|
|
283
|
+
**See:**
|
|
284
|
+
- [monday.com items_page_by_column_values](https://developer.monday.com/api-reference/reference/items-page-by-column-values)
|
|
285
|
+
- [Pagination guide](/guides/advanced/pagination)
|
|
286
|
+
|
|
287
|
+
## Response Structure
|
|
288
|
+
|
|
289
|
+
All methods return a `Monday::Response` object. Access data using:
|
|
290
|
+
|
|
291
|
+
```ruby
|
|
292
|
+
response.success? # => true/false
|
|
293
|
+
response.status # => 200
|
|
294
|
+
response.body # => Hash with GraphQL response
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
### Typical Response Pattern
|
|
298
|
+
|
|
299
|
+
```ruby
|
|
300
|
+
response = client.item.query(args: { ids: [123456] })
|
|
301
|
+
|
|
302
|
+
if response.success?
|
|
303
|
+
items = response.body.dig("data", "items")
|
|
304
|
+
# Work with items
|
|
305
|
+
else
|
|
306
|
+
# Handle error
|
|
307
|
+
end
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
## Constants
|
|
311
|
+
|
|
312
|
+
### DEFAULT_SELECT
|
|
313
|
+
|
|
314
|
+
Default fields returned by `query`, `create`, and `duplicate`:
|
|
315
|
+
|
|
316
|
+
```ruby
|
|
317
|
+
["id", "name", "created_at"]
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
### DEFAULT_PAGINATED_SELECT
|
|
321
|
+
|
|
322
|
+
Default fields returned by `page_by_column_values`:
|
|
323
|
+
|
|
324
|
+
```ruby
|
|
325
|
+
["id", "name"]
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
## Error Handling
|
|
329
|
+
|
|
330
|
+
Common errors when working with items:
|
|
331
|
+
|
|
332
|
+
- `Monday::AuthorizationError` - Invalid or missing API token
|
|
333
|
+
- `Monday::InvalidRequestError` - Invalid board_id or item_id
|
|
334
|
+
- `Monday::Error` - Invalid field requested or other API errors
|
|
335
|
+
|
|
336
|
+
See the [Error Handling guide](/guides/advanced/errors) for more details.
|
|
337
|
+
|
|
338
|
+
## Related Resources
|
|
339
|
+
|
|
340
|
+
- [Board](/reference/resources/board) - Item parent boards
|
|
341
|
+
- [Column](/reference/resources/column) - Item column values
|
|
342
|
+
- [Group](/reference/resources/group) - Item groups
|
|
343
|
+
- [Subitem](/reference/resources/subitem) - Item subitems
|
|
344
|
+
|
|
345
|
+
## External References
|
|
346
|
+
|
|
347
|
+
- [monday.com Items API](https://developer.monday.com/api-reference/reference/items)
|
|
348
|
+
- [GraphQL API Overview](https://developer.monday.com/api-reference/docs/introduction-to-graphql)
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
# Subitem
|
|
2
|
+
|
|
3
|
+
Access and manage subitems (child items) via the `client.subitem` resource.
|
|
4
|
+
|
|
5
|
+
::: tip <span style="display: inline-flex; align-items: center; gap: 6px;"><svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="16" x2="12" y2="12"></line><line x1="12" y1="8" x2="12.01" y2="8"></line></svg>What are Subitems?</span>
|
|
6
|
+
Subitems are child items that belong to a parent item. They help break down tasks into smaller, manageable pieces. Subitems live on their own separate board.
|
|
7
|
+
:::
|
|
8
|
+
|
|
9
|
+
## Methods
|
|
10
|
+
|
|
11
|
+
### query
|
|
12
|
+
|
|
13
|
+
Retrieves subitems for parent items.
|
|
14
|
+
|
|
15
|
+
```ruby
|
|
16
|
+
client.subitem.query(args: {}, select: DEFAULT_SELECT)
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
**Parameters:**
|
|
20
|
+
|
|
21
|
+
| Name | Type | Default | Description |
|
|
22
|
+
|------|------|---------|-------------|
|
|
23
|
+
| `args` | Hash | `{}` | Query arguments |
|
|
24
|
+
| `select` | Array | `["id", "name", "created_at"]` | Fields to retrieve |
|
|
25
|
+
|
|
26
|
+
**Returns:** `Monday::Response`
|
|
27
|
+
|
|
28
|
+
**Common args:**
|
|
29
|
+
- `ids` - Array of parent item IDs or single parent item ID
|
|
30
|
+
|
|
31
|
+
**Response Structure:**
|
|
32
|
+
|
|
33
|
+
The response contains items with their subitems nested:
|
|
34
|
+
|
|
35
|
+
```ruby
|
|
36
|
+
items = response.body.dig("data", "items")
|
|
37
|
+
subitems = items.first&.dig("subitems") || []
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
**Example:**
|
|
41
|
+
|
|
42
|
+
```ruby
|
|
43
|
+
# Query subitems for a parent item
|
|
44
|
+
response = client.subitem.query(
|
|
45
|
+
args: { ids: [987654321] }
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
if response.success?
|
|
49
|
+
items = response.body.dig("data", "items")
|
|
50
|
+
subitems = items.first&.dig("subitems") || []
|
|
51
|
+
|
|
52
|
+
puts "Found #{subitems.length} subitems"
|
|
53
|
+
subitems.each do |subitem|
|
|
54
|
+
puts " • #{subitem['name']}"
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
**Query multiple parent items:**
|
|
60
|
+
|
|
61
|
+
```ruby
|
|
62
|
+
response = client.subitem.query(
|
|
63
|
+
args: { ids: [987654321, 987654322] },
|
|
64
|
+
select: [
|
|
65
|
+
"id",
|
|
66
|
+
"name",
|
|
67
|
+
"created_at",
|
|
68
|
+
"state"
|
|
69
|
+
]
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
items = response.body.dig("data", "items")
|
|
73
|
+
items.each do |item|
|
|
74
|
+
subitems = item["subitems"] || []
|
|
75
|
+
puts "Item #{item['id']} has #{subitems.length} subitems"
|
|
76
|
+
end
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**GraphQL:** `query { items { subitems { ... } } }`
|
|
80
|
+
|
|
81
|
+
**See:** [monday.com subitems query](https://developer.monday.com/api-reference/reference/subitems)
|
|
82
|
+
|
|
83
|
+
### create
|
|
84
|
+
|
|
85
|
+
Creates a new subitem under a parent item.
|
|
86
|
+
|
|
87
|
+
```ruby
|
|
88
|
+
client.subitem.create(args: {}, select: DEFAULT_SELECT)
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**Parameters:**
|
|
92
|
+
|
|
93
|
+
| Name | Type | Default | Description |
|
|
94
|
+
|------|------|---------|-------------|
|
|
95
|
+
| `args` | Hash | `{}` | Creation arguments (required) |
|
|
96
|
+
| `select` | Array | `["id", "name", "created_at"]` | Fields to retrieve |
|
|
97
|
+
|
|
98
|
+
**Required args:**
|
|
99
|
+
- `parent_item_id` - Integer - The parent item ID
|
|
100
|
+
- `item_name` - String - Name of the subitem
|
|
101
|
+
|
|
102
|
+
**Optional args:**
|
|
103
|
+
- `column_values` - Hash or JSON String - Initial column values
|
|
104
|
+
- `create_labels_if_missing` - Boolean - Auto-create status labels
|
|
105
|
+
|
|
106
|
+
**Returns:** `Monday::Response`
|
|
107
|
+
|
|
108
|
+
**Example:**
|
|
109
|
+
|
|
110
|
+
```ruby
|
|
111
|
+
response = client.subitem.create(
|
|
112
|
+
args: {
|
|
113
|
+
parent_item_id: 987654321,
|
|
114
|
+
item_name: "Design Phase"
|
|
115
|
+
}
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
if response.success?
|
|
119
|
+
subitem = response.body.dig("data", "create_subitem")
|
|
120
|
+
puts "Created: #{subitem['name']}"
|
|
121
|
+
puts "ID: #{subitem['id']}"
|
|
122
|
+
puts "Created at: #{subitem['created_at']}"
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
# => Created: Design Phase
|
|
126
|
+
# => ID: 7092811738
|
|
127
|
+
# => Created at: 2024-07-25T04:00:04Z
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
**Create with column values:**
|
|
131
|
+
|
|
132
|
+
```ruby
|
|
133
|
+
# Note: Replace column IDs with your subitems board's actual column IDs
|
|
134
|
+
response = client.subitem.create(
|
|
135
|
+
args: {
|
|
136
|
+
parent_item_id: 987654321,
|
|
137
|
+
item_name: "Development Task",
|
|
138
|
+
column_values: {
|
|
139
|
+
status: { # Your status column ID
|
|
140
|
+
label: "Working on it"
|
|
141
|
+
},
|
|
142
|
+
date4: { # Your date column ID
|
|
143
|
+
date: "2024-12-31"
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
)
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
**GraphQL:** `mutation { create_subitem { ... } }`
|
|
151
|
+
|
|
152
|
+
**See:** [monday.com create_subitem](https://developer.monday.com/api-reference/reference/subitems#create-subitem)
|
|
153
|
+
|
|
154
|
+
## Updating and Deleting Subitems
|
|
155
|
+
|
|
156
|
+
Subitems are regular items, so use the standard item and column methods:
|
|
157
|
+
|
|
158
|
+
### Update Subitem Column Values
|
|
159
|
+
|
|
160
|
+
```ruby
|
|
161
|
+
# Use column.change_value or column.change_multiple_values
|
|
162
|
+
response = client.column.change_value(
|
|
163
|
+
args: {
|
|
164
|
+
board_id: 1234567890, # Subitems board ID
|
|
165
|
+
item_id: 7092811738, # Subitem ID
|
|
166
|
+
column_id: "status", # Column ID
|
|
167
|
+
value: JSON.generate({ label: "Done" })
|
|
168
|
+
}
|
|
169
|
+
)
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### Delete Subitem
|
|
173
|
+
|
|
174
|
+
```ruby
|
|
175
|
+
# Use item.delete
|
|
176
|
+
response = client.item.delete(7092811738)
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Archive Subitem
|
|
180
|
+
|
|
181
|
+
```ruby
|
|
182
|
+
# Use item.archive
|
|
183
|
+
response = client.item.archive(7092811738)
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## Response Structure
|
|
187
|
+
|
|
188
|
+
All methods return a `Monday::Response` object. Access data using:
|
|
189
|
+
|
|
190
|
+
```ruby
|
|
191
|
+
response.success? # => true/false
|
|
192
|
+
response.status # => 200
|
|
193
|
+
response.body # => Hash with GraphQL response
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Typical Response Pattern
|
|
197
|
+
|
|
198
|
+
```ruby
|
|
199
|
+
response = client.subitem.create(
|
|
200
|
+
args: {
|
|
201
|
+
parent_item_id: 987654321,
|
|
202
|
+
item_name: "New Subitem"
|
|
203
|
+
}
|
|
204
|
+
)
|
|
205
|
+
|
|
206
|
+
if response.success?
|
|
207
|
+
subitem = response.body.dig("data", "create_subitem")
|
|
208
|
+
# Work with subitem
|
|
209
|
+
else
|
|
210
|
+
# Handle error
|
|
211
|
+
end
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
## Constants
|
|
215
|
+
|
|
216
|
+
### DEFAULT_SELECT
|
|
217
|
+
|
|
218
|
+
Default fields returned by `query` and `create`:
|
|
219
|
+
|
|
220
|
+
```ruby
|
|
221
|
+
["id", "name", "created_at"]
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
## Error Handling
|
|
225
|
+
|
|
226
|
+
Common errors when working with subitems:
|
|
227
|
+
|
|
228
|
+
- `Monday::AuthorizationError` - Invalid or missing API token
|
|
229
|
+
- `Monday::Error` - Invalid parent item ID, invalid field, or other API errors
|
|
230
|
+
|
|
231
|
+
**Example:**
|
|
232
|
+
|
|
233
|
+
```ruby
|
|
234
|
+
begin
|
|
235
|
+
response = client.subitem.create(
|
|
236
|
+
args: {
|
|
237
|
+
parent_item_id: 123, # Invalid ID
|
|
238
|
+
item_name: "Test"
|
|
239
|
+
}
|
|
240
|
+
)
|
|
241
|
+
rescue Monday::Error => e
|
|
242
|
+
puts "Error: #{e.message}"
|
|
243
|
+
end
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
See the [Error Handling guide](/guides/advanced/errors) for more details.
|
|
247
|
+
|
|
248
|
+
## Important Notes
|
|
249
|
+
|
|
250
|
+
::: warning <span style="display: inline-flex; align-items: center; gap: 6px;"><svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"></path><line x1="12" y1="9" x2="12" y2="13"></line><line x1="12" y1="17" x2="12.01" y2="17"></line></svg>Subitems Board</span>
|
|
251
|
+
Subitems live on a separate board, not the parent board. To update subitem column values, you need the **subitems board ID**, not the parent board ID.
|
|
252
|
+
:::
|
|
253
|
+
|
|
254
|
+
::: tip <span style="display: inline-flex; align-items: center; gap: 6px;"><svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="16" x2="12" y2="12"></line><line x1="12" y1="8" x2="12.01" y2="8"></line></svg>No Nested Subitems</span>
|
|
255
|
+
Subitems cannot have their own subitems. monday.com only supports one level of parent-child relationship.
|
|
256
|
+
:::
|
|
257
|
+
|
|
258
|
+
## Related Resources
|
|
259
|
+
|
|
260
|
+
- [Item](/reference/resources/item) - Parent items
|
|
261
|
+
- [Column](/reference/resources/column) - Update subitem column values
|
|
262
|
+
- [Board](/reference/resources/board) - Query boards and items
|
|
263
|
+
|
|
264
|
+
## External References
|
|
265
|
+
|
|
266
|
+
- [monday.com Subitems API](https://developer.monday.com/api-reference/reference/subitems)
|
|
267
|
+
- [GraphQL API Overview](https://developer.monday.com/api-reference/docs/introduction-to-graphql)
|