---
title: "Apply a rule template to a rule scope"
method: POST
path: "/api/rule_templates/{id}/apply/"
tags: ["Rule templates"]
---

# Apply a rule template to a rule scope

`POST /api/rule_templates/{id}/apply/`

## Request

- Base URL: `https://eyalsec.com`
- URL: `https://eyalsec.com/api/rule_templates/{id}/apply/`
- Auth: one of:
  - API key in header `X-API-Key`
  - API key in cookie `__Host-es2session`

Copies the template's items into a rule scope as ordinary rules: enabled, with the polarity the mode implies. machine is a machine public_id, or empty for the caller's global rules. An item is skipped when an identical rule (same source, event_pattern, mode and sanitize_scope) is already in the scope, when it repeats an earlier item of the same template, and when it is a Raise rule (mode 3) and the caller lacks the raise grant or the item carries a sanitize_scope other than any. Every skip is counted in the response. 404 if the template is not visible to the caller. Cookie callers must pass CSRF.

This is a **write**: a read-only API key is refused with 403.

## Path parameters

- `id` integer, required

## Request body

- object
  - `machine` string: Machine public_id, or empty for global rules.

## Response `200`

OK.

- object

## Other responses

- `401`: The API key is missing, wrong, revoked or expired.
- `429`: A rate limit was hit, or the account is locked after wrong passwords. Retry-After gives the seconds to wait.
- `default`: An error. Check the status first; the body carries a short message, as JSON ({"error": "..."}) on most endpoints and as plain text on some. 400: malformed JSON, an invalid regex, an unreadable cursor or date, or an unknown value. 401: the API key is missing, wrong, revoked or expired. 403: a failed CSRF check, a read-only key trying to write, a product or feature not enabled on your account, a wrong password, or a write on an account limited to reading. 404: not found, including things that belong to another account. 409: conflict with the current state. 422: a field is missing or invalid. 429: a rate limit was hit, or the account is locked after wrong passwords. 500: something failed on our side.

---

[API](https://skmtc.dev/eyalsec/apis/eyalsec-api.md) · [All operations](https://skmtc.dev/eyalsec/apis/eyalsec-api/llms.txt) · [OpenAPI document](https://skmtc.dev/eyalsec/apis/eyalsec-api/revisions/dc7520689cf1?raw)
