Open Document UI
This endpoint allows you to open a document within the Xtracta App web UI. This allows the document to be fixed should it have an error or if data hasn't been captured, the user can help the App learn by clicking on the pertinent data for a field.
POST Parameters
| Parameter | Required | Value | Description |
|---|---|---|---|
api_key | {key} | An API key that has access to the resource you want to query for. | |
document_id | {integer} | The ID of a specific document you want to open in the UI of the Xtracta App. | |
expire | {integer} | The length of time the returned URL will be valid for before it expires and cannot be used (and thus must be regenerated). The time will be in seconds. It has a maximum value of 86,400 (One day) and a default value of 600 seconds (Ten Minutes). | |
callback_url | {url} | The URL the browser opens after a completed UI action, including Save and Close or Close Without Saving. Both use the same return URL. Xtracta adds no action flag or document data. See Callback URL and button actions below. | |
after_api_download_status | active, archived | Choose which status you wish the document to have after it has been processed through the provided URL. If not set, the archived status will not change. | |
no_lockout | {integer} | Passing this as true ("1") will enable multiple users to access a single document concurrently, by default only a single user can access a document at any given time. | |
free_form | {string} | Custom data can be passed to this field. It can be used to track the user accessing the document. Previous values will be overwritten. | |
buttons | save, output, indexing, qa, reject, archive, delete, save_and_learn | Additional buttons to display. Comma separated. By default, Save and Output are displayed. | |
user_email | {unicode} | This optional field can be used to record the email address of the user uploading the document. | |
user_id | {integer} | This optional field can be used to record the user ID of the user uploading the document. | |
field_options | {xml} | Gives the ability to disable and hide fields from the user when accessing the document. | |
version | {integer} | Used to select whether to open a document in the legacy Engine Learning Screen (ELS) with default value = 1. Use value = 2 to open the document using the New ELS |
URL Expiration: Generated URLs expire after the specified time (default: 10 minutes, max: 24 hours). Use no_lockout=1 to allow multiple concurrent users.
- If a value is passed for the user_email that does not exist as a current user, a new user record will be created.
- If the user_id option is passed, the user ID must be a valid value.
If both are passed, user_email will take precedence.
Callback URL and button actions
Pass callback_url in the POST request to /v1/documents/ui when you generate the document UI URL. It sets the return URL for that UI session. You can use a different return URL for each environment or request. Open the generated UI URL from the response; adding callback_url to that URL later does not set the return URL.
The UI sends the browser to this URL after the user completes an action. This is browser navigation, not a server-to-server webhook or a POST of document data to your application.
Save and Close / Close Without Saving
In Classic ELS, both buttons use the same callback_url:
Save and Close: Saves the current field changes, then sends the browser to callback_url once the action succeeds. The buttons setting controls whether this button runs Save, Send to Indexing, or Output. If the action fails, the UI shows the error instead of returning through the success path.
Close Without Saving: Closes the document without saving the current field changes and releases it from processing, then sends the browser to the same callback_url. It does not undo changes saved earlier.
The New ELS also uses callback_url as the return destination after completed actions from the Open Document UI API.
If you omit callback_url, the UI attempts to close the browser tab. Browser rules may prevent the tab from closing.
What your application receives
Xtracta opens the supplied URL without adding a button name, save/cancel flag, document ID, or extracted field data. The callback alone cannot tell your application which button the user clicked.
You can include your own reference in the return URL, for example:
https://your-app.example/xtracta/return?reference=invoice-123
This reference helps your application identify the session; it does not report the action or its result. Use the Get Document(s) endpoint if your application needs to read the stored document data after the user returns.
Both Save and Close and Close Without Saving return to the same URL. In Classic ELS, opening an expired UI link can also send the browser to the callback. Do not treat a visit to your return URL as proof that the user saved or output the document.
Example request with a return URL
curl --request POST 'https://api-app.xtracta.com/v1/documents/ui' \ --header 'Accept: application/json' \ --header 'Content-Type: application/x-www-form-urlencoded' \ --data-urlencode 'api_key=<API_KEY>' \ --data-urlencode 'document_id=<DOCUMENT_ID>' \ --data-urlencode 'buttons=save' \ --data-urlencode 'callback_url=https://your-app.example/xtracta/return?reference=invoice-123'
Use form URL encoding for callback_url, as shown by --data-urlencode above, so any query string stays part of the return URL.
Code Examples
The cURL, PHP, Python, Node.js, and C# examples call Xtracta from a trusted server. The React example calls an application-defined backend proxy so the API key is never exposed in browser code.
Store XTRACTA_API_KEY as a server-side environment variable. Never embed it in browser-delivered code.
curl --request POST 'https://api-app.xtracta.com/v1/documents/ui' \ --header 'Accept: application/json' \ --header 'Content-Type: application/x-www-form-urlencoded' \ --data-urlencode 'api_key=<API_KEY>' \ --data-urlencode 'document_id=<DOCUMENT_ID>'
Sample Request
POST https://api-app.xtracta.com/v1/documents/ui HTTP/1.1 api_key=123&document_id=456789
Sample Response
<?xml version="1.0" encoding="UTF-8"?>
<documents_response>
<status>200</status>
<message>The request has been successfully processed</message>
<url>https://api-app-ui.xtracta.com/main/an_entry/index/d/XXvVBmX.Jdk.rx2OKLOleBzLC__Q3VLbDYYWqvCUrOQ-</url>
<expire>1426630034</expire>
</documents_response>
Schema Definition
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:simpleType name="ConfidenceType">
<xs:union>
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:minInclusive value="0"/>
<xs:maxInclusive value="100"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value=""/>
</xs:restriction>
</xs:simpleType>
</xs:union>
</xs:simpleType>
<xs:element name="documents_response">
<xs:complexType>
<xs:sequence>
<xs:element name="status" type="xs:integer" minOccurs="0"/>
<xs:element name="message" type="xs:string" minOccurs="0"/>
<xs:element name="url" type="xs:anyURI" minOccurs="0"/>
<xs:element name="expire" type="xs:integer" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Error Responses
For JSON and XML responses generated by this endpoint, the response is wrapped in documents_response and includes the HTTP status code and a message.
| Status | Message | Description |
|---|---|---|
400 | <parameter> must be natural number | document_id, workflow_id, expire, document_expire, items_per_page, and page must use supported positive integer values. |
400 | <parameter> must be greater than ... / <parameter> must be less than ... | Keep expire and document_expire within the configured URL-expiry range. |
400 | <parameter> must be '0' or '1' | Boolean options such as redirect and no_lockout accept only 0 or 1. |
400 | <parameter> must be one of the values of [...] | Use a supported document status, download status, or document order. |
400 | <parameter> must be URL format / <parameter> must be email address format | Supply a valid callback_url or user_email. |
400 | Invalid XML format in field_options / Invalid field_id in field_options / Invalid field_name in field_options | Correct the field_options XML and reference fields from the selected document workflow. |
400 | Neither valid workflow_id nor document_id is specified | Supply one valid selector: workflow_id or document_id. |
403 | Document is not in valid status to process this request (...) | The selected document cannot be opened in its current processing state. |
403 | This document is not available because of the billing issue. | Resolve the billing issue, then retry. |
404 | No documents found | Check the document ID and API-key access. |
409 | Document is being processed by someone else | Wait for the current user or process to release the document, or use the supported lockout option where appropriate. |
500 | Failed to generate the New ELS URL for document ... | Retry the request. If it persists, contact support with the document ID and request timestamp. |
500 | Internal server error occurred. Please try again later or contact support@xtracta.com | Retry and contact support if the error persists. |
Authentication, permission, IP-access-control, and rate-limit failures can be returned before this endpoint processes the request. Confirm the API key and caller access first.