> ## 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.

# supportMacroAttachmentAdd

> Add a file to a macro, as the macro editor's attach button does: a file sent with every reply the macro fills. Images the body shows go with the body, in SupportMacroBodyInput.inlineImages. Returns null if the store has no such macro. Throws INVALID_UPLOAD when the upload is missing, used, another store's, or not the declared type; the upload is spent only when the file is added. Needs support_macros_write, which the Create macro permission grants, as the app's macro editor asks.

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

## Arguments

**id** `ID!` *required*

The id of the macro to add the file to.

**input** `[SupportMacroAttachmentAddInput!](/docs/api-reference/v3/reference/support/support-macro-attachment-add-input)` *required*

The file.

**fields**

**file** `[SupportAttachmentInput!](/docs/api-reference/v3/reference/support/support-attachment-input)` *required*

The file, uploaded with supportAttachmentUploadCreate. Its upload is used once.

**fields**

**contentType** `String!` *required*

The file's MIME type, such as application/pdf or image/png. A PNG, JPEG, GIF or PDF must be declared as what it is.

**filename** `String!` *required*

The file's name as the customer sees it, 1 to 255 characters, with no control characters.

**uploadId** `String!` *required*

The uploadId `supportAttachmentUploadCreate` returned.

## Returns

**supportMacroAttachmentAdd** `[SupportMacroAttachmentAddResult](/docs/api-reference/v3/reference/support/support-macro-attachment-add-result)`

The file added and the macro it was added to.

**fields**

**attachment** `[SupportMacroAttachment!](/docs/api-reference/v3/reference/support/support-macro-attachment)` *required*

The file added.

**fields**

**description** `String`

File description as shown in the app. Null when none was saved.

**id** `ID!` *required*

The id of this attachment.

**mimeType** `String`

MIME type, such as image/png. Null for some imported files.

**url** `String`

Signed download link, valid for one hour. Null when it can't be signed right now; the attachment still exists.

**macro** `[SupportMacro!](/docs/api-reference/v3/reference/support/support-macro)` *required*

The macro, with the file in attachments.

**fields**

**addsInternalNote** `String`

Plain-text internal note the macro adds. Null adds none.

**addsTagNames** `[String!]!` *required*

Names of the tags the macro adds when applied. A name with no matching tag in the store is skipped.

**attachments** `[\[SupportMacroAttachment!\]!](/docs/api-reference/v3/reference/support/support-macro-attachment)` *required*

Files the macro attaches to a reply. Images the body shows are in inlineImages instead.

**fields**

**description** `String`

File description as shown in the app. Null when none was saved.

**id** `ID!` *required*

The id of this attachment.

**mimeType** `String`

MIME type, such as image/png. Null for some imported files.

**url** `String`

Signed download link, valid for one hour. Null when it can't be signed right now; the attachment still exists.

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

Reply body as plain text. A variable appears as its bare name, such as customer\_first\_name, and the app fills it in from the ticket when the macro is used. This field returns variables unfilled. Variable names: current\_date, customer\_first\_name, customer\_full\_name, customer\_last\_name, customer\_email, agent\_first\_name, agent\_full\_name, agent\_last\_name, recent\_claim\_created\_date, recent\_claim\_processed\_date, recent\_claim\_status, recent\_order\_date, recent\_order\_delivery\_status, recent\_order\_fulfillment\_status, recent\_return\_status, recent\_order\_price, recent\_order\_returned\_date, recent\_order\_shipping\_address, recent\_order\_shipping\_date, recent\_order\_tracking\_number, recent\_order\_tracking\_url\_link, recent\_order\_number, recent\_return\_created\_date, recent\_return\_processed\_date, store\_name.

**bodyHtml** `String!` *required*

Reply body as HTML, with the same unfilled variables, each as \<span data-variable="customer\_first\_name">customer\_first\_name\</span>. Inline images use signed links that expire after one hour; query again for fresh ones.

**createdAt** `[DateTime!](/docs/api-reference/v3/reference/common/date-time)` *required*

When the macro was created.

**filledBody** `[SupportMacroFilledBody](/docs/api-reference/v3/reference/support/support-macro-filled-body)`

The macro's body with its variables filled for a ticket, as the help desk composer fills it. Send its text with supportTicketReply. Needs customers\_read and orders\_read as well as support\_tickets\_read, because a variable can name the customer's email or an order's address. Null when the store has no such ticket. Costs 10 points per macro.

**fields**

**Arguments**

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

The ticket whose customer, orders and returns fill the variables.

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

**Fields**

**allVariablesFilled** `Boolean!` *required*

False when a variable had no value and its default was used. The agent name variables never have one: an API token isn't a team member.

**text** `String!` *required*

The plain-text body with each variable replaced by its value for the ticket, formatted as the composer formats it (names in title case, dates in UTC). Values are inserted literally: `$&` stays `$&`.

**id** `ID!` *required*

The id of this macro.

**inlineImages** `[\[SupportMacroAttachment!\]!](/docs/api-reference/v3/reference/support/support-macro-attachment)` *required*

Images the body shows, each where bodyHtml has an \<img> with its url. They go when a new body leaves them out, as in the app; supportMacroAttachmentDelete doesn't take them.

**fields**

**description** `String`

File description as shown in the app. Null when none was saved.

**id** `ID!` *required*

The id of this attachment.

**mimeType** `String`

MIME type, such as image/png. Null for some imported files.

**url** `String`

Signed download link, valid for one hour. Null when it can't be signed right now; the attachment still exists.

**name** `String!` *required*

Name shown in the macro picker. Unique within the store.

**setsEmailSubject** `String`

Email subject the macro sets on the thread. Null leaves it unchanged.

**setsStatus** `[SupportMacroStatus](/docs/api-reference/v3/reference/support/support-macro-status)`

Status the macro sets when applied. Null leaves the status unchanged.

**snoozeDuration** `[SupportTicketSnoozeDuration](/docs/api-reference/v3/reference/support/support-ticket-snooze-duration)`

How long the ticket is snoozed. Set only when setsStatus is SNOOZED.

## 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. |
| `INVALID_UPLOAD` | `400` | An uploadId has no file: it was never uploaded, expired, or was already used. Or the file isn't the one described, such as a PDF declared as an image. Nothing was sent. | Start a new upload, PUT the file, and send again with its uploadId and the file's real content type. |
| `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 {
  supportMacroAttachmentAdd(id: "...", input: { ... })
}
```


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