Generate Lab Visit Public Share Token (v1)
Method & Path
POST /api/v1/workspace/:workspaceId/labs/visits/:labVisitId/public-share-token
Actual backend path: /v1/workspace/:workspaceId/labs/visits/:labVisitId/public-share-token
Description
Creates (or regenerates) the public share token for a lab visit. This token can be used to build a public, no-auth link for viewing/printing lab results.
Authentication
Required: JWT token in Authorization header
Persona Access:
- Admin: Not applicable (workspace-scoped endpoint)
- Workspace Owner: Allowed (root persona for workspace features)
- Staff: Allowed (role-based)
- Customer: Not allowed
Required Permissions:
labs.view
Headers
| Header | Type | Required | Description |
|---|---|---|---|
Authorization | string | Yes | Bearer token: Bearer <token> |
X-Staff-Id | string | No | Staff member ID (omit for Workspace Owner access) |
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
workspaceId | string | Yes | Workspace identifier (MongoDB ObjectId) |
labVisitId | string | Yes | Lab visit identifier (MongoDB ObjectId) |
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
regenerate | true | false | No | If true, invalidates the previous token and returns a new one |
Request Body
None
Response 200 OK
{
"token": "9f2c9f5a2c1c0f... (hex)"
}
Common Errors
- 400 Bad Request: Invalid identifiers or malformed request
- 401 Unauthorized: Missing/invalid JWT
- 403 Forbidden: Missing
labs.viewpermission - 404 Not Found: Workspace or lab visit not found
- 500 Internal Server Error: Token generation failure