API Clients
The Rossum API SDK provides both synchronous and asynchronous clients for interacting with the Rossum API. Both clients offer identical functionality, so choose the one that best fits your application architecture.
Overview
The external clients are the primary interfaces for interacting with Rossum API. They handle authentication, pagination, error handling, and provide convenient methods for all API operations.
When to use async vs sync:
Use
AsyncRossumAPIClientwhen:Your application is already async-based
You need to make concurrent API calls
You want optimal performance for I/O-bound operations
Use
SyncRossumAPIClientwhen:You’re working in a traditional synchronous application
You’re scripting or prototyping
Asynchronous Client
- class rossum_api.clients.external_async_client.AsyncRossumAPIClient(base_url, credentials, *, deserializer=None, timeout=None, n_retries=3, retry_backoff_factor=1.0, retry_max_jitter=1.0, max_in_flight_requests=4, response_post_processor=None)[source]
Asynchronous Rossum API Client.
- Parameters:
base_url (
str) – Base API URL including the “/api” and version (“/v1”) in the url path. For example “https://elis.rossum.ai/api/v1”.credentials (
UserCredentials|Token) – User credentials or API token used for authentication.deserializer (
Callable[[Resource,dict[str,Any]],TypeVar(RossumApiType)] |None) – Pass a custom deserialization callable if different model classes should be returned.timeout (
float|None) – The timeout configuration (in seconds) to use when sending requests.n_retries (
int) – Number of request retries before raising an exception.retry_backoff_factor (
float) – Backoff factor for exponential backoff between retries (multiplies the delay).retry_max_jitter (
float) – Maximum random jitter (in seconds) added to retry delays.max_in_flight_requests (
int) – Maximum number of concurrent requests allowed.response_post_processor (
Callable[[Response],Any] |None) – pass a custom response post-processing callable. Applied only if http_client is not provided.
- async retrieve_queue(queue_id)[source]
Retrieve a single
Queueobject.- Parameters:
queue_id (
int) – ID of a queue to be retrieved.- Return type:
QueueType
References
- async list_queues(ordering=(), **filters)[source]
Retrieve all
Queueobjects satisfying the specified filters.- Parameters:
ordering (
Sequence[Literal['id','name','workspace','connector','webhooks','schema','inbox','locale']]) – List of object names. Their URLs are used for sorting the resultsfilters (
Any) –id: ID of a
Queue.name: Name of a
Queue.workspace: ID of a
Workspace.inbox: ID of an
Inbox.connector: ID of an
Connector.webhooks: IDs of a
Hook.hooks: IDs of a
Hook.locale:
Queueobject locale.dedicated_engine: ID of a dedicated engine.
generic_engine: ID of a generic engine.
deleting: Boolean filter - queue is being deleted (
delete_afteris set)
- Return type:
AsyncIterator[QueueType]
References
- async create_new_queue(data)[source]
Create a new
Queueobject.References
- async delete_queue(queue_id)[source]
Delete
Queueobject.- Parameters:
queue_id (
int) – ID of a queue to be deleted.
Notes
By default, the deletion will start after 24 hours.
Warning
It also deletes all the related objects. Please note that while the queue and related objects are being deleted the API may return inconsistent results. We strongly discourage from any interaction with the queue after being scheduled for deletion.
References
- async import_document(queue_id, files, values=None, metadata=None)[source]
https://elis.rossum.ai/api/docs/#import-a-document.
Deprecated now, consider upload_document.
- Parameters:
queue_id (
int) – ID of the queue to upload the files tofiles (
Sequence[tuple[str|Path,str]]) – 2-tuple containing current filepath and name to be used by Elis for the uploaded filemetadata (
dict[str,Any] |None) – metadata will be set to newly created annotation objectvalues (
dict[str,Any] |None) – may be used to initialize datapoint values by setting the value of rir_field_names in the schema
- Returns:
list of IDs of created annotations, respects the order of files argument
- Return type:
annotation_ids
- async upload_document(queue_id, files, values=None, metadata=None)[source]
https://elis.rossum.ai/api/docs/#create-upload.
- Parameters:
queue_id (
int) – ID of the queue to upload the files tofiles (
Sequence[tuple[str|Path,str]]) – 2-tuple containing current filepath and name to be used by Elis for the uploaded filemetadata (
dict[str,Any] |None) – metadata will be set to newly created annotation objectvalues (
dict[str,Any] |None) – may be used to initialize datapoint values by setting the value of rir_field_names in the schema
- Returns:
list of Task object responses, respects the order of files argument Tasks can be polled using poll_task and if succeeded, will contain a link to an Upload object that contains info on uploaded documents/annotations
- Return type:
task_responses
- async retrieve_upload(upload_id)[source]
Retrieve rossum_api.models.upload.Upload object.
- Parameters:
upload_id (
int) – ID of an upload to be retrieved.- Return type:
UploadType
References
- async export_annotations_to_json(queue_id, **filters)[source]
Export annotations from the queue to JSON.
Notes
JSON export is paginated and returns the result in a way similar to other list_all methods.
- Parameters:
queue_id (
int) – ID of a queue annotions should be exported from.filters (
Any) –- id
Id of annotation to be exported, multiple ids may be separated by a comma.
- status
Annotationstatus.- modifier
Userid.- arrived_at_before
ISO 8601 timestamp (e.g.
arrived_at_before=2019-11-15).- arrived_at_after
ISO 8601 timestamp (e.g.
arrived_at_after=2019-11-14).- exported_at_after
ISO 8601 timestamp (e.g.
exported_at_after=2019-11-14 12:00:00).- export_failed_at_before
ISO 8601 timestamp (e.g.
export_failed_at_before=2019-11-14 22:00:00).- export_failed_at_after
ISO 8601 timestamp (e.g.
export_failed_at_after=2019-11-14 12:00:00).- page_size
Number of the documents to be exported. To be used together with
pageattribute. See pagination.- page
Number of a page to be exported when using pagination. Useful for exports of large amounts of data. To be used together with the
page_sizeattribute.
- Return type:
AsyncIterator[AnnotationType]
Notes
When the search filter is used, results are limited to 10 000. We suggest narrowing down the search query if there are this many results.
References
- async export_annotations_to_file(queue_id, export_format, **filters)[source]
Export annotations from the queue to a desired export format.
Notes
JSON export is paginated and returns the result in a way similar to other list_all methods.
- Parameters:
queue_id (
int) – ID of a queue annotions should be exported from.export_format (
ExportFileFormats) – Target export format.filters (
Any) –- id
Id of annotation to be exported, multiple ids may be separated by a comma.
- status
Annotationstatus.- modifier
Userid.- arrived_at_before
ISO 8601 timestamp (e.g.
arrived_at_before=2019-11-15).- arrived_at_after
ISO 8601 timestamp (e.g.
arrived_at_after=2019-11-14).- exported_at_after
ISO 8601 timestamp (e.g.
exported_at_after=2019-11-14 12:00:00).- export_failed_at_before
ISO 8601 timestamp (e.g.
export_failed_at_before=2019-11-14 22:00:00).- export_failed_at_after
ISO 8601 timestamp (e.g.
export_failed_at_after=2019-11-14 12:00:00).- page_size
Number of the documents to be exported. To be used together with
pageattribute. See pagination.- page
Number of a page to be exported when using pagination. Useful for exports of large amounts of data. To be used together with the
page_sizeattribute.
- Return type:
Notes
When the search filter is used, results are limited to 10 000. We suggest narrowing down the search query if there are this many results.
References
- async list_organizations(ordering=(), **filters)[source]
Retrieve all organization objects satisfying the specified filters.
- Parameters:
ordering (
Sequence[Literal['id','name']]) – List of object names. Their IDs are used for sorting the resultsfilters (
Any) –id: ID of a
Organizationname: Name of a
Organization
- Return type:
AsyncIterator[OrganizationType]
References
- async retrieve_organization(org_id)[source]
Retrieve a single
Qrganizationobject.- Parameters:
org_id (
int) – ID of an organization to be retrieved.- Return type:
OrganizationType
References
- async retrieve_own_organization()[source]
Retrieve organization of currently logged in user.
- Return type:
OrganizationType
- async list_schemas(ordering=(), **filters)[source]
Retrieve all
Schemaobjects satisfying the specified filters.- Parameters:
- Return type:
AsyncIterator[SchemaType]
References
- async retrieve_schema(schema_id)[source]
Retrieve a single
Schemaobject.- Parameters:
schema_id (
int) – ID of a schema to be retrieved.- Return type:
SchemaType
References
- async create_new_schema(data)[source]
Create a new
Schemaobject.References
- async delete_schema(schema_id)[source]
Delete
Schemaobject.- Parameters:
schema_id (
int) – ID of a schema to be deleted.
Warning
In case the schema is linked to some objects, like queue or annotation, the deletion is not possible and the request will fail with 409 status code.
References
- async list_users(ordering=(), **filters)[source]
Retrieve all
Userobjects satisfying the specified filters.- Parameters:
ordering (
Sequence[Literal['id','username','first_name','last_name','email','last_login','date_joined','deleted','not_deleted']]) – List of object names. Their URLs are used for sorting the resultsfilters (
Any) –id: ID of a
Userorganization: ID of an
Organizationusername: Username of a
Userfirst_name: First name of a
Userlast_name: Last name of a
Useremail: Email address of a
Useris_active: Boolean filter - whether the
Useris activelast_login: ISO 8601 timestamp filter for last login date
groups: IDs of
Groupobjectsqueue: ID of a
Queuedeleted: Boolean filter - whether the
Useris deleted
- Return type:
AsyncIterator[UserType]
References
- async retrieve_user(user_id)[source]
Retrieve a single
Userobject.- Parameters:
user_id (
int) – ID of a user to be retrieved.- Return type:
UserType
References
- async create_new_user(data)[source]
Create a new
Userobject.References
- async list_annotations(ordering=(), sideloads=(), content_schema_ids=(), **filters)[source]
Retrieve all
Annotationobjects satisfying the specified filters.- Parameters:
ordering (
Sequence[Literal['document','document__arrived_at','document__original_file_name','modifier','modifier__username','modified_by','modified_by__username','creator','creator__username','queue','status','created_at','assigned_at','confirmed_at','modified_at','exported_at','export_failed_at','purged_at','rejected_at','deleted_at','confirmed_by','deleted_by','exported_by','purged_by','rejected_by','confirmed_by__username','deleted_by__username','exported_by__username','purged_by__username','rejected_by__username']]) – List of object names. Their URLs are used for sorting the resultssideloads (
Sequence[Literal['content','automation_blockers','documents','modifiers','queues']]) – List of additional objects to sideloadcontent_schema_ids (
Sequence[str]) – List of content schema IDsfilters (
Any) –status:
Annotationstatus, multiple values may be separated using a commaid: List of ids separated by a comma
modifier:
Useridconfirmed_by:
Useriddeleted_by:
Useridexported_by:
Useridpurged_by:
Useridrejected_by:
Useridassignees:
Userid, multiple values may be separated using a commalabels: Label id, multiple values may be separated using a comma
document:
Documentidqueue: List of
Queueids separated by a commaqueue__workspace: List of
Workspaceids separated by a commarelations__parent: ID of parent annotation defined in related Relation object
relations__type: Type of Relation that annotation belongs to
relations__key: Key of Relation that annotation belongs to
arrived_at_before: ISO 8601 timestamp (e.g.
arrived_at_before=2019-11-15)arrived_at_after: ISO 8601 timestamp (e.g.
arrived_at_after=2019-11-14)assigned_at_before: ISO 8601 timestamp (e.g.
assigned_at_before=2019-11-15)assigned_at_after: ISO 8601 timestamp (e.g.
assigned_at_after=2019-11-14)confirmed_at_before: ISO 8601 timestamp (e.g.
confirmed_at_before=2019-11-15)confirmed_at_after: ISO 8601 timestamp (e.g.
confirmed_at_after=2019-11-14)modified_at_before: ISO 8601 timestamp (e.g.
modified_at_before=2019-11-15)modified_at_after: ISO 8601 timestamp (e.g.
modified_at_after=2019-11-14)deleted_at_before: ISO 8601 timestamp (e.g.
deleted_at_before=2019-11-15)deleted_at_after: ISO 8601 timestamp (e.g.
deleted_at_after=2019-11-14)exported_at_before: ISO 8601 timestamp (e.g.
exported_at_before=2019-11-14 22:00:00)exported_at_after: ISO 8601 timestamp (e.g.
exported_at_after=2019-11-14 12:00:00)export_failed_at_before: ISO 8601 timestamp (e.g.
export_failed_at_before=2019-11-14 22:00:00)export_failed_at_after: ISO 8601 timestamp (e.g.
export_failed_at_after=2019-11-14 12:00:00)purged_at_before: ISO 8601 timestamp (e.g.
purged_at_before=2019-11-15)purged_at_after: ISO 8601 timestamp (e.g.
purged_at_after=2019-11-14)rejected_at_before: ISO 8601 timestamp (e.g.
rejected_at_before=2019-11-15)rejected_at_after: ISO 8601 timestamp (e.g.
rejected_at_after=2019-11-14)restricted_access: Boolean
automated: Boolean
has_email_thread_with_replies: Boolean (related email thread contains more than one incoming emails)
has_email_thread_with_new_replies: Boolean (related email thread contains unread incoming email)
search: String, see Annotation search
- Return type:
AsyncIterator[AnnotationType]
References
- async search_for_annotations(query=None, query_string=None, ordering=(), sideloads=(), **kwargs)[source]
Search for
Annotationobjects.- Parameters:
query_string (
dict|None) – Query string dictionary for text searchordering (
Sequence[Literal['document','document__arrived_at','document__original_file_name','modifier','modifier__username','modified_by','modified_by__username','creator','creator__username','queue','status','created_at','assigned_at','confirmed_at','modified_at','exported_at','export_failed_at','purged_at','rejected_at','deleted_at','confirmed_by','deleted_by','exported_by','purged_by','rejected_by','confirmed_by__username','deleted_by__username','exported_by__username','purged_by__username','rejected_by__username']]) – List of object names. Their URLs are used for sorting the resultssideloads (
Sequence[Literal['content','automation_blockers','documents','modifiers','queues']]) – List of additional objects to sideloadkwargs (
Any) – Additional search parameters
- Return type:
AsyncIterator[AnnotationType]
References
- async retrieve_annotation(annotation_id, sideloads=())[source]
Retrieve a single
Annotationobject.- Parameters:
- Return type:
AnnotationType
References
- async poll_annotation(annotation_id, predicate, sleep_s=3, sideloads=())[source]
Poll on Annotation until predicate is true.
Sideloading is done only once after the predicate becomes true to avoid spamming the server.
- Return type:
AnnotationType
- async poll_annotation_until_imported(annotation_id, **poll_kwargs)[source]
Wait until annotation is imported.
- Return type:
AnnotationType
- async poll_task(task_id, predicate, sleep_s=3)[source]
Poll on Task until predicate is true.
As with Annotation polling, there is no innate retry limit.
- Return type:
TaskType
- async poll_task_until_succeeded(task_id, sleep_s=3)[source]
Poll on Task until it is succeeded.
- Return type:
TaskType
- async retrieve_task(task_id)[source]
Retrieve a single
Taskobject.- Parameters:
task_id (
int) – ID of a task to be retrieved.- Return type:
TaskType
References
- async upload_and_wait_until_imported(queue_id, filepath, filename, **poll_kwargs)[source]
Upload a single file and waiting until its annotation is imported in a single call.
- Return type:
AnnotationType
- async start_annotation(annotation_id)[source]
Start annotation processing.
- Parameters:
annotation_id (
int) – ID of an annotation to be started.
References
- async update_annotation(annotation_id, data)[source]
Update an
Annotationobject.- Parameters:
annotation_id (
int) – ID of an annotation to be updated.data (
dict[str,Any]) –Annotationobject update data.
- Return type:
AnnotationType
References
- async update_part_annotation(annotation_id, data)[source]
Update part of an
Annotationobject.- Parameters:
annotation_id (
int) – ID of an annotation to be updated.data (
dict[str,Any]) – PartialAnnotationobject update data.
- Return type:
AnnotationType
References
https://elis.rossum.ai/api/docs/#update-part-of-an-annotation.
- async bulk_update_annotation_data(annotation_id, operations)[source]
Bulk update annotation data.
- Parameters:
References
https://elis.rossum.ai/api/docs/#bulk-update-annotation-data.
- async confirm_annotation(annotation_id)[source]
Confirm annotation.
- Parameters:
annotation_id (
int) – ID of an annotation to be confirmed.
References
- async create_new_annotation(data)[source]
Create a new
Annotationobject.- Parameters:
data (
dict[str,Any]) –Annotationobject configuration.- Return type:
AnnotationType
References
- async delete_annotation(annotation_id)[source]
Delete
Annotationobject.- Parameters:
annotation_id (
int) – ID of an annotation to be deleted.
References
- async cancel_annotation(annotation_id)[source]
Cancel
Annotationobject.- Parameters:
annotation_id (
int) – ID of an annotation to be cancelled.
References
- async retrieve_document(document_id)[source]
Retrieve a single
Documentobject.- Parameters:
document_id (
int) – ID of a document to be retrieved.- Return type:
DocumentType
References
- async retrieve_document_content(document_id)[source]
Retrieve
DocumentDocuntentobject.- Parameters:
document_id (
int) – ID of a document to retrieve content for.- Returns:
Raw document content.
- Return type:
References
- async create_new_document(file_name, file_data, metadata=None, parent=None)[source]
Create a new
Documentobject.- Parameters:
- Return type:
DocumentType
References
- async list_document_relations(ordering=(), **filters)[source]
Retrieve all
DocumentRelationobjects satisfying the specified filters.- Parameters:
ordering (
Sequence[Literal['id','type','annotation']]) – List of object names. Their URLs are used for sorting the resultsfilters (
Any) –id: ID of
DocumentRelation.type: Relation type.
annotation: ID of
Annotation.key: Document relation key
documents: ID of related
Document.
- Return type:
AsyncIterator[DocumentRelationType]
References
https://elis.rossum.ai/api/docs/#list-all-document-relations.
- async retrieve_document_relation(document_relation_id)[source]
Retrieve a single
DocumentRelationobject.- Parameters:
document_relation_id (
int) – ID of a document relation to be retrieved.- Return type:
DocumentRelationType
References
https://elis.rossum.ai/api/docs/#retrieve-a-document-relation.
- async create_new_document_relation(data)[source]
Create a new
DocumentRelationobject.- Parameters:
data (
dict[str,Any]) –DocumentRelationobject configuration.- Return type:
DocumentRelationType
References
https://elis.rossum.ai/api/docs/#create-a-new-document-relation.
- async update_document_relation(document_relation_id, data)[source]
Update a
DocumentRelationobject.- Parameters:
document_relation_id (
int) – ID of a document relation to be updated.data (
dict[str,Any]) –DocumentRelationobject configuration.
- Return type:
DocumentRelationType
References
https://elis.rossum.ai/api/docs/#update-a-document-relation.
- async update_part_document_relation(document_relation_id, data)[source]
Update part of a
DocumentRelationobject.- Parameters:
document_relation_id (
int) – ID of a document relation to be updated.data (
dict[str,Any]) –DocumentRelationobject partial configuration.
- Return type:
DocumentRelationType
References
https://elis.rossum.ai/api/docs/#update-part-of-a-document-relation.
- async delete_document_relation(document_relation_id)[source]
Delete a
DocumentRelationobject.- Parameters:
document_relation_id (
int) – ID of a document relation to be deleted.
References
https://elis.rossum.ai/api/docs/#delete-a-document-relation.
- async list_relations(ordering=(), **filters)[source]
Retrieve all
Relationobjects satisfying the specified filters.- Parameters:
ordering (
Sequence[Literal['type','parent','key']]) – List of object names. Their URLs are used for sorting the resultsfilters (
Any) –id: ID of the
Relation.type: Relation type, see
RelationType.parent: ID of parent
Annotation.key: Relation key.
annotation: ID of related
Annotation.
- Return type:
AsyncIterator[RelationType]
References
- async create_new_relation(data)[source]
Create a new
Relationobject.References
- async list_workspaces(ordering=(), **filters)[source]
Retrieve all
Workspaceobjects satisfying the specified filters.- Parameters:
- Return type:
AsyncIterator[WorkspaceType]
References
- async retrieve_workspace(workspace_id)[source]
Retrieve a single
Workspaceobject.- Parameters:
workspace_id (
int) – ID of a workspace to be retrieved.- Return type:
WorkspaceType
References
- async create_new_workspace(data)[source]
Create a new
Workspaceobject.References
- async delete_workspace(workspace_id)[source]
Delete
rossum_api.models.workspace.Workspaceobject.- Parameters:
workspace_id (
int) – ID of a workspace to be deleted.
References
- async create_new_inbox(data)[source]
https://elis.rossum.ai/api/docs/#create-a-new-inbox.
- Return type:
InboxType
- async retrieve_email(email_id)[source]
Retrieve a single rossum_api.models.email.Email object.
- Parameters:
email_id (
int) – ID of email to be retrieved- Return type:
EmailType
References
- async import_email(raw_message, recipient, mime_type=None)[source]
Import an email as raw data.
Calling this endpoint starts an asynchronous process of creating an email object and importing its contents to the specified recipient inbox in Rossum.
- Parameters:
- Return type:
References
- async list_email_templates(ordering=(), **filters)[source]
Retrieve all
EmailTemplateobjects satisfying the specified filters.- Parameters:
ordering (
Sequence[Literal['id','name']]) – List of object names. Their URLs are used for sorting the resultsfilters (
Any) –id: ID of an
EmailTemplatequeue: ID of a
Queuetype: Type of the email template
name: Name of the
EmailTemplate
- Return type:
AsyncIterator[EmailTemplateType]
References
- async retrieve_email_template(email_template_id)[source]
Retrieve a single
EmailTemplateobject.- Parameters:
email_template_id (
int) – ID of an email template to be retrieved.- Return type:
EmailTemplateType
References
https://elis.rossum.ai/api/docs/#retrieve-an-email-template-object.
- async create_new_email_template(data)[source]
Create a new
EmailTemplateobject.- Parameters:
data (
dict[str,Any]) –EmailTemplateobject configuration.- Return type:
EmailTemplateType
References
https://elis.rossum.ai/api/docs/#create-new-email-template-object.
- async list_connectors(ordering=(), **filters)[source]
Retrieve all
Connectorobjects satisfying the specified filters.- Parameters:
- Return type:
AsyncIterator[ConnectorType]
References
- async retrieve_connector(connector_id)[source]
Retrieve a single
Connectorobject.- Parameters:
connector_id (
int) – ID of a connector to be retrieved.- Return type:
ConnectorType
References
- async create_new_connector(data)[source]
Create a new
Connectorobject.References
- async list_hooks(ordering=(), **filters)[source]
Retrieve all
Hookobjects satisfying the specified filters.- Parameters:
ordering (
Sequence[Literal['id','name','type','active','config_url','config_app_url','events']]) – List of object names. Their URLs are used for sorting the resultsfilters (
Any) –id: ID of a
Hookname: Name of a
Hooktype: Hook type. Possible values:
webhook, functionqueue: ID of a
Queueactive: If set to true the hook is notified.
config_url:
config_app_url:
extension_source: Import source of the extension. For more, see Extension sources.
- Return type:
AsyncIterator[HookType]
References
- async retrieve_hook(hook_id)[source]
Retrieve a single
Hookobject.- Parameters:
hook_id (
int) – ID of a hook to be retrieved.- Return type:
HookType
References
- async create_new_hook(data)[source]
Create a new
Hookobject.References
- async update_part_hook(hook_id, data)[source]
Update part of a
Hookobject.- Parameters:
- Return type:
HookType
References
- async delete_hook(hook_id)[source]
Delete a
Hookobject.- Parameters:
hook_id (
int) – ID of a hook to be deleted.
References
- async list_rules(ordering=(), **filters)[source]
Retrieve all
Ruleobjects satisfying the specified filters.- Parameters:
ordering (
Sequence[Literal['id','name','organization']]) – List of object names. Their URLs are used for sorting the resultsfilters (
Any) –id: ID of a
Rule.name: Name of a
Rule.schema: ID of a
Schema.rule_template: URL of the rule template the rule was created from.
organization: ID of a
Organization.
- Return type:
AsyncIterator[RuleType]
References
- async retrieve_rule(rule_id)[source]
Retrieve a single
Ruleobject.- Parameters:
rule_id (
int) – ID of a rule to be retrieved.- Return type:
RuleType
References
- async create_new_rule(data)[source]
Create a new
Ruleobject.References
- async update_part_rule(rule_id, data)[source]
Update part of a
Ruleobject.- Parameters:
- Return type:
RuleType
References
- async delete_rule(rule_id)[source]
Delete a
Ruleobject.- Parameters:
rule_id (
int) – ID of a rule to be deleted.
References
- async list_user_roles(ordering=(), **filters)[source]
Retrieve all
Groupobjects satisfying the specified filters.- Parameters:
- Return type:
AsyncIterator[GroupType]
References
- async request_paginated(url, *args, **kwargs)[source]
Request to endpoints with paginated response that do not have direct support in the client.
- Return type:
- async request_json(method, *args, **kwargs)[source]
Request to endpoints that do not have direct support in the client and return plain JSON.
- async request(method, *args, **kwargs)[source]
Request to endpoints that do not have direct support in the client and return plain response.
- Return type:
Response
Synchronous Client
- class rossum_api.clients.external_sync_client.SyncRossumAPIClient(base_url, credentials, *, deserializer=None, timeout=None, n_retries=3, response_post_processor=None)[source]
Synchronous Rossum API Client.
- Parameters:
base_url (
str) – base API URL including the “/api” and version (“/v1”) in the url path. For example “https://elis.rossum.ai/api/v1”deserializer (
Callable[[Resource,dict[str,Any]],TypeVar(RossumApiType)] |None) – pass a custom deserialization callable if different model classes should be returnedresponse_post_processor (
Callable[[Response],Any] |None) – pass a custom response post-processing callable
- retrieve_queue(queue_id)[source]
Retrieve a single
Queueobject.- Parameters:
queue_id (
int) – ID of a queue to be retrieved.- Return type:
QueueType
References
- list_queues(ordering=(), **filters)[source]
Retrieve all queue objects satisfying the specified filters.
- Parameters:
ordering (
Sequence[Literal['id','name','workspace','connector','webhooks','schema','inbox','locale']]) – List of object names. Their IDs are used for sorting the resultsfilters (
Any) –id: ID of a
Queuename: Name of a
Queueworkspace: ID of a
Workspaceinbox: ID of an
Inboxconnector: ID of an
Connectorwebhooks: IDs of a
Hookshooks: IDs of a
Hookslocale:
Queueobject locale.dedicated_engine: ID of a dedicated engine.
generic_engine: ID of a generic engine.
deleting: Boolean filter - queue is being deleted (
delete_afteris set)
- Return type:
Iterator[QueueType]
References
- create_new_queue(data)[source]
Create a new
Queueobject.References
- delete_queue(queue_id)[source]
Delete
Queueobject.- Parameters:
deleted. (ID of a queue to be)
Notes
By default, the deletion will start after 24 hours.
Warning
It also deletes all the related objects. Please note that while the queue and related objects are being deleted the API may return inconsistent results. We strongly discourage from any interaction with the queue after being scheduled for deletion.
References
- import_document(queue_id, files, values=None, metadata=None)[source]
https://elis.rossum.ai/api/docs/#import-a-document.
Deprecated now, consider upload_document.
- Parameters:
queue_id (
int) – ID of the queue to upload the files tofiles (
Sequence[tuple[str|Path,str]]) – 2-tuple containing current filepath and name to be used by Elis for the uploaded filevalues (
dict[str,Any] |None) – may be used to initialize datapoint values by setting the value of rir_field_names in the schemametadata (
dict[str,Any] |None) – will be set to newly created annotation object
- Returns:
list of IDs of created annotations, respects the order of files argument
- Return type:
annotation_ids
- upload_document(queue_id, files, values=None, metadata=None)[source]
Do the same thing as import_document method, but uses a different endpoint.
- Parameters:
queue_id (
int) – ID of the queue to upload the files tofiles (
Sequence[tuple[str|Path,str]]) – 2-tuple containing current filepath and name to be used by Elis for the uploaded filevalues (
dict[str,Any] |None) – may be used to initialize datapoint values by setting the value of rir_field_names in the schemametadata (
dict[str,Any] |None) – will be set to newly created annotation object
- Returns:
list of Task object responses, respects the order of files argument Tasks can be polled using poll_task and if succeeded, will contain a link to an Upload object that contains info on uploaded documents/annotations
- Return type:
task_responses
References
- retrieve_upload(upload_id)[source]
Retrieve rossum_api.models.upload.Upload object.
- Parameters:
upload_id (
int) – ID of an upload to be retrieved.- Return type:
UploadType
References
- export_annotations_to_json(queue_id, **filters)[source]
Export annotations from the queue to JSON.
Notes
JSON export is paginated and returns the result in a way similar to other list_all methods.
- Parameters:
queue_id (
int) – ID of a queue annotions should be exported from.filters (
Any) –- id
Id of annotation to be exported, multiple ids may be separated by a comma.
- status
Annotationstatus.- modifier
Userid.- arrived_at_before
ISO 8601 timestamp (e.g.
arrived_at_before=2019-11-15).- arrived_at_after
ISO 8601 timestamp (e.g.
arrived_at_after=2019-11-14).- exported_at_after
ISO 8601 timestamp (e.g.
exported_at_after=2019-11-14 12:00:00).- export_failed_at_before
ISO 8601 timestamp (e.g.
export_failed_at_before=2019-11-14 22:00:00).- export_failed_at_after
ISO 8601 timestamp (e.g.
export_failed_at_after=2019-11-14 12:00:00).- page_size
Number of the documents to be exported. To be used together with
pageattribute. See pagination.- page
Number of a page to be exported when using pagination. Useful for exports of large amounts of data. To be used together with the
page_sizeattribute.
- Return type:
Iterator[AnnotationType]
Notes
When the search filter is used, results are limited to 10 000. We suggest narrowing down the search query if there are this many results.
References
- export_annotations_to_file(queue_id, export_format, **filters)[source]
Export annotations from the queue to a desired export format.
Notes
JSON export is paginated and returns the result in a way similar to other list_all methods.
- Parameters:
queue_id (
int) – ID of a queue annotions should be exported from.export_format (
ExportFileFormats) – Target export format.filters (
Any) –- id
Id of annotation to be exported, multiple ids may be separated by a comma.
- status
Annotationstatus.- modifier
Userid.- arrived_at_before
ISO 8601 timestamp (e.g.
arrived_at_before=2019-11-15).- arrived_at_after
ISO 8601 timestamp (e.g.
arrived_at_after=2019-11-14).- exported_at_after
ISO 8601 timestamp (e.g.
exported_at_after=2019-11-14 12:00:00).- export_failed_at_before
ISO 8601 timestamp (e.g.
export_failed_at_before=2019-11-14 22:00:00).- export_failed_at_after
ISO 8601 timestamp (e.g.
export_failed_at_after=2019-11-14 12:00:00).- page_size
Number of the documents to be exported. To be used together with
pageattribute. See pagination.- page
Number of a page to be exported when using pagination. Useful for exports of large amounts of data. To be used together with the
page_sizeattribute.
- Return type:
Notes
When the search filter is used, results are limited to 10 000. We suggest narrowing down the search query if there are this many results.
References
- list_organizations(ordering=(), **filters)[source]
Retrieve all organization objects satisfying the specified filters.
- Parameters:
ordering (
Sequence[Literal['id','name']]) – List of object names. Their IDs are used for sorting the resultsfilters (
Any) –id: ID of a
Organizationname: Name of a
Organization
- Return type:
Iterator[OrganizationType]
References
- retrieve_organization(org_id)[source]
Retrieve a single
Qrganizationobject.- Parameters:
org_id (
int) – ID of an organization to be retrieved.- Return type:
OrganizationType
References
- retrieve_own_organization()[source]
Retrieve organization of currently logged in user.
- Return type:
OrganizationType
- retrieve_my_organization()[source]
Retrieve organization of currently logged in user.
- Return type:
OrganizationType
- list_schemas(ordering=(), **filters)[source]
Retrieve all
Schemaobjects satisfying the specified filters.- Parameters:
- Return type:
Iterator[SchemaType]
References
- retrieve_schema(schema_id)[source]
Retrieve a single
Schemaobject.- Parameters:
schema_id (
int) – ID of a schema to be retrieved.- Return type:
SchemaType
References
- create_new_schema(data)[source]
Create a new
Schemaobject.References
- delete_schema(schema_id)[source]
Delete
Schemaobject.- Parameters:
schema_id (
int) – ID of a schema to be deleted.
Notes
Warning
In case the schema is linked to some objects, like queue or annotation, the deletion is not possible and the request will fail with 409 status code.
References
- list_users(ordering=(), **filters)[source]
Retrieve all
Userobjects satisfying the specified filters.- Parameters:
ordering (
Sequence[Literal['id','username','first_name','last_name','email','last_login','date_joined','deleted','not_deleted']]) – List of object names. Their URLs are used for sorting the resultsfilters (
Any) –id: ID of a
Userusername: Username of a
Userfirst_name: First name of a
Userlast_name: Last name of a
Useremail: Email address of a
Useris_active: Boolean filter - whether the
Useris activelast_login: ISO 8601 timestamp filter for last login date
groups: IDs of
Groupobjectsqueue: ID of a
Queuedeleted: Boolean filter - whether the
Useris deleted
- Return type:
Iterator[UserType]
References
- retrieve_user(user_id)[source]
Retrieve a single
Userobject.- Parameters:
user_id (
int) – ID of a user to be retrieved.- Return type:
UserType
References
- create_new_user(data)[source]
https://elis.rossum.ai/api/docs/#create-new-user.
- Return type:
UserType
- retrieve_annotation(annotation_id, sideloads=())[source]
Retrieve a single
Annotationobject.- Parameters:
- Return type:
AnnotationType
References
- list_annotations(ordering=(), sideloads=(), content_schema_ids=(), **filters)[source]
Retrieve all
Annotationobjects satisfying the specified filters.- Parameters:
ordering (
Sequence[Literal['document','document__arrived_at','document__original_file_name','modifier','modifier__username','modified_by','modified_by__username','creator','creator__username','queue','status','created_at','assigned_at','confirmed_at','modified_at','exported_at','export_failed_at','purged_at','rejected_at','deleted_at','confirmed_by','deleted_by','exported_by','purged_by','rejected_by','confirmed_by__username','deleted_by__username','exported_by__username','purged_by__username','rejected_by__username']]) – List of object names. Their URLs are used for sorting the resultssideloads (
Sequence[Literal['content','automation_blockers','documents','modifiers','queues']]) – List of additional objects to sideloadcontent_schema_ids (
Sequence[str]) – List of content schema IDsfilters (
Any) –status:
Annotationstatus, multiple values may be separated using a commaid: List of ids separated by a comma
modifier:
Useridconfirmed_by:
Useriddeleted_by:
Useridexported_by:
Useridpurged_by:
Useridrejected_by:
Useridassignees:
Userid, multiple values may be separated using a commalabels: Label id, multiple values may be separated using a comma
document:
Documentidqueue: List of
Queueids separated by a commaqueue__workspace: List of
Workspaceids separated by a commarelations__parent: ID of parent annotation defined in related Relation object
relations__type: Type of Relation that annotation belongs to
relations__key: Key of Relation that annotation belongs to
arrived_at_before: ISO 8601 timestamp (e.g.
arrived_at_before=2019-11-15)arrived_at_after: ISO 8601 timestamp (e.g.
arrived_at_after=2019-11-14)assigned_at_before: ISO 8601 timestamp (e.g.
assigned_at_before=2019-11-15)assigned_at_after: ISO 8601 timestamp (e.g.
assigned_at_after=2019-11-14)confirmed_at_before: ISO 8601 timestamp (e.g.
confirmed_at_before=2019-11-15)confirmed_at_after: ISO 8601 timestamp (e.g.
confirmed_at_after=2019-11-14)modified_at_before: ISO 8601 timestamp (e.g.
modified_at_before=2019-11-15)modified_at_after: ISO 8601 timestamp (e.g.
modified_at_after=2019-11-14)deleted_at_before: ISO 8601 timestamp (e.g.
deleted_at_before=2019-11-15)deleted_at_after: ISO 8601 timestamp (e.g.
deleted_at_after=2019-11-14)exported_at_before: ISO 8601 timestamp (e.g.
exported_at_before=2019-11-14 22:00:00)exported_at_after: ISO 8601 timestamp (e.g.
exported_at_after=2019-11-14 12:00:00)export_failed_at_before: ISO 8601 timestamp (e.g.
export_failed_at_before=2019-11-14 22:00:00)export_failed_at_after: ISO 8601 timestamp (e.g.
export_failed_at_after=2019-11-14 12:00:00)purged_at_before: ISO 8601 timestamp (e.g.
purged_at_before=2019-11-15)purged_at_after: ISO 8601 timestamp (e.g.
purged_at_after=2019-11-14)rejected_at_before: ISO 8601 timestamp (e.g.
rejected_at_before=2019-11-15)rejected_at_after: ISO 8601 timestamp (e.g.
rejected_at_after=2019-11-14)restricted_access: Boolean
automated: Boolean
has_email_thread_with_replies: Boolean (related email thread contains more than one incoming emails)
has_email_thread_with_new_replies: Boolean (related email thread contains unread incoming email)
search: String, see Annotation search
- Return type:
Iterator[AnnotationType]
References
- search_for_annotations(query=None, query_string=None, ordering=(), sideloads=(), **kwargs)[source]
Search for
Annotationobjects.- Parameters:
query_string (
dict|None) – Query string dictionary for text searchordering (
Sequence[Literal['document','document__arrived_at','document__original_file_name','modifier','modifier__username','modified_by','modified_by__username','creator','creator__username','queue','status','created_at','assigned_at','confirmed_at','modified_at','exported_at','export_failed_at','purged_at','rejected_at','deleted_at','confirmed_by','deleted_by','exported_by','purged_by','rejected_by','confirmed_by__username','deleted_by__username','exported_by__username','purged_by__username','rejected_by__username']]) – List of object names. Their URLs are used for sorting the resultssideloads (
Sequence[Literal['content','automation_blockers','documents','modifiers','queues']]) – List of additional objects to sideloadkwargs (
Any) – Additional search parameters
- Return type:
Iterator[AnnotationType]
References
- poll_annotation(annotation_id, predicate, sleep_s=3, sideloads=())[source]
Poll on Annotation until predicate is true.
Sideloading is done only once after the predicate becomes true to avoid spamming the server.
- Return type:
AnnotationType
- poll_annotation_until_imported(annotation_id, **poll_kwargs)[source]
Wait until annotation is imported.
- retrieve_task(task_id)[source]
https://elis.rossum.ai/api/docs/#retrieve-task.
- Return type:
TaskType
- poll_task(task_id, predicate, sleep_s=3)[source]
Poll on Task until predicate is true.
As with Annotation polling, there is no innate retry limit.
- Return type:
TaskType
- poll_task_until_succeeded(task_id, sleep_s=3)[source]
Poll on Task until it is succeeded.
- Return type:
TaskType
- upload_and_wait_until_imported(queue_id, filepath, filename, **poll_kwargs)[source]
Upload a single file and waiting until its annotation is imported in a single call.
- Return type:
AnnotationType
- start_annotation(annotation_id)[source]
Start annotation processing.
- Parameters:
annotation_id (
int) – ID of an annotation to be started.
References
- update_annotation(annotation_id, data)[source]
Update an
Annotationobject.- Parameters:
annotation_id (
int) – ID of an annotation to be updated.data (
dict[str,Any]) –Annotationobject update data.
- Return type:
AnnotationType
References
- update_part_annotation(annotation_id, data)[source]
Update part of an
Annotationobject.- Parameters:
annotation_id (
int) – ID of an annotation to be updated.data (
dict[str,Any]) – PartialAnnotationobject update data.
- Return type:
AnnotationType
References
https://elis.rossum.ai/api/docs/#update-part-of-an-annotation.
- bulk_update_annotation_data(annotation_id, operations)[source]
Bulk update annotation data.
- Parameters:
References
https://elis.rossum.ai/api/docs/#bulk-update-annotation-data.
- confirm_annotation(annotation_id)[source]
Confirm annotation.
- Parameters:
annotation_id (
int) – ID of an annotation to be confirmed.
References
- create_new_annotation(data)[source]
Create a new
Annotationobject.- Parameters:
data (
dict[str,Any]) –Annotationobject configuration.- Return type:
AnnotationType
References
- delete_annotation(annotation_id)[source]
Delete
Annotationobject.- Parameters:
annotation_id (
int) – ID of an annotation to be deleted.
References
- cancel_annotation(annotation_id)[source]
Cancel
Annotationobject.- Parameters:
annotation_id (
int) – ID of an annotation to be cancelled.
References
- retrieve_document(document_id)[source]
Retrieve a single
Documentobject.- Parameters:
document_id (
int) – ID of a document to be retrieved.- Return type:
DocumentType
References
- retrieve_document_content(document_id)[source]
Get the binary content of a document.
References
- create_new_document(file_name, file_data, metadata=None, parent=None)[source]
Create a new
Documentobject.- Parameters:
- Return type:
DocumentType
References
- list_document_relations(ordering=(), **filters)[source]
Retrieve all
DocumentRelationobjects satisfying the specified filters.- Parameters:
ordering (
Sequence[Literal['id','type','annotation']]) – List of object names. Their URLs are used for sorting the resultsfilters (
Any) –id: ID of
DocumentRelation.type: Relation type.
annotation: ID of
Annotation.key: Document relation key
documents: ID of related
Document.
- Return type:
Iterator[DocumentRelationType]
References
https://elis.rossum.ai/api/docs/#list-all-document-relations.
- retrieve_document_relation(document_relation_id)[source]
Retrieve a single
DocumentRelationobject.- Parameters:
document_relation_id (
int) – ID of a document relation to be retrieved.- Return type:
DocumentRelationType
References
https://elis.rossum.ai/api/docs/#retrieve-a-document-relation.
- create_new_document_relation(data)[source]
Create a new
DocumentRelationobject.- Parameters:
data (
dict[str,Any]) –DocumentRelationobject configuration.- Return type:
DocumentRelationType
References
https://elis.rossum.ai/api/docs/#create-a-new-document-relation.
- update_document_relation(document_relation_id, data)[source]
Update a
DocumentRelationobject.- Parameters:
document_relation_id (
int) – ID of a document relation to be updated.data (
dict[str,Any]) –DocumentRelationobject configuration.
- Return type:
DocumentRelationType
References
https://elis.rossum.ai/api/docs/#update-a-document-relation.
- update_part_document_relation(document_relation_id, data)[source]
Update part of a
DocumentRelationobject.- Parameters:
document_relation_id (
int) – ID of a document relation to be updated.data (
dict[str,Any]) –DocumentRelationobject partial configuration.
- Return type:
DocumentRelationType
References
https://elis.rossum.ai/api/docs/#update-part-of-a-document-relation.
- delete_document_relation(document_relation_id)[source]
Delete a
DocumentRelationobject.- Parameters:
document_relation_id (
int) – ID of a document relation to be deleted.
References
https://elis.rossum.ai/api/docs/#delete-a-document-relation.
- list_relations(ordering=(), **filters)[source]
Retrieve all
Relationobjects satisfying the specified filters.- Parameters:
ordering (
Sequence[Literal['type','parent','key']]) – List of object names. Their URLs are used for sorting the resultsfilters (
Any) –id: ID of the
Relation.type: Relation type, see
RelationType.parent: ID of parent
Annotation.key: Relation key.
annotation: ID of related
Annotation.
- Return type:
Iterator[RelationType]
References
- create_new_relation(data)[source]
Create a new
Relationobject.References
- list_workspaces(ordering=(), **filters)[source]
Retrieve all
Workspaceobjects satisfying the specified filters.- Parameters:
- Return type:
Iterator[WorkspaceType]
References
- retrieve_workspace(workspace_id)[source]
Retrieve a single
Workspaceobject.- Parameters:
workspace_id (
int) – ID of a workspace to be retrieved.- Return type:
WorkspaceType
References
- create_new_workspace(data)[source]
Create a new
Workspaceobject.References
- delete_workspace(workspace_id)[source]
Delete
rossum_api.models.workspace.Workspaceobject.- Parameters:
workspace_id (
int) – ID of a workspace to be deleted.
References
- create_new_inbox(data)[source]
Create a new
Inboxobject.References
- retrieve_email(email_id)[source]
Retrieve a single rossum_api.models.email.Email object.
- Parameters:
email_id (
int) – ID of email to be retrieved- Return type:
EmailType
References
- import_email(raw_message, recipient, mime_type=None)[source]
Import an email as raw data.
Calling this endpoint starts an asynchronous process of creating an email object and importing its contents to the specified recipient inbox in Rossum.
- Parameters:
- Returns:
Task URL that can be used to track the import status.
- Return type:
References
- list_email_templates(ordering=(), **filters)[source]
Retrieve all
EmailTemplateobjects satisfying the specified filters.- Parameters:
ordering (
Sequence[Literal['id','name']]) – List of object names. Their URLs are used for sorting the resultsfilters (
Any) –id: ID of an
EmailTemplatequeue: ID of a
Queuetype: Type of the email template
name: Name of the
EmailTemplate
- Return type:
Iterator[EmailTemplateType]
References
- retrieve_email_template(email_template_id)[source]
Retrieve a single
EmailTemplateobject.- Parameters:
email_template_id (
int) – ID of an email template to be retrieved.- Return type:
EmailTemplateType
References
https://elis.rossum.ai/api/docs/#retrieve-an-email-template-object.
- create_new_email_template(data)[source]
Create a new
EmailTemplateobject.- Parameters:
data (
dict[str,Any]) –EmailTemplateobject configuration.- Return type:
EmailTemplateType
References
https://elis.rossum.ai/api/docs/#create-new-email-template-object.
- list_connectors(ordering=(), **filters)[source]
Retrieve all
Connectorobjects satisfying the specified filters.- Parameters:
- Return type:
Iterator[ConnectorType]
References
- retrieve_connector(connector_id)[source]
Retrieve a single
Connectorobject.- Parameters:
connector_id (
int) – ID of a connector to be retrieved.- Return type:
ConnectorType
References
- create_new_connector(data)[source]
Create a new
Connectorobject.References
- list_hooks(ordering=(), **filters)[source]
Retrieve all
Hookobjects satisfying the specified filters.- Parameters:
ordering (
Sequence[Literal['id','name','type','active','config_url','config_app_url','events']]) – List of object names. Their URLs are used for sorting the resultsfilters (
Any) –id: ID of a
Hookname: Name of a
Hooktype: Hook type. Possible values:
webhook, functionqueue: ID of a
Queueactive: If set to true the hook is notified.
config_url:
config_app_url:
extension_source: Import source of the extension. For more, see Extension sources.
- Return type:
Iterator[HookType]
References
- retrieve_hook(hook_id)[source]
Retrieve a single
Hookobject.- Parameters:
hook_id (
int) – ID of a hook to be retrieved.- Return type:
HookType
References
- create_new_hook(data)[source]
Create a new
Hookobject.References
- update_part_hook(hook_id, data)[source]
Update part of a
Hookobject.- Parameters:
- Return type:
HookType
References
- delete_hook(hook_id)[source]
Delete a
Hookobject.- Parameters:
hook_id (
int) – ID of a hook to be deleted.
References
- list_rules(ordering=(), **filters)[source]
Retrieve all
Ruleobjects satisfying the specified filters.- Parameters:
ordering (
Sequence[Literal['id','name','organization']]) – List of object names. Their URLs are used for sorting the resultsfilters (
Any) –id: ID of a
Rule.name: Name of a
Rule.schema: ID of a
Schema.rule_template: URL of the rule template the rule was created from.
organization: ID of a
Organization.
- Return type:
Iterator[RuleType]
References
- retrieve_rule(rule_id)[source]
Retrieve a single
Ruleobject.- Parameters:
rule_id (
int) – ID of a rule to be retrieved.- Return type:
RuleType
References
- create_new_rule(data)[source]
Create a new
Ruleobject.References
- update_part_rule(rule_id, data)[source]
Update part of a
Ruleobject.- Parameters:
- Return type:
RuleType
References
- delete_rule(rule_id)[source]
Delete a
Ruleobject.- Parameters:
rule_id (
int) – ID of a rule to be deleted.
References
- list_user_roles(ordering=(), **filters)[source]
Retrieve all
Groupobjects satisfying the specified filters.- Parameters:
- Return type:
Iterator[GroupType]
References
- request_paginated(url, *args, **kwargs)[source]
Request to endpoints with paginated response that do not have direct support in the client.
- request_json(method, *args, **kwargs)[source]
Request to endpoints that do not have direct support in the client and return plain JSON.
Client Usage Examples
Authentication
Both clients support authentication via username/password credentials or token-based authentication:
from rossum_api import SyncRossumAPIClient
from rossum_api.dtos import UserCredentials, Token
# Username/password authentication
credentials = UserCredentials(
username="your.email@example.com",
password="your-password"
)
# Token-based authentication
credentials = Token(token="your-api-token")
# Initialize the Rossum API client
client = SyncRossumAPIClient(base_url="...", credentials=credentials)
Working with Annotations
Async version:
# Retrieve a single annotation
annotation = await client.retrieve_annotation(12345)
# List annotations with filtering
async for annotation in client.list_annotations(
status="to_review",
ordering=["-created_at"]
):
print(annotation.id, annotation.status)
# Search for annotations
async for annotation in client.search_for_annotations(
query={"status": "to_review"},
ordering=["-created_at"]
):
print(annotation.id, annotation.status)
# Update annotation
updated = await client.update_annotation(
annotation_id=12345,
data={"status": "confirmed"}
)
# Poll annotation until imported
annotation = await client.poll_annotation_until_imported(12345)
# Confirm annotation
await client.confirm_annotation(12345)
Sync version:
# Retrieve a single annotation
annotation = client.retrieve_annotation(12345)
# List annotations with filtering
for annotation in client.list_annotations(
status="to_review",
ordering=["-created_at"]
):
print(annotation.id, annotation.status)
# Search for annotations
for annotation in client.search_for_annotations(
query={"status": "to_review"},
ordering=["-created_at"]
):
print(annotation.id, annotation.status)
# Update annotation
updated = client.update_annotation(
annotation_id=12345,
data={"status": "confirmed"}
)
# Poll annotation until imported
annotation = client.poll_annotation_until_imported(12345)
# Confirm annotation
client.confirm_annotation(12345)
Working with Documents
Async version:
# Upload documents (creates tasks)
tasks = await client.upload_document(
queue_id=123,
files=[("path/to/invoice.pdf", "invoice.pdf")]
)
# Poll task until completion
task = await client.poll_task_until_succeeded(tasks[0].id)
# Retrieve document
document = await client.retrieve_document(12345)
# Get document content
content = await client.retrieve_document_content(12345)
# Create new document
document = await client.create_new_document(
file_name="invoice.pdf",
file_data=content,
metadata={"source": "email"}
)
# Upload and wait for import in one call
annotation = await client.upload_and_wait_until_imported(
queue_id=123,
filepath="invoice.pdf",
filename="invoice.pdf"
)
Sync version:
# Upload documents (creates tasks)
tasks = client.upload_document(
queue_id=123,
files=[("path/to/invoice.pdf", "invoice.pdf")]
)
# Poll task until completion
task = client.poll_task_until_succeeded(tasks[0].id)
# Retrieve document
document = client.retrieve_document(12345)
# Get document content
content = client.retrieve_document_content(12345)
# Create new document
document = client.create_new_document(
file_name="invoice.pdf",
file_data=content,
metadata={"source": "email"}
)
# Upload and wait for import in one call
annotation = client.upload_and_wait_until_imported(
queue_id=123,
filepath="invoice.pdf",
filename="invoice.pdf"
)
Working with Workspaces and Queues
Async version:
# Create workspace
workspace = await client.create_new_workspace(data={
"name": "My Workspace",
"organization": organization_url,
})
# Retrieve workspace
workspace = await client.retrieve_workspace(123)
# List workspaces
async for workspace in client.list_workspaces():
print(workspace.name)
# Create queue in workspace
queue = await client.create_new_queue(data={
"name": "Invoices",
"workspace": workspace.url,
"schema": schema_url,
})
# Retrieve queue
queue = await client.retrieve_queue(456)
# List queues with filtering
async for queue in client.list_queues(workspace=workspace.id):
print(queue.name)
# Delete queue
await client.delete_queue(456)
Sync version:
# Create workspace
workspace = client.create_new_workspace(data={
"name": "My Workspace",
"organization": organization_url,
})
# Retrieve workspace
workspace = client.retrieve_workspace(123)
# List workspaces
for workspace in client.list_workspaces():
print(workspace.name)
# Create queue in workspace
queue = client.create_new_queue(data={
"name": "Invoices",
"workspace": workspace.url,
"schema": schema_url,
})
# Retrieve queue
queue = client.retrieve_queue(456)
# List queues with filtering
for queue in client.list_queues(workspace=workspace.id):
print(queue.name)
# Delete queue
client.delete_queue(456)
Pagination
The clients handle pagination automatically:
# All `list_*` methods automatically handle pagination
# and yield results one by one
async for user in client.list_users():
print(user.email)
# Lists can be filtered and ordered
async for queue in client.list_queues(
workspace=123,
ordering=["-id"]
):
print(queue.name)
Export Operations
Both export formats are supported:
# Export annotations to JSON (paginated)
async for annotation in client.export_annotations_to_json(
queue_id=123,
status="confirmed"
):
print(annotation.id)
# Export annotations to file format (CSV, XML, XLSX)
from rossum_api.domain_logic.annotations import ExportFileFormats
async for chunk in client.export_annotations_to_file(
queue_id=123,
export_format=ExportFileFormats.CSV,
status="confirmed"
):
# Process file chunk
pass
Working with Relations
Relations represent parent-child relationships between annotations (e.g., duplicates, attachments, edits):
Async version:
from rossum_api.models.relation import RelationType
# List all relations
async for relation in client.list_relations():
print(relation.id, relation.type)
# Filter by type
async for relation in client.list_relations(type="duplicate"):
print(relation.id, relation.key)
# Filter by parent annotation
async for relation in client.list_relations(parent=12345):
print(relation.id, relation.annotations)
# Create a new relation
relation = await client.create_new_relation(data={
"type": "attachment",
"parent": "https://elis.rossum.ai/api/v1/annotations/123",
"annotations": ["https://elis.rossum.ai/api/v1/annotations/456"]
})
Sync version:
from rossum_api.models.relation import RelationType
# List all relations
for relation in client.list_relations():
print(relation.id, relation.type)
# Filter by type
for relation in client.list_relations(type="duplicate"):
print(relation.id, relation.key)
# Filter by parent annotation
for relation in client.list_relations(parent=12345):
print(relation.id, relation.annotations)
# Create a new relation
relation = client.create_new_relation(data={
"type": "attachment",
"parent": "https://elis.rossum.ai/api/v1/annotations/123",
"annotations": ["https://elis.rossum.ai/api/v1/annotations/456"]
})
Working with Additional Resources
The clients also provide methods for managing other API resources:
# Organizations
async for org in client.list_organizations():
print(org.name)
org = await client.retrieve_organization(123)
my_org = await client.retrieve_my_organization()
# Schemas
schema = await client.create_new_schema(data={
"name": "Invoice Schema",
"content": schema_definition
})
async for schema in client.list_schemas():
print(schema.name)
# Users and Roles
user = await client.create_new_user(data={
"email": "user@example.com",
"first_name": "John",
"last_name": "Doe"
})
async for role in client.list_user_roles():
print(role.name)
# Hooks and Connectors
hook = await client.create_new_hook(data={
"name": "My Hook",
"target": "https://example.com/webhook"
})
connector = await client.create_new_connector(data={
"name": "My Connector",
"connector_type": "webhook"
})
Authentication and Token Management
# Get current authentication token
token = await client.get_token()
# Force refresh the token
token = await client.get_token(refresh=True)
# Manually authenticate (usually not needed)
await client.authenticate()
Generic Request Methods
For advanced use cases, raw request methods are available in both clients:
Async version:
# Make paginated requests to custom endpoints
async for item in client.request_paginated(
"custom/endpoint",
ordering=["id"]
):
print(item)
# Make JSON requests
response = await client.request_json(
"POST",
"custom/endpoint",
json={"data": "value"}
)
# Make raw HTTP requests
response = await client.request(
"GET",
"custom/endpoint"
)
Sync version:
# Make paginated requests to custom endpoints
for item in client.request_paginated(
"custom/endpoint",
ordering=["id"]
):
print(item)
# Make JSON requests
response = client.request_json(
"POST",
"custom/endpoint",
json={"data": "value"}
)
# Make raw HTTP requests
response = client.request(
"GET",
"custom/endpoint"
)
Error Handling
from httpx import HTTPStatusError
try:
annotation = await client.retrieve_annotation(99999)
except HTTPStatusError as e:
if e.response.status_code == 404:
print("Annotation not found")
else:
print(f"API error: {e}")
Client Configuration
Both clients support various configuration options:
from rossum_api.dtos import UserCredentials, Token
# Using username/password
client = AsyncRossumAPIClient(
base_url="https://elis.rossum.ai/api/v1",
credentials=UserCredentials("user@example.com", "password"),
timeout=30.0,
n_retries=5,
retry_backoff_factor=2.0,
retry_max_jitter=1.0,
max_in_flight_requests=8 # async only
)
# Using token
client = AsyncRossumAPIClient(
base_url="https://elis.rossum.ai/api/v1",
credentials=Token("your-api-token")
)
See Also
Data Models - Data models returned by the clients
Rossum API Documentation - Official API reference