SortSpoke reads insurance documents and turns them into structured, verified JSON you can feed straight into your own app. Its AI does the extraction and people review what it isn't sure about, and every value carries how it was verified and the document it came from. Send documents through the API, embed SortSpoke's review screen in your own app, or both.
Your systemupload →SortSpoke sorts and extracts→Review: auto-accept or a person→Finishedexport →Your system
A document is ready to export when it reaches Finished. That happens when your project's auto-accept rules accept it, or when a person accepts it in SortSpoke or in the embedded review screen. Until then it waits for review.
The essentials
Base URLhttps://api.sortspoke.com/api/v2Use the host for your account's data center. Base URLs
File typesPDF, BMP, GIF, JPG, PNG, TIF, DOC, DOCX, XLS, XLSX, PPT, PPTX. Up to 200 MB per upload request; Office files up to 100 MB each.
WebhooksSortSpoke calls your endpoint when a submission or document changes state. Set one up in Admin → Webhooks: Create a webhook. Webhooks and polling
ResultsThe document's export, as JSON (JsonV2) or Excel, once it's Finished. Export a document
API reference filesThe OpenAPI description and a Postman collection of every public call, ready to import. Downloads
Every request sends an API token in the Authorization header. The token acts as the SortSpoke user it belongs to, with that user's access to projects and documents.
Get a token
A SortSpoke admin opens Admin → Users, picks the user and generates a token under API Tokens. Step-by-step: Create an API token.
Copy it straight away. SortSpoke shows it once.
Store it on your server, for example as SORTSPOKE_API_TOKEN. Never put it in browser code.
Tokens have an expiry date, shown on the user's page in SortSpoke. Generate a new one before it passes. Revoking a token is permanent.
Send it
Add Authorization: Bearer $SORTSPOKE_API_TOKEN and Accept: application/json to every request. The call on the right lists the projects the token can see.
A missing, wrong, expired or revoked token returns 401 with the standard error body.
Base URLs and data centers
Use the host for the data center your SortSpoke account is on. Ask SortSpoke if you're not sure. The samples on these pages use the US host; swap in yours if your account is elsewhere.
Data center
API host
Review links come from
US
https://api.sortspoke.com
https://auth.sortspoke.com
Canada
https://api.ca.sortspoke.com
https://auth.ca.sortspoke.com
US (second)
https://api.c4.sortspoke.com
https://auth.c4.sortspoke.com
User-Agent
No particular User-Agent is required. Send one that names your app, such as your-app/1.0, so SortSpoke support can find your requests. If a request ever returns an HTML page with status 403 instead of JSON, a firewall rule blocked it: send support the time of the request and your server's IP address.
Client
User-Agent sent
Result
Sample User-Agent
your-app/1.0
Accepted (200)
Python requests (default)
python-requests/2.32.5
Accepted (200)
curl (default)
curl/8.23.0
Accepted (200)
Node.js fetch (default)
node (undici), v24.14.0
Accepted (200)
.NET HttpClient (default: no User-Agent header)
(none)
Accepted (200)
Checked on 2026-11-24 against the Canada and US hosts with a valid token.
A project in SortSpoke with at least one document category.
1
Find your project and category
List projects with expanded=1 to see their names, then list the project's categories. Keep the projectId and the labelId of the category your documents belong to.
Send the file as multipart/form-data. Passing labelId sorts it into that category, so it goes straight to extraction. Keep the docId from the response.
Poll document status until documentState is 7 (Finished). Stop and handle the document if it reaches 1002 (preprocessing error), 1004 (export error), 1005 (rejected) or 1006 (quarantined). Prefer not to poll? Set up a webhook in SortSpoke for document.status_changed: Webhooks and polling.
If your project doesn't auto-accept a category, the document waits in Extracting (5) until a person accepts it. To have people review inside your own app, create a review link and embed it: Embed guide.
A commercial application arrives by email. Your system uploads it, an underwriter checks the extracted fields inside your app, and the accepted data flows back to your system.
Prerequisites
A webhook in SortSpoke for document.status_changed.ready and document.status_changed, pointing at your server (Webhooks and polling). Or poll document status instead.
SortSpoke has added your page's exact https origin to the allowed hosts for your data center, so the review screen can load in your page.
Your server creates review links. The API token never reaches the browser.
1
Upload with the category
Upload the attachment with the labelId of your application category, so it skips sorting.
Your server creates a review link for the document and returns returnUrl to your page. Create it just before showing the screen: it works once and expires 60 minutes after it's created.
Uploads one or more files into the project's default stream. SortSpoke preprocesses each file, then sorts it into a category or, if you pass labelId, sends it straight to extraction. The response comes back as soon as the files are stored. To upload into a specific stream, use POST /api/v2/streams/{streamId}/upload with the same parameters.
Downloads the document's export in the project's export format. Use it once the document is Finished (state 7) or Delivered (8).
The response is always a file download (application/octet-stream), whatever Accept header you send. In a JsonV2 project, read the body and parse it as JSON.
Export files use PascalCase keys (DocId, Fields). Other API responses use camelCase.
AutoAccepted, SortPrediction and FieldPrediction appear only when the project exports scores.
Take a finished submission out of SortSpoke and into your system: the submission's data as one JSON file, and each of its documents as a PDF with its own extracted data.
A submission is a batch in SortSpoke, for example one emailed submission with all its attachments. SortSpoke splits it into documents (an application, a loss run, a statement of values), extracts each one, and combines the values into one record for the submission. Your system pulls both levels with an API token.
Level
What you get
Call
Submission
One JSON file per submission. Values are merged across all its documents, conflicts are resolved, and each value lists the documents it came from. SortSpoke can reshape it into your format.
Know when it's done. SortSpoke calls your webhook with batch.status_changed. Act on status50 (Finished) and skip 110 (Rejected). Can't receive webhooks? See Webhooks and polling.
Get the submission data with the batchId from the event. This is the record to create in your system.
List the documents in the batch. Each has a docId; state7 means Finished.
Download each document. The PDF is the document's pages. Its JSON export carries the metadata you'll want to file it under: DocClass (the document type), SrcFilename, PageCount, ReceivedDate.
Before you start
An API token for a SortSpoke user with access to the project. Keep it on your server. Authentication
The base URL for your account's data center. Base URLs
A webhook for Batch Status Changed, set up in SortSpoke under Admin → Webhooks with your HTTPS URL. Copy the secret when it's shown: it's shown once.
Your format, if you have one. SortSpoke can map the submission JSON to the field names, codes, date formats and nesting your system expects. Send SortSpoke a sample of what your system imports. The call stays the same.
Read the submission data
The file has two parts. batch describes the submission: batchId, name, state, dates, owner and project. data holds the values, keyed by the project's field keys. Each entry in data is one of three things:
Entry
Looks like
Example
Value
{ Name, Status, Value, Sources }
uwScreeningDecision
Section
An object of values
policyInformation.proposedEffDate
Repeating group
An array of records, one per vehicle, driver or location. Each record is an array holding one object of values.
vehicle[0][0].vin
Value is the agreed value as text. Sources lists where it came from: each source has the DocId and FieldId it was read from, the text as printed (DisplayValue), a NormalizedValue, and a Tier: HumanVerified, AutoVerified or Predicted. A value typed directly on the submission, such as an underwriter's decision, has SourceTypeSubmission and no DocId.
Link a value to its page
Use the DocId to show the source document next to the value, or to open SortSpoke's review screen on that field. Read-only links and field deep links
Make it reliable
Answer the webhook within 60 seconds with any 2xx, then do the downloads in the background. SortSpoke retries failed deliveries, so the same event can arrive twice: skip an id you've already handled.
Pull again any time. The submission export works in any batch state and returns the same file for the same data. After the submission is accepted in SortSpoke its values are frozen.
Stream PDFs to disk. A 30-page application can be several megabytes.
Ignore keys you don't use. SortSpoke adds keys over time, and the keys in data follow the project's setup.
Default batches don't send batch.status_changed: only named batches, such as one per emailed submission, do. Note the casing sourcefileId, with a lowercase f. status is a number from State codes.
Set up a webhook
In SortSpoke, go to Admin → Webhooks and add a webhook.
Enter your HTTPS URL and pick the events, for example Batch Status Changed.
Copy the secret. It's shown once; store it with your other secrets.
Step by step, with screenshots: Create or remove a webhook. Ask SortSpoke if you want webhooks set up for you.
What you receive
A POST with Content-Type: application/json and User-Agent: SortSpoke/1.0. The body is an envelope around the event's data: id (unique per event), event, attempt (1 on the first try), data and creationTimeUtc.
Verify the signature
Every delivery has a sortspoke-webhook-signature header: an HMAC-SHA256 of the raw request body, keyed with your webhook secret exactly as shown (its UTF-8 bytes; don't decode it first), written as uppercase hex pairs joined by dashes, like 3A-F2-…. Compute it over the bytes you received, before any JSON parsing, and compare in constant time. Reject anything that doesn't match.
Delivery and retries
Answer with any 2xx within 60 seconds. Anything else, or no answer, is a failed delivery.
SortSpoke retries with growing gaps, up to about a day apart, for about 30 days. attempt counts the tries.
The same event can arrive more than once. Use id to skip repeats.
A webhook that keeps failing gets warnings on days 7, 14, 21 and 28 and is switched off on day 30.
Polling instead
If your system can't receive calls from outside, poll. Keep the interval to 15 seconds or more, and run a daily check for anything missed even when you use webhooks.
A submission: call Export submission data and check batch.state. Finished means it's ready.
Returns one submission's data as a single JSON file: values merged across all of the batch's documents, conflicts resolved, in the format set up for your project. This is the call to create a record in your system.
Send Accept: application/json to get JSON back. Without it the same body comes as a file download named after the batch.
Works in any batch state. Wait for batch.status_changed with status50, or check batch.state, before you import.
Needs a project with submission review switched on.
Batch ID. One batch is one submission. It arrives as batchId in the batch.status_changed webhook.
formatstringquery
Leave it out to get the project's assigned format. transform:{specName} or transform:{specName}@{version} applies a named transformation. Only JSON is available.
Your format
SortSpoke can apply a transformation to this file: rename and nest fields, split one value into several (an address into street, city, state and ZIP), change date formats, map values to your codes and drop what you don't need. SortSpoke sets it up for your project from a sample of what your system imports, and can preview it against a real submission first. Once it's assigned, this call returns your format with no change on your side.
When the batch was created. dateFinished is when it finished.
ownedByuuid
The user who owns the batch. ownedByUserName is their user name.
acctIduuid
The account.
projectIduuid
The project. projectName is its name.
streamIduuid
The stream. streamName is its name.
dataobject
The values, keyed by the project's field keys. Each entry is a value, a section (an object of values) or a repeating group (an array of records, each an array holding one object of values).
Show a value's 4 fields
Namestring
The field's display name.
Statusstring
Resolved once one value has been agreed.
Valuestring
The agreed value as text.
Sourcesarray
Where the value came from: SourceType (Document or Submission), DisplayValue, NormalizedValue, DocId, FieldId, ValueId, RecordId, RowId, TableInstanceId and Tier (HumanVerified, AutoVerified or Predicted). RecordId and RowId are null unless the value came from a record or table row.
Errors
Status
When
401
Missing, wrong, expired or revoked token.
404
Unknown batch or no access, a project without submission review, or an unknown transformation in format.
422
format asked for CSV or Excel: "Only JSON is available for a submission export."
Returns the submission's data exactly as the Submission tab in SortSpoke shows it, with no transformation. Use it to see the full shape while you build a mapping. To import into your system, use Export submission data, which applies your project's format.
Creates an empty named batch and returns its ID. A batch groups the files of one submission: upload files into it with Upload files to a batch. The project route uses the project's default stream; the stream route takes streamId in place of projectId and the same body.
Named batches need a custom project configuration. Ask SortSpoke support to set it up.
batchName must be unique among active batches (Filling, Filled or Claimed). The check ignores case.
Leave out assigneeUserIdOrUserName to create the batch unassigned. You can assign it later with Assign a batch.
When a named batch is Finished or Rejected, SortSpoke sends the batch.status_changed webhook. See Webhooks and polling.
Parameters
projectIduuidpathrequired
Project ID from List projects.
batchNamestringbodyrequired
Unique among active batches.
assigneeUserIdOrUserNamestringbody
Leave out to create the batch unassigned.
Returns
The new batch's ID as a bare JSON string, not an object.
Errors
Status
When
400
The batch wasn't created: for example, the name is already used by an active batch, the project or stream ID is wrong, or the token's user can't use it.
Uploads one or more files into a named batch. It works like Upload files to a project: the same multipart/form-data body, the same limits and the same response. Every file part in the form is processed; name the field file.
Pass labelId to send the documents straight to extraction in that category instead of sorting them.
A request can be up to 200,000,000 bytes. Office files (doc, docx, xls, xlsx, ppt, pptx) can be up to 100,000,000 bytes each.
Parameters
batchIduuidpathrequired
Batch ID.
labelIduuidquery
Category to sort the document into. The document skips sorting and goes to Extracting.
filefileform fieldrequired
One or more files as multipart/form-data. Every file part is processed.
Returns
An array with one entry per file:
docIduuid
The document SortSpoke created.
sourceFileIduuid
The stored file. One file can become several documents when it's split.
filenamestring
Stored path: /<uploader>/<file name>.
sizeinteger
File size in bytes.
Errors
Status
When
400
Every file failed, the batch ID is wrong, or the token's user can't use the batch.
401
Missing, wrong, expired or revoked token.
413
An Office file is over 100,000,000 bytes, or the request is over 200,000,000 bytes.
state accepts only the active states: Filling (10), Filled (20) and Claimed (30).
The batch itself must be active and created through the API. Batches from a cloud storage import (isCloudImportedBatch is true) can't be updated.
Parameters
batchIduuidpathrequired
Batch ID.
batchNamestringbodyrequired
The new name. It can't be empty.
stateintegerbody
10, 20 or 30 only.
Returns
200 with an empty body.
Errors
Status
When
400
batchName is empty, state isn't 10, 20 or 30, the batch isn't active or came from a cloud storage import, the batch ID is wrong, or the token's user can't use the batch.
The user the batch is assigned to. null when it's unassigned.
creationDatedate-time
When the batch was created.
finishedDatedate-time
When the batch finished. Left out until then.
isDefaultboolean
A user's default batch, not a named one.
isCloudImportedBatchboolean
Created by a cloud storage import, not through the API.
triageBucketIduuid
The batch's TriageAI bucket. All zeros when it has none.
triageBucketNamestring
The bucket's name. Empty when it has none.
emailImportInfoobject or null
null unless the batch came from an email import.
customColumnDataarray
Values for the project's custom columns. Empty when it has none.
Errors
Status
When
400
The project or stream ID is wrong, the token's user can't use it, or the body isn't valid JSON. If every request returns 400, even { "limit": 1, "pageNumber": 1 }, send the traceId to SortSpoke support.
Marks finished batches, and their documents, as Delivered: the batch moves to state 60 and its documents to 8. Call it once your system has imported the submission.
Send a bare JSON array of batch IDs, not an object.
A batch is ready to deliver when it's Finished (50).
Parameters
(request body)uuid[]bodyrequired
A bare JSON array of finished batch IDs.
Returns
200 with an empty body.
Errors
Status
When
400
The body isn't a JSON array of IDs, or the batches couldn't be delivered: for example, an ID is wrong or the token's user can't use the batch.
Lists a project's documents, one page at a time, filtered by state, category, dates or name. To search one stream instead of the whole project, send the same body to POST /api/v2/streams/{streamId}/docs/list with the stream's ID.
Every filter is optional.
query is a single string, not an array.
Parameters
projectIduuidpathrequired
Project ID from List projects.
pageNumberintegerbody
1-based page number.
limitintegerbody
Results per page. Default 25, maximum 1000.
querystringbody
Prefix match on the name.
stateFilter.filterValuesinteger[]body
States to include.
sortingobject[]body
[{ "fieldName": "FinishedDate", "type": "Descending" }]. type also accepts 0 (ascending) or 1 (descending).
labelFilter.filterValuesuuid[]body
Categories to include.
dateFilterobjectbody
One object with fromCreationDate, toCreationDate, fromFinishedDate, toFinishedDate, fromExportedDate, toExportedDate.
Each filter takes the form { "filterValues": [ … ] }, for example "stateFilter": { "filterValues": [7] } for Finished documents. dateFilter is one object: send only the bounds you need, as date-times, for example { "fromFinishedDate": "2026-11-01T00:00:00Z" }.
In sorting, set type to "Descending" or 1 for newest first, or 0 for ascending. This page shows FinishedDate as the sort field; ask SortSpoke before you sort on another one.
Paging through results
pageNumber starts at 1. Ask for the next page until pageNumber reaches pageCount. limit defaults to 25 and can go up to 1000.
Returns
One page of results:
itemCountinteger
The number of documents that match.
pageCountinteger
The number of pages at this limit. pageSize and offset describe the page you got.
searchTooManyResultsboolean
A flag on the search. Ask SortSpoke before you rely on it.
When the document was created. finishedDate, exportedDate, splitDate and rejectedDate follow the same format. A date that isn't set comes back as 0001-01-01T00:00:00, with or without a Z, or as null.
rejectionReasonstring
Why the document was rejected, or null.
virusScanFailedboolean
The file failed the antivirus scan. Can be null.
stageNamestring
Can be null.
fieldPredictionFailureobject
Null, or { date, reasonCode, message }.
Errors
Status
When
400
The body isn't valid JSON, the project or stream ID is wrong, or the token's user can't use the project.
401
Missing, wrong, expired or revoked token.
If every search on a project returns 400, even {"limit": 1, "pageNumber": 1}, send SortSpoke the traceId. Errors use the standard error body.
Lists the documents that came from the same uploaded file as this one, with their category, state and pages. The list includes the document you asked about.
Parameters
docIduuidpathrequired
Document ID from the upload response.
Returns
An array with one entry per document:
docIduuid
The document.
labelIduuid
The document's category.
predictedLabelobject
The category SortSpoke predicted: labelId, confidence and datePredicted. It can differ from labelId.
Which pages of the uploaded file make up the document.
Show 3 fields
docPageNuminteger
Page number in the document, from 1.
sourceFileIduuid
The uploaded file.
sourceFilePageNuminteger
Page number in the uploaded file, from 1.
Each entry also has stageId, containsVerifiedFields, containsComments, ownedByCurrentUser and ownedByCurrentUserInDifferentBatch. SortSpoke's own screens use them; you can ignore them.
Creates a one-time link that opens SortSpoke's review screen for one document. Load the link in an iframe in your app. A document in state 3, 4, 5 or 510 opens in the Extract view; a document in state 7 or 8 opens in the read-only Finished view. Other states return 400.
Call this from your server only.
The API rejects browser calls, and your API token must stay on your server. Send the returnUrl to your page.
A JSON body is required. Send {} for the defaults.
Each link works once and expires 60 minutes after you create it; SortSpoke can change both per project. The embedded session also ends at expiryDate, so create the link right before you show the screen.
An editable link puts the document in the token user's queue: a document with no batch joins that user's default batch, and an unassigned batch is claimed by them. Send "readOnly": true to avoid this.
Downloads one document's export as an Excel file. Call it once the document is Finished (state 7).
The response is a binary file, not JSON: application/vnd.ms-excel for an .xlsx file, or the macro-enabled Excel type for an .xlsm file. Stream it to disk.
Downloads the exports of several documents in one ZIP file. The first route uses the project's export format. The /Excel route returns the exports as Excel files.
Send the document IDs as form data (multipart/form-data or form-urlencoded), not JSON. Repeat the docIds field once per document.
The response is a binary file, not JSON: application/zip, named SortSpokeExport_<UTC time>.zip. Stream it to disk.
Lists the projects the token's user can access. By default the response is an array of project IDs. Send expanded=1 to get a project object for each one, with its name and default stream.
A project object has more fields than the ones below. Use only these; the rest is internal configuration.
Lists the document categories set up in a project. The API calls a category a label, so its ID is labelId. Pass it as labelId when you upload to send a document straight to that category, or use it to list the category's fields.
Each category has more settings than the ones below. Use only these.
Uploads one or more files into a specific stream of a project. It works like Upload files to a project, which always uses the project's default stream: same parameters, same response, same limits.
A project's default stream is its defaultStreamId in List projects with expanded=1.
Send the files as multipart/form-data. Every file part in the form is processed; name the part file.
Pass labelId to send a document straight to that category's extraction; without it, SortSpoke sorts it first.
Parameters
streamIduuidpathrequired
Stream ID (a project's defaultStreamId, or a custom stream).
uploadPathstringquery
Virtual folder, for example /inbox/claims@example.com. Without it, files go to the uploading user's queue.
labelIduuidquery
Category to sort the document into. The document skips sorting and goes to Extracting.
filefileform fieldrequired
One or more files as multipart/form-data. Every file part is processed.
Returns the state of a file you uploaded. A source file is the stored upload; SortSpoke can split it into several documents. State 300 (Finished) means the file and all of its documents are finished.
Take sourceFileId from the upload response.
An unknown source file ID returns 400.
Parameters
sourceFileIduuidpathrequired
Source file ID from the upload response.
Returns
sourceFileIduuid
The source file.
projectIduuid
The project it was uploaded to.
stateinteger
The source file state. 300 is Finished. State codes
sourceFileNamestring
The file name.
pageCountinteger
Number of pages in the file.
Errors
Status
When
400
Unknown source file, or the token's user can't use it.
Splits an uploaded file into documents by page range. Each entry in docPageRanges becomes one document in the category you give, made of the pages you list. Use it when one file holds several documents, for example an application followed by a loss run.
Page numbers in sourceFilePageNums start at 1. Take category IDs from List categories.
Every document from the file must still be at state 5 (Extracting) or earlier, or the request fails.
Pages with an invalid labelId or page range don't become a document, and there's no error for them. Check documents in the response.
The file's earlier documents are removed or regenerated by the split: state 1100 (Deleted During Split).
Marks finished source files as Delivered (state 310), to record that you've received their exports. Their finished documents become Delivered (8) too, and a related batch moves to Delivered when it qualifies.
Send a bare JSON array of source file IDs, not an object.
Parameters
(request body)uuid[]bodyrequired
A bare JSON array of finished source file IDs.
Returns
200 with an empty body.
Errors
Status
When
400
The body isn't a JSON array of IDs, or the request failed. Check that each ID is a finished source file the token's user can use.
Show SortSpoke's review screen in an iframe so people check and correct extracted data inside your app. Your server creates a review link, your page loads it, and SortSpoke posts messages to your page as the reviewer works.
Before you start
Send SortSpoke the exact https origin of the page that will show the iframe, for example https://app.example.com, for each data center you use. SortSpoke adds it to the allowed hosts; until then the browser refuses to show the screen.
Create review links on your server. The API rejects browser calls, and your API token must stay on your server.
1. Create a review link on your server
Call POST /api/v2/presigned/document/{docId}. A JSON body is required: send {} for the defaults, or set options in embedConfig. The link opens the Extract view for a document in states 3, 4, 5 or 510, and the read-only Finished view for states 7 and 8. Other states return 400.
// On your server: never call this from the browser.
const res = await fetch(`${BASE}/api/v2/presigned/document/${docId}`, {
method: "POST",
headers: { ...headers, "Content-Type": "application/json" },
body: JSON.stringify({
embedConfig: { ui: { language: "en-CA" }, messaging: { emitExportFieldsData: true } },
}),
});
if (!res.ok) throw new Error(`SortSpoke ${res.status}: ${await res.text()}`);
const { returnUrl, expiryDate } = await res.json();
// Send returnUrl to your page.
# On your server: never call this from the browser.
res = requests.post(
f"{BASE}/api/v2/presigned/document/{doc_id}",
json={"embedConfig": {"ui": {"language": "en-CA"}, "messaging": {"emitExportFieldsData": True}}},
headers=HEADERS,
)
res.raise_for_status()
return_url = res.json()["returnUrl"]
// On your server: never call this from the browser.
var res = await http.PostAsJsonAsync($"/api/v2/presigned/document/{docId}", new
{
embedConfig = new { ui = new { language = "en-CA" }, messaging = new { emitExportFieldsData = true } },
});
res.EnsureSuccessStatusCode();
using var link = JsonDocument.Parse(await res.Content.ReadAsStringAsync());
var returnUrl = link.RootElement.GetProperty("returnUrl").GetString();
Each link works once and expires 60 minutes after you create it.
The embedded session also ends at expiryDate, so create the link right before you show the screen. SortSpoke can change uses (1 to 100) and expiry (10 minutes to 24 hours) per project on request.
Creating an editable link also puts the document in the token user's queue: a document with no batch joins that user's default batch, and an unassigned batch is claimed by them. A document in someone else's batch returns 400. Send "readOnly": true to open a view-only link without these effects.
2. Load the iframe
Use all three sandbox tokens. allow-forms is required: the review screen starts with a form post inside the frame.
SortSpoke posts messages to your page with target "*", so check where each one came from. Trust a message only if event.source is your iframe and event.origin is your API host or the origin of returnUrl.
Your page · JavaScript
const API_ORIGIN = "https://api.sortspoke.com";
const iframe = document.getElementById("sortspoke-iframe");
async function openReview(docId) {
// Your own endpoint, which calls the presigned API on your server.
const { returnUrl } = await (await fetch(`/review-links/${docId}`, { method: "POST" })).json();
const allowed = [API_ORIGIN, new URL(returnUrl).origin];
window.addEventListener("message", (event) => {
if (event.source !== iframe.contentWindow || !allowed.includes(event.origin)) return;
const msg = event.data;
if (msg.messageType === "Document_State_Change" && msg.message === "Exporting") {
// Accepted: wait for the document to reach Finished (7), then download the export.
}
if (msg.messageType === "Close_Window") iframe.hidden = true;
});
iframe.setAttribute("src", returnUrl);
iframe.hidden = false;
}
Message
Sent when
Key fields
Document_State_Change
The reviewer accepts ("Exporting", 6), rejects ("Rejected", 1005) or sorts the document ("Predicting Values", 4). In batch sessions, re-sorting sends "Sorting", 3. On by default.
subjectId (the document), message, state, timestamp
Export_Fields_Data
Right after an accept. Off by default: set messaging.emitExportFieldsData to true.
message ("success" or "error"), data (the fields)
Close_Window
The reviewer clicks the close button. SortSpoke signs the session out first. Also sent from the expired-link page.
sortSpokeModule is "App"; field data only if messaging.closeWindowData is "changed" or "all"
"none", "changed" or "all": what Close_Window carries. "changed" sends every field plus changedFieldIds.
theme.primaryColour
#0091B6
Main colour, as #RRGGBB. Note the British spelling.
theme.headerColour
—
Header bar colour.
featureFlags.enhancedNavOn
false
Start with fast navigation on.
featureFlags.splitEnabled
false
Allow splitting. Batch review only.
Read-only links and field deep links
Next to embedConfig, send "readOnly": true for a view-only link, or fieldTarget to open at one field: { "fieldId": "…" }, { "fieldId": "…", "recordId": "…" } for one row or record, or { "valueId": "…" }.
Known limits
The review screen uses a cookie that sortspoke.com sets inside your page. Browsers that block third-party cookies may not load it. Test in the browsers your users run.
The iframe doesn't accept messages from your page.