Skip to content
Engine API

Workspaces

Workspaces endpoints of the MedHook engine API: 15 operations with parameters, schemas and a curl example for each.

On this page

Per-environment workspaces.

List workspaces

get/api/workspaces

The workspaces the caller may work in, the default first. Admins, API clients and root tokens see every workspace; any other signed-in person sees only the workspaces they are a member of. Rate limited to 300 requests per minute per caller.

Minimum role: viewer.

Auth: Bearer token (how to get one) · Operation: listWorkspaces

Responses

  • 200The workspaces.
    Response fields

    application/json · object

  • 401No credential, or the token is invalid or expired.

    application/json · ApiError

  • 429Rate limit exceeded (see the `Retry-After` header), or on the AI routes the daily AI budget is used up.

    application/json · ApiError

  • 500Unexpected server error.

    application/json · ApiError

Example request

curl
curl "$ENGINE_URL/api/workspaces" \
  -H "Authorization: Bearer $TOKEN"

Create a workspace

post/api/workspaces

Creates a workspace. The slug comes from the name. Rate limited to 10 requests per minute.

Minimum role: admin.

Auth: Bearer token (how to get one) · Operation: createWorkspace

Request body (required)

application/json · object

  • namestringrequired
  • colorstring

    A 6-digit hex colour.

Responses

  • 201Created.
    Response fields

    application/json · object

  • 400The request is malformed or fails validation.

    application/json · ApiError

  • 401No credential, or the token is invalid or expired.

    application/json · ApiError

  • 409The request conflicts with the current state.

    application/json · ApiError

  • 429Rate limit exceeded (see the `Retry-After` header), or on the AI routes the daily AI budget is used up.

    application/json · ApiError

  • 500Unexpected server error.

    application/json · ApiError

Example request

curl
curl -X POST "$ENGINE_URL/api/workspaces" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "string",
  "color": "#6366f1"
}'

Get a workspace

get/api/workspaces/{id}

One workspace. 404 for a signed-in person who is not a member of it (admins are members of every workspace).

Minimum role: viewer.

Auth: Bearer token (how to get one) · Operation: getWorkspace

Parameters

NameInTypeDescription
idrequiredpathstring

Workspace id.

Responses

  • 200The workspace.
    Response fields

    application/json · object

  • 401No credential, or the token is invalid or expired.

    application/json · ApiError

  • 404Not found in the caller's workspace.

    application/json · ApiError

  • 500Unexpected server error.

    application/json · ApiError

Example request

curl
curl "$ENGINE_URL/api/workspaces/<id>" \
  -H "Authorization: Bearer $TOKEN"

Rename or recolour a workspace

patch/api/workspaces/{id}

Changes name and color. Send at least one.

Minimum role: admin.

Auth: Bearer token (how to get one) · Operation: updateWorkspace

Parameters

NameInTypeDescription
idrequiredpathstring

Workspace id.

Request body (required)

application/json · object

  • namestring
  • colorstring

Responses

  • 200Updated.
    Response fields

    application/json · object

  • 400The request is malformed or fails validation.

    application/json · ApiError

  • 401No credential, or the token is invalid or expired.

    application/json · ApiError

  • 404Not found in the caller's workspace.

    application/json · ApiError

  • 409The request conflicts with the current state.

    application/json · ApiError

  • 500Unexpected server error.

    application/json · ApiError

Example request

curl
curl -X PATCH "$ENGINE_URL/api/workspaces/<id>" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "string",
  "color": "string"
}'

Delete a workspace

delete/api/workspaces/{id}

Deletes an empty workspace. The default workspace cannot be deleted (403), and a workspace that still holds anything with a restricting foreign key is refused with 409: error names what remains (e.g. "3 mapping sets and 1 VPN tunnel"), with the counts workflows, adapterProfiles, topics, apiClients (unrevoked API clients scoped to it; revoked ones are removed with it), mappingSets, codeTables, vpnTunnels, workspaceVariables and sharedLibraries. Members, onboarding, incumbent connections and parallel runs are removed with the workspace. Its audit log and run history are kept as written, under the deleted workspace's id, for the retention period; workspace.deleted is recorded in the default workspace with the id and name.

Minimum role: admin.

Auth: Bearer token (how to get one) · Operation: deleteWorkspace

Parameters

NameInTypeDescription
idrequiredpathstring

Workspace id.

Responses

  • 200Deleted.
    Response fields

    application/json · object

    • successboolean
    • deletedAtstring (date-time)
  • 401No credential, or the token is invalid or expired.

    application/json · ApiError

  • 403The caller's role, license or network address does not allow this. A signed-in person who is not a member of the requested workspace gets code `WORKSPACE_FORBIDDEN`; a viewer asking for message content gets `PHI_FORBIDDEN` (or `PHI_SEARCH_FORBIDDEN` for a search on message content).

    application/json · ApiError

  • 404Not found in the caller's workspace.

    application/json · ApiError

  • 409The request conflicts with the current state.

    application/json · ApiError

  • 500Unexpected server error.

    application/json · ApiError

Example request

curl
curl -X DELETE "$ENGINE_URL/api/workspaces/<id>" \
  -H "Authorization: Bearer $TOKEN"

List workspace members

get/api/workspaces/{id}/members

The people who may work in this workspace and their role there. A member's role is a ceiling under their engine role: a workspace admin row never gives a global operator admin powers. Global admins are members of every workspace and are not listed. Admins, and members of the workspace, may read it (404 otherwise).

Minimum role: viewer.

Auth: Bearer token (how to get one) · Operation: listWorkspaceMembers

Parameters

NameInTypeDescription
idrequiredpathstring

Workspace id.

Responses

  • 200The members.
    Response fields

    application/json · object

  • 401No credential, or the token is invalid or expired.

    application/json · ApiError

  • 404Not found in the caller's workspace.

    application/json · ApiError

  • 429Rate limit exceeded (see the `Retry-After` header), or on the AI routes the daily AI budget is used up.

    application/json · ApiError

  • 500Unexpected server error.

    application/json · ApiError

Example request

curl
curl "$ENGINE_URL/api/workspaces/<id>/members" \
  -H "Authorization: Bearer $TOKEN"

Add a member or change their role

put/api/workspaces/{id}/members

Makes an existing engine user (invited with Invite people on Settings › Users & roles, or created with create-engine-user) a member of the workspace, or changes their role there. An email nobody has yet answers 404 with code USER_NOT_FOUND. Audited as workspace.member_added or workspace.member_changed. Signed-in sessions pick the change up within 10 seconds.

Minimum role: admin.

Auth: Bearer token (how to get one) · Operation: putWorkspaceMember

Parameters

NameInTypeDescription
idrequiredpathstring

Workspace id.

Request body (required)

application/json · object

  • emailstring (email)required
  • rolestringrequired

    One of: "admin", "operator", "viewer"

Responses

  • 200Saved.
    Response fields

    application/json · object

  • 400The request is malformed or fails validation.

    application/json · ApiError

  • 401No credential, or the token is invalid or expired.

    application/json · ApiError

  • 403The caller's role, license or network address does not allow this. A signed-in person who is not a member of the requested workspace gets code `WORKSPACE_FORBIDDEN`; a viewer asking for message content gets `PHI_FORBIDDEN` (or `PHI_SEARCH_FORBIDDEN` for a search on message content).

    application/json · ApiError

  • 404Not found in the caller's workspace.

    application/json · ApiError

  • 429Rate limit exceeded (see the `Retry-After` header), or on the AI routes the daily AI budget is used up.

    application/json · ApiError

  • 500Unexpected server error.

    application/json · ApiError

Example request

curl
curl -X PUT "$ENGINE_URL/api/workspaces/<id>/members" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "email": "user@example.test",
  "role": "admin"
}'

Remove a member

delete/api/workspaces/{id}/members

Removes the person from this workspace (their other workspaces are unchanged). Audited as workspace.member_removed. Takes effect within 10 seconds.

Minimum role: admin.

Auth: Bearer token (how to get one) · Operation: deleteWorkspaceMember

Parameters

NameInTypeDescription
idrequiredpathstring

Workspace id.

emailrequiredquerystring

The member's email.

Responses

  • 200Removed.
    Response fields

    application/json · object

    • removedboolean
  • 400The request is malformed or fails validation.

    application/json · ApiError

  • 401No credential, or the token is invalid or expired.

    application/json · ApiError

  • 403The caller's role, license or network address does not allow this. A signed-in person who is not a member of the requested workspace gets code `WORKSPACE_FORBIDDEN`; a viewer asking for message content gets `PHI_FORBIDDEN` (or `PHI_SEARCH_FORBIDDEN` for a search on message content).

    application/json · ApiError

  • 404Not found in the caller's workspace.

    application/json · ApiError

  • 429Rate limit exceeded (see the `Retry-After` header), or on the AI routes the daily AI budget is used up.

    application/json · ApiError

  • 500Unexpected server error.

    application/json · ApiError

Example request

curl
curl -X DELETE "$ENGINE_URL/api/workspaces/<id>/members?email=string" \
  -H "Authorization: Bearer $TOKEN"

List engine users

get/api/users

Everyone who can sign in to the engine UI, with their engine role and status. No password, authenticator or recovery-code data is ever returned. People are created with the create-engine-user CLI.

Minimum role: admin.

Auth: Bearer token (how to get one) · Operation: listEngineUsers

Responses

  • 200The users.
    Response fields

    application/json · object

  • 401No credential, or the token is invalid or expired.

    application/json · ApiError

  • 403The caller's role, license or network address does not allow this. A signed-in person who is not a member of the requested workspace gets code `WORKSPACE_FORBIDDEN`; a viewer asking for message content gets `PHI_FORBIDDEN` (or `PHI_SEARCH_FORBIDDEN` for a search on message content).

    application/json · ApiError

  • 429Rate limit exceeded (see the `Retry-After` header), or on the AI routes the daily AI budget is used up.

    application/json · ApiError

  • 500Unexpected server error.

    application/json · ApiError

Example request

curl
curl "$ENGINE_URL/api/users" \
  -H "Authorization: Bearer $TOKEN"

List the people who may work in a workspace

get/api/workspaces/{id}/people

Everyone who may work in this workspace now, for pickers such as the workflow Settings Owner: global admins (members of every workspace, with no member row) and the people with a member row. Disabled people are left out. Identity only (email and name), sorted by email; roles are on GET /api/workspaces/{id}/members. Admins, and members of the workspace, may read it (404 otherwise). Rate limited to 60 requests per minute.

Minimum role: viewer.

Auth: Bearer token (how to get one) · Operation: listWorkspacePeople

Parameters

NameInTypeDescription
idrequiredpathstring

Workspace id.

Responses

  • 200The people.
    Response fields

    application/json · object

    • workspaceIdstring
    • peoplearray of object
      2 fields
      • emailstring (email)
      • namestring | null
  • 401No credential, or the token is invalid or expired.

    application/json · ApiError

  • 404Not found in the caller's workspace.

    application/json · ApiError

  • 429Rate limit exceeded (see the `Retry-After` header), or on the AI routes the daily AI budget is used up.

    application/json · ApiError

  • 500Unexpected server error.

    application/json · ApiError

Example request

curl
curl "$ENGINE_URL/api/workspaces/<id>/people" \
  -H "Authorization: Bearer $TOKEN"

Change an engine user's role

patch/api/users/{id}

Sets someone's engine role (admin, operator or viewer). Their workspace rows follow: rows below the new role are raised to it, and a non-admin left in no workspace joins default. The last active admin can't be demoted (409, code LAST_ADMIN). While Settings > Single sign-on directory sync is on, a role a mapped Google group sets can't be changed here (409, code ROLE_FROM_GROUP, naming the group). The same role again answers changed: false and audits nothing; a change is audited as user.role_changed with from and to. ssoManaged is true when the person signs in through an enterprise identity provider without a password: its groups set the role again at their next sign-in. Rate limited to 30 requests per minute.

Minimum role: admin.

Auth: Bearer token (how to get one) · Operation: changeEngineUserRole

Parameters

NameInTypeDescription
idrequiredpathstring

The engine user's id.

Request body (required)

application/json · object

  • rolestringrequired

    One of: "admin", "operator", "viewer"

Responses

  • 200The person, before and after.
    Response fields

    application/json · object

    • fromstring

      The role before.

      One of: "admin", "operator", "viewer"

    • tostring

      The role now.

      One of: "admin", "operator", "viewer"

    • changedboolean
    • ssoManagedboolean

      Single sign-on sets the role again at the next sign-in.

  • 400The request is malformed or fails validation.

    application/json · ApiError

  • 401No credential, or the token is invalid or expired.

    application/json · ApiError

  • 403The caller's role, license or network address does not allow this. A signed-in person who is not a member of the requested workspace gets code `WORKSPACE_FORBIDDEN`; a viewer asking for message content gets `PHI_FORBIDDEN` (or `PHI_SEARCH_FORBIDDEN` for a search on message content).

    application/json · ApiError

  • 404Not found in the caller's workspace.

    application/json · ApiError

  • 409The request conflicts with the current state.

    application/json · ApiError

  • 429Rate limit exceeded (see the `Retry-After` header), or on the AI routes the daily AI budget is used up.

    application/json · ApiError

  • 500Unexpected server error.

    application/json · ApiError

Example request

curl
curl -X PATCH "$ENGINE_URL/api/users/<id>" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "role": "admin"
}'

Unlock a paused password sign-in

post/api/users/{id}/unlock

Lifts the pause ten wrong sign-in codes put on someone's password sign-in and clears their count of wrong codes, the same as create-engine-user <email> --unlock. Changes nothing else: no sign-out, no new password. Admin only. Audited as auth.signin_unlocked with via: "settings". Rate limited to 30 requests per minute.

Minimum role: admin.

Auth: Bearer token (how to get one) · Operation: unlockEngineUserSignin

Parameters

NameInTypeDescription
idrequiredpathstring

The engine user's id.

Responses

  • 200Unlocked.
    Response fields

    application/json · object

    • userIdstring
    • emailstring
    • wasLockedboolean

      Password sign-in was paused.

  • 401No credential, or the token is invalid or expired.

    application/json · ApiError

  • 403The caller's role, license or network address does not allow this. A signed-in person who is not a member of the requested workspace gets code `WORKSPACE_FORBIDDEN`; a viewer asking for message content gets `PHI_FORBIDDEN` (or `PHI_SEARCH_FORBIDDEN` for a search on message content).

    application/json · ApiError

  • 404Not found in the caller's workspace.

    application/json · ApiError

  • 429Rate limit exceeded (see the `Retry-After` header), or on the AI routes the daily AI budget is used up.

    application/json · ApiError

  • 500Unexpected server error.

    application/json · ApiError

Example request

curl
curl -X POST "$ENGINE_URL/api/users/<id>/unlock" \
  -H "Authorization: Bearer $TOKEN"

List someone's remembered devices

get/api/users/{id}/devices

The browsers that skip the emailed sign-in code for this person (ENGINE_TRUSTED_DEVICE_DAYS above 0): a browser summary such as Chrome on macOS, when it was last used and when it is forgotten. Never the device token. Admin only. Rate limited to 30 requests per minute.

Minimum role: admin.

Auth: Bearer token (how to get one) · Operation: listEngineUserDevices

Parameters

NameInTypeDescription
idrequiredpathstring

The engine user's id.

Responses

  • 200The person's live remembered devices.
    Response fields

    application/json · object

    • devicesarray of object
      6 fields
      • idstring
      • labelstring

        Browser and system, e.g. Chrome on macOS.

      • createdAtstring (date-time)
      • lastUsedAtstring (date-time)
      • expiresAtstring (date-time)
      • currentboolean

        Always false here.

  • 401No credential, or the token is invalid or expired.

    application/json · ApiError

  • 403The caller's role, license or network address does not allow this. A signed-in person who is not a member of the requested workspace gets code `WORKSPACE_FORBIDDEN`; a viewer asking for message content gets `PHI_FORBIDDEN` (or `PHI_SEARCH_FORBIDDEN` for a search on message content).

    application/json · ApiError

  • 404Not found in the caller's workspace.

    application/json · ApiError

  • 429Rate limit exceeded (see the `Retry-After` header), or on the AI routes the daily AI budget is used up.

    application/json · ApiError

  • 500Unexpected server error.

    application/json · ApiError

Example request

curl
curl "$ENGINE_URL/api/users/<id>/devices" \
  -H "Authorization: Bearer $TOKEN"

Forget someone's remembered devices

delete/api/users/{id}/devices

Every browser of this person asks for the emailed code again at the next password sign-in. Open sessions are not ended. Admin only. Audited as auth.device_forgotten with via: "admin". Rate limited to 30 requests per minute.

Minimum role: admin.

Auth: Bearer token (how to get one) · Operation: forgetEngineUserDevices

Parameters

NameInTypeDescription
idrequiredpathstring

The engine user's id.

Responses

  • 200Forgotten.
    Response fields

    application/json · object

    • forgotteninteger

      How many devices were forgotten.

  • 401No credential, or the token is invalid or expired.

    application/json · ApiError

  • 403The caller's role, license or network address does not allow this. A signed-in person who is not a member of the requested workspace gets code `WORKSPACE_FORBIDDEN`; a viewer asking for message content gets `PHI_FORBIDDEN` (or `PHI_SEARCH_FORBIDDEN` for a search on message content).

    application/json · ApiError

  • 404Not found in the caller's workspace.

    application/json · ApiError

  • 429Rate limit exceeded (see the `Retry-After` header), or on the AI routes the daily AI budget is used up.

    application/json · ApiError

  • 500Unexpected server error.

    application/json · ApiError

Example request

curl
curl -X DELETE "$ENGINE_URL/api/users/<id>/devices" \
  -H "Authorization: Bearer $TOKEN"

Invite someone to sign in

post/api/users/invite

Creates an engine user with no password and a one-time set-password link that works for 24 hours, as the create-engine-user CLI does. A non-admin joins the default workspace at their role; admins are members of every workspace. When the engine can send email and ENGINE_PUBLIC_URL is set, the link is emailed and not returned (emailed: true); otherwise it is returned once in link, for the admin to hand over. Audited as user.invited (never the link). An email that already has an account is a 409 (USER_EXISTS). Rate limited to 10 requests per minute.

Minimum role: admin.

Auth: Bearer token (how to get one) · Operation: inviteEngineUser

Request body (required)

application/json · object

  • emailstringrequired

    Their email; stored lowercased.

  • namestring

    Optional display name.

  • rolestringrequired

    One of: "admin", "operator", "viewer"

Responses

  • 201Invited.
    Response fields

    application/json · object

    • emailedboolean
    • expiresAtstring (date-time)

      When the link stops working.

    • linkstring

      Only when not emailed: the one-time set-password link (/sign-in/reset#token=…, prefixed with ENGINE_PUBLIC_URL when set).

  • 400The request is malformed or fails validation.

    application/json · ApiError

  • 401No credential, or the token is invalid or expired.

    application/json · ApiError

  • 403The caller's role, license or network address does not allow this. A signed-in person who is not a member of the requested workspace gets code `WORKSPACE_FORBIDDEN`; a viewer asking for message content gets `PHI_FORBIDDEN` (or `PHI_SEARCH_FORBIDDEN` for a search on message content).

    application/json · ApiError

  • 409The request conflicts with the current state.

    application/json · ApiError

  • 429Rate limit exceeded (see the `Retry-After` header), or on the AI routes the daily AI budget is used up.

    application/json · ApiError

  • 500Unexpected server error.

    application/json · ApiError

Example request

curl
curl -X POST "$ENGINE_URL/api/users/invite" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "email": "string",
  "name": "string",
  "role": "admin"
}'

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).

  • errorstringrequired

    Human-readable error message.

  • codestring

    Machine-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"

  • detailsany

    Optional structured context about the error.

EngineUser

  • idstring
  • emailstring
  • namestring
  • rolestring

    One of: "admin", "operator", "viewer"

  • disabledboolean
  • lastLoginAtstring (date-time)

Workspace

  • idstring
  • namestring
  • slugstring
  • colorstring
  • isDefaultboolean

WorkspaceMember

  • userIdstring
  • emailstring
  • namestring
  • rolestring

    Role in this workspace: a ceiling under globalRole.

    One of: "admin", "operator", "viewer"

  • globalRolestring

    The person's engine-wide role.

  • disabledboolean
  • createdAtstring (date-time)
  • createdBystring