Shared Libraries
Shared Libraries endpoints of the MedHook engine API: 5 operations with parameters, schemas and a curl example for each.
On this page
Versioned JavaScript shared by sandboxed steps (Mirth code template libraries), reached as libs.NAME. A step pins the version it was tested with.
List shared libraries
get/api/libraries
Every library in the caller's workspace with its latest version.
Minimum role: viewer.
Auth: Bearer token (how to get one) · Operation: listLibraries
Responses
- 200The libraries.
Response fields
application/json · object
librariesarray of object6 fields
idstringnamestringdescriptionstring | nulllatestVersionintegerexportNamesarray of stringpinnedByintegerWorkflow drafts that pin it (list only).
totalinteger
Example request
curl "$ENGINE_URL/api/libraries" \
-H "Authorization: Bearer $TOKEN"Create a shared library
post/api/libraries
Stores v1 after running the source once in the sandbox: it must assign at least one export, each a function or a JSON constant. Audited (shared_library.created).
Minimum role: operator.
Auth: Bearer token (how to get one) · Operation: createLibrary
Request body (required)
application/json · object
namestringrequiredsourcestringrequireddescriptionstring | null
Responses
- 201Created.
Response fields
application/json · object
libraryobject6 fields
idstringnamestringdescriptionstring | nulllatestVersionintegerexportNamesarray of stringpinnedByintegerWorkflow drafts that pin it (list only).
- 400The request is malformed or fails validation.
application/json · ApiError
- 409The request conflicts with the current state.
application/json · ApiError
Example request
curl -X POST "$ENGINE_URL/api/libraries" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "string",
"source": "string",
"description": "string"
}'Get a shared library
get/api/libraries/{id}
The library, every version (newest first) and the workflows that pin it.
Minimum role: viewer.
Auth: Bearer token (how to get one) · Operation: getLibrary
Parameters
| Name | In | Type | Description |
|---|---|---|---|
idrequired | path | string | Id in the caller's workspace. |
Responses
- 200The library.
Response fields
application/json · object
libraryobject6 fields
idstringnamestringdescriptionstring | nulllatestVersionintegerexportNamesarray of stringpinnedByintegerWorkflow drafts that pin it (list only).
versionsarray of object6 fields
versionintegersha256stringexportNamesarray of stringsourcestringcreatedBystring | nullcreatedAtstring (date-time)
pinnedByarray of string
- 404Not found in the caller's workspace.
application/json · ApiError
Example request
curl "$ENGINE_URL/api/libraries/<id>" \
-H "Authorization: Bearer $TOKEN"Save a new library version
put/api/libraries/{id}
Adds version N+1 (none when the source is unchanged). Earlier versions never change, so a workflow that pins one keeps running it; deploy validation reports the update. Audited (shared_library.versioned).
Minimum role: operator.
Auth: Bearer token (how to get one) · Operation: saveLibraryVersion
Parameters
| Name | In | Type | Description |
|---|---|---|---|
idrequired | path | string | Id in the caller's workspace. |
Request body (required)
application/json · object
sourcestringrequireddescriptionstring | null
Responses
- 200Saved.
Response fields
application/json · object
libraryobject6 fields
idstringnamestringdescriptionstring | nulllatestVersionintegerexportNamesarray of stringpinnedByintegerWorkflow drafts that pin it (list only).
createdboolean
- 400The request is malformed or fails validation.
application/json · ApiError
- 404Not found in the caller's workspace.
application/json · ApiError
- 409The request conflicts with the current state.
application/json · ApiError
Example request
curl -X PUT "$ENGINE_URL/api/libraries/<id>" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"source": "string",
"description": "string"
}'Delete a shared library
delete/api/libraries/{id}
Refused (409, with the workflow names) while any workflow draft or saved version pins it. Audited (shared_library.deleted).
Minimum role: operator.
Auth: Bearer token (how to get one) · Operation: deleteLibrary
Parameters
| Name | In | Type | Description |
|---|---|---|---|
idrequired | path | string | Id in the caller's workspace. |
Responses
Example request
curl -X DELETE "$ENGINE_URL/api/libraries/<id>" \
-H "Authorization: Bearer $TOKEN"Schemas
Named objects the operations above link to.
ApiError
The error body. error is always present. code is present on most errors and is the field to branch on; a few routes and the sign-in and role checks return only error (and sometimes detail).
errorstringrequiredHuman-readable error message.
codestringMachine-readable error code.
One of: "BAD_REQUEST", "INVALID_REQUEST", "UNAUTHORIZED", "UNAUTHENTICATED", "FORBIDDEN", "NOT_FOUND", "CONFLICT", "UNPROCESSABLE_ENTITY", "RATE_LIMITED", "INTERNAL_ERROR", "SERVICE_UNAVAILABLE", "NOT_CONFIGURED", "SIGNATURE_REQUIRED", "INVALID_SIGNATURE", "TIMESTAMP_REQUIRED", "TIMESTAMP_INVALID", "TIMESTAMP_OUT_OF_TOLERANCE", "INVALID_CREDENTIALS", "INVALID_TOKEN", "PAYLOAD_TOO_LARGE", "INVALID_NDJSON", "PHI_NOT_AUTHORIZED", "PHI_IN_SANDBOX", "IN_PROGRESS", "RETRY_SCHEDULED", "WORKFLOW_DISABLED", "CONFLICTING_SCOPE", "ALREADY_DELIVERED", "CHAIN_TOO_DEEP", "NO_FAILED_DESTINATION", "STALE_SCOPE", "UNKNOWN_DESTINATION", "NO_DESTINATIONS", "NOT_A_MESSAGE", "AI_FEATURES_DISABLED"
detailsanyOptional structured context about the error.