spektr SDK
📦 JavaScript: client-sdk (npm)
client-sdk (npm)- Get the npm repository endpoint:
export CODEARTIFACT_NPM_URL=$(aws codeartifact get-repository-endpoint \
--domain spektr \
--domain-owner {spektr-id} \
--repository spektr-npm \
--format npm \
--query repositoryEndpoint \
--output text)- Authenticate npm:
aws codeartifact login \
--tool npm \
--domain spektr \
--domain-owner {spektr-id} \
--repository spektr-npmThis command automatically configures your .npmrc to use the CodeArtifact repo.
- Install the package:
npm install @spektr/client-sdk✅ Notes
- Your access is limited to read-only access to specific repositories.
- The external ID is required when assuming the role, do not share it externally.
- The token expires after 12 hours; you’ll need to refresh it using the above steps.
Conditional Fields unwrap
Usage:
The formEvaluation method unwraps the full form after evaluation of all the conditional fields and rules.
import SpektrSdk from '@spektr/client-sdk';
// example
const unwrappedForm = SpektrSdk.formEvaluation(form, {
first_name: 'John',
last_name: 'Doe',
date_of_birth: '1747170000000',
country_of_residence: 'DK',
});Translation
Usage:
The translateFields method transforms all the field labels to the provided language passed as argument. This can also be used to generate all the options for static values such as NACE codes, Country codes, etc.
import SpektrSdk from '@spektr/client-sdk';
const translatedForm = await SpektrSdk.translateFields(
response.node.form.fields,
selectedLanguage
);Form summary steps
When polling Fetch current step, the node may have type: "formSummary". That step is a read-only recap:
- Render
node.summary(heading, subtitle, blocks/fields, optional button labels). - Do not call
translateFieldson it — there is nonode.form. - Continue by submitting an empty body (
{}) tosubmitUrl. Sending any field values returns400with messageForm summary continue does not accept field values.
Expired links
A client-facing link lives for 90 days. Once it lapses, execution.status on Fetch current step can be expired —
a new terminal value in the status enum, so treat any unrecognised status as terminal rather than as a reason to keep
polling:
Fetch current stepanswers200withexecution.status: "expired",node: nullandgoBackAllowed: false.
Render your expiry screen and stop polling; there is no step to show.- Submitting to
submitUrl(or go-back, confirm, or file submission) answers410 Gonewith
errorCode: "context_expired". The link is permanently dead — do not retry. - In the short window between the link lapsing and the platform recording it, the same calls answer
401. Treat 401
and 410 the same way in the end-client UI; only 410 tells you the link expired for certain.
The lapse is also published as the process_expired webhook event, so a back office can react without polling. See the
webhook documentation.
Related-entity wait steps
When polling Fetch current step, the node may have type: "relatedEntitiesProcessWait" while the parent execution waits for related-entity subprocesses (for example UBO onboarding loops):
- Render
node.subprocessesas status cards. Each item includes optional identity fields (firstName,lastName,fullName,email), an optionalformUrlfor the child session, and astatusofpending,complete, orfailed. - Keep polling this endpoint to refresh subprocess status. When every subprocess is settled and the parent is ready to continue, the node type changes and the parent execution advances automatically.
- While child executions are still being registered, the node may temporarily be
type: "internal"— keep polling until subprocess cards appear or the execution completes or fails. - Direct end users to each child’s
formUrlwhile itsstatusispending. Do not submit the parentsubmitUrlfor this step.
Updated 11 days ago