JavaScript API

Quick Start

import PlaidClient from 'plaid-client';

const client = await PlaidClient.login('http://localhost:8085', 'user@example.com', 'password');

// Create a project
const project = await client.projects.create('My Project');

// Create a document
const doc = await client.documents.create(project.id, 'Document 1');

// Get a project with its documents
const full = await client.projects.get(project.id, true);

// Batch multiple operations atomically
client.beginBatch();
client.tokens.create(tokenLayerId, textId, 0, 5);
client.tokens.create(tokenLayerId, textId, 6, 11);
const results = await client.submitBatch();

Client

constructor(baseUrl, token)

Create a new PlaidClient instance

ParameterTypeDescription
baseUrl string The base URL for the API
token string The authentication token
login(baseUrl, userId, password) static

Authenticate and return a new client instance with token

ParameterTypeDescription
baseUrl string The base URL for the API
userId string User ID for authentication
password string Password for authentication
enterStrictMode(documentId)

Enter strict mode for a specific document.

ParameterTypeDescription
documentId string The ID of the document to track versions for
exitStrictMode()

Exit strict mode and stop tracking document versions for writes.

setAgentName(agentName)

Set the user agent name for audit logging.

ParameterTypeDescription
agentName string Name to identify this client in audit logs
beginBatch()

Begin a batch of operations. Subsequent API calls will be queued.

submitBatch()

Submit all queued batch operations as a single batch request.

abortBatch()

Abort the current batch without executing any operations.

isBatchMode()

Check if currently in batch mode.

Batch

batch.submit(body)

Execute multiple API operations atomically.

ParameterTypeDescription
body Array The request body

Documents

documents.checkLock(documentId, [asOf])

Get information about a document lock

ParameterTypeDescription
documentId string The document ID
asOf optional string Temporal query timestamp
documents.acquireLock(documentId)

Acquire or refresh a document lock

ParameterTypeDescription
documentId string The document ID
documents.releaseLock(documentId)

Release a document lock

ParameterTypeDescription
documentId string The document ID
documents.getMedia(documentId, [asOf])

Get media file for a document

ParameterTypeDescription
documentId string The document ID
asOf optional string Temporal query timestamp
documents.uploadMedia(documentId, file)

Upload a media file for a document. Uses Apache Tika for content validation.

ParameterTypeDescription
documentId string The document ID
file File The file to upload
documents.deleteMedia(documentId)

Delete media file for a document

ParameterTypeDescription
documentId string The document ID
documents.setMetadata(documentId, body)

Replace all metadata for a document.

ParameterTypeDescription
documentId string The document ID
body any The request body
documents.deleteMetadata(documentId)

Remove all metadata from a document.

ParameterTypeDescription
documentId string The document ID
documents.audit(documentId, [startTime], [endTime], [asOf])

Get audit log for a document

ParameterTypeDescription
documentId string The document ID
startTime optional string Start of time range
endTime optional string End of time range
asOf optional string Temporal query timestamp
documents.get(documentId, [includeBody], [asOf])

Get a document. Set `includeBody` to true to include all data.

ParameterTypeDescription
documentId string The document ID
includeBody optional boolean Include document body data
asOf optional string Temporal query timestamp
documents.delete(documentId)

Delete a document and all data contained.

ParameterTypeDescription
documentId string The document ID
documents.update(documentId, name)

Update a document's name.

ParameterTypeDescription
documentId string The document ID
name string The name
documents.create(projectId, name, [metadata])

Create a new document in a project.

ParameterTypeDescription
projectId string The project ID
name string The name
metadata optional any Metadata map

Messages

messages.listen(projectId, onEvent)

Listen for project events including service coordination messages

ParameterTypeDescription
projectId string The UUID of the project to listen to
onEvent function Callback function that receives (eventType, data). If it returns true, listening will stop.
messages.sendMessage(projectId, data)

Send a message to project listeners

ParameterTypeDescription
projectId string The UUID of the project to send to
data any The message data to send
messages.discoverServices(projectId, [timeout])

Discover available services in a project

ParameterTypeDescription
projectId string The UUID of the project to query
timeout optional number Timeout in milliseconds (default: 3000)
messages.serve(projectId, serviceInfo, onServiceRequest, [extras])

Register as a service and handle incoming requests

ParameterTypeDescription
projectId string The UUID of the project to serve
serviceInfo Object Service information {serviceId, serviceName, description}
onServiceRequest function Callback to handle service requests
extras optional Object Optional additional service metadata
messages.requestService(projectId, serviceId, data, [timeout])

Request a service to perform work

ParameterTypeDescription
projectId string The UUID of the project
serviceId string The ID of the service to request
data any The request data
timeout optional number Timeout in milliseconds (default: 10000)

Projects

projects.addWriter(id, userId)

Set a user's access level to read and write for this project.

ParameterTypeDescription
id string The resource ID
userId string The user ID
projects.removeWriter(id, userId)

Remove a user's writer privileges for this project.

ParameterTypeDescription
id string The resource ID
userId string The user ID
projects.addReader(id, userId)

Set a user's access level to read-only for this project.

ParameterTypeDescription
id string The resource ID
userId string The user ID
projects.removeReader(id, userId)

Remove a user's reader privileges for this project.

ParameterTypeDescription
id string The resource ID
userId string The user ID
projects.setConfig(id, namespace, configKey, configValue)

Set a configuration value for a project in an editor namespace.

ParameterTypeDescription
id string The resource ID
namespace string The config namespace
configKey string The config key
configValue any Configuration value to set
projects.deleteConfig(id, namespace, configKey)

Remove a configuration value for a project.

ParameterTypeDescription
id string The resource ID
namespace string The config namespace
configKey string The config key
projects.addMaintainer(id, userId)

Assign a user as a maintainer for this project.

ParameterTypeDescription
id string The resource ID
userId string The user ID
projects.removeMaintainer(id, userId)

Remove a user's maintainer privileges for this project.

ParameterTypeDescription
id string The resource ID
userId string The user ID
projects.audit(projectId, [startTime], [endTime], [asOf])

Get audit log for a project

ParameterTypeDescription
projectId string The project ID
startTime optional string Start of time range
endTime optional string End of time range
asOf optional string Temporal query timestamp
projects.linkVocab(id, vocabId)

Link a vocabulary to a project.

ParameterTypeDescription
id string The resource ID
vocabId string The vocab layer ID
projects.unlinkVocab(id, vocabId)

Unlink a vocabulary from a project.

ParameterTypeDescription
id string The resource ID
vocabId string The vocab layer ID
projects.get(id, [includeDocuments], [asOf])

Get a project by ID.

ParameterTypeDescription
id string The resource ID
includeDocuments optional boolean Include document IDs and names
asOf optional string Temporal query timestamp
projects.delete(id)

Delete a project.

ParameterTypeDescription
id string The resource ID
projects.update(id, name)

Update a project's name.

ParameterTypeDescription
id string The resource ID
name string The name
projects.list([asOf])

List all projects accessible to user

ParameterTypeDescription
asOf optional string Temporal query timestamp
projects.create(name)

Create a new project. Note: this also registers the user as a maintainer.

ParameterTypeDescription
name string The name

Relation Layers

relationLayers.shift(relationLayerId, direction)

Shift a relation layer's order.

ParameterTypeDescription
relationLayerId string The relation layer ID
direction string The direction ("up" or "down")
relationLayers.create(spanLayerId, name)

Create a new relation layer.

ParameterTypeDescription
spanLayerId string The span layer ID
name string The name
relationLayers.setConfig(relationLayerId, namespace, configKey, configValue)

Set a configuration value for a layer in an editor namespace.

ParameterTypeDescription
relationLayerId string The relation layer ID
namespace string The config namespace
configKey string The config key
configValue any Configuration value to set
relationLayers.deleteConfig(relationLayerId, namespace, configKey)

Remove a configuration value for a layer.

ParameterTypeDescription
relationLayerId string The relation layer ID
namespace string The config namespace
configKey string The config key
relationLayers.get(relationLayerId, [asOf])

Get a relation layer by ID.

ParameterTypeDescription
relationLayerId string The relation layer ID
asOf optional string Temporal query timestamp
relationLayers.delete(relationLayerId)

Delete a relation layer.

ParameterTypeDescription
relationLayerId string The relation layer ID
relationLayers.update(relationLayerId, name)

Update a relation layer's name.

ParameterTypeDescription
relationLayerId string The relation layer ID
name string The name

Relations

relations.setMetadata(relationId, body)

Replace all metadata for a relation.

ParameterTypeDescription
relationId string The relation ID
body any The request body
relations.deleteMetadata(relationId)

Remove all metadata from a relation.

ParameterTypeDescription
relationId string The relation ID
relations.setTarget(relationId, spanId)

Update the target span of a relation.

ParameterTypeDescription
relationId string The relation ID
spanId string The span ID
relations.get(relationId, [asOf])

Get a relation by ID.

ParameterTypeDescription
relationId string The relation ID
asOf optional string Temporal query timestamp
relations.delete(relationId)

Delete a relation.

ParameterTypeDescription
relationId string The relation ID
relations.update(relationId, value)

Update a relation's value.

ParameterTypeDescription
relationId string The relation ID
value any The value
relations.setSource(relationId, spanId)

Update the source span of a relation.

ParameterTypeDescription
relationId string The relation ID
spanId string The span ID
relations.create(layerId, sourceId, targetId, value, [metadata])

Create a new relation.

ParameterTypeDescription
layerId string The relation layer ID
sourceId string The source span ID
targetId string The target span ID
value any The value
metadata optional any Metadata map
relations.bulkCreate(body)

Create multiple relations in a single operation.

ParameterTypeDescription
body Array The request body
relations.bulkDelete(body)

Delete multiple relations in a single operation. Provide an array of IDs.

ParameterTypeDescription
body Array The request body

Span Layers

spanLayers.setConfig(spanLayerId, namespace, configKey, configValue)

Set a configuration value for a layer in an editor namespace.

ParameterTypeDescription
spanLayerId string The span layer ID
namespace string The config namespace
configKey string The config key
configValue any Configuration value to set
spanLayers.deleteConfig(spanLayerId, namespace, configKey)

Remove a configuration value for a layer.

ParameterTypeDescription
spanLayerId string The span layer ID
namespace string The config namespace
configKey string The config key
spanLayers.get(spanLayerId, [asOf])

Get a span layer by ID.

ParameterTypeDescription
spanLayerId string The span layer ID
asOf optional string Temporal query timestamp
spanLayers.delete(spanLayerId)

Delete a span layer.

ParameterTypeDescription
spanLayerId string The span layer ID
spanLayers.update(spanLayerId, name)

Update a span layer's name.

ParameterTypeDescription
spanLayerId string The span layer ID
name string The name
spanLayers.create(tokenLayerId, name)

Create a new span layer.

ParameterTypeDescription
tokenLayerId string The token layer ID
name string The name
spanLayers.shift(spanLayerId, direction)

Shift a span layer's order.

ParameterTypeDescription
spanLayerId string The span layer ID
direction string The direction ("up" or "down")

Spans

spans.setTokens(spanId, tokens)

Replace tokens for a span.

ParameterTypeDescription
spanId string The span ID
tokens Array The tokens
spans.create(spanLayerId, tokens, value, [metadata])

Create a new span.

ParameterTypeDescription
spanLayerId string The span layer ID
tokens Array The tokens
value any The value
metadata optional any Metadata map
spans.get(spanId, [asOf])

Get a span by ID.

ParameterTypeDescription
spanId string The span ID
asOf optional string Temporal query timestamp
spans.delete(spanId)

Delete a span.

ParameterTypeDescription
spanId string The span ID
spans.update(spanId, value)

Update a span's value.

ParameterTypeDescription
spanId string The span ID
value any The value
spans.bulkCreate(body)

Create multiple spans in a single operation.

ParameterTypeDescription
body Array The request body
spans.bulkDelete(body)

Delete multiple spans in a single operation. Provide an array of IDs.

ParameterTypeDescription
body Array The request body
spans.setMetadata(spanId, body)

Replace all metadata for a span.

ParameterTypeDescription
spanId string The span ID
body any The request body
spans.deleteMetadata(spanId)

Remove all metadata from a span.

ParameterTypeDescription
spanId string The span ID

Text Layers

textLayers.setConfig(textLayerId, namespace, configKey, configValue)

Set a configuration value for a layer in an editor namespace.

ParameterTypeDescription
textLayerId string The text layer ID
namespace string The config namespace
configKey string The config key
configValue any Configuration value to set
textLayers.deleteConfig(textLayerId, namespace, configKey)

Remove a configuration value for a layer.

ParameterTypeDescription
textLayerId string The text layer ID
namespace string The config namespace
configKey string The config key
textLayers.get(textLayerId, [asOf])

Get a text layer by ID.

ParameterTypeDescription
textLayerId string The text layer ID
asOf optional string Temporal query timestamp
textLayers.delete(textLayerId)

Delete a text layer.

ParameterTypeDescription
textLayerId string The text layer ID
textLayers.update(textLayerId, name)

Update a text layer's name.

ParameterTypeDescription
textLayerId string The text layer ID
name string The name
textLayers.shift(textLayerId, direction)

Shift a text layer's order within the project.

ParameterTypeDescription
textLayerId string The text layer ID
direction string The direction ("up" or "down")
textLayers.create(projectId, name)

Create a new text layer for a project.

ParameterTypeDescription
projectId string The project ID
name string The name

Texts

texts.setMetadata(textId, body)

Replace all metadata for a text.

ParameterTypeDescription
textId string The text ID
body any The request body
texts.deleteMetadata(textId)

Remove all metadata from a text.

ParameterTypeDescription
textId string The text ID
texts.create(textLayerId, documentId, body, [metadata])

Create a new text in a document's text layer.

ParameterTypeDescription
textLayerId string The text layer ID
documentId string The document ID
body string The request body
metadata optional any Metadata map
texts.get(textId, [asOf])

Get a text.

ParameterTypeDescription
textId string The text ID
asOf optional string Temporal query timestamp
texts.delete(textId)

Delete a text and all dependent data.

ParameterTypeDescription
textId string The text ID
texts.update(textId, body)

Update a text's body.

ParameterTypeDescription
textId string The text ID
body any The request body

Token Layers

tokenLayers.shift(tokenLayerId, direction)

Shift a token layer's order.

ParameterTypeDescription
tokenLayerId string The token layer ID
direction string The direction ("up" or "down")
tokenLayers.create(textLayerId, name)

Create a new token layer.

ParameterTypeDescription
textLayerId string The text layer ID
name string The name
tokenLayers.setConfig(tokenLayerId, namespace, configKey, configValue)

Set a configuration value for a layer in an editor namespace.

ParameterTypeDescription
tokenLayerId string The token layer ID
namespace string The config namespace
configKey string The config key
configValue any Configuration value to set
tokenLayers.deleteConfig(tokenLayerId, namespace, configKey)

Remove a configuration value for a layer.

ParameterTypeDescription
tokenLayerId string The token layer ID
namespace string The config namespace
configKey string The config key
tokenLayers.get(tokenLayerId, [asOf])

Get a token layer by ID.

ParameterTypeDescription
tokenLayerId string The token layer ID
asOf optional string Temporal query timestamp
tokenLayers.delete(tokenLayerId)

Delete a token layer.

ParameterTypeDescription
tokenLayerId string The token layer ID
tokenLayers.update(tokenLayerId, name)

Update a token layer's name.

ParameterTypeDescription
tokenLayerId string The token layer ID
name string The name

Tokens

tokens.create(tokenLayerId, text, begin, end, [precedence], [metadata])

Create a new token in a token layer.

ParameterTypeDescription
tokenLayerId string The token layer ID
text string The text ID
begin number Start offset (inclusive)
end number End offset (exclusive)
precedence optional number Ordering precedence
metadata optional any Metadata map
tokens.get(tokenId, [asOf])

Get a token.

ParameterTypeDescription
tokenId string The token ID
asOf optional string Temporal query timestamp
tokens.delete(tokenId)

Delete a token and remove it from any spans.

ParameterTypeDescription
tokenId string The token ID
tokens.update(tokenId, [begin], [end], [precedence])

Update a token.

ParameterTypeDescription
tokenId string The token ID
begin optional number New start offset
end optional number New end offset
precedence optional number Ordering precedence
tokens.bulkCreate(body)

Create multiple tokens in a single operation.

ParameterTypeDescription
body Array The request body
tokens.bulkDelete(body)

Delete multiple tokens in a single operation. Provide an array of IDs.

ParameterTypeDescription
body Array The request body
tokens.setMetadata(tokenId, body)

Replace all metadata for a token.

ParameterTypeDescription
tokenId string The token ID
body any The request body
tokens.deleteMetadata(tokenId)

Remove all metadata from a token.

ParameterTypeDescription
tokenId string The token ID

Users

users.list([asOf])

List all users

ParameterTypeDescription
asOf optional string Temporal query timestamp
users.create(username, password, isAdmin)

Create a new user

ParameterTypeDescription
username string The username
password string The password
isAdmin boolean Whether the user is an admin
users.audit(userId, [startTime], [endTime], [asOf])

Get audit log for a user's actions

ParameterTypeDescription
userId string The user ID
startTime optional string Start of time range
endTime optional string End of time range
asOf optional string Temporal query timestamp
users.get(id, [asOf])

Get a user by ID

ParameterTypeDescription
id string The resource ID
asOf optional string Temporal query timestamp
users.delete(id)

Delete a user

ParameterTypeDescription
id string The resource ID
users.update(id, [password], [username], [isAdmin])

Modify a user.

ParameterTypeDescription
id string The resource ID
password optional string New password
username optional string New username
isAdmin optional boolean New admin status

Vocab Items

vocabItems.setMetadata(id, body)

Replace all metadata for a vocab item.

ParameterTypeDescription
id string The resource ID
body any The request body
vocabItems.deleteMetadata(id)

Remove all metadata from a vocab item.

ParameterTypeDescription
id string The resource ID
vocabItems.create(vocabLayerId, form, [metadata])

Create a new vocab item

ParameterTypeDescription
vocabLayerId string The vocab layer ID
form string The vocab item form
metadata optional any Metadata map
vocabItems.get(id, [asOf])

Get a vocab item by ID

ParameterTypeDescription
id string The resource ID
asOf optional string Temporal query timestamp
vocabItems.delete(id)

Delete a vocab item

ParameterTypeDescription
id string The resource ID
vocabItems.update(id, form)

Update a vocab item's form

ParameterTypeDescription
id string The resource ID
form string The vocab item form

Vocab Layers

vocabLayers.get(id, [includeItems], [asOf])

Get a vocab layer by ID

ParameterTypeDescription
id string The resource ID
includeItems optional boolean Include vocab items
asOf optional string Temporal query timestamp
vocabLayers.delete(id)

Delete a vocab layer.

ParameterTypeDescription
id string The resource ID
vocabLayers.update(id, name)

Update a vocab layer's name.

ParameterTypeDescription
id string The resource ID
name string The name
vocabLayers.setConfig(id, namespace, configKey, configValue)

Set a configuration value for a layer in an editor namespace.

ParameterTypeDescription
id string The resource ID
namespace string The config namespace
configKey string The config key
configValue any Configuration value to set
vocabLayers.deleteConfig(id, namespace, configKey)

Remove a configuration value for a layer.

ParameterTypeDescription
id string The resource ID
namespace string The config namespace
configKey string The config key
vocabLayers.list([asOf])

List all vocab layers accessible to user

ParameterTypeDescription
asOf optional string Temporal query timestamp
vocabLayers.create(name)

Create a new vocab layer. Note: this also registers the user as a maintainer.

ParameterTypeDescription
name string The name
vocabLayers.addMaintainer(id, userId)

Assign a user as a maintainer for this vocab layer.

ParameterTypeDescription
id string The resource ID
userId string The user ID
vocabLayers.removeMaintainer(id, userId)

Remove a user's maintainer privileges for this vocab layer.

ParameterTypeDescription
id string The resource ID
userId string The user ID