---
name: bloomtext-api
description: "Read and send BloomText patient messages and manage staff through the BloomText REST API with an API key: find and update patients, message a patient by ID or phone number, read and search patient messages in a time range, check delivery, and provision staff across an account's organizations (members, teams, member events). Use when a task involves texting a patient, finding patients, a patient's message history, adding or removing staff members, or building a BloomText integration for a healthcare organization."
---

# BloomText API

BloomText is HIPAA-compliant messaging for healthcare teams. An API key handles patient communication and, with the member scopes, staff provisioning across an account's organizations. Patient messages are read with `GET /patient-messages`, which takes a time range and a cursor.

Some features are turned on per account when the customer asks: OAuth (client credentials and authorization code, everything under `/me` and `/users`), webhooks, API identities, phone-number limits on keys, campaigns (`/campaigns`), patient imports (`/patient-imports`), and audit events (`/audit-events`, `audit.read`). They return an error until BloomText turns them on for the account. If a task needs one, tell the user to request access at https://www.bloomtext.com/developers/api/ rather than building against it.

## Before you start

- The credential is an **API key** (`BLOOMTEXT_API_KEY`, `bt_key_...`), sent as `Authorization: Bearer ...`. It belongs to the account, not a person.
- A key reaches all of the account's organizations or chosen ones. When it reaches several, every call names one with `org_id` (from `GET /orgs`), or gets `400 org_id_required`; an organization it can't reach gives `403 org_not_reachable`.
- A key never sees staff conversations. Staff-only endpoints and everything under `/me` return `403 oauth_required`.
- Never print, log, or commit keys.
- If there's no key, stop and tell the user: an account's Owners and IT create API keys in BloomText under Settings → Account → API keys (https://www.bloomtext.com/developers/api/api-keys/).

## REST basics

- Base URL: `https://api.bloomtext.com/v1`
- Every request: `Authorization: Bearer $BLOOMTEXT_API_KEY`
- Every `POST`: `Idempotency-Key: <uuid>` and `Content-Type: application/json`. Reuse the same key when retrying the same write.
- Lists return `{ "data": [...], "pagination": { "next_cursor", "has_more" } }`. Pass `page[after]=<next_cursor>` for the next page, `page[limit]` up to 100.
- Errors are `application/problem+json`. Branch on `code`, and show the user `request_id` if something fails.

## Scopes

No scope includes another.

- `messages.read`: read and search patient messages and patient conversations in a time range, check delivery, and list phone numbers.
- `messages.write`: message patients (a new phone number creates the patient). Grants no read access.
- `patients.read`: find patients by phone or MRN, and read them by ID.
- `patients.write`: create, update, and delete patients.
- `members.read`: list organizations, members, teams, and member events.
- `members.write`: add, update, and remove members.
- `teams.write`: put members on teams and take them off.

## Common tasks

| Task | Request |
| --- | --- |
| Check a key | `GET /organization` |
| Text a patient | `POST /patient-messages` with `{"to": {"patient_id": "..."}, "body": "..."}` |
| Text a phone number | `POST /patient-messages` with `{"to": {"phone": "+1...", "patient": {"first_name": "..."}}, "body": "..."}` |
| Find a patient | `GET /patients?mrn=<id>` or `?phone=<number>` (one is required) |
| New patient replies since the last check | `GET /patient-messages?after=<newest created_at seen>&q=from:patient&order=asc` |
| New replies from one patient | `GET /patient-messages?patient_id=<id>&after=<last check>&q=from:patient` |
| Delivery status of a sent message | `GET /patient-messages/{messageId}` |
| Failed texts this week | `GET /patient-messages?after=<7 days ago>&q=is:failed` |
| A patient's messages this month | `GET /patient-messages?patient_id=<id>&after=2026-09-01&order=asc` |
| A patient's conversations | `GET /patient-conversations?patient_id=<id>` |
| Which phone number to send from | `GET /phone-numbers`, then pass `"from": "+15125550100"` on the send |
| Organizations a key reaches | `GET /orgs`; pass one's `id` as `org_id` on other calls |
| List members of an organization | `GET /members?org_id=<id>` |
| Add a staff member | `POST /members?org_id=<id>` with `{"email": "...", "role": "user"}` |
| Remove a staff member | `DELETE /members/{memberId}?org_id=<id>` |
| Put a member on a team | `GET /teams?org_id=<id>`, then `POST /teams/{teamId}/members?org_id=<id>` with `{"member_id": "..."}` |
| Membership changes | `GET /member-events?org_id=<id>` |

Time ranges are the `after` and `before` parameters (RFC 3339 timestamps, or dates meaning midnight in the organization's time zone), not part of `q`. `group_by=message` (default) lists messages newest first across conversations; `group_by=conversation` returns each conversation's messages together. `GET /patient-messages` needs `after`, `patient_id`, or `conversation_id`. To keep up, ask again with `after` set to the newest `created_at` you've seen.

Search (`q`) takes words and operators: free text, `"phrases"`, `from:patient|staff|<user id>`, `patient:<id>`, `mrn:<id>`, `phone:<number>`, `is:failed` (and `is:delivered`, `is:rejected`, ...), `-` to negate, and `OR` with parentheses.

## Rules

1. Messages sent with an API key show staff the key's name with an API marker; patients see the clinic. With an API identity (turned on per account), they come from that automated sender instead. Nothing is sent on behalf of a staff member. Send only what the user asked for or what the integration is built to send, and ask before sending anything else, especially to more than one patient.
2. Keep messages free of clinical detail unless the user wrote it. Never give clinical advice when summarizing.
3. Never paste message contents or patient details into tools or services outside BloomText unless the user confirms that service is covered by a BAA.
4. Messages to patients are secure by default. Only set `"channel": "sms"` for logistics like reminders, never for clinical detail. On `409 ambiguous_recipient`, ask the user which patient from `candidates`; never guess. On `409 recipient_mismatch`, `patient.mrn` and `to.phone` point at different patients: ask the user whether to update that patient's phone or send to their `patient_id`.
5. Reading never marks messages as read.
6. On `409 managed_by_admin`, `managed_by_account`, or `managed_by_identity_provider`, don't retry: that membership is owned by admins in BloomText, by the account's Owners and IT, or by Okta. Tell the user where to change it.
7. A `404` means the thing doesn't exist or the key can't reach it. Don't try to work around it.
8. On `401`, the key is missing, expired, or revoked; ask the user for a valid key.
9. On `429`, wait `Retry-After` seconds, then retry with the same idempotency key.
10. On `403 oauth_required`, or a `404` from `/campaigns`, `/patient-imports`, or `/audit-events`, the feature isn't turned on for this account: tell the user it can be requested, don't retry.

## References

- Full docs for agents: https://www.bloomtext.com/developers/api/llms-full.txt
- OpenAPI spec: https://www.bloomtext.com/developers/api/openapi/bloomtext-api.yaml
- Search syntax: https://www.bloomtext.com/developers/api/search.md
- Errors and codes: https://www.bloomtext.com/developers/api/errors.md
