---
metadata:
  - name: generator
    content: Diplodoc Platform v5.47.3
alternate:
  - https://yandex.com.tr/support/tracker/en/api-ref/post-macros.md
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.com.tr/support/tracker/en/llms.txt

# Creating a macro

Use this request to create a [macro](https://yandex.com.tr/support/tracker/en/manager/create-macroses.md).

<div class="request_example method_post yfm-clipboard">
    <p>POST</p>
    <pre><code>https://api.tracker.yandex.net/v3/queues/&lt;queue_ID>/macros</code></pre>
    <button class="yfm-clipboard-button"><svg width="16" height="16" viewBox="0 0 24 24" class="yfm-clipboard-icon" data-animation="15">
    <path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path>
    <path stroke="currentColor" fill="transparent" strokewidth="1.5" d="M9.5 13l3 3l5 -5" visibility="hidden">
        <animate id="visibileAnimation-15" attributeName="visibility" from="hidden" to="visible" dur="0.2s" fill="freeze" begin=""></animate>
        <animate id="hideAnimation-15" attributeName="visibility" from="visible" to="hidden" dur="1s" begin="visibileAnimation-15.end+1" fill="freeze"></animate>
    </path>
</svg>
</button>
</div>

<!-- source: en/_assets/style/methods.md -->

<!-- endsource: en/_assets/style/methods.md -->

## Query format {#query}

Before making a request, [get permission to access the API](https://yandex.com.tr/support/tracker/en/api-ref/access.md).

To create a macro, use an HTTP `POST` request:

```json
POST /v3/queues/<queue_ID>/macros
Host: api.tracker.yandex.net
Authorization: OAuth <OAuth_token>
X-Org-ID or X-Cloud-Org-ID: <organization_ID>

{
  "name": "<macro_name>",
  "body": "<comment_text>\n{{currentDateTime}}\n{{issue.author}}",
  "issueUpdate": {
       "description": "New issue",
       "tags": { "add": "New tag" },
       "resolution": null
   }
}
```

<!-- source: en/_includes/api/headings.md -->
{% cut "Headers" %}

* `Host`: address of the node that provides the API.

* <!-- source: en/_includes/api/authorization.md -->
  `Authorization`: Authorization token about these formats:

    - `OAuth <OAuth_token>`: For authorization using the OAuth 2.0 protocol. [Learn more](https://yandex.com.tr/support/tracker/en/api-ref/access.md#about_OAuth)

    - `Bearer <IAM_token>`: For authorization using an IAM token, if a Yandex Cloud Organization organization is linked to Tracker. [Learn more](https://yandex.com.tr/support/tracker/en/api-ref/access.md#iam-token)
  <!-- endsource: en/_includes/api/authorization.md -->


* <!-- source: en/_includes/api/org-id.md -->
  `X-Org-ID` or `X-Cloud-Org-ID`: Organization ID.

  - Use the `X-Org-ID` header if a Tracker organization is linked to Yandex 360 for Business.

  - Use the `X-Cloud-Org-ID` header if a Tracker organization is linked to Yandex Cloud Organization.

  To get the organization ID, go to **Administration** → [**Organizations**](https://tracker.yandex.com/admin/orgs) and copy the value from the **ID** field. {#find-id}
  <!-- endsource: en/_includes/api/org-id.md -->


{% endcut %}
<!-- endsource: en/_includes/api/headings.md -->

{% cut "Resource" %}

| Parameter | Description | Data type |
-------- | -------- | ----------
| \<queue_ID> | Queue ID or key. The queue key is case-sensitive. | String |

{% endcut %}

{% cut "Request body parameters" %}

**Required parameters**

| Parameter | Value | Data type |
----- | ----- | -----
| name | Macro name. | String |

**Additional parameters**

| Parameter | Description | Data type |
----- | ----- | -----
| body | Message to be created when executing the macro. Use the [formatting rules](common-format.md#text-format) for the message text.<br/>To delete a message, use `"body": {"unset":1}` | String |
| issueUpdate | Object with a list of issue fields that you want to change. [Full list of issue fields](https://tracker.yandex.com/admin/fields)<br><br>To clear the field, specify the `null` value.<br>You can also use the `set`, `add`, and `remove` operators (see [Editing parameters](common-format.md#edit-fields)) | Object |

{% endcut %}

## Response format {#answer}

{% list tabs %}

- Request executed successfully

    <!-- source: en/_includes/api/answer-201.md -->
    If the request is successful, the API returns a response with code `201 Created`.
    <!-- endsource: en/_includes/api/answer-201.md -->

    The response body contains a JSON object with the parameters of the created macro.

    ```json
      {
        "self": "https://api.tracker.yandex.net/v3/queues/TEST/macros/3",
        "id": 3,
        "queue": {
          "self": "https://api.tracker.yandex.net/v3/queues/TEST",
          "id": "1",
          "key": "TEST",
          "display": "Test queue"
           },
        "name": "Test macro",
        "body": "Test comment\n{{currentDateTime}}\n{{issue.author}}",
        "issueUpdate": [
          {
            "field": {
               "self": "https://api.tracker.yandex.net/v3/fields/tags",
               "id": "tags",
               "display": "Tags"
              },
            "update": {
                "add": ["tag 1", "tag 2"]
            }
          },
           ...
        ]
      }
    ```

    {% cut "Response parameters" %}

    | Parameter | Description | Data type |
    ----- | ----- | -----
    | self | Address of the API resource with macro parameters. | String |
    | id | Macro ID. | Number |
    | [queue](#queue) | Object with information about the queue whose issues that the macro is applied to. | Map item |
    | name | Macro name. | String |
    | body | Message to be created when executing the macro. | String |
    | [issueUpdate](#issueUpdate) | Array with information about the issue fields that the macro will trigger changes to. | Array of objects |

    `queue` **object fields** {#queue}

    <!-- source: en/_includes/api/queue.md -->
    | Parameter | Description | Data type |
    ----- | ----- | -----
    | self | Address of the API resource with information about the queue. | String |
    | id | Queue ID. | String |
    | key | Queue key. | String |
    | display | Queue name displayed. | String |
    <!-- endsource: en/_includes/api/queue.md -->

    <!-- source: en/_includes/api/answer-macro-issue-update.md -->
    `issueUpdate` **array objects** {#issueUpdate}

    | Parameter | Description | Data type |
    -------- | -------- | ----------
    | [field](#field) | Object with information about the issue field. | Map item |
    | update | Object with information about the issue field update. | Object |

    `field` **object fields** {#field}

    | Parameter | Description | Data type |
    -------- | -------- | ----------
    | self | Address of the API resource with information about the issue field. | String |
    | id | Issue field ID. | String |
    | display | Issue field name displayed. | String |
    <!-- endsource: en/_includes/api/answer-macro-issue-update.md -->

    {% endcut %}

- Request failed

    If the request is processed incorrectly, the API returns a response with an error code:

    <!-- source: en/_includes/api/answer-error-400.md -->
    400
    :   One or more request parameters have an invalid value.
    <!-- endsource: en/_includes/api/answer-error-400.md -->

    <!-- source: en/_includes/api/answer-error-403.md -->
    403
    :   You are not authorized to perform this action. You can check what rights you have in the Tracker interface. The same rights are required to perform an action via the API and interface.
    <!-- endsource: en/_includes/api/answer-error-403.md -->

    <!-- source: en/_includes/api/answer-error-404.md -->
    404
    :   The requested object was not found. You may have specified an invalid object ID or key.
    <!-- endsource: en/_includes/api/answer-error-404.md -->

    <!-- source: en/_includes/api/answer-error-409.md -->
    409
    :   There was a conflict when editing the object. The error may be due to an invalid update version.
    <!-- endsource: en/_includes/api/answer-error-409.md -->

    <!-- source: en/_includes/api/answer-error-500.md -->
    500
    :   Internal service error. Try again later.
    <!-- endsource: en/_includes/api/answer-error-500.md -->

    <!-- source: en/_includes/api/answer-error-503.md -->
    503
    :   The API service is temporarily unavailable.
    <!-- endsource: en/_includes/api/answer-error-503.md -->

{% endlist %}
