Search documentation
Find a documentation page by the words on it.
Documentation
Routine API Trigger
This integration has not been released yet. The steps below describe how it will work.
A routine is a saved assistant workflow that runs as the person who owns it, with no one watching, using only the tools and limits its owner approved. The API trigger lets another system, such as a scheduler or an intake form, start one routine with a single web request. You make a secret token for the routine, give it to the other system, and the other system uses it to start a run.
What you need
- Routines turned on for your clinic, with the API trigger setting on. Only Serelora can turn these on, and the API trigger is off until it does. Contact Serelora at support@serelora.com. Without them, the API trigger card does not offer a token.
- To own the routine. Only the routine's owner can create or rotate its token. By default only an Admin has the Routines permissions. An Admin who can manage clinic routines can also revoke a token on a clinic routine.
- An approved, active routine. The routine must be approved by its owner and active. Until then the token is refused. A routine can be a Practice Agent routine, or a chart routine tied to one patient. A chart routine with no patient cannot be started through the API, because the call names no patient.
- A system that can send a web request and keep a secret safely, such as a secret store.
Step 1: Open the routine
Select Routines under Clinical in the sidebar, and open the routine. The API trigger card is on the routine's page, and also under its editor.
The card says "Start this routine from another system with a secret token. A call runs with the tools and limits you approved, and any text it sends is treated as untrusted."
Step 2: Select Create API token
Select Create API token. A routine has at most one token. A dialog titled "Your API token" opens.
Step 3: Copy the token now
The dialog says "Copy this token now. You won't be able to see it again." Select Copy beside the API token box. Put the token in the other system's secret store, and select Done. Serelora keeps only a fingerprint of the token and its last four characters, so nobody can read it again, including you and Serelora. A click outside the dialog does not close it, so a stray click does not lose the token.
Treat the token like a password. Anyone who has it can start this routine as its owner. A token starts with srt_.
Step 4: Make the call from the other system
The dialog shows an example under "Start the routine from another system". The other system sends a POST request to your Serelora address, with the token in an Authorization header:
curl -X POST "https://<your Serelora address>/api/routines/<routine id>/fire" \
-H "Authorization: Bearer $ROUTINE_TOKEN" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: <a unique key per event>" \
-d '{"text": "optional context, up to 4000 characters"}'
Authorizationcarries the token. Keep it in a secret store and read it intoROUTINE_TOKEN. Do not put it in a web address or the body.Idempotency-Keyis optional, 1 to 128 visible characters. Use a different one for each event. If the same key is sent again with the same text, Serelora returns the run it already started instead of starting another.textis optional, up to 4,000 characters. It is the only thing the call can add. The call names no user, clinic or patient.
When Serelora accepts the call it answers 202 with the run's identifier, and the run is queued. The reply carries nothing else, so the other system does not receive the run's results. You read those in Serelora, under Routines.
Step 5: Check that it worked
Back on the routine's page, the card reads "Token ending in" and the last four characters, with when it was created and when it was last used. "Never" means no call has arrived yet. After a call, the run appears in the routine's runs.
What the text can and cannot do
Any text the other system sends is shown to the assistant as outside input, marked as data and not instructions. It is stored with the run, like any chat message. It grants nothing. A run uses only the tools and limits the owner approved, whatever the text says, and a tool the routine was not approved for is refused. Even so, an assistant can be talked into following text, so send only what the routine needs, and only from systems you trust.
How to use it
Rotate the token to replace it. Select Rotate, then Rotate token to confirm. The old token stops working immediately, and the new one is shown once, in a dialog titled "Your new API token".
Revoke the token to switch the trigger off. Select Revoke, then Revoke token to confirm. Anything using the token stops working. Revoking also cancels runs that token had queued but not yet started. Rotating does not.
A token does not expire. It stays valid until you rotate or revoke it, the routine is disabled, or the routine's ownership is transferred, which revokes it. After a suspected leak, revoke it and create a new one.
What data moves
- To Serelora: the token, an optional key and optional text. The text can contain patient information if the other system puts it there.
- From Serelora: the run's identifier, and an error message if the call is refused.
- What is recorded: creating, rotating and revoking a token are written to the audit log with the token's last four characters, never the token. Each call that presented a valid token is recorded with its outcome and, if refused, a coded reason. A call with a bad token writes nothing, so guessing cannot fill the log.
- What is not stored: the token itself, and the
Idempotency-Keyvalue.
If it does not work
The other system sees one of these answers. Every answer carries Cache-Control: no-store.
| Answer | Meaning | What to do |
|---|---|---|
202 |
A run was queued. Idempotent-Replayed: true means the key had already started one. |
Nothing. |
400 |
A field is wrong, such as an unknown field, text over 4,000 characters, or a bad Idempotency-Key. |
Fix the request. |
401 "The routine token is missing or not valid." |
The token is missing, wrong, revoked, or belongs to another routine. Every failure reads the same on purpose. | Check the token. Create a new one if it was revoked or lost. |
404 "That routine couldn't be found." |
The token is valid but the routine cannot start now. | Ask the routine's owner to check that the routine is active and approved, that the API trigger setting is on for the clinic, and that the owner still has access. |
409 |
The same Idempotency-Key was already used with different text. |
Use a new key. |
413 "That request is too large." |
The request is over 32 KB. | Send less. |
429 |
Too many calls, for this routine or for the clinic. The answer carries Retry-After. |
Wait and try again. |
503 |
Serelora could not queue the run. Nothing was created. | Try again later. |
In the card, "Calls are refused until this routine is approved and active." means the routine is not ready. "The API trigger is turned off for your clinic. This token can't start the routine." means Serelora has switched the setting off. Revoke is still offered, so you can always remove a token.
What it does not do
- It does not let the other system read anything from Serelora. It can only start the routine.
- It does not choose a patient, a user or a clinic. The routine already names them.
- It does not give the other system more than the owner approved.
- It does not let an assistant or a colleague create the token. Only the owner can, in the Serelora app.
- It does not sign requests or expire tokens, so keep the token secret and rotate it if you are unsure.