rossum-mcp 0.3.5__py3-none-any.whl → 1.0.0__py3-none-any.whl

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.
@@ -1,1787 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: rossum-mcp
3
- Version: 0.3.5
4
- Summary: MCP server for AI-powered Rossum orchestration: document workflows, debug pipelines automatically, and configure intelligent document processing through natural language.
5
- Author-email: "Dan Stancl (Rossum AI)" <daniel.stancl@gmail.com>
6
- License: MIT
7
- Keywords: mcp,rossum,document-processing
8
- Requires-Python: >=3.12
9
- Description-Content-Type: text/markdown
10
- Requires-Dist: fastmcp>2.0.0
11
- Requires-Dist: pydantic>2.0.0
12
- Requires-Dist: rossum-api>=3.7.0
13
- Provides-Extra: docs
14
- Requires-Dist: myst-parser>=2.0.0; extra == "docs"
15
- Requires-Dist: sphinx>=7.0.0; extra == "docs"
16
- Requires-Dist: sphinx-autodoc-typehints>=1.25.0; extra == "docs"
17
- Requires-Dist: sphinx-copybutton>=0.5.2; extra == "docs"
18
- Requires-Dist: sphinx-rtd-theme>=2.0.0; extra == "docs"
19
- Provides-Extra: tests
20
- Requires-Dist: coverage>=7.0.0; extra == "tests"
21
- Requires-Dist: pytest>=7.0.0; extra == "tests"
22
- Requires-Dist: pytest-asyncio>=0.21.0; extra == "tests"
23
- Requires-Dist: pytest-cov>=4.0.0; extra == "tests"
24
- Requires-Dist: redis>=7.0.0; extra == "tests"
25
- Provides-Extra: all
26
- Requires-Dist: coverage>=7.0.0; extra == "all"
27
- Requires-Dist: fastmcp>=1.0.0; extra == "all"
28
- Requires-Dist: myst-parser>=2.0.0; extra == "all"
29
- Requires-Dist: pydantic>2.0.0; extra == "all"
30
- Requires-Dist: pytest>=7.0.0; extra == "all"
31
- Requires-Dist: pytest-asyncio>=0.21.0; extra == "all"
32
- Requires-Dist: redis>=7.0.0; extra == "all"
33
- Requires-Dist: rossum-api>=3.7.0; extra == "all"
34
- Requires-Dist: sphinx>=7.0.0; extra == "all"
35
- Requires-Dist: sphinx-autodoc-typehints>=1.25.0; extra == "all"
36
- Requires-Dist: sphinx-copybutton>=0.5.2; extra == "all"
37
- Requires-Dist: sphinx-rtd-theme>=2.0.0; extra == "all"
38
-
39
- # Rossum MCP Server
40
-
41
- <div align="center">
42
-
43
- [![Documentation](https://img.shields.io/badge/docs-latest-blue.svg)](https://stancld.github.io/rossum-mcp/)
44
- [![Python](https://img.shields.io/badge/python-3.12+-blue.svg)](https://www.python.org/downloads/)
45
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
46
- [![PyPI - rossum-mcp](https://img.shields.io/pypi/v/rossum-mcp?label=rossum-mcp)](https://pypi.org/project/rossum-mcp/)
47
- [![Coverage](https://codecov.io/gh/stancld/rossum-mcp/branch/master/graph/badge.svg?flag=rossum-mcp)](https://codecov.io/gh/stancld/rossum-mcp)
48
- [![MCP Tools](https://img.shields.io/badge/MCP_Tools-49-blue.svg)](#available-tools)
49
-
50
- [![Rossum API](https://img.shields.io/badge/Rossum-API-orange.svg)](https://github.com/rossumai/rossum-api)
51
- [![MCP](https://img.shields.io/badge/MCP-compatible-green.svg)](https://modelcontextprotocol.io/)
52
- [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
53
- [![uv](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json)](https://github.com/astral-sh/uv)
54
-
55
- </div>
56
-
57
- A Model Context Protocol (MCP) server that provides tools for uploading documents and retrieving annotations using the Rossum API. Built with Python and the official [rossum-api](https://github.com/rossumai/rossum-api).
58
-
59
- > [!NOTE]
60
- > This is not an official Rossum project. It is a community-developed integration built on top of the Rossum API.
61
-
62
- > [!WARNING]
63
- > This project is in early stage development. Breaking changes to both implementation and agent behavior are expected.
64
-
65
- ## Features
66
-
67
- ### Document Processing
68
- - **upload_document**: Upload a document to Rossum for processing
69
- - **get_annotation**: Retrieve annotation data for a previously uploaded document
70
- - **list_annotations**: List all annotations for a queue with optional filtering
71
- - **start_annotation**: Start annotation to move it to 'reviewing' status
72
- - **bulk_update_annotation_fields**: Bulk update annotation field values using JSON Patch operations
73
- - **confirm_annotation**: Confirm annotation to move it to 'confirmed' status
74
-
75
- ### Queue & Schema Management
76
- - **get_queue**: Retrieve queue details including schema_id
77
- - **list_queues**: List all queues with optional filtering by workspace or name
78
- - **get_schema**: Retrieve schema details and content
79
- - **list_schemas**: List all schemas with optional filtering by name or queue
80
- - **get_schema_tree_structure**: Get lightweight tree view of schema with only ids, labels, categories, and types
81
- - **get_queue_schema**: Retrieve complete schema for a queue in a single call
82
- - **get_queue_engine**: Retrieve engine information for a queue
83
- - **create_queue**: Create a new queue with schema and optional engine assignment
84
- - **create_schema**: Create a new schema with sections and datapoints
85
- - **update_queue**: Update queue settings including automation thresholds
86
- - **update_schema**: Update schema with field-level automation thresholds
87
- - **patch_schema**: Add, update, or remove individual schema nodes without replacing entire content
88
- - **prune_schema_fields**: Efficiently remove multiple fields from schema at once (for organization setup)
89
-
90
- ### Workspace Management
91
- - **get_workspace**: Retrieve workspace details by ID
92
- - **list_workspaces**: List all workspaces with optional filtering
93
- - **create_workspace**: Create a new workspace
94
-
95
- ### User Management
96
- - **get_user**: Retrieve user details by ID
97
- - **list_users**: List users with optional filtering by username, email, etc.
98
- - **list_user_roles**: List all user roles (permission groups) in the organization
99
-
100
- ### Engine Management
101
- - **get_engine**: Retrieve engine details by ID
102
- - **list_engines**: List all engines with optional filters
103
- - **create_engine**: Create a new engine (extractor or splitter)
104
- - **update_engine**: Update engine settings including learning and training queues
105
- - **create_engine_field**: Create engine fields and link them to schemas
106
- - **get_engine_fields**: Retrieve engine fields for a specific engine or all engine fields
107
-
108
- ### Extensions & Rules
109
- - **get_hook**: Get hook/extension details
110
- - **list_hooks**: List webhooks and serverless functions (extensions)
111
- - **create_hook**: Create webhooks or serverless function hooks for custom logic
112
- - **update_hook**: Update existing hook properties (name, queues, config, events, settings)
113
- - **list_hook_templates**: List available hook templates from Rossum Store
114
- - **create_hook_from_template**: Create a hook from a Rossum Store template
115
- - **list_hook_logs**: List hook execution logs for debugging and monitoring
116
- - **get_rule**: Get business rule details
117
- - **list_rules**: List business rules with trigger conditions and actions
118
-
119
- ### Email Templates
120
- - **get_email_template**: Retrieve email template details by ID
121
- - **list_email_templates**: List email templates with optional filtering by queue, type, or name
122
- - **create_email_template**: Create email templates for automated or manual email sending
123
-
124
- ### Relations Management
125
- - **get_relation**: Retrieve relation details by ID
126
- - **list_relations**: List all relations between annotations (edit, attachment, duplicate)
127
- - **get_document_relation**: Retrieve document relation details by ID
128
- - **list_document_relations**: List all document relations (export, einvoice)
129
-
130
- ## Prerequisites
131
-
132
- - Python 3.12 or higher
133
- - Rossum account with API credentials
134
- - A Rossum queue ID
135
-
136
- ## Installation
137
-
138
- ### Docker (Recommended)
139
-
140
- ```bash
141
- git clone https://github.com/stancld/rossum-mcp.git
142
- cd rossum-mcp
143
-
144
- # Set up environment variables
145
- export ROSSUM_API_TOKEN="your-api-token"
146
- export ROSSUM_API_BASE_URL="https://api.elis.rossum.ai/v1"
147
- export ROSSUM_MCP_MODE="read-write" # Optional: "read-only" or "read-write" (default)
148
-
149
- # Run the MCP server
150
- docker-compose up rossum-agent
151
- ```
152
-
153
- <details>
154
- <summary>Install from source (alternative)</summary>
155
-
156
- ```bash
157
- git clone https://github.com/stancld/rossum-mcp.git
158
- cd rossum-mcp/rossum-mcp
159
- uv sync
160
- ```
161
-
162
- Install with extras:
163
- ```bash
164
- uv sync --extra all # All extras (docs, tests)
165
- uv sync --extra docs # Documentation only
166
- uv sync --extra tests # Testing only
167
- ```
168
-
169
- </details>
170
-
171
- ### Environment Variables
172
-
173
- - **ROSSUM_API_TOKEN** (required): Your Rossum API authentication token
174
- - **ROSSUM_API_BASE_URL** (required): Base URL for the Rossum API
175
- - **ROSSUM_MCP_MODE** (optional): Controls which tools are available
176
- - `read-write` (default): All tools available (GET, LIST, CREATE, UPDATE operations)
177
- - `read-only`: Only read operations available (GET and LIST operations only)
178
-
179
- #### Read-Only vs Read-Write Mode
180
-
181
- When `ROSSUM_MCP_MODE` is set to `read-only`, only read operations are available:
182
- - **Annotations:** `get_annotation`, `list_annotations`
183
- - **Queues:** `get_queue`, `list_queues`, `get_queue_schema`, `get_queue_engine`
184
- - **Schemas:** `get_schema`, `list_schemas`
185
- - **Engines:** `get_engine`, `list_engines`, `get_engine_fields`
186
- - **Hooks:** `get_hook`, `list_hooks`, `list_hook_templates`, `list_hook_logs`
187
- - **Email Templates:** `get_email_template`, `list_email_templates`
188
- - **Users:** `get_user`, `list_users`, `list_user_roles`
189
- - **Rules:** `get_rule`, `list_rules`
190
- - **Relations:** `get_relation`, `list_relations`
191
- - **Document Relations:** `get_document_relation`, `list_document_relations`
192
- - **Workspaces:** `get_workspace`, `list_workspaces`
193
-
194
- All CREATE, UPDATE, and UPLOAD operations are disabled in read-only mode for security purposes.
195
-
196
- ## Usage
197
-
198
- <details>
199
- <summary>Running the MCP Server</summary>
200
-
201
- Start the server using:
202
- ```bash
203
- python server.py
204
- ```
205
-
206
- Or using the installed script:
207
- ```bash
208
- rossum-mcp
209
- ```
210
-
211
- </details>
212
-
213
- <details>
214
- <summary>Claude Desktop Configuration</summary>
215
-
216
- Configure your MCP client to use this server. In Claude Desktop's config:
217
-
218
- **Read-write mode:**
219
- ```json
220
- {
221
- "mcpServers": {
222
- "rossum": {
223
- "command": "python",
224
- "args": ["/path/to/rossum-mcp/rossum-mcp/rossum_mcp/server.py"],
225
- "env": {
226
- "ROSSUM_API_TOKEN": "your-api-token",
227
- "ROSSUM_API_BASE_URL": "https://api.elis.rossum.ai/v1",
228
- "ROSSUM_MCP_MODE": "read-write"
229
- }
230
- }
231
- }
232
- }
233
- ```
234
-
235
- **Read-only mode:**
236
- ```json
237
- {
238
- "mcpServers": {
239
- "rossum-readonly": {
240
- "command": "python",
241
- "args": ["/path/to/rossum-mcp/rossum-mcp/rossum_mcp/server.py"],
242
- "env": {
243
- "ROSSUM_API_TOKEN": "your-api-token",
244
- "ROSSUM_API_BASE_URL": "https://api.elis.rossum.ai/v1",
245
- "ROSSUM_MCP_MODE": "read-only"
246
- }
247
- }
248
- }
249
- }
250
- ```
251
-
252
- </details>
253
-
254
- ## Available Tools
255
-
256
- ### Document Processing
257
-
258
- #### upload_document
259
-
260
- Uploads a document to Rossum for processing. Returns a task ID. Use `list_annotations` to get the annotation ID.
261
-
262
- **Parameters:**
263
- - `file_path` (string, required): Absolute path to the document file
264
- - `queue_id` (integer, required): Rossum queue ID where the document should be uploaded
265
-
266
- **Returns:**
267
- ```json
268
- {
269
- "task_id": "12345",
270
- "task_status": "created",
271
- "queue_id": 12345,
272
- "message": "Document upload initiated. Use `list_annotations` to find the annotation ID for this queue."
273
- }
274
- ```
275
-
276
- #### get_annotation
277
-
278
- Retrieves annotation data for a previously uploaded document. Use this to check the status of a document.
279
-
280
- **Parameters:**
281
- - `annotation_id` (integer, required): The annotation ID obtained from list_annotations
282
- - `sideloads` (array, optional): List of sideloads to include. Use `['content']` to fetch annotation content with datapoints
283
-
284
- **Returns:**
285
- ```json
286
- {
287
- "id": "12345",
288
- "status": "to_review",
289
- "url": "https://elis.rossum.ai/api/v1/annotations/12345",
290
- "schema": "67890",
291
- "modifier": "11111",
292
- "document": "22222",
293
- "content": [...],
294
- "created_at": "2024-01-01T00:00:00Z",
295
- "modified_at": "2024-01-01T00:00:00Z"
296
- }
297
- ```
298
-
299
- #### list_annotations
300
-
301
- Lists all annotations for a queue with optional filtering. Useful for checking the status of multiple uploaded documents.
302
-
303
- **Parameters:**
304
- - `queue_id` (integer, required): Rossum queue ID to list annotations from
305
- - `status` (string, optional): Filter by annotation status (default: 'importing,to_review,confirmed,exported')
306
-
307
- **Returns:**
308
- ```json
309
- {
310
- "count": 42,
311
- "results": [
312
- {
313
- "id": "12345",
314
- "status": "to_review",
315
- "url": "https://elis.rossum.ai/api/v1/annotations/12345",
316
- "document": "67890",
317
- "created_at": "2024-01-01T00:00:00Z",
318
- "modified_at": "2024-01-01T00:00:00Z"
319
- }
320
- ]
321
- }
322
- ```
323
-
324
- #### start_annotation
325
-
326
- Starts an annotation to move it from 'importing' to 'reviewing' status. This is required before you can update annotation fields.
327
-
328
- **Parameters:**
329
- - `annotation_id` (integer, required): Rossum annotation ID to start
330
-
331
- **Returns:**
332
- ```json
333
- {
334
- "annotation_id": 12345,
335
- "message": "Annotation 12345 started successfully. Status changed to 'reviewing'."
336
- }
337
- ```
338
-
339
- #### bulk_update_annotation_fields
340
-
341
- Bulk update annotation field values using JSON Patch operations. This is the correct way to update annotation field values. Must be called after `start_annotation`.
342
-
343
- **Parameters:**
344
- - `annotation_id` (integer, required): Rossum annotation ID to update
345
- - `operations` (array, required): List of JSON Patch operations with format:
346
- ```json
347
- [
348
- {
349
- "op": "replace",
350
- "id": 1234,
351
- "value": {
352
- "content": {
353
- "value": "new_value",
354
- "page": 1,
355
- "position": [x, y, w, h]
356
- }
357
- }
358
- }
359
- ]
360
- ```
361
-
362
- **Important:** Use the numeric datapoint `id` from `annotation.content`, NOT the `schema_id`.
363
-
364
- **Returns:**
365
- ```json
366
- {
367
- "annotation_id": 12345,
368
- "operations_count": 1,
369
- "message": "Annotation 12345 updated with 1 operations successfully."
370
- }
371
- ```
372
-
373
- #### confirm_annotation
374
-
375
- Confirms an annotation to move it to 'confirmed' status. Can be called after `bulk_update_annotation_fields`.
376
-
377
- **Parameters:**
378
- - `annotation_id` (integer, required): Rossum annotation ID to confirm
379
-
380
- **Returns:**
381
- ```json
382
- {
383
- "annotation_id": 12345,
384
- "message": "Annotation 12345 confirmed successfully. Status changed to 'confirmed'."
385
- }
386
- ```
387
-
388
- ### Queue & Schema Management
389
-
390
- #### get_queue
391
-
392
- Retrieves queue details including the schema_id.
393
-
394
- **Parameters:**
395
- - `queue_id` (integer, required): Rossum queue ID to retrieve
396
-
397
- #### list_queues
398
-
399
- Lists all queues with optional filtering by workspace or name.
400
-
401
- **Parameters:**
402
- - `workspace_id` (integer, optional): Filter by workspace ID
403
- - `name` (string, optional): Filter by queue name
404
-
405
- **Returns:**
406
- ```json
407
- [
408
- {
409
- "id": 12345,
410
- "name": "Invoice Processing",
411
- "url": "https://elis.rossum.ai/api/v1/queues/12345",
412
- "workspace": "https://elis.rossum.ai/api/v1/workspaces/100",
413
- "schema": "https://elis.rossum.ai/api/v1/schemas/200",
414
- "inbox": "https://elis.rossum.ai/api/v1/inboxes/300",
415
- "status": "active",
416
- "locale": "en_GB",
417
- "automation_enabled": true
418
- }
419
- ]
420
- ```
421
-
422
- **Example usage:**
423
- ```python
424
- # List all queues
425
- all_queues = list_queues()
426
-
427
- # List queues in a specific workspace
428
- workspace_queues = list_queues(workspace_id=100)
429
-
430
- # List queues by name
431
- named_queues = list_queues(name="Invoice Processing")
432
-
433
- # Combine filters
434
- filtered_queues = list_queues(workspace_id=100, name="Invoice")
435
- ```
436
-
437
- #### get_schema
438
-
439
- Retrieves schema details including the schema content/structure.
440
-
441
- **Parameters:**
442
- - `schema_id` (integer, required): Rossum schema ID to retrieve
443
-
444
- #### list_schemas
445
-
446
- Lists all schemas with optional filtering by name or queue.
447
-
448
- **Parameters:**
449
- - `name` (string, optional): Filter by schema name
450
- - `queue_id` (integer, optional): Filter by queue ID
451
-
452
- **Returns:**
453
- ```json
454
- [
455
- {
456
- "id": 12345,
457
- "name": "Invoice Schema",
458
- "url": "https://elis.rossum.ai/api/v1/schemas/12345",
459
- "queues": ["https://elis.rossum.ai/api/v1/queues/100"],
460
- "content": "<omitted>",
461
- "metadata": {},
462
- "modified_at": "2025-01-15T10:00:00Z"
463
- }
464
- ]
465
- ```
466
-
467
- **Example usage:**
468
- ```python
469
- # List all schemas
470
- all_schemas = list_schemas()
471
-
472
- # List schemas by name
473
- named_schemas = list_schemas(name="Invoice Schema")
474
-
475
- # List schemas used by a specific queue
476
- queue_schemas = list_schemas(queue_id=100)
477
-
478
- # Combine filters
479
- filtered_schemas = list_schemas(name="Invoice", queue_id=100)
480
- ```
481
-
482
- #### get_queue_schema
483
-
484
- Retrieves the complete schema for a queue in a single call. This is the recommended way to get a queue's schema.
485
-
486
- **Parameters:**
487
- - `queue_id` (integer, required): Rossum queue ID
488
-
489
- #### get_queue_engine
490
-
491
- Retrieves the complete engine information for a given queue in a single call.
492
-
493
- **Parameters:**
494
- - `queue_id` (integer, required): Rossum queue ID
495
-
496
- #### create_queue
497
-
498
- Creates a new queue with schema and optional engine assignment.
499
-
500
- **Parameters:**
501
- - `name` (string, required): Name of the queue to create
502
- - `workspace_id` (integer, required): Workspace ID where the queue should be created
503
- - `schema_id` (integer, required): Schema ID to assign to the queue
504
- - `engine_id` (integer, optional): Optional engine ID to assign for document processing
505
- - Additional optional parameters for automation, locale, training, etc.
506
-
507
- #### update_queue
508
-
509
- Updates an existing queue's settings including automation thresholds.
510
-
511
- **Parameters:**
512
- - `queue_id` (integer, required): Queue ID to update
513
- - `queue_data` (object, required): Dictionary containing queue fields to update
514
-
515
- #### create_schema
516
-
517
- Creates a new schema with sections and datapoints.
518
-
519
- **Parameters:**
520
- - `name` (string, required): Schema name
521
- - `content` (array, required): Schema content array containing sections with datapoints. Must follow Rossum schema structure with sections containing children.
522
-
523
- **Example content structure:**
524
- ```json
525
- [
526
- {
527
- "category": "section",
528
- "id": "document_info",
529
- "label": "Document Information",
530
- "children": [
531
- {
532
- "category": "datapoint",
533
- "id": "document_type",
534
- "label": "Document Type",
535
- "type": "enum",
536
- "rir_field_names": [],
537
- "constraints": {"required": false},
538
- "options": [
539
- {"value": "invoice", "label": "Invoice"},
540
- {"value": "receipt", "label": "Receipt"}
541
- ]
542
- }
543
- ]
544
- }
545
- ]
546
- ```
547
-
548
- **Returns:**
549
- ```json
550
- {
551
- "id": 12345,
552
- "name": "My Schema",
553
- "url": "https://elis.rossum.ai/api/v1/schemas/12345",
554
- "content": [...],
555
- "message": "Schema 'My Schema' created successfully with ID 12345"
556
- }
557
- ```
558
-
559
- #### update_schema
560
-
561
- Updates an existing schema, typically used to set field-level automation thresholds.
562
-
563
- **Parameters:**
564
- - `schema_id` (integer, required): Schema ID to update
565
- - `schema_data` (object, required): Dictionary containing schema fields to update
566
-
567
- #### patch_schema
568
-
569
- Patch a schema by adding, updating, or removing individual nodes without replacing the entire content. This is particularly useful for making incremental changes to schemas.
570
-
571
- **Parameters:**
572
- - `schema_id` (integer, required): Schema ID to patch
573
- - `operation` (string, required): One of "add", "update", or "remove"
574
- - `node_id` (string, required): ID of the node to operate on
575
- - `node_data` (object, optional): Data for add/update operations. Required for "add" and "update"
576
- - `parent_id` (string, optional): Parent node ID for add operation. Required for "add"
577
- - `position` (integer, optional): Position for add operation (appends if not specified)
578
-
579
- **Operations:**
580
- - **add**: Add a new datapoint/multivalue to a parent (section or tuple). Requires `parent_id` and `node_data`.
581
- - **update**: Update properties of an existing node. Requires `node_data` with fields to update.
582
- - **remove**: Remove a node from the schema. Only `node_id` is required.
583
-
584
- **Returns:**
585
- ```json
586
- {
587
- "id": 123,
588
- "name": "Invoice Schema",
589
- "content": [
590
- {
591
- "id": "header_section",
592
- "label": "Header",
593
- "category": "section",
594
- "children": [
595
- {"id": "invoice_number", "label": "Invoice Number", "category": "datapoint"},
596
- {"id": "vendor_name", "label": "Vendor Name", "category": "datapoint"}
597
- ]
598
- }
599
- ]
600
- }
601
- ```
602
-
603
- **Example usage:**
604
- ```python
605
- # Add a new datapoint to a section
606
- patch_schema(
607
- schema_id=123,
608
- operation="add",
609
- node_id="vendor_name",
610
- parent_id="header_section",
611
- node_data={"label": "Vendor Name", "type": "string", "category": "datapoint"}
612
- )
613
-
614
- # Update a field's label and threshold
615
- patch_schema(
616
- schema_id=123,
617
- operation="update",
618
- node_id="invoice_number",
619
- node_data={"label": "Invoice #", "score_threshold": 0.9}
620
- )
621
-
622
- # Remove a field
623
- patch_schema(
624
- schema_id=123,
625
- operation="remove",
626
- node_id="old_field"
627
- )
628
- ```
629
-
630
- ### Engine Management
631
-
632
- #### get_engine
633
-
634
- Retrieves detailed information about a specific engine by its ID.
635
-
636
- **Parameters:**
637
- - `engine_id` (integer, required): Engine ID to retrieve
638
-
639
- **Returns:**
640
- ```json
641
- {
642
- "id": 12345,
643
- "name": "Invoice Extractor",
644
- "url": "https://elis.rossum.ai/api/v1/engines/12345",
645
- "type": "extractor",
646
- "learning_enabled": true,
647
- "training_queues": ["https://elis.rossum.ai/api/v1/queues/100", "https://elis.rossum.ai/api/v1/queues/200"],
648
- "description": "Extracts invoice data",
649
- "agenda_id": "agenda-123",
650
- "organization": "https://elis.rossum.ai/api/v1/organizations/10",
651
- "message": "Engine 'Invoice Extractor' (ID 12345) retrieved successfully"
652
- }
653
- ```
654
-
655
- **Example usage:**
656
- ```python
657
- # Get engine details
658
- engine = get_engine(engine_id=12345)
659
- ```
660
-
661
- #### list_engines
662
-
663
- Lists all engines with optional filtering.
664
-
665
- **Parameters:**
666
- - `id` (integer, optional): Filter by engine ID
667
- - `engine_type` (string, optional): Filter by engine type ('extractor' or 'splitter')
668
- - `agenda_id` (string, optional): Filter by agenda ID
669
-
670
- **Returns:**
671
- ```json
672
- {
673
- "count": 2,
674
- "results": [
675
- {
676
- "id": 12345,
677
- "name": "My Engine",
678
- "url": "https://elis.rossum.ai/api/v1/engines/12345",
679
- "type": "extractor",
680
- "learning_enabled": true,
681
- "training_queues": ["https://elis.rossum.ai/api/v1/queues/100"],
682
- "description": "Engine description",
683
- "agenda_id": "abc123",
684
- "organization": "https://elis.rossum.ai/api/v1/organizations/123"
685
- }
686
- ],
687
- "message": "Retrieved 2 engine(s)"
688
- }
689
- ```
690
-
691
- **Example usage:**
692
- ```python
693
- # List all engines
694
- all_engines = list_engines()
695
-
696
- # List specific engine by ID
697
- engine = list_engines(id=12345)
698
-
699
- # List extractors only
700
- extractors = list_engines(engine_type="extractor")
701
-
702
- # List engines by agenda
703
- agenda_engines = list_engines(agenda_id="abc123")
704
- ```
705
-
706
- #### create_engine
707
-
708
- Creates a new engine for document processing.
709
-
710
- **Parameters:**
711
- - `name` (string, required): Engine name
712
- - `organization_id` (integer, required): Organization ID where the engine should be created
713
- - `engine_type` (string, required): Engine type - either 'extractor' or 'splitter'
714
-
715
- **Returns:**
716
- ```json
717
- {
718
- "id": 12345,
719
- "name": "My Engine",
720
- "url": "https://elis.rossum.ai/api/v1/engines/12345",
721
- "type": "extractor",
722
- "organization": "https://elis.rossum.ai/api/v1/organizations/123",
723
- "message": "Engine 'My Engine' created successfully with ID 12345"
724
- }
725
- ```
726
-
727
- #### update_engine
728
-
729
- Updates an existing engine's settings including learning and training queues.
730
-
731
- **Parameters:**
732
- - `engine_id` (integer, required): Engine ID to update
733
- - `engine_data` (object, required): Dictionary containing engine fields to update
734
- - `name` (string): Engine name
735
- - `description` (string): Engine description
736
- - `learning_enabled` (boolean): Enable/disable learning
737
- - `training_queues` (array): List of queue URLs for training
738
-
739
- **Example:**
740
- ```json
741
- {
742
- "learning_enabled": true,
743
- "training_queues": [
744
- "https://elis.rossum.ai/api/v1/queues/12345",
745
- "https://elis.rossum.ai/api/v1/queues/67890"
746
- ]
747
- }
748
- ```
749
-
750
- **Returns:**
751
- ```json
752
- {
753
- "id": 12345,
754
- "name": "My Engine",
755
- "url": "https://elis.rossum.ai/api/v1/engines/12345",
756
- "type": "extractor",
757
- "learning_enabled": true,
758
- "training_queues": [...],
759
- "description": "Engine description",
760
- "message": "Engine 'My Engine' (ID 12345) updated successfully"
761
- }
762
- ```
763
-
764
- #### get_hook
765
-
766
- Retrieves details of a specific hook/extension by its ID.
767
-
768
- **Parameters:**
769
- - `hook_id` (integer, required): Hook ID
770
-
771
- **Returns:**
772
- ```json
773
- {
774
- "id": 12345,
775
- "name": "Validation Hook",
776
- "url": "https://elis.rossum.ai/api/v1/hooks/12345",
777
- "type": "webhook",
778
- "active": true,
779
- "queues": ["https://elis.rossum.ai/api/v1/queues/100"],
780
- "events": ["annotation_status", "annotation_content"],
781
- "config": {
782
- "url": "https://example.com/webhook",
783
- "secret": "***"
784
- },
785
- "settings": {},
786
- "extension_source": "rossum_store"
787
- }
788
- ```
789
-
790
- **Example usage:**
791
- ```python
792
- # Get hook details
793
- hook = get_hook(hook_id=12345)
794
- ```
795
-
796
- #### list_hooks
797
-
798
- Lists all hooks/extensions configured in your organization. Hooks (also called extensions) are webhooks or serverless functions that respond to Rossum events.
799
-
800
- **Parameters:**
801
- - `queue_id` (integer, optional): Filter hooks by queue ID
802
- - `active` (boolean, optional): Filter by active status (true for active hooks, false for inactive)
803
-
804
- **Returns:**
805
- ```json
806
- {
807
- "count": 2,
808
- "results": [
809
- {
810
- "id": 12345,
811
- "name": "Validation Hook",
812
- "url": "https://elis.rossum.ai/api/v1/hooks/12345",
813
- "type": "webhook",
814
- "active": true,
815
- "queues": ["https://elis.rossum.ai/api/v1/queues/100"],
816
- "events": ["annotation_status", "annotation_content"],
817
- "config": {
818
- "url": "https://example.com/webhook",
819
- "secret": "***"
820
- },
821
- "extension_source": "rossum_store"
822
- }
823
- ]
824
- }
825
- ```
826
-
827
- **Example usage:**
828
- ```python
829
- # List all hooks
830
- all_hooks = list_hooks()
831
-
832
- # List hooks for a specific queue
833
- queue_hooks = list_hooks(queue_id=12345)
834
-
835
- # List only active hooks
836
- active_hooks = list_hooks(active=True)
837
-
838
- # List inactive hooks for a queue
839
- inactive_queue_hooks = list_hooks(queue_id=12345, active=False)
840
- ```
841
-
842
- #### create_hook
843
-
844
- Creates a new hook (webhook or serverless function). Hooks respond to Rossum events and can be used for custom validation, data enrichment, or integration with external systems.
845
-
846
- **Parameters:**
847
- - `name` (string, required): Hook name
848
- - `type` (string, required): Hook type - either 'webhook' or 'function'
849
- - `queues` (array, optional): List of queue URLs to attach the hook to. If not provided, hook applies to all queues
850
- - Format: `["https://api.elis.rossum.ai/v1/queues/12345"]`
851
- - `events` (array, optional): List of events that trigger the hook. Common events:
852
- - `annotation_content.initialize` - When annotation is first created
853
- - `annotation_content.confirm` - When annotation is confirmed
854
- - `annotation_content.export` - When annotation is exported
855
- - `annotation_status` - When annotation status changes
856
- - `annotation_content` - When annotation content changes
857
- - `datapoint_value` - When individual field value changes
858
- - `config` (object, optional): Hook configuration
859
- - For webhook: `{"url": "https://example.com/webhook"}`
860
- - For function: `{"runtime": "python3.12", "function": "import json\ndef rossum_hook_request_handler(payload):\n return {}"}`
861
- - `settings` (object, optional): Specific settings included in the payload when executing the hook
862
- - `secret` (string, optional): Secret key for securing webhook requests
863
-
864
- **Returns:**
865
- ```json
866
- {
867
- "id": 12345,
868
- "name": "My Hook",
869
- "url": "https://elis.rossum.ai/api/v1/hooks/12345",
870
- "enabled": true,
871
- "queues": ["https://elis.rossum.ai/api/v1/queues/100"],
872
- "events": ["annotation_content.initialize"],
873
- "config": {"runtime": "python3.12", "function": "..."},
874
- "settings": {"custom_key": "custom_value"},
875
- "message": "Hook 'My Hook' created successfully with ID 12345"
876
- }
877
- ```
878
-
879
- **Example usage:**
880
- ```python
881
- # Create a serverless function hook
882
- create_hook(
883
- name="Splitting & Sorting",
884
- type="function",
885
- queues=["https://api.elis.rossum.ai/v1/queues/12345"],
886
- events=["annotation_content.initialize", "annotation_content.confirm"],
887
- config={"runtime": "python3.12", "function": "import json\ndef rossum_hook_request_handler(payload):\n return {}"},
888
- settings={"sorting_queues": {"A": 1, "B": 2}}
889
- )
890
-
891
- # Create a webhook hook
892
- create_hook(
893
- name="External Validation",
894
- type="webhook",
895
- queues=["https://api.elis.rossum.ai/v1/queues/12345"],
896
- events=["annotation_content.confirm"],
897
- config={"url": "https://example.com/validate"},
898
- secret="webhook_secret_123"
899
- )
900
- ```
901
-
902
- #### update_hook
903
-
904
- Updates an existing hook. Use this to modify hook properties like name, queues, config, events, or settings. Only provide the fields you want to change - other fields will remain unchanged.
905
-
906
- **Parameters:**
907
- - `hook_id` (integer, required): The ID of the hook to update
908
- - `name` (string, optional): New hook name
909
- - `queues` (array, optional): New list of queue URLs
910
- - `events` (array, optional): New list of events that trigger the hook
911
- - `config` (object, optional): New hook configuration
912
- - `settings` (object, optional): New hook settings
913
- - `active` (boolean, optional): Enable or disable the hook
914
-
915
- **Returns:**
916
- ```json
917
- {
918
- "id": 12345,
919
- "name": "Updated Hook Name",
920
- "url": "https://elis.rossum.ai/api/v1/hooks/12345",
921
- "active": true,
922
- "queues": ["https://elis.rossum.ai/api/v1/queues/100"],
923
- "events": ["annotation_content.initialize", "annotation_content.confirm"],
924
- "config": {"runtime": "python3.12", "function": "..."},
925
- "settings": {"updated_key": "updated_value"}
926
- }
927
- ```
928
-
929
- **Example usage:**
930
- ```python
931
- # Update hook name and add a new event
932
- update_hook(
933
- hook_id=12345,
934
- name="Renamed Hook",
935
- events=["annotation_content.initialize", "annotation_content.confirm"]
936
- )
937
-
938
- # Disable a hook
939
- update_hook(hook_id=12345, active=False)
940
-
941
- # Update hook settings
942
- update_hook(hook_id=12345, settings={"new_setting": "value"})
943
- ```
944
-
945
- #### list_hook_templates
946
-
947
- Lists available hook templates from Rossum Store. Hook templates provide pre-built extension configurations (e.g., data validation, field mapping, notifications) that can be used to quickly create hooks instead of writing code from scratch.
948
-
949
- **Parameters:**
950
- None
951
-
952
- **Returns:**
953
- ```json
954
- [
955
- {
956
- "id": 5,
957
- "url": "https://elis.rossum.ai/api/v1/hook_templates/5",
958
- "name": "Document Splitting",
959
- "description": "Automatically split multi-page documents into separate annotations",
960
- "type": "function",
961
- "events": ["annotation_content.initialize"],
962
- "config": {"runtime": "python3.12", "function": "..."},
963
- "settings_schema": {"type": "object", "properties": {...}},
964
- "guide": "https://knowledge-base.rossum.ai/docs/..."
965
- }
966
- ]
967
- ```
968
-
969
- **Example usage:**
970
- ```python
971
- # List all available hook templates
972
- templates = list_hook_templates()
973
-
974
- # Find a template by name
975
- for template in templates:
976
- if "splitting" in template.name.lower():
977
- print(f"Found: {template.name} (ID: {template.id})")
978
- ```
979
-
980
- #### create_hook_from_template
981
-
982
- Creates a hook from a Rossum Store template. Use `list_hook_templates` first to find available templates and their IDs. This is the recommended way to create hooks as it uses battle-tested configurations from the Rossum Store.
983
-
984
- **Parameters:**
985
- - `name` (string, required): Name for the new hook
986
- - `hook_template_id` (integer, required): ID of the hook template to use (from `list_hook_templates`)
987
- - `queues` (array, required): List of queue URLs to attach the hook to
988
- - `events` (array, optional): List of events to trigger the hook (overrides template defaults if provided)
989
- - `token_owner` (string, optional): User URL for token ownership. Required when the hook template has `use_token_owner=True`. Use `list_users` to find the user URL by username.
990
-
991
- **Important:** If the hook template has `use_token_owner=True`, you must provide the `token_owner` parameter with a valid user URL. Ask the user for their username and use `list_users` to find the correct user URL.
992
-
993
- **Returns:**
994
- ```json
995
- {
996
- "id": 12345,
997
- "name": "My Document Splitting Hook",
998
- "url": "https://elis.rossum.ai/api/v1/hooks/12345",
999
- "hook_template": "https://elis.rossum.ai/api/v1/hook_templates/5",
1000
- "type": "function",
1001
- "queues": ["https://elis.rossum.ai/api/v1/queues/100"],
1002
- "events": ["annotation_content.initialize"],
1003
- "config": {...},
1004
- "settings": {...}
1005
- }
1006
- ```
1007
-
1008
- **Example usage:**
1009
- ```python
1010
- # Create a hook from template
1011
- create_hook_from_template(
1012
- name="Invoice Splitting",
1013
- hook_template_id=5,
1014
- queues=["https://api.elis.rossum.ai/v1/queues/12345"],
1015
- settings={"split_by": "barcode", "target_queue": 67890}
1016
- )
1017
-
1018
- # Create a hook with token_owner (for templates with use_token_owner=True)
1019
- create_hook_from_template(
1020
- name="Data Export Hook",
1021
- hook_template_id=17,
1022
- queues=["https://api.elis.rossum.ai/v1/queues/12345"],
1023
- token_owner="https://api.elis.rossum.ai/v1/users/456"
1024
- )
1025
- ```
1026
-
1027
- #### list_hook_logs
1028
-
1029
- Lists hook execution logs for debugging, monitoring performance, and troubleshooting errors. Logs are retained for 7 days and at most 100 logs are returned per call.
1030
-
1031
- **Parameters:**
1032
- - `hook_id` (integer, optional): Filter by hook ID
1033
- - `queue_id` (integer, optional): Filter by queue ID
1034
- - `annotation_id` (integer, optional): Filter by annotation ID
1035
- - `email_id` (integer, optional): Filter by email ID
1036
- - `log_level` (string, optional): Filter by log level - 'INFO', 'ERROR', or 'WARNING'
1037
- - `status` (string, optional): Filter by execution status
1038
- - `status_code` (integer, optional): Filter by HTTP status code
1039
- - `request_id` (string, optional): Filter by request ID
1040
- - `timestamp_before` (string, optional): ISO 8601 timestamp, filter logs triggered before this time
1041
- - `timestamp_after` (string, optional): ISO 8601 timestamp, filter logs triggered after this time
1042
- - `start_before` (string, optional): ISO 8601 timestamp, filter logs started before this time
1043
- - `start_after` (string, optional): ISO 8601 timestamp, filter logs started after this time
1044
- - `end_before` (string, optional): ISO 8601 timestamp, filter logs ended before this time
1045
- - `end_after` (string, optional): ISO 8601 timestamp, filter logs ended after this time
1046
- - `search` (string, optional): Full-text search across log messages
1047
- - `page_size` (integer, optional): Number of results per page (default 100, max 100)
1048
-
1049
- **Returns:**
1050
- ```json
1051
- {
1052
- "count": 2,
1053
- "results": [
1054
- {
1055
- "log_level": "INFO",
1056
- "action": "initialize",
1057
- "event": "annotation_content",
1058
- "request_id": "abc123",
1059
- "organization_id": 100,
1060
- "hook_id": 12345,
1061
- "hook_type": "function",
1062
- "queue_id": 200,
1063
- "annotation_id": 300,
1064
- "message": "Hook executed successfully",
1065
- "start": "2024-01-01T00:00:00Z",
1066
- "end": "2024-01-01T00:00:01Z",
1067
- "status": "success",
1068
- "status_code": 200,
1069
- "timestamp": "2024-01-01T00:00:00Z",
1070
- "uuid": "uuid-here"
1071
- }
1072
- ]
1073
- }
1074
- ```
1075
-
1076
- **Example usage:**
1077
- ```python
1078
- # List all logs for a specific hook
1079
- logs = list_hook_logs(hook_id=12345)
1080
-
1081
- # List error logs only
1082
- error_logs = list_hook_logs(log_level="ERROR")
1083
-
1084
- # List logs for a specific annotation
1085
- annotation_logs = list_hook_logs(annotation_id=300)
1086
-
1087
- # Search logs by message content
1088
- search_logs = list_hook_logs(search="validation failed")
1089
-
1090
- # List logs from the last hour
1091
- from datetime import datetime, timedelta
1092
- one_hour_ago = (datetime.utcnow() - timedelta(hours=1)).isoformat() + "Z"
1093
- recent_logs = list_hook_logs(timestamp_after=one_hour_ago)
1094
- ```
1095
-
1096
- #### create_engine_field
1097
-
1098
- Creates a new engine field and links it to schemas. Engine fields define what data the engine extracts and must be created for each field in the schema when setting up an engine.
1099
-
1100
- **Parameters:**
1101
- - `engine_id` (integer, required): Engine ID to which this field belongs
1102
- - `name` (string, required): Field name (slug format, max 50 chars)
1103
- - `label` (string, required): Human-readable label (max 100 chars)
1104
- - `field_type` (string, required): Field type - 'string', 'number', 'date', or 'enum'
1105
- - `schema_ids` (array, required): List of schema IDs to link this engine field to (at least one required)
1106
- - `tabular` (boolean, optional): Whether this field is in a table (default: false)
1107
- - `multiline` (string, optional): Multiline setting - 'true', 'false', or '' (default: 'false')
1108
- - `subtype` (string, optional): Optional field subtype (max 50 chars)
1109
- - `pre_trained_field_id` (string, optional): Optional pre-trained field ID (max 50 chars)
1110
-
1111
- **Returns:**
1112
- ```json
1113
- {
1114
- "id": 12345,
1115
- "name": "invoice_number",
1116
- "label": "Invoice Number",
1117
- "url": "https://elis.rossum.ai/api/v1/engine_fields/12345",
1118
- "type": "string",
1119
- "engine": "https://elis.rossum.ai/api/v1/engines/123",
1120
- "tabular": false,
1121
- "multiline": "false",
1122
- "schema_ids": [456, 789],
1123
- "message": "Engine field 'Invoice Number' created successfully with ID 12345 and linked to 2 schema(s)"
1124
- }
1125
- ```
1126
-
1127
- #### get_engine_fields
1128
-
1129
- Retrieves engine fields for a specific engine or all engine fields.
1130
-
1131
- **Parameters:**
1132
- - `engine_id` (integer, optional): Engine ID to filter fields by. If not provided, retrieves all engine fields.
1133
-
1134
- **Returns:**
1135
- ```json
1136
- {
1137
- "count": 2,
1138
- "results": [
1139
- {
1140
- "id": 12345,
1141
- "url": "https://elis.rossum.ai/api/v1/engine_fields/12345",
1142
- "engine": "https://elis.rossum.ai/api/v1/engines/123",
1143
- "name": "invoice_number",
1144
- "label": "Invoice Number",
1145
- "type": "string",
1146
- "subtype": null,
1147
- "tabular": false,
1148
- "multiline": "false",
1149
- "pre_trained_field_id": null,
1150
- "schemas": ["https://elis.rossum.ai/api/v1/schemas/456"]
1151
- },
1152
- {
1153
- "id": 12346,
1154
- "url": "https://elis.rossum.ai/api/v1/engine_fields/12346",
1155
- "engine": "https://elis.rossum.ai/api/v1/engines/123",
1156
- "name": "invoice_date",
1157
- "label": "Invoice Date",
1158
- "type": "date",
1159
- "subtype": null,
1160
- "tabular": false,
1161
- "multiline": "false",
1162
- "pre_trained_field_id": null,
1163
- "schemas": ["https://elis.rossum.ai/api/v1/schemas/456"]
1164
- }
1165
- ]
1166
- }
1167
- ```
1168
-
1169
- **Example usage:**
1170
- ```python
1171
- # Get all engine fields for a specific engine
1172
- engine_fields = get_engine_fields(engine_id=123)
1173
-
1174
- # Get all engine fields
1175
- all_fields = get_engine_fields()
1176
- ```
1177
-
1178
- ### User Management
1179
-
1180
- #### get_user
1181
-
1182
- Retrieves a single user by ID. Use `list_users` first to find users by username or email.
1183
-
1184
- **Parameters:**
1185
- - `user_id` (integer, required): The user ID to retrieve
1186
-
1187
- **Returns:**
1188
- ```json
1189
- {
1190
- "id": 12345,
1191
- "url": "https://elis.rossum.ai/api/v1/users/12345",
1192
- "username": "john.doe@example.com",
1193
- "first_name": "John",
1194
- "last_name": "Doe",
1195
- "email": "john.doe@example.com",
1196
- "organization": "https://elis.rossum.ai/api/v1/organizations/100",
1197
- "is_active": true,
1198
- "date_joined": "2024-01-01T00:00:00Z",
1199
- "last_login": "2024-01-15T10:30:00Z"
1200
- }
1201
- ```
1202
-
1203
- #### list_users
1204
-
1205
- Lists users in the organization. Use this to find a user's URL when you need it for `token_owner` in `create_hook_from_template`.
1206
-
1207
- **Parameters:**
1208
- - `username` (string, optional): Filter by exact username
1209
- - `email` (string, optional): Filter by email address
1210
- - `first_name` (string, optional): Filter by first name
1211
- - `last_name` (string, optional): Filter by last name
1212
- - `is_active` (boolean, optional): Filter by active status
1213
- - `is_organization_group_admin` (boolean, optional): Filter by organization group admin role. Use `false` to exclude admin users (e.g., when finding users for `token_owner`)
1214
-
1215
- **Returns:**
1216
- ```json
1217
- [
1218
- {
1219
- "id": 12345,
1220
- "url": "https://elis.rossum.ai/api/v1/users/12345",
1221
- "username": "john.doe@example.com",
1222
- "first_name": "John",
1223
- "last_name": "Doe",
1224
- "email": "john.doe@example.com",
1225
- "organization": "https://elis.rossum.ai/api/v1/organizations/100",
1226
- "is_active": true
1227
- }
1228
- ]
1229
- ```
1230
-
1231
- **Example usage:**
1232
- ```python
1233
- # Find user by username to get their URL for token_owner
1234
- users = list_users(username="john.doe@example.com")
1235
- if users:
1236
- user_url = users[0].url
1237
- # Use user_url in create_hook_from_template
1238
-
1239
- # Find non-admin users suitable for token_owner
1240
- non_admin_users = list_users(is_organization_group_admin=False)
1241
- ```
1242
-
1243
- #### list_user_roles
1244
-
1245
- Lists all user roles (groups of permissions) in the organization. Useful for understanding what roles are available and identifying users with specific permissions.
1246
-
1247
- **Parameters:**
1248
- None
1249
-
1250
- **Returns:**
1251
- ```json
1252
- [
1253
- {
1254
- "id": 12345,
1255
- "url": "https://elis.rossum.ai/api/v1/groups/12345",
1256
- "name": "admin",
1257
- "organization": "https://elis.rossum.ai/api/v1/organizations/100"
1258
- },
1259
- {
1260
- "id": 12346,
1261
- "url": "https://elis.rossum.ai/api/v1/groups/12346",
1262
- "name": "annotator",
1263
- "organization": "https://elis.rossum.ai/api/v1/organizations/100"
1264
- }
1265
- ]
1266
- ```
1267
-
1268
- **Example usage:**
1269
- ```python
1270
- # List all available roles
1271
- roles = list_user_roles()
1272
- ```
1273
-
1274
- ### Rules Management
1275
-
1276
- #### get_rule
1277
-
1278
- Retrieves details of a specific business rule by its ID.
1279
-
1280
- **Parameters:**
1281
- - `rule_id` (integer, required): Rule ID
1282
-
1283
- **Returns:**
1284
- ```json
1285
- {
1286
- "id": 12345,
1287
- "name": "Auto-calculate Total",
1288
- "url": "https://elis.rossum.ai/api/v1/rules/12345",
1289
- "enabled": true,
1290
- "organization": "https://elis.rossum.ai/api/v1/organizations/100",
1291
- "schema": "https://elis.rossum.ai/api/v1/schemas/200",
1292
- "trigger_condition": "field.amount_total.changed",
1293
- "created_by": "https://elis.rossum.ai/api/v1/users/300",
1294
- "created_at": "2024-01-01T00:00:00Z",
1295
- "modified_by": "https://elis.rossum.ai/api/v1/users/300",
1296
- "modified_at": "2024-01-01T00:00:00Z",
1297
- "rule_template": null,
1298
- "synchronized_from_template": false,
1299
- "actions": [
1300
- {
1301
- "id": 54321,
1302
- "type": "set_datapoint_value",
1303
- "payload": {
1304
- "datapoint_id": "tax_amount",
1305
- "value": "field.amount_total.value * 0.2"
1306
- },
1307
- "event": "trigger",
1308
- "enabled": true
1309
- }
1310
- ]
1311
- }
1312
- ```
1313
-
1314
- **Example usage:**
1315
- ```python
1316
- # Get rule details
1317
- rule = get_rule(rule_id=12345)
1318
- ```
1319
-
1320
- #### list_rules
1321
-
1322
- Lists all business rules configured in your organization. Rules define custom business logic with trigger conditions (TxScript formulas) and actions that execute when conditions are met.
1323
-
1324
- **Parameters:**
1325
- - `schema_id` (integer, optional): Filter rules by schema ID
1326
- - `organization_id` (integer, optional): Filter rules by organization ID
1327
- - `enabled` (boolean, optional): Filter by enabled status (true for enabled rules, false for disabled)
1328
-
1329
- **Returns:**
1330
- ```json
1331
- {
1332
- "count": 2,
1333
- "results": [
1334
- {
1335
- "id": 12345,
1336
- "name": "Auto-calculate Total",
1337
- "url": "https://elis.rossum.ai/api/v1/rules/12345",
1338
- "enabled": true,
1339
- "organization": "https://elis.rossum.ai/api/v1/organizations/100",
1340
- "schema": "https://elis.rossum.ai/api/v1/schemas/200",
1341
- "trigger_condition": "field.amount_total.changed",
1342
- "created_by": "https://elis.rossum.ai/api/v1/users/300",
1343
- "created_at": "2024-01-01T00:00:00Z",
1344
- "modified_by": "https://elis.rossum.ai/api/v1/users/300",
1345
- "modified_at": "2024-01-01T00:00:00Z",
1346
- "rule_template": null,
1347
- "synchronized_from_template": false,
1348
- "actions": [
1349
- {
1350
- "id": 54321,
1351
- "type": "set_datapoint_value",
1352
- "payload": {
1353
- "datapoint_id": "tax_amount",
1354
- "value": "field.amount_total.value * 0.2"
1355
- },
1356
- "event": "trigger",
1357
- "enabled": true
1358
- }
1359
- ]
1360
- }
1361
- ]
1362
- }
1363
- ```
1364
-
1365
- **Example usage:**
1366
- ```python
1367
- # List all rules
1368
- all_rules = list_rules()
1369
-
1370
- # List rules for a specific schema
1371
- schema_rules = list_rules(schema_id=12345)
1372
-
1373
- # List only enabled rules
1374
- enabled_rules = list_rules(enabled=True)
1375
-
1376
- # List enabled rules for a specific organization
1377
- org_enabled_rules = list_rules(organization_id=100, enabled=True)
1378
- ```
1379
-
1380
- ### Relations Management
1381
-
1382
- #### get_relation
1383
-
1384
- Retrieves details of a specific relation by its ID. Relations introduce common relations between annotations.
1385
-
1386
- **Parameters:**
1387
- - `relation_id` (integer, required): Relation ID
1388
-
1389
- **Returns:**
1390
- ```json
1391
- {
1392
- "id": 12345,
1393
- "type": "duplicate",
1394
- "key": "abc123def456",
1395
- "parent": "https://elis.rossum.ai/api/v1/annotations/100",
1396
- "annotations": [
1397
- "https://elis.rossum.ai/api/v1/annotations/100",
1398
- "https://elis.rossum.ai/api/v1/annotations/101"
1399
- ],
1400
- "url": "https://elis.rossum.ai/api/v1/relations/12345"
1401
- }
1402
- ```
1403
-
1404
- **Example usage:**
1405
- ```python
1406
- # Get relation details
1407
- relation = get_relation(relation_id=12345)
1408
- ```
1409
-
1410
- #### list_relations
1411
-
1412
- Lists all relations between annotations with optional filters. Relations introduce common relations between annotations:
1413
- - **edit**: Created after editing annotation in user interface (rotation or split of the document)
1414
- - **attachment**: One or more documents are attachments to another document
1415
- - **duplicate**: Created after importing the same document that already exists in Rossum
1416
-
1417
- **Parameters:**
1418
- - `id` (integer, optional): Filter by relation ID
1419
- - `type` (string, optional): Filter by relation type ('edit', 'attachment', 'duplicate')
1420
- - `parent` (integer, optional): Filter by parent annotation ID
1421
- - `key` (string, optional): Filter by relation key
1422
- - `annotation` (integer, optional): Filter by annotation ID
1423
-
1424
- **Returns:**
1425
- ```json
1426
- {
1427
- "count": 2,
1428
- "results": [
1429
- {
1430
- "id": 12345,
1431
- "type": "duplicate",
1432
- "key": "abc123def456",
1433
- "parent": "https://elis.rossum.ai/api/v1/annotations/100",
1434
- "annotations": [
1435
- "https://elis.rossum.ai/api/v1/annotations/100",
1436
- "https://elis.rossum.ai/api/v1/annotations/101"
1437
- ],
1438
- "url": "https://elis.rossum.ai/api/v1/relations/12345"
1439
- },
1440
- {
1441
- "id": 12346,
1442
- "type": "edit",
1443
- "key": null,
1444
- "parent": "https://elis.rossum.ai/api/v1/annotations/200",
1445
- "annotations": [
1446
- "https://elis.rossum.ai/api/v1/annotations/201",
1447
- "https://elis.rossum.ai/api/v1/annotations/202"
1448
- ],
1449
- "url": "https://elis.rossum.ai/api/v1/relations/12346"
1450
- }
1451
- ]
1452
- }
1453
- ```
1454
-
1455
- **Example usage:**
1456
- ```python
1457
- # List all relations
1458
- all_relations = list_relations()
1459
-
1460
- # List duplicate relations
1461
- duplicate_relations = list_relations(type="duplicate")
1462
-
1463
- # List relations for a specific parent annotation
1464
- parent_relations = list_relations(parent=12345)
1465
-
1466
- # List relations containing a specific annotation
1467
- annotation_relations = list_relations(annotation=12345)
1468
- ```
1469
-
1470
- #### get_document_relation
1471
-
1472
- Retrieves details of a specific document relation by its ID. Document relations introduce additional relations between annotations and documents.
1473
-
1474
- **Parameters:**
1475
- - `document_relation_id` (integer, required): Document relation ID
1476
-
1477
- **Returns:**
1478
- ```json
1479
- {
1480
- "id": 12345,
1481
- "type": "export",
1482
- "annotation": "https://elis.rossum.ai/api/v1/annotations/100",
1483
- "key": "exported_file_key",
1484
- "documents": [
1485
- "https://elis.rossum.ai/api/v1/documents/200",
1486
- "https://elis.rossum.ai/api/v1/documents/201"
1487
- ],
1488
- "url": "https://elis.rossum.ai/api/v1/document_relations/12345"
1489
- }
1490
- ```
1491
-
1492
- **Example usage:**
1493
- ```python
1494
- # Get document relation details
1495
- doc_relation = get_document_relation(document_relation_id=12345)
1496
- ```
1497
-
1498
- #### list_document_relations
1499
-
1500
- Lists all document relations with optional filters. Document relations introduce additional relations between annotations and documents:
1501
- - **export**: Documents generated from exporting an annotation
1502
- - **einvoice**: Electronic invoice documents associated with an annotation
1503
-
1504
- **Parameters:**
1505
- - `id` (integer, optional): Filter by document relation ID
1506
- - `type` (string, optional): Filter by relation type ('export', 'einvoice')
1507
- - `annotation` (integer, optional): Filter by annotation ID
1508
- - `key` (string, optional): Filter by relation key
1509
- - `documents` (integer, optional): Filter by document ID
1510
-
1511
- **Returns:**
1512
- ```json
1513
- {
1514
- "count": 2,
1515
- "results": [
1516
- {
1517
- "id": 12345,
1518
- "type": "export",
1519
- "annotation": "https://elis.rossum.ai/api/v1/annotations/100",
1520
- "key": "exported_file_key",
1521
- "documents": [
1522
- "https://elis.rossum.ai/api/v1/documents/200",
1523
- "https://elis.rossum.ai/api/v1/documents/201"
1524
- ],
1525
- "url": "https://elis.rossum.ai/api/v1/document_relations/12345"
1526
- },
1527
- {
1528
- "id": 12346,
1529
- "type": "einvoice",
1530
- "annotation": "https://elis.rossum.ai/api/v1/annotations/102",
1531
- "key": null,
1532
- "documents": [
1533
- "https://elis.rossum.ai/api/v1/documents/300"
1534
- ],
1535
- "url": "https://elis.rossum.ai/api/v1/document_relations/12346"
1536
- }
1537
- ]
1538
- }
1539
- ```
1540
-
1541
- **Example usage:**
1542
- ```python
1543
- # List all document relations
1544
- all_doc_relations = list_document_relations()
1545
-
1546
- # List export-type document relations
1547
- export_relations = list_document_relations(type="export")
1548
-
1549
- # List document relations for a specific annotation
1550
- annotation_doc_relations = list_document_relations(annotation=100)
1551
-
1552
- # List document relations containing a specific document
1553
- document_relations = list_document_relations(documents=200)
1554
- ```
1555
-
1556
- ### Email Templates
1557
-
1558
- #### get_email_template
1559
-
1560
- Retrieves details of a specific email template by its ID.
1561
-
1562
- **Parameters:**
1563
- - `email_template_id` (integer, required): Email template ID
1564
-
1565
- **Returns:**
1566
- ```json
1567
- {
1568
- "id": 1500,
1569
- "name": "Rejection Email",
1570
- "url": "https://elis.rossum.ai/api/v1/email_templates/1500",
1571
- "queue": "https://elis.rossum.ai/api/v1/queues/8199",
1572
- "organization": "https://elis.rossum.ai/api/v1/organizations/1",
1573
- "subject": "Document Rejected",
1574
- "message": "<p>Your document has been rejected.</p>",
1575
- "type": "rejection",
1576
- "enabled": true,
1577
- "automate": false,
1578
- "triggers": [],
1579
- "to": [{"type": "annotator", "value": ""}],
1580
- "cc": [],
1581
- "bcc": []
1582
- }
1583
- ```
1584
-
1585
- **Example usage:**
1586
- ```python
1587
- # Get email template details
1588
- template = get_email_template(email_template_id=1500)
1589
- ```
1590
-
1591
- #### list_email_templates
1592
-
1593
- Lists all email templates with optional filters. Email templates define automated or manual email responses sent from Rossum queues.
1594
-
1595
- **Parameters:**
1596
- - `queue_id` (integer, optional): Filter by queue ID
1597
- - `type` (string, optional): Filter by template type ('rejection', 'rejection_default', 'email_with_no_processable_attachments', 'custom')
1598
- - `name` (string, optional): Filter by template name
1599
- - `first_n` (integer, optional): Limit results to first N templates
1600
-
1601
- **Returns:**
1602
- ```json
1603
- {
1604
- "count": 2,
1605
- "results": [
1606
- {
1607
- "id": 1500,
1608
- "name": "Rejection Email",
1609
- "type": "rejection",
1610
- "queue": "https://elis.rossum.ai/api/v1/queues/8199",
1611
- "automate": false
1612
- },
1613
- {
1614
- "id": 1501,
1615
- "name": "No Attachments Notification",
1616
- "type": "email_with_no_processable_attachments",
1617
- "queue": "https://elis.rossum.ai/api/v1/queues/8199",
1618
- "automate": true
1619
- }
1620
- ]
1621
- }
1622
- ```
1623
-
1624
- **Example usage:**
1625
- ```python
1626
- # List all email templates
1627
- all_templates = list_email_templates()
1628
-
1629
- # List email templates for a specific queue
1630
- queue_templates = list_email_templates(queue_id=8199)
1631
-
1632
- # List rejection templates
1633
- rejection_templates = list_email_templates(type="rejection")
1634
-
1635
- # List first 5 templates
1636
- first_templates = list_email_templates(first_n=5)
1637
- ```
1638
-
1639
- #### create_email_template
1640
-
1641
- Creates a new email template. Templates can be automated to send emails automatically on specific triggers, or manual for user-initiated sending.
1642
-
1643
- **Parameters:**
1644
- - `name` (string, required): Name of the email template
1645
- - `queue` (string, required): URL of the queue to associate with
1646
- - `subject` (string, required): Email subject line
1647
- - `message` (string, required): Email body (HTML supported)
1648
- - `type` (string, optional): Template type - 'rejection', 'rejection_default', 'email_with_no_processable_attachments', 'custom' (default: 'custom')
1649
- - `automate` (boolean, optional): If true, email is sent automatically on trigger (default: false)
1650
- - `to` (array, optional): List of recipient objects with 'type' and 'value' keys
1651
- - `cc` (array, optional): List of CC recipient objects
1652
- - `bcc` (array, optional): List of BCC recipient objects
1653
- - `triggers` (array, optional): List of trigger URLs
1654
-
1655
- **Recipient object types:**
1656
- - `{"type": "annotator", "value": ""}` - Send to the document annotator
1657
- - `{"type": "constant", "value": "email@example.com"}` - Send to a fixed email address
1658
- - `{"type": "datapoint", "value": "email_field_id"}` - Send to email from a datapoint field
1659
-
1660
- **Returns:**
1661
- ```json
1662
- {
1663
- "id": 1502,
1664
- "name": "Custom Notification",
1665
- "url": "https://elis.rossum.ai/api/v1/email_templates/1502",
1666
- "queue": "https://elis.rossum.ai/api/v1/queues/8199",
1667
- "subject": "Document Processed",
1668
- "message": "<p>Your document has been processed.</p>",
1669
- "type": "custom",
1670
- "automate": true,
1671
- "to": [{"type": "constant", "value": "notifications@example.com"}]
1672
- }
1673
- ```
1674
-
1675
- **Example usage:**
1676
- ```python
1677
- # Create a simple custom email template
1678
- template = create_email_template(
1679
- name="Processing Complete",
1680
- queue="https://elis.rossum.ai/api/v1/queues/8199",
1681
- subject="Document Processing Complete",
1682
- message="<p>Your document has been successfully processed.</p>"
1683
- )
1684
-
1685
- # Create an automated rejection template
1686
- template = create_email_template(
1687
- name="Auto Rejection",
1688
- queue="https://elis.rossum.ai/api/v1/queues/8199",
1689
- subject="Document Rejected",
1690
- message="<p>Your document could not be processed.</p>",
1691
- type="rejection",
1692
- automate=True,
1693
- to=[{"type": "annotator", "value": ""}]
1694
- )
1695
-
1696
- # Create template with multiple recipients
1697
- template = create_email_template(
1698
- name="Team Notification",
1699
- queue="https://elis.rossum.ai/api/v1/queues/8199",
1700
- subject="New Document",
1701
- message="<p>A new document has arrived.</p>",
1702
- to=[{"type": "constant", "value": "team@example.com"}],
1703
- cc=[{"type": "datapoint", "value": "sender_email"}]
1704
- )
1705
- ```
1706
-
1707
- ## Annotation Status Workflow
1708
-
1709
- When a document is uploaded, the annotation progresses through various states:
1710
-
1711
- 1. **importing** - Initial state after upload. Document is being processed.
1712
- 2. **to_review** - Extraction complete, ready for user validation.
1713
- 3. **reviewing** - Annotation is being reviewed (triggered by `start_annotation`). This state is required before you can update annotation fields.
1714
- 4. **confirmed** - The annotation has been validated and confirmed (via `confirm_annotation`).
1715
- 5. **exporting** - The annotation is being exported.
1716
- 6. **exported** - Final state for successfully processed documents.
1717
-
1718
- Other possible states include: `created`, `failed_import`, `split`, `in_workflow`, `rejected`, `failed_export`, `postponed`, `deleted`, `purged`.
1719
-
1720
- **Important Notes:**
1721
- - After uploading documents, agents should wait for annotations to transition from `importing` to `to_review` (or later states) before considering them fully processed.
1722
- - To update annotation field values, you must first call `start_annotation` to move the annotation to 'reviewing' status.
1723
- - After updating fields with `bulk_update_annotation_fields`, you can call `confirm_annotation` to move to 'confirmed' status.
1724
-
1725
- ## Example Workflows
1726
-
1727
- <details>
1728
- <summary>Single Document Upload</summary>
1729
-
1730
- 1. Upload a document using `upload_document`
1731
- 2. Get the annotation ID using `list_annotations`
1732
- 3. Check annotation status using `get_annotation`
1733
- 4. Wait until status is `to_review`, `confirmed`, or `exported`
1734
-
1735
- </details>
1736
-
1737
- <details>
1738
- <summary>Document Upload with Field Updates</summary>
1739
-
1740
- 1. Upload a document using `upload_document`
1741
- 2. Get the annotation ID using `list_annotations`
1742
- 3. Wait until status is `importing` or `to_review`
1743
- 4. Start the annotation using `start_annotation` (moves to 'reviewing')
1744
- 5. Get annotation content using `get_annotation` with `sideloads=['content']`
1745
- 6. Update field values using `bulk_update_annotation_fields` with datapoint IDs from content
1746
- 7. Confirm the annotation using `confirm_annotation` (moves to 'confirmed')
1747
-
1748
- </details>
1749
-
1750
- <details>
1751
- <summary>Bulk Document Upload</summary>
1752
-
1753
- 1. Upload all documents in bulk using `upload_document` for each file
1754
- 2. Check status of all annotations using `list_annotations`
1755
- 3. Monitor until all documents finish processing
1756
-
1757
- </details>
1758
-
1759
- <details>
1760
- <summary>Create Queue with Engine</summary>
1761
-
1762
- 1. Create a schema using `create_schema` with sections and datapoints
1763
- 2. Create an engine using `create_engine` with type 'extractor' or 'splitter'
1764
- 3. Create engine fields using `create_engine_field` for each schema field
1765
- 4. Create a queue using `create_queue` linking the schema and engine
1766
- 5. Optionally update engine training queues using `update_engine`
1767
-
1768
- </details>
1769
-
1770
- ## Error Handling
1771
-
1772
- The server provides detailed error messages for common issues:
1773
- - Missing API token
1774
- - File not found
1775
- - Upload failures
1776
- - API errors
1777
-
1778
- ## License
1779
-
1780
- MIT License - see LICENSE file for details
1781
-
1782
- ## Resources
1783
-
1784
- - [Rossum API Documentation](https://elis.rossum.ai/api/docs/)
1785
- - [Model Context Protocol](https://modelcontextprotocol.io/)
1786
- - [Rossum SDK](https://github.com/rossumai/rossum-sdk)
1787
- - [Main Repository](https://github.com/stancld/rossum-mcp)