# Saved Replies

Keep reply texts agents insert in the inbox, for the workspace, teams or one user.

5 operations in the Saved Replies resource group.

## Operations

- [List saved replies](/api/reference/saved-replies/list-saved-replies.md) - GET `/saved-replies` - Returns the saved replies the caller can see, ordered by `title`, then `id`: every
workspace reply, the team replies of the caller's teams, and the caller's own personal
replies. Workspace owners and admins, and API keys, see every team reply, and also
another user's personal replies when they filter by `createdBy`.

- `400` with code `gateway_invalid_request`: a parameter breaks this schema, for
  example an unknown `scope`, a negative `pageSize` or a `query` over 200 characters.
- `400` with code `messaging_saved_reply_invalid_page_token`: `pageToken` is invalid,
  older than 24 hours, or was issued for other filters or another caller.
- [Create saved reply](/api/reference/saved-replies/create-saved-reply.md) - POST `/saved-replies` - Creates a saved reply; `createdBy` is the calling user. Any agent can create a
personal reply; workspace and team replies need a workspace owner or admin, or an API
key. An API key can't create a personal reply because it has no user to manage it.

- `400` with code `gateway_invalid_request`: the request breaks this schema, for
  example a length, the `shortcut` pattern, an unknown `scope` or more than 50
  `teamIds`.
- `400` with code `messaging_saved_reply_invalid_input`: `title` or `body` is only
  whitespace, `teamIds` is empty for scope `teams`, or set for another scope.
- `400` with code `messaging_saved_reply_body_invalid`: `body` isn't a valid template.
- `400` with code `messaging_saved_reply_owner_required`: an API key created a
  personal reply.
- `403` with code `messaging_saved_reply_manage_shared_denied`: an agent created a
  workspace or team reply.
- `404` with code `messaging_saved_reply_team_not_found`: a team doesn't exist in the
  workspace.
- `422` with code `messaging_saved_reply_limit_reached`: the workspace has 500
  workspace and team replies, or the caller has 100 personal replies.
- [Get saved reply](/api/reference/saved-replies/get-saved-reply.md) - GET `/saved-replies/{id}` - Returns one saved reply with its all-time `uses`.

- `404` with code `messaging_saved_reply_not_found`: the reply doesn't exist, or it is
  another user's personal reply and the caller is an agent, or it is a team reply and
  the caller is an agent who isn't a member of any of its teams. API keys, workspace
  owners and admins read every reply.
- [Update saved reply](/api/reference/saved-replies/update-saved-reply.md) - PATCH `/saved-replies/{id}` - Changes the fields that are present. Only the user who created a personal reply can
change it, and only workspace owners and admins, and API keys, can change workspace and
team replies. They can also move anyone's personal reply to scope `workspace` or
`teams`, and a reply between those two. A workspace or team reply can't become
personal. `createdBy` never changes.

- `400` with code `gateway_invalid_request`, `messaging_saved_reply_invalid_input` or
  `messaging_saved_reply_body_invalid`: as for create; moving to scope `teams` needs
  `teamIds`.
- `403` with code `messaging_saved_reply_manage_shared_denied`: an agent changed a
  workspace or team reply, or moved a personal one to them.
- `403` with code `messaging_saved_reply_owner_only`: a workspace owner or admin, or an
  API key, changed another user's personal reply without moving it to scope
  `workspace` or `teams`.
- `404` with code `messaging_saved_reply_not_found`: the reply doesn't exist, or it is
  another user's personal reply and the caller is an agent, or it is a team reply and
  the caller is an agent who isn't a member of any of its teams. API keys, workspace
  owners and admins read every reply.
- `404` with code `messaging_saved_reply_team_not_found`: a team isn't a team of the
  workspace, or it was deleted.
- `422` with code `messaging_saved_reply_scope_change_denied`: a workspace or team reply
  was moved to scope `personal`.
- `422` with code `messaging_saved_reply_limit_reached`: moving a personal reply would
  exceed 500 workspace and team replies.
- [Delete saved reply](/api/reference/saved-replies/delete-saved-reply.md) - DELETE `/saved-replies/{id}` - Deletes a saved reply and its usage counts. Only the user who created a personal reply
can delete it; workspace and team replies need a workspace owner or admin, or an API
key.

- `403` with code `messaging_saved_reply_manage_shared_denied` or
  `messaging_saved_reply_owner_only`: the caller can't delete this reply.
- `404` with code `messaging_saved_reply_not_found`: the reply doesn't exist, or it is
  another user's personal reply and the caller is an agent, or it is a team reply and
  the caller is an agent who isn't a member of any of its teams. API keys, workspace
  owners and admins read every reply.

## Schemas

- [ProblemDetails](/api/reference/schemas/problem-details.md) - object - RFC 9457 Problem Details response with a stable Flownally error code.
- [FieldViolation](/api/reference/schemas/field-violation.md) - object - A request field that failed validation.
- [Window](/api/reference/schemas/messaging-window.md) - object - Whether `forActor` can reply in this conversation right now. The window restarts with
each customer message and lasts as long as the channel allows. `state` is evaluated when
the response is built; `expiresAt` is the authority, so re-derive the state from it
instead of polling. A conversation has no `messagingWindow` on channels without a window
or on a session's messages page.
- [SavedReplyScope](/api/reference/schemas/saved-reply-scope.md) - enum - Who reads the reply and where the inbox offers it. `workspace`: every agent of the
workspace. `teams`: members of one of `teamIds`, the same membership that lets them read
those teams' conversations; workspace owners and admins, and API keys, read every team
reply. `personal`: only the user who created it; workspace owners and admins, and API
keys, can read it and move it to `workspace` or `teams`.
- [ListSavedRepliesResponse](/api/reference/schemas/list-saved-replies-response.md) - object
- [SavedReply](/api/reference/schemas/saved-reply.md) - object
- [SavedReplyBody](/api/reference/schemas/saved-reply-body.md) - string - The reply text, at most 4096 characters. It can contain `{{ }}` expressions over the
variables `contact.name`, `contact.firstName` (guessed from `name`, and may be
missing), `contact.phone`, `contact.email`, `contact.customFields.<id>` and
`agent.name`. Only the root (`contact` or `agent`) is validated, and the `matches`
operator isn't allowed. The Flownally inbox fills the placeholders when an agent
inserts the reply. No public operation fills them: an API client receives the text as
stored and replaces them itself, or uses replies without them.
- [CreateSavedReplyRequest](/api/reference/schemas/create-saved-reply-request.md) - object
- [UpdateSavedReplyRequest](/api/reference/schemas/update-saved-reply-request.md) - object
