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

# supportMacrosImport

> Import macros, as the help desk's macro import does, and say what happened to each. A macro whose name the store already has, ignoring case, is SKIPPED rather than refused, so running an import again adds only what's new. A tag a macro adds that the store doesn't have fails that macro (UNKNOWN_TAGS) unless createMissingTags is true, which creates it and needs support_config_write. An image the body links to is copied into Redo, or left as a link when it can't be fetched. One macro that fails doesn't stop the rest. Runs while the request waits, for at most 100 macros. Each call draws on the store's import quota, a burst of 10 refilling at about 60 an hour; over it returns THROTTLED. 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

**createMissingTags** `Boolean`

Create the tags the macros add that the store doesn't have, in its default tag group, as the help desk import does. Needs support\_config\_write, which creating a tag needs.

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

**idempotencyKey** `String`

A key you choose, up to 100 characters, that makes a retry safe. For 24 hours, repeating the request with the same key returns the first result and writes nothing; that result is null if it has since been deleted or hidden. The same key with a different request throws IDEMPOTENCY\_KEY\_REUSED (422): repeat the first request exactly, or use a new key. While the first request is still running, a repeat throws CONFLICT (409): retry with the same key in a moment. A request that fails without writing frees its key, so a retry runs it again. Each mutation has its own keys.

**inputs** `[\[SupportMacroCreateInput!\]!](/docs/api-reference/v3/reference/support/support-macro-create-input)` *required*

1 to 100 macros, each in the shape supportMacroCreate takes, without inlineImages: the import copies the images a body links to. Each is checked as supportMacroCreate checks its input, and one that fails refuses the whole call, naming its index, before anything is written. Here a tag name the store lacks is created when createMissingTags is true, and fails the macro otherwise.

**fields**

**addsInternalNote** `String`

Plain-text internal note to add when applied.

**addsTagNames** `[String!]`

Names of the store's tags to add when applied, at most 100. A name that is no tag of the store is refused with BAD\_USER\_INPUT, as the app's tag picker offers only the store's tags. In supportMacrosImport such a name instead fails that macro with UNKNOWN\_TAGS, or is created when createMissingTags is true.

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

The reply body.

**fields**

**html** `String!` *required*

HTML as the app's reply editor writes it, at most 100,000 characters. It may use only what the composer's editor writes: the elements \<p>, \<div>, \<span>, \<br>, \<hr>, \<strong>, \<b>, \<em>, \<i>, \<u>, \<s>, \<sub>, \<sup>, \<small>, \<blockquote>, \<pre>, \<h1>, \<h2>, \<h3>, \<h4>, \<h5>, \<h6>, \<ul>, \<ol>, \<li>, \<a>, \<img>, \<table>, \<thead>, \<tbody>, \<tr>, \<td>, \<th>; the attributes class, style, title on any element; href, target, rel on \<a>; src, alt, width, height on \<img>; data-list on \<li>; data-variable on \<span>; colspan, rowspan on \<td>; colspan, rowspan on \<th>; URLs using http, https, mailto (http, https on \<img>), absolute only; the CSS properties background-color, border, border-bottom, border-collapse, border-left, border-right, border-top, color, font-family, font-size, font-style, font-weight, height, line-height, margin, margin-bottom, margin-left, margin-right, margin-top, max-height, max-width, padding, padding-bottom, padding-left, padding-right, padding-top, text-align, text-decoration, vertical-align, width, with no url() or other function that loads or runs anything; classes matching ^ql-\[\w-]+\$. Anything else is refused with BAD\_USER\_INPUT naming it; HTML comments, a doctype and empty attributes are removed. A variable is its bare name, as in text, or \<span data-variable="customer\_first\_name">customer\_first\_name\</span>; a name that isn't a variable stays as text.

**inlineImages** `[\[SupportMacroInlineImageInput!\]](/docs/api-reference/v3/reference/support/support-macro-inline-image-input)`

New images the body shows, at most 10, stored in the same write. Each needs an \<img> in html whose src is its src; one without, a src given twice, or a file that isn't an image is BAD\_USER\_INPUT. An image the macro already has stays when its \<img> keeps the url SupportMacro.bodyHtml or SupportMacro.inlineImages gave it.

**text** `String`

Plain text, 1 to 10,000 characters; it may be empty only when html shows an image. Omitted, it is html's text. A variable is its bare name, such as customer\_first\_name; the app fills it in from the ticket when the macro is used. See SupportMacro.body for the list.

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

Name shown in the macro picker, unique within the store, at most 255 characters. Leading and trailing spaces are dropped.

**setsEmailSubject** `String`

Email subject to set on the thread when applied.

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

Status to set when applied. Omit to leave the status unchanged.

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

How long applying the macro snoozes the ticket. Required with setsStatus SNOOZED, and only then, as in the app's editor.

## Returns

**supportMacrosImport** `[SupportMacrosImportResult!](/docs/api-reference/v3/reference/support/support-macros-import-result)` *required*

What an import did with each macro. It runs while the request waits, so the result is final.

**fields**

**counts** `[BulkCounts!](/docs/api-reference/v3/reference/common/bulk-counts)` *required*

How many items ended each way.

**fields**

**failed** `Int!` *required*

The items that couldn't be changed.

**ok** `Int!` *required*

The items the action changed.

**skipped** `Int!` *required*

The items it didn't apply to.

**total** `Int!` *required*

The items given.

**results** `[\[SupportMacroImportItem!\]!](/docs/api-reference/v3/reference/support/support-macro-import-item)` *required*

One per macro, in the order of inputs; at most 100.

**fields**

**code** `String`

Why the item was skipped or failed: NAME\_TAKEN (SKIPPED), the store or an earlier input already has a macro of that name, ignoring case; UNKNOWN\_TAGS (FAILED), a tag it adds isn't the store's and createMissingTags wasn't set; CREATE\_FAILED (FAILED), it couldn't be saved, and importing it again is safe. Null when it is OK.

**imageFailures** `[\[SupportMacroImportImageFailure!\]!](/docs/api-reference/v3/reference/support/support-macro-import-image-failure)` *required*

Images left as links: the macro is created, and its body links to each image's original host.

**fields**

**imageHost** `String!` *required*

The host the image is linked from.

**reason** `String!` *required*

Why it couldn't be copied.

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

The macro the import created. Null when it created none.

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

**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)

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

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

**message** `String`

The same, in words. Null when it is OK.

**status** `[BulkItemStatus!](/docs/api-reference/v3/reference/common/bulk-item-status)` *required*

What the action did with the item.

## 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. |
| `CONFLICT` | `409` | The change clashes with another record, such as a name already in use, and nothing was written. Or a request with the same idempotencyKey is still in progress or its outcome isn't known yet, and its write, such as an email to the customer, may already exist. | Change the clashing value, then send it again. When the message says a request with the same idempotencyKey is still in progress, wait a few seconds and send it again with the same key, which returns that request's result once it settles. Don't resend it with a new key or without one: it may write twice. |
| `IDEMPOTENCY_KEY_REUSED` | `422` | The idempotencyKey was already used for a different request. Nothing was written. | Send the new request with a new idempotencyKey, or resend the first request unchanged to get its result. |
| `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 {
  supportMacrosImport(createMissingTags: true, idempotencyKey: "...", inputs: { ... })
}
```


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