@abgov/adsp-sdk-mcp-server 1.24.0 → 1.24.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,19 +14,65 @@ client `urn:ads:platform:form-service`
14
14
 
15
15
  | name | description |
16
16
  |:-|:-|
17
- | form-admin | Administrator role for form service. This role allows a user to query and unlock forms, and to manage data registers. |
18
- | intake-application | Intake application role for form service. This role is used to grant a service account the ability to retrieve draft forms and submit forms on behalf of an anonymous applicant. |
19
-
20
- The data register API also accepts the configuration service role `urn:ads:platform:configuration-service:configuration-admin`, which tenant administrators have by default.
21
-
17
+ | form-admin | Administrator role for form service. This role allows a user to manage form definitions, find and read all forms and submissions of the tenant, unlock, archive and delete forms, delete submissions, and manage data registers. |
18
+ | intake-application | Intake application role for form service. This role is used to grant a service account the ability to retrieve draft forms and submit forms on behalf of an anonymous applicant. |
19
+ | form-applicant | Applicant role for form service that allows a user to apply from the form app. It permits subscribing to the submitted form PDF and form question update streams. |
20
+ | form-support | Support role for viewing and responding to form question topics. It is a commenter role of the form questions comment topic type, and a subscriber role of the form message reviewer notifications. |
21
+ | form-file-reader | File reader role that allows assessors and clerks to review uploaded supporting documents. |
22
+ | form-file-uploader | File uploader role that allows applicants to upload supporting documents for the form. |
23
+ | form-tester | Tester role for form service that allows access to forms without open intakes. |
24
+ | form-service | Form service role used to permit deletion of orphaned form support document files. |
25
+
26
+ The data register API also accepts the configuration service role `urn:ads:platform:configuration-service:configuration-admin`, which tenant administrators have by default. Form and submission searches also accept the export service role `urn:ads:platform:export-service:export-job`.
27
+
28
+ Each form definition also names its own **applicant**, **clerk** and **assessor** roles. These are tenant roles, and they control who can create and fill in forms of the definition, and who can review its submissions.
29
+
30
+ ## Tenancy
31
+ - **Which tenant is used.** Tenant users and service accounts act on the tenant of their token. Core (platform) users set the `tenantId` query parameter to choose the tenant. The form definition, form, submission, data register and intake schedule endpoints act on one tenant, so core users must set `tenantId` on them.
32
+ - **Anonymous requests.** Only `GET /form/v1/definitions/{definitionId}` allows anonymous requests, for definitions that allow anonymous applications. Anonymous requests have no token to determine the tenant from, so they must include `tenantId`; without it the request responds 400.
33
+ - **Form definitions.** Form definitions are tenant configuration in the [configuration service](configuration-service.md). Form service uses the tenant's own definitions and does not fall back to platform definitions.
34
+ - **Isolation.** Forms and submissions are stored with the ID of their tenant. A form or submission ID from another tenant responds 404, not 403.
35
+ - **Role scope.** The roles of a form definition must be held in the tenant. Most `form-admin` checks also accept a core user with the role, but listing definitions, reading a definition, finding submissions and setting a form back to draft need the role in the tenant. The `export-job` role is accepted from core service accounts.
36
+
37
+ ## API overview
38
+ All endpoints are under `https://form-service.adsp.alberta.ca/form/v1`. See the [API documentation](https://api.adsp.alberta.ca) for request and response schemas.
39
+
40
+ | Endpoint | Purpose | Required role |
41
+ |:-|:-|:-|
42
+ | `GET /form/v1/definitions` | List and search form definitions. | `form-admin` |
43
+ | `POST /form/v1/definitions` | Create a form definition from a name and description. | `form-admin` |
44
+ | `GET /form/v1/definitions/{definitionId}` | Read a form definition and its current intake. | `form-admin`, `intake-application`, or the definition's applicant or clerk roles; anonymous for definitions that allow anonymous applications |
45
+ | `PUT`, `PATCH`, `DELETE /form/v1/definitions/{definitionId}` | Replace, update or delete a form definition. | `form-admin` |
46
+ | `PUT /form/v1/definitions/{definitionId}/schemas` | Update the data and UI schemas. | `form-admin` |
47
+ | `PUT /form/v1/definitions/{definitionId}/roles` | Replace the applicant, assessor and clerk roles. | `form-admin` |
48
+ | `PATCH /form/v1/definitions/{definitionId}/lifecycle` | Update the anonymous application, applicant limit, support topic and security classification settings. | `form-admin` |
49
+ | `PATCH /form/v1/definitions/{definitionId}/submission-actions` | Update what happens when a form is submitted. | `form-admin` |
50
+ | `PUT /form/v1/definitions/{definitionId}/schedule` | Update the scheduled intake period. | `form-admin` |
51
+ | `GET /form/v1/forms` | Find forms. | Any signed-in user; `form-admin` and `export-job` find all forms, assessors find the submitted forms of their definition, and other users find the forms they created |
52
+ | `POST /form/v1/forms` | Create a draft form, and optionally submit it. | The definition's applicant or clerk roles; `intake-application` for definitions that allow anonymous applications |
53
+ | `GET /form/v1/forms/{formId}` | Read a form. | `form-admin`, `intake-application`, the definition's clerk or assessor roles, or the applicant who created it |
54
+ | `POST /form/v1/forms/{formId}` | Run a form operation: `send-code`, `unlock`, `submit`, `to-draft` or `archive`. | Depends on the operation (see the API documentation) |
55
+ | `DELETE /form/v1/forms/{formId}` | Delete a form and its files. | `form-admin`; the definition's clerk roles or the applicant who created it, for draft forms |
56
+ | `GET`, `PUT /form/v1/forms/{formId}/data` | Read or update the form data. | The applicant who created it or the definition's clerk roles; reading also allows `form-admin`, assessors of submitted forms, and `intake-application` with a verification code |
57
+ | `GET /form/v1/submissions`, `GET /form/v1/forms/{formId}/submissions` | Find submissions. | `form-admin`, `export-job`, or the definition's assessor roles |
58
+ | `GET /form/v1/submissions/{submissionId}`, `GET /form/v1/forms/{formId}/submissions/{submissionId}` | Read a submission. | `form-admin` or the definition's assessor roles |
59
+ | `POST /form/v1/forms/{formId}/submissions/{submissionId}` | Disposition a submission. | `form-admin` or the definition's assessor roles |
60
+ | `POST /form/v1/forms/{formId}/submissions/{submissionId}/notes`, `DELETE .../notes/{noteId}` | Add or remove a reviewer note. | `form-admin` or the definition's assessor roles |
61
+ | `DELETE /form/v1/submissions/{submissionId}` | Delete a submission. | `form-admin` |
62
+ | `/form/v1/registers` | Manage data registers (see [Data registers](#data-registers)). | `form-admin` or `configuration-admin` |
63
+
64
+ Form definitions are stored in the configuration service, so they can also be managed through the configuration service API.
22
65
 
23
66
  ## Concepts
24
67
  ### Form definition
25
- Form definition describes a type of form including the allowed applicant and assessor roles and whether anonymous applicants are permitted. Form definitions are configured in the [configuration service](configuration-service.md) under the `platform:form-service` namespace and name.
68
+ Form definition describes a type of form including the allowed applicant and assessor roles and whether anonymous applicants are permitted. Form definitions are configured in the [configuration service](configuration-service.md) under the `form-service` namespace, with the definition ID as the name.
26
69
 
27
70
  ### Form
28
71
  Form represents a particular instance of an application including the information entered by the *applicant*. Each form is associated with a *definition* and has a status. Statuses represent the lifecycle steps of the form and include: Draft, Locked, Submitted, and Archived.
29
72
 
73
+ ### Submission
74
+ When a form is submitted and its definition has submission records enabled, form service creates a *submission* with a copy of the form data. Assessors review submissions, add notes, and record a *disposition* using one of the definition's disposition states. A form that is set back to draft and submitted again gets a new submission.
75
+
30
76
  ### Draft expiry
31
77
  Draft forms include an expiry process so that information entered into draft forms are purged if the draft is abandoned. If a draft form is not accessed for some expiry period, the form is locked and the applicant is notified. In this state, the form cannot be accessed by the applicant but can be unlocked by an administrator. If the form remains in a locked state for some additional expiry period, the form is deleted so that applicant information is not unnecessarily retained.
32
78
 
@@ -67,6 +113,30 @@ Registers are returned as `{ namespace: 'data-register', name, description, entr
67
113
 
68
114
  Form service does not emit its own events for data registers. Configuration service emits `configuration-updated` and `configuration-deleted` for the underlying configuration.
69
115
 
116
+ ## Events
117
+ Form service sends these domain events in the `form-service` namespace. Form events use the form ID as the correlation ID.
118
+
119
+ | name | sent when |
120
+ |:-|:-|
121
+ | form-created | A draft form is created. When a form is created with `submit: true`, `form-submitted` is sent instead. |
122
+ | form-locked | The draft expiry job locks a draft that has not been accessed. |
123
+ | form-unlocked | An administrator unlocks a locked form. |
124
+ | form-submitted | A form is submitted. The form data is included when the definition sets `includeDataInSubmission`. |
125
+ | form-to-draft | A submitted form is set back to draft. |
126
+ | form-archived | A form is archived. |
127
+ | form-deleted | A form is deleted through the API or by the draft expiry job. |
128
+ | submission-dispositioned | A submission is dispositioned. |
129
+ | submission-deleted | A submission is deleted. |
130
+ | form-message-to-applicant | A reviewer posts a message on a form's questions topic. |
131
+ | form-message-to-reviewer | An applicant posts a message and a reviewer is part of the conversation. |
132
+ | form-message-forwarded | An applicant posts a message, no reviewer is part of the conversation, and the definition sets an address to forward questions to. |
133
+
134
+ When a definition sets a custom submission event (`event` in the submission actions), form service also sends that event, in the namespace and with the name it configures, each time a form is submitted.
135
+
136
+ Form service registers the `form-status-updates`, `form-message-notifications` and `form-message-reviewer-notifications` notification types, which notify applicants and reviewers of these events. It also registers two push service streams: `submitted-form-pdf-updates` (PDF service PDF generation events) and `form-questions-updates` (comment service events on form question topics).
137
+
138
+ Form service consumes the comment service `comment-created` event for form question topics to send the message events above.
139
+
70
140
  ## Audit actions
71
141
  Form service records audit events in the `form-service` namespace of the [audit service](audit-service.md). Records are written to the tenant of the form, submission or data register. Form records use the form as the resource (`{ type: 'form', id: <form ID> }`) and correlation ID, with the form `definitionId`, `status` (after the operation), `anonymousApplicant` and `dryRun` in the metadata. Form data and applicant details are never recorded. All actions are version 1.
72
142
 
@@ -98,6 +168,43 @@ Draft data is saved frequently, so form service sends audit events in batches of
98
168
  Audit recording is on by default. Set the environment variable `FORM_AUDIT_ENABLED=false` on form service to turn it off, or `true` to turn it on regardless of the SDK `AUDIT_ENABLED` variable, which applies when `FORM_AUDIT_ENABLED` is not set. The action catalog is still registered while recording is off, so turning it back on needs only a restart.
99
169
 
100
170
  ## Code examples
171
+ ### Create a form definition
172
+ ```typescript
173
+ const response = await fetch(
174
+ 'https://form-service.adsp.alberta.ca/form/v1/definitions',
175
+ {
176
+ method: 'POST',
177
+ headers: {
178
+ 'Authorization': `Bearer ${accessToken}`,
179
+ 'Content-Type': 'application/json',
180
+ },
181
+ body: JSON.stringify({
182
+ name: 'Business licence application',
183
+ description: 'Application for a municipal business licence.',
184
+ }),
185
+ }
186
+ );
187
+
188
+ // The ID is generated from the name, for example 'business-licence-application'.
189
+ const { id, revision } = await response.json();
190
+
191
+ // Set who can apply and who can assess submissions.
192
+ await fetch(
193
+ `https://form-service.adsp.alberta.ca/form/v1/definitions/${id}/roles`,
194
+ {
195
+ method: 'PUT',
196
+ headers: {
197
+ 'Authorization': `Bearer ${accessToken}`,
198
+ 'Content-Type': 'application/json',
199
+ },
200
+ body: JSON.stringify({
201
+ applicantRoles: ['business-licence-applicant'],
202
+ assessorRoles: ['business-licence-assessor'],
203
+ }),
204
+ }
205
+ );
206
+ ```
207
+
101
208
  ### Create a draft form for an anonymous applicant
102
209
  ```typescript
103
210
  const form = {
@@ -125,12 +232,12 @@ Audit recording is on by default. Set the environment variable `FORM_AUDIT_ENABL
125
232
 
126
233
  const {
127
234
  id,
128
- definitionId,
235
+ definition,
129
236
  status,
130
237
  created,
131
238
  createdBy,
132
239
  lastAccessed,
133
- } = response.json();
240
+ } = await response.json();
134
241
  ```
135
242
 
136
243
  ### Access form data using a time limited code.
@@ -167,12 +274,13 @@ Intake applications can retrieve form data on behalf of anonymous applicants by
167
274
  ```
168
275
 
169
276
  ### Update data in a draft form
277
+ Files are referenced by their file service URN in the data. Form service finds the file references using the data schema, and returns them in `files`.
170
278
  ```typescript
171
279
  const formData = {
172
- data: {}
173
- files: {
174
- 'proof-of-status': fileUrn,
175
- }
280
+ data: {
281
+ businessName: 'Example Bakery Ltd.',
282
+ proofOfStatus: fileUrn,
283
+ },
176
284
  }
177
285
 
178
286
  const response = await fetch(
@@ -213,5 +321,37 @@ Intake applications can retrieve form data on behalf of anonymous applicants by
213
321
  id,
214
322
  status,
215
323
  submitted,
324
+ submission,
216
325
  } = await response.json();
217
326
  ```
327
+
328
+ ### Disposition a submission
329
+ Assessors find the submissions of a definition that are waiting for a decision, and record a disposition using one of the definition's disposition states.
330
+ ```typescript
331
+ const criteria = JSON.stringify({ definitionIdEquals: definitionId, dispositioned: false });
332
+ const response = await fetch(
333
+ `https://form-service.adsp.alberta.ca/form/v1/submissions?criteria=${encodeURIComponent(criteria)}`,
334
+ {
335
+ headers: { Authorization: `Bearer ${accessToken}` },
336
+ }
337
+ );
338
+ const { results, page } = await response.json();
339
+
340
+ const [{ id: submissionId, formId }] = results;
341
+ const dispositionResponse = await fetch(
342
+ `https://form-service.adsp.alberta.ca/form/v1/forms/${formId}/submissions/${submissionId}`,
343
+ {
344
+ method: 'POST',
345
+ headers: {
346
+ 'Authorization': `Bearer ${accessToken}`,
347
+ 'Content-Type': 'application/json',
348
+ },
349
+ body: JSON.stringify({
350
+ dispositionStatus: 'Approved',
351
+ dispositionReason: 'Application meets all eligibility criteria.',
352
+ }),
353
+ }
354
+ );
355
+
356
+ const { disposition } = await dispositionResponse.json();
357
+ ```
@@ -47,6 +47,8 @@ All endpoints are under `https://notification-service.adsp.alberta.ca/subscripti
47
47
 
48
48
  There are no separate template or event endpoints. Templates are part of each notification type's `events`, and events are sent through the [event service](event-service.md).
49
49
 
50
+ `POST /provider/v1/bot/messages` is the Bot Framework webhook used by the `bot` channel provider. Only the Bot Framework calls it, so it is not part of the API documentation.
51
+
50
52
  ## Concepts
51
53
  ### Notification type
52
54
  Notification type represents a bundled set of notifications that can be subscribed to and provides the access roles for that set. For example, an 'Application Progress' type could include notifications for submission of the application, processing started, and application processed. A subscriber has a subscription to the set and cannot subscribe to the individual notifications in the set. Notification types are configured in the [configuration service](configuration-service.md) under the `platform:notification-service` namespace and name.
@@ -77,17 +77,17 @@ These events are available on the [push service](push-service.md) stream `pdf-ge
77
77
 
78
78
  ## Audit actions
79
79
 
80
- PDF service records audit events in the `pdf-service` namespace of the [audit service](audit-service.md). Action names start with `pdf.` so they do not take generic names such as `job.created` from tenant catalogs. Records are written to the tenant of the job or template. All actions are version 1, and their retention class is derived from the category.
80
+ PDF service records audit events in the `pdf-service` namespace of the [audit service](audit-service.md). Records are written to the tenant of the job or template. All actions are version 1, and their retention class is derived from the category.
81
81
 
82
82
  | action | category | severity | retention class | recorded when |
83
83
  |:-|:-|:-|:-|:-|
84
- | pdf.job.created | runtime | info | standard | A PDF generation job is queued through `POST /pdf/v1/jobs`. |
85
- | pdf.job.generated | runtime | info | standard | A generation job finishes: status `success` when the PDF is stored in file service, with the resulting `fileId` in the metadata, or status `failure` when the job fails, with the `error` in the metadata. |
86
- | pdf.template.created | administrative | info | compliance | A template is created through `POST /pdf/v1/templates`. |
87
- | pdf.template.updated | administrative | warning | compliance | A template is updated through `PATCH /pdf/v1/templates/{templateId}`, with the names of the changed fields as `changedFields` in the metadata. |
88
- | pdf.template.deleted | administrative | warning | compliance | A template is deleted through `DELETE /pdf/v1/templates/{templateId}`. |
84
+ | job.created | runtime | info | standard | A PDF generation job is queued through `POST /pdf/v1/jobs`. |
85
+ | job.generated | runtime | info | standard | A generation job finishes: status `success` when the PDF is stored in file service, with the resulting `fileId` in the metadata, or status `failure` when the job fails, with the `error` in the metadata. |
86
+ | template.created | administrative | info | compliance | A template is created through `POST /pdf/v1/templates`. |
87
+ | template.updated | administrative | warning | compliance | A template is updated through `PATCH /pdf/v1/templates/{templateId}`, with the names of the changed fields as `changedFields` in the metadata. |
88
+ | template.deleted | administrative | warning | compliance | A template is deleted through `DELETE /pdf/v1/templates/{templateId}`. |
89
89
 
90
- Job records have the job as the resource (`{ type: 'pdf-job', id: <job ID>, name: <filename> }`), the `recordId` of the generated file as the correlation ID, and the `templateId`, `filename`, `fileType` and `recordId` in the metadata. Since file service uses the same `recordId` as the correlation ID, the `fileId` and correlation ID link a job to the `file.uploaded` record of the generated file. `pdf.job.generated` is recorded by the job worker after generation completes, with the requester of the job as the actor; a failure is recorded only when the job is marked failed, not on an attempt that will be retried. Failures are found by filtering on `status=failure`.
90
+ Job records have the job as the resource (`{ type: 'pdf-job', id: <job ID>, name: <filename> }`), the `recordId` of the generated file as the correlation ID, and the `templateId`, `filename`, `fileType` and `recordId` in the metadata. Since file service uses the same `recordId` as the correlation ID, the `fileId` and correlation ID link a job to the `file.uploaded` record of the generated file. `job.generated` is recorded by the job worker after generation completes, with the requester of the job as the actor; a failure is recorded only when the job is marked failed, not on an attempt that will be retried. Failures are found by filtering on `status=failure`.
91
91
 
92
92
  Template records have the template as the resource (`{ type: 'pdf-template', id: <template ID>, name: <name> }`) and the `templateId` and `name` in the metadata. Template changes made directly in the [configuration service](configuration-service.md) rather than through the PDF service API are recorded only in the `configuration-service` namespace; changes through the PDF service API are recorded in both. Reads of templates and job status are not recorded.
93
93
 
@@ -128,20 +128,20 @@ Project planner service records audit events in the `project-planner-service` na
128
128
 
129
129
  | action | category | severity | retention class | recorded when |
130
130
  |:-|:-|:-|:-|:-|
131
- | planner.solution.created | administrative | info | compliance | A solution is created (`POST /solutions`), with the `scenario` in the metadata. |
132
- | planner.solution.deleted | administrative | warning | compliance | A solution is deleted by its owner (`DELETE /solutions/{id}`), with its `scenario` and `status`. |
133
- | planner.solution.exported | data-access | info | compliance | A solution is downloaded (`GET /solutions/{id}/export`, `scope: 'solution'` with the latest `version` and `unsavedChanges`) or a saved version is downloaded (`GET /solutions/{id}/versions/{number}/export`, `scope: 'version'` with the `version`). |
134
- | planner.solution.admin-accessed | data-access | info | compliance | A `planner-admin` successfully reads, changes or exports a solution owned by another user, with the `ownerId` and the `operation` (`read`, `update` or `export`) in the metadata. Reading the solution or its versions is `read`; changes, analysis, discovery, chat, consultations, blueprints, component reviews and version checkpoints or renames are `update`. A specialist chat that uses the solution as context is `read`, or `update` when the chat changes the solution. |
135
- | planner.solution.analyzed | runtime | info | standard | A request sends solution content to the AI model, with the `endpoint` (`analyze`, `discovery`, `chat`, `blueprint`, `consult` or `specialist-chat`), the `mode` of the result (`ai`, or `rules` after a fallback), the configured `model`, whether any model call in the request `fellBack` to rules, and the specialist `service` for consultations and specialist chats. |
136
- | planner.pattern.created | administrative | info | compliance | A tenant pattern is created (`POST /patterns`), with `source: 'custom'`. |
137
- | planner.pattern.updated | administrative | info | compliance | A pattern is updated or a built-in pattern is customized (`PUT /patterns/{id}`), with the `source` after the update and the `previousSource`. The change set holds the before and after values of the changed pattern fields. |
138
- | planner.pattern.deleted | administrative | warning | compliance | A custom pattern is deleted or a customized built-in pattern is reset (`DELETE /patterns/{id}`), with the `source` (`custom` or `customized`) of the deleted pattern. |
139
- | planner.specialist-chat.exported | data-access | info | compliance | A user downloads one saved specialist chat (`scope: 'single'`) or all of their chats (`scope: 'all'`), with the `chatCount`, the specialist `service` and the `solutionId` (the filters, for an export of all chats). |
140
- | planner.specialist-chat.deleted | administrative | info | compliance | A saved specialist chat is deleted, with its specialist `service` and `solutionId`. |
131
+ | solution.created | administrative | info | compliance | A solution is created (`POST /solutions`), with the `scenario` in the metadata. |
132
+ | solution.deleted | administrative | warning | compliance | A solution is deleted by its owner (`DELETE /solutions/{id}`), with its `scenario` and `status`. |
133
+ | solution.exported | data-access | info | compliance | A solution is downloaded (`GET /solutions/{id}/export`, `scope: 'solution'` with the latest `version` and `unsavedChanges`) or a saved version is downloaded (`GET /solutions/{id}/versions/{number}/export`, `scope: 'version'` with the `version`). |
134
+ | solution.admin-accessed | data-access | info | compliance | A `planner-admin` successfully reads, changes or exports a solution owned by another user, with the `ownerId` and the `operation` (`read`, `update` or `export`) in the metadata. Reading the solution or its versions is `read`; changes, analysis, discovery, chat, consultations, blueprints, component reviews and version checkpoints or renames are `update`. A specialist chat that uses the solution as context is `read`, or `update` when the chat changes the solution. |
135
+ | solution.analyzed | runtime | info | standard | A request sends solution content to the AI model, with the `endpoint` (`analyze`, `discovery`, `chat`, `blueprint`, `consult` or `specialist-chat`), the `mode` of the result (`ai`, or `rules` after a fallback), the configured `model`, whether any model call in the request `fellBack` to rules, and the specialist `service` for consultations and specialist chats. |
136
+ | pattern.created | administrative | info | compliance | A tenant pattern is created (`POST /patterns`), with `source: 'custom'`. |
137
+ | pattern.updated | administrative | info | compliance | A pattern is updated or a built-in pattern is customized (`PUT /patterns/{id}`), with the `source` after the update and the `previousSource`. The change set holds the before and after values of the changed pattern fields. |
138
+ | pattern.deleted | administrative | warning | compliance | A custom pattern is deleted or a customized built-in pattern is reset (`DELETE /patterns/{id}`), with the `source` (`custom` or `customized`) of the deleted pattern. |
139
+ | specialist-chat.exported | data-access | info | compliance | A user downloads one saved specialist chat (`scope: 'single'`) or all of their chats (`scope: 'all'`), with the `chatCount`, the specialist `service` and the `solutionId` (the filters, for an export of all chats). |
140
+ | specialist-chat.deleted | administrative | info | compliance | A saved specialist chat is deleted, with its specialist `service` and `solutionId`. |
141
141
 
142
142
  Solution records use `{ type: 'solution', id: <solution ID>, name: <solution name> }` as the resource, pattern records use `{ type: 'pattern', id: <pattern ID>, name: <pattern name> }`, and chat records use `{ type: 'specialist-chat', id: <chat ID> }`. An export of all chats has no single chat, so it has no resource. A pattern change set that would exceed the 16 KB audit limit is omitted, with `changeSetOmitted: true` in the metadata.
143
143
 
144
- `planner.solution.analyzed` is recorded only when the model is called: rule-based requests, and AI requests when no model is configured, send nothing to the model and are not recorded. It is recorded once per request when the request completes, including when the request fails after solution content was sent to the model. A failed request is recorded with status `failure` (client error) or `error` (server error) and without a `mode`, since there is no result.
144
+ `solution.analyzed` is recorded only when the model is called: rule-based requests, and AI requests when no model is configured, send nothing to the model and are not recorded. It is recorded once per request when the request completes, including when the request fails after solution content was sent to the model. A failed request is recorded with status `failure` (client error) or `error` (server error) and without a `mode`, since there is no result.
145
145
 
146
146
  Routine reads by the solution owner (listing and reading solutions, patterns, specialists, chats and versions) are not audited, and neither is a `planner-admin` listing the solutions of the tenant. Solution updates are not recorded as separate actions; they are covered by the `solution-updated` event. Patterns defined in the `patterns` configuration are managed in the [configuration service](configuration-service.md), which records those changes in the `configuration-service` namespace. Denied and failed operations are not recorded.
147
147
 
@@ -5,24 +5,180 @@ parent: Services
5
5
  ---
6
6
 
7
7
  # Status service
8
+
8
9
  Status services provides configuration of applications, operational status of those applications, and allows posting of service notices.
9
10
 
10
11
  ## Client roles
12
+
11
13
  client `urn:ads:platform:status-service`
12
14
 
13
- | name | description |
14
- |:-|:-|
15
- | status-admin | Administrator role for status service. This role allows a user to read and update status service entities. |
15
+ | name | description |
16
+ | :----------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
17
+ | status-admin | Administrator role for status service. It is included in the tenant admin role. The notice endpoints require it to create, update, and delete notices, and to read draft and archived notices. |
18
+
19
+ The application endpoints (`/status/v1`) require an authenticated user of the tenant, but don't check for a specific role. The public status endpoint is anonymous.
20
+
21
+ ## Tenancy
22
+
23
+ - **Application and notice management.** Tenant users act on the tenant of their token. These endpoints don't accept a `tenantId` parameter, so a token without a tenant context (a core user) is not supported.
24
+ - **Isolation.** Applications and notices of other tenants respond 404.
25
+ - **Public status.** `GET /public_status/v1/applications/{tenant}` takes the tenant name in the path and doesn't need a token.
26
+ - **Public notices.** Anonymous requests to `GET /notice/v1/notices` read published notices; set the `name` query parameter to a tenant name to read only that tenant's notices. Authenticated users read the notices of the tenant of their token.
27
+ - **Configuration.** Applications are stored in the tenant's `platform:status-service` configuration in the [configuration service](configuration-service.md). The status service uses only the tenant configuration; there are no platform (core) applications.
28
+
29
+ ## API overview
30
+
31
+ All endpoints are under `https://status-service.adsp.alberta.ca`. See the [API documentation](https://api.adsp.alberta.ca) for request and response schemas.
32
+
33
+ | Endpoint | Purpose | Required role |
34
+ | :------------------------------------------------------------------- | :---------------------------------------------------- | :---------------------------------------------------- |
35
+ | `GET /status/v1/applications` | List the tenant's applications with their status. | Authenticated tenant user |
36
+ | `POST /status/v1/applications` | Add an application. | Authenticated tenant user |
37
+ | `PUT /status/v1/applications/{appKey}` | Replace an application's configuration. | Authenticated tenant user |
38
+ | `DELETE /status/v1/applications/{appKey}` | Delete an application and its health check results. | Authenticated tenant user |
39
+ | `PATCH /status/v1/applications/{appKey}/enable`, `disable`, `toggle` | Turn health checks on or off. | Authenticated tenant user |
40
+ | `PATCH /status/v1/applications/{appKey}/status` | Set the published status of an application. | Authenticated tenant user |
41
+ | `GET /status/v1/applications/{appKey}/endpoint-status-entries` | Read the health check results of an application. | Authenticated tenant user |
42
+ | `GET /status/v1/applications/endpoint-status-entries` | Read recent health check results. | Authenticated tenant user |
43
+ | `GET /status/v1/webhook/{id}/test/{eventName}` | Send a test event to a monitoring webhook. | Authenticated tenant user |
44
+ | `GET /public_status/v1/applications/{tenant}` | Read the published status of a tenant's applications. | Anonymous |
45
+ | `GET /notice/v1/notices` | List notices. | Anonymous (published), `status-admin` (all) |
46
+ | `GET /notice/v1/notices/{id}` | Read a notice. | Authenticated tenant user (published), `status-admin` |
47
+ | `POST /notice/v1/notices` | Create a draft notice. | `status-admin` |
48
+ | `PATCH /notice/v1/notices/{id}` | Update, publish, or archive a notice. | `status-admin` |
49
+ | `DELETE /notice/v1/notices/{id}` | Delete a draft notice. | `status-admin` |
50
+
51
+ The service contact information and the intervals of [webhooks](/adsp-monorepo/tutorials/status-service/webhooks.html) are managed in the tenant's `platform:status-service` configuration through the configuration service; the status service has no endpoints of its own for them. Monitoring webhooks themselves are configured in the push service.
16
52
 
17
53
  ## Concepts
54
+
18
55
  ### Application
19
- Applications represent digital services that an end user may wish to access. Each application should be meaningful and distinguishable to end users, so that they understand what tasks may be unavailable to the outage of any particular application.
56
+
57
+ Applications represent digital services that an end user may wish to access. Each application should be meaningful and distinguishable to end users, so that they understand what tasks may be unavailable to the outage of any particular application. Applications with `monitorOnly` set are monitored but not shown on the public status page.
20
58
 
21
59
  ### Status
22
- The status of an application indicates whether the service is fully available to end users, may be experiencing disruption, or is in planned or unplanned outage.
60
+
61
+ The status of an application indicates whether the service is fully available to end users, may be experiencing disruption, or is in planned or unplanned outage. It is one of `operational`, `reported-issues`, `maintenance`, or `outage`.
23
62
 
24
63
  ### Health check
64
+
25
65
  Health checks poll against an application endpoint to check for issues. It helps the tenant administrators monitor for issues. By default, health checks do not update the status. If `autoChangeStatus` is set on the application, the status changes from `operational` to `reported-issues` after the health check fails for 5 minutes, and back to `operational` after it succeeds for 5 minutes. Other statuses, such as `maintenance` and `outage`, are only changed manually.
26
66
 
67
+ The `toggle` endpoint starts or stops health checks immediately. The `enable` and `disable` endpoints change the setting, and health checks pick up the change when the service reloads them, every 5 minutes. Health check results older than 48 hours are deleted nightly.
68
+
27
69
  ### Notice
28
- Notices are important messages to users regarding upcoming changes to an application. For example, they can be used to inform users of scheduled maintenance events or service disruptions.
70
+
71
+ Notices are important messages to users regarding upcoming changes to an application. For example, they can be used to inform users of scheduled maintenance events or service disruptions. A notice is created as a `draft`, then `published`, and finally `archived`. Only draft notices can be edited or deleted, and only published notices are shown on the public status page.
72
+
73
+ ## Events
74
+
75
+ Status service sends these domain events in the `status-service` namespace:
76
+
77
+ | Event | Sent when |
78
+ | :----------------------------- | :---------------------------------------------------------------------------------------- |
79
+ | `health-check-started` | Health checks of an application are started (toggle). |
80
+ | `health-check-stopped` | Health checks of an application are stopped (toggle, or delete). |
81
+ | `application-healthy` | A health check finds an application online after it was not. |
82
+ | `application-unhealthy` | A health check finds an application offline after it was not. |
83
+ | `application-status-changed` | The published status of an application is changed. |
84
+ | `application-notice-published` | A notice is published. |
85
+ | `monitored-service-down` | An application is down for the interval configured for a webhook, or a webhook is tested. |
86
+ | `monitored-service-up` | An application is back up after being reported down, or a webhook is tested. |
87
+
88
+ The service consumes its own `health-check-started` and `health-check-stopped` events to start and stop health check jobs.
89
+
90
+ It also registers two notification types: `status-application-health-change` (health check started, stopped, healthy, and unhealthy; for `status-admin` subscribers) and `status-application-status-change` (status changed and notice published).
91
+
92
+ ## Audit
93
+ Changes made by status administrators are recorded in the [audit service](/adsp-monorepo/services/audit-service.html) under the `status-service` namespace. The actor is the administrator (ID, name and roles, without the email address), not the service account.
94
+
95
+ | Action | Resource | Notes |
96
+ |---|---|---|
97
+ | `application.created` / `application.updated` / `application.deleted` | application | |
98
+ | `application.status-changed` | application | Change set holds the previous and new status; each transition is its own record. |
99
+ | `notice.created` / `notice.updated` / `notice.deleted` | notice | Metadata holds the message, dates and mode. |
100
+ | `health-check.configured` | application | Health check URL changed, or monitoring enabled or disabled. |
101
+
102
+ Health check polling results, automatic status changes and public reads are not audited. Set `STATUS_AUDIT_ENABLED` to `false` to disable; when unset it follows the SDK `AUDIT_ENABLED` variable (on by default).
103
+
104
+ ## Code examples
105
+
106
+ ### Add an application and start health checks
107
+
108
+ ```typescript
109
+ const statusServiceUrl = 'https://status-service.adsp.alberta.ca';
110
+
111
+ const response = await fetch(`${statusServiceUrl}/status/v1/applications`, {
112
+ method: 'POST',
113
+ headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' },
114
+ body: JSON.stringify({
115
+ name: 'My Application',
116
+ description: 'Online application for a benefit program.',
117
+ endpoint: { url: 'https://my-application.alberta.ca/health' },
118
+ }),
119
+ });
120
+ const { appKey } = await response.json();
121
+
122
+ // Toggle turns on health checks for the new application.
123
+ const toggled = await fetch(`${statusServiceUrl}/status/v1/applications/${appKey}/toggle`, {
124
+ method: 'PATCH',
125
+ headers: { Authorization: `Bearer ${token}` },
126
+ });
127
+ const { enabled, internalStatus } = await toggled.json();
128
+ ```
129
+
130
+ ### Set the status of an application
131
+
132
+ ```typescript
133
+ const response = await fetch(`https://status-service.adsp.alberta.ca/status/v1/applications/${appKey}/status`, {
134
+ method: 'PATCH',
135
+ headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' },
136
+ body: JSON.stringify({ status: 'maintenance' }),
137
+ });
138
+ const { status, statusTimestamp } = await response.json();
139
+ ```
140
+
141
+ ### Read the public status of a tenant's applications
142
+
143
+ ```typescript
144
+ const response = await fetch(`https://status-service.adsp.alberta.ca/public_status/v1/applications/${tenantName}`);
145
+ const applications = await response.json();
146
+ for (const { name, status, lastUpdated } of applications) {
147
+ console.log(`${name}: ${status} (updated ${lastUpdated})`);
148
+ }
149
+ ```
150
+
151
+ ### Publish a notice
152
+
153
+ ```typescript
154
+ const statusServiceUrl = 'https://status-service.adsp.alberta.ca';
155
+
156
+ // Requires the status-admin role.
157
+ const created = await fetch(`${statusServiceUrl}/notice/v1/notices`, {
158
+ method: 'POST',
159
+ headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' },
160
+ body: JSON.stringify({
161
+ message: 'My Application will be down for weekly maintenance during the following hours.',
162
+ tennantServRef: [{ id: 'my-application', name: 'My Application' }],
163
+ isAllApplications: false,
164
+ startDate: '2026-11-15T02:00:00.000Z',
165
+ endDate: '2026-11-15T04:00:00.000Z',
166
+ }),
167
+ });
168
+ const { id } = await created.json();
169
+
170
+ const published = await fetch(`${statusServiceUrl}/notice/v1/notices/${id}`, {
171
+ method: 'PATCH',
172
+ headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' },
173
+ body: JSON.stringify({ mode: 'published' }),
174
+ });
175
+ const { mode } = await published.json();
176
+ ```
177
+
178
+ ### Read the published notices of a tenant
179
+
180
+ ```typescript
181
+ const response = await fetch(`https://status-service.adsp.alberta.ca/notice/v1/notices?name=${tenantName}`);
182
+ const { results, page } = await response.json();
183
+ // page.next is a query string, for example after=50&top=50, or null on the last page.
184
+ ```
@@ -16,6 +16,34 @@ client `urn:ads:platform:token-handler`
16
16
  |:-|:-|
17
17
  | token-handler-admin | Administrator role for token handler allowed to register clients. |
18
18
 
19
+ ## Tenancy
20
+
21
+ - **Administration endpoints.** The client endpoints that take a bearer token act on the tenant of the token, and need the `token-handler-admin` role in that tenant. Only tokens from tenant realms are accepted; core (platform) tokens respond 401, and there is no `tenantId` parameter.
22
+ - **Sign in.** The sign in endpoint is anonymous, so the tenant is given by the `X-ADSP-TENANT` header (for example set by the app's reverse proxy) or the `tenant` query parameter, as a tenant name or tenant URN. The header is used if both are set. The tenant is kept in the session, so the callback uses the tenant that sign in was started with, unless the header is set. Without a tenant, sign in responds 400, and an unknown tenant responds 404.
23
+ - **Sessions and targets.** After sign in, the session belongs to the tenant of the client that the user signed in with. Session information, logout, and target requests use that session; they take no tenant parameter.
24
+ - **Platform and tenant clients.** A tenant has its own clients and the clients of the core configuration. When both have a client with the same ID, the core client is used, so a tenant cannot change or replace it. Each tenant registers core clients separately, in its own realm. See [Core (platform) clients](#core-platform-clients).
25
+ - **Isolation.** A client ID that is not configured for the tenant or in the core configuration responds 404. A target ID that is not a target of the session's client responds 404.
26
+
27
+ ## API overview
28
+
29
+ The API is under `/token-handler/v1` on the token handler host; the examples use `https://token-handler.example.ca` as a placeholder for it. Frontend applications call the browser endpoints through a reverse proxy on their own site (see [Reverse proxy](#reverse-proxy)), not at this URL. See the [API documentation](https://api.adsp.alberta.ca) for request and response schemas.
30
+
31
+ | Endpoint | Purpose | Access |
32
+ | :- | :- | :- |
33
+ | `GET /token-handler/v1/clients` | List the clients of the tenant and the core configuration, with their registration status. | `token-handler-admin` |
34
+ | `GET /token-handler/v1/clients/{clientId}` | Get a client and its registration. | `token-handler-admin` |
35
+ | `POST /token-handler/v1/clients/{clientId}` | Register a client in access service. | `token-handler-admin` |
36
+ | `PUT /token-handler/v1/clients/{clientId}` | Update the redirect URIs of a registered client. | `token-handler-admin` |
37
+ | `GET /token-handler/v1/clients/{clientId}/auth` | Start sign in; redirects (302) to access service. | Anonymous (browser) |
38
+ | `GET /token-handler/v1/clients/{clientId}/callback` | Complete sign in; starts the session and redirects (302) to the client's success or failure URL. | Anonymous (browser) |
39
+ | `GET /token-handler/v1/clients/{clientId}/logout` | End the session; redirects (302) to the site root or access service. | Signed in user (session cookie) |
40
+ | `GET /token-handler/v1/sessions` | Get the session of the signed in user. | Signed in user (session cookie) |
41
+ | `GET`, `POST`, `PUT`, `PATCH`, `DELETE /token-handler/v1/targets/{targetId}/*` | Proxy a request to the upstream of a target, with the user's access token. | Signed in user (session cookie), plus the `X-XSRF-TOKEN` header for requests other than `GET` |
42
+
43
+ The sign in, callback, and logout endpoints are rate limited to 100 requests per 5 minutes per client IP address, and respond 429 above it. Responses of target requests are the responses of the upstream; the token handler only adds 400 (invalid CSRF token, path, or upstream), 401 (no session), and 404 (unknown target). The OpenAPI documentation shows target paths as a single `{targetPath}` parameter, because OpenAPI cannot express a path with any number of segments.
44
+
45
+ Clients and targets are configured in the [configuration service](configuration-service.md); token handler has no endpoints of its own for changing them.
46
+
19
47
  ## Concepts
20
48
 
21
49
  ### Clients
@@ -107,6 +135,14 @@ There are some special considerations for local development workflows when using
107
135
  }
108
136
  ```
109
137
 
138
+ ## Events
139
+
140
+ | Event | Description |
141
+ | :- | :- |
142
+ | `token-handler:client-registered` | Sent when a client is registered (`POST /token-handler/v1/clients/{clientId}`), and when its redirect URIs are updated (`PUT /token-handler/v1/clients/{clientId}`). The payload has the `client` (`id`, `name`, `clientId`, `authCallbackUrl`) and `registeredBy` (`id`, `name`). |
143
+
144
+ Token handler does not consume domain events of its own, but it receives configuration updates from the [configuration service](configuration-service.md) to invalidate its cached configuration, so changes to clients and targets take effect without a restart.
145
+
110
146
  ## Code examples
111
147
 
112
148
  ### Register a client
@@ -114,7 +150,7 @@ Registering a client creates a confidential client in access service and securel
114
150
 
115
151
  ```typescript
116
152
  const response = await fetch(
117
- `https://adsp.alberta.ca/api/token-handler/v1/clients/${clientId}`,
153
+ `https://token-handler.example.ca/token-handler/v1/clients/${clientId}`,
118
154
  {
119
155
  method: 'POST',
120
156
  headers: {
@@ -138,7 +174,7 @@ Updating a client's registration allows changing the registered redirect URIs in
138
174
 
139
175
  ```typescript
140
176
  const response = await fetch(
141
- `https://adsp.alberta.ca/api/token-handler/v1/clients/${clientId}`,
177
+ `https://token-handler.example.ca/token-handler/v1/clients/${clientId}`,
142
178
  {
143
179
  method: 'PUT',
144
180
  headers: {
@@ -160,15 +196,37 @@ Updating a client's registration allows changing the registered redirect URIs in
160
196
  ```
161
197
 
162
198
  ### Retrieving session information
163
- Frontend application can determine if the user is logged in and access their session information via the sessions endpoint.
199
+ Frontend applications can find out if the user is signed in, and who they are, with the sessions endpoint through their reverse proxy. The session cookie is sent by the browser. The endpoint responds 401 when no user is signed in.
164
200
 
165
201
  ```typescript
166
- const response = await fetch(
167
- '/sessions',
168
- {
169
- method: 'GET',
170
- }
171
- );
202
+ const response = await fetch('/token-handler/sessions');
203
+
204
+ if (response.status === 401) {
205
+ // Not signed in; navigate to sign in.
206
+ window.location.href =
207
+ `/token-handler/clients/${clientId}/auth?tenant=my-tenant&callbackUrl=${encodeURIComponent(callbackUrl)}`;
208
+ } else {
209
+ const [{ id, name, email, roles, expiry }] = await response.json();
210
+ }
211
+ ```
172
212
 
173
- const [session] = await response.json();
213
+ ### Making a request to a target
214
+ Frontend applications make API requests to a target through their reverse proxy. The token handler adds the user's access token. Requests other than `GET` need the value of the `XSRF-TOKEN` cookie in the `X-XSRF-TOKEN` header.
215
+
216
+ ```typescript
217
+ const csrfToken = document.cookie
218
+ .split('; ')
219
+ .find((cookie) => cookie.startsWith('XSRF-TOKEN='))
220
+ ?.split('=')[1];
221
+
222
+ const response = await fetch('/token-handler/targets/form-service/form/v1/forms', {
223
+ method: 'POST',
224
+ headers: {
225
+ 'Content-Type': 'application/json',
226
+ 'X-XSRF-TOKEN': csrfToken,
227
+ },
228
+ body: JSON.stringify({ definitionId: 'my-form-definition' }),
229
+ });
230
+
231
+ const { id, status } = await response.json();
174
232
  ```