> ## Documentation Index
> Fetch the complete documentation index at: https://developers.redo.com/llms.txt
> Use this file to discover all available pages before exploring further.

# supportTicketReplyCompose

> Have the AI write or rewrite reply text for a ticket, as the help desk composer's AI bar does, with the same rule for which of its actions runs and the same model calls. `text` alone is improved; `instruction` alone is followed to write a reply from the conversation; both apply the instruction to `text`. Text or an instruction that is only whitespace counts as none, and with neither it fails with BAD_USER_INPUT: to have the AI suggest a reply on its own, use `supportAiDraftReplyGenerate`. The AI reads the thread's recent messages and writes as the store. Nothing is stored or sent. It costs 50 points and draws on the store's AI reply quota, shared with `supportAiDraftReplyGenerate`, of 60 calls, refilling at about 600 an hour; past it, THROTTLED. Returns null if the store has no such ticket, or it is hidden from the API. Throws BAD_USER_INPUT for a thread that isn't the ticket's or that `supportTicketReply` can't send on, such as a contact form or voice thread, or a ticket with no thread that takes replies. Throws TRY_AGAIN (503) when the AI couldn't write it: retry it. A throttled, invalid or null call gives back its points and quota.

**Required scopes:** [`support_tickets_write`](https://developers.redo.com/docs/api-reference/v3/reference/scopes#scope-support_tickets_write)

## Arguments

**instruction** `String`

What to write or change, such as `apologize for the delay and offer a refund`: at most 10,000 characters.

**text** `String`

Reply text to improve, or to apply `instruction` to: at most 10,000 characters.

**threadId** `ID`

One of the ticket's threads, whose messages the AI reads. Defaults to the thread the customer wrote on most recently, the one `supportTicketReply` defaults to.

**ticketId** `ID!` *required*

The id of the ticket the reply is for.

## Returns

**supportTicketReplyCompose** `[SupportReplyComposition](/docs/api-reference/v3/reference/support/support-reply-composition)`

Reply text the AI wrote for a ticket. Nothing is stored or sent: pass `body`, edited or not, to `supportTicketReply`.

**fields**

**body** `String!` *required*

The reply as plain text, ready to send.

## Errors

Besides the [errors any request can return](https://developers.redo.com/docs/api-reference/v3/errors.md), this operation fails with these codes in `extensions.code`.

| Code | HTTP status | Meaning | Retry |
| - | - | - | - |
| `API_TOKEN_REQUIRED` | `403` | The credential has no API token to attribute the change to, such as a first-party token. Nothing was sent. | Call with a store API token. |
| `BAD_USER_INPUT` | `400` | An argument is invalid, or names something the store doesn't have. The message says which. Nothing was written. | Fix the input the message names, then send it again. |
| `TRY_AGAIN` | `503` | The change couldn't start for a passing reason, and nothing was written or sent. | Send the same request again after a short wait, with the same idempotencyKey if it has one. |
| `INTERNAL_SERVER_ERROR` | `500` | Something failed on Redo's side. The change may or may not have been made. | Read the record to see whether the change was made before sending it again. A send with an idempotencyKey is safe to retry with the same key. |

## Example

```graphql theme={null}
mutation {
  supportTicketReplyCompose(instruction: "...", text: "...", threadId: "...", ticketId: "...") {
    body
  }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.