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

# Compile and save instruction

> Compile a Watch DSL script and persist it as an instruction for transaction evaluation.

<Note>Blnk Watch is currently in beta. [Send us a message](mailto:support@blnkfinance.com)</Note>

Use this endpoint to compile a Watch DSL script and save it as an instruction. Once saved, Watch evaluates incoming transactions against the compiled rule.

For DSL syntax and examples, see [Watch rule examples](/watch/rules/examples/basic-conditions).

### Body

<ParamField body="script" type="string" required>
  The Watch DSL script to compile. The rule name is extracted from the script and must be unique across instructions.
</ParamField>

<RequestExample>
  ```bash theme={"system"}
  curl -X POST http://localhost:8081/compile-and-save-instruction \
    -H "Content-Type: application/json" \
    -d '{
      "script": "rule HighValueTransaction {\n    description \"Review any transaction above $10,000\"\n    when amount > 10000\n    then review\n         score   0.5\n         reason  \"Amount exceeds threshold\"\n}"
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json 201 theme={"system"}
  {
    "id": 1,
    "name": "HighValueTransaction",
    "text": "rule HighValueTransaction {\n    description \"Review any transaction above $10,000\"\n    when amount > 10000\n    then review\n         score   0.5\n         reason  \"Amount exceeds threshold\"\n}",
    "description": "Review any transaction above $10,000",
    "dsl_json": "{\"name\":\"HighValueTransaction\",\"when\":[...],\"then\":{...}}",
    "created_at": "2026-03-16T10:00:00Z",
    "updated_at": "2026-03-16T10:00:00Z"
  }
  ```

  ```text 400 theme={"system"}
  Missing required field: script cannot be empty
  ```

  ```text 409 theme={"system"}
  Failed to save instruction: An instruction with name 'HighValueTransaction' already exists.
  ```

  ```text 500 theme={"system"}
  Failed to compile script: ...
  ```
</ResponseExample>

### Response fields

<ResponseField name="id" type="integer">
  Auto-generated instruction ID. Use this with [get instruction](/watch/reference/get-instruction) and [delete instruction](/watch/reference/delete-instruction).
</ResponseField>

<ResponseField name="name" type="string">
  Unique rule name extracted from the DSL script.
</ResponseField>

<ResponseField name="text" type="string">
  Original Watch DSL script text.
</ResponseField>

<ResponseField name="description" type="string">
  Rule description from the DSL script, if provided.
</ResponseField>

<ResponseField name="dsl_json" type="string">
  Compiled rule JSON used during transaction evaluation.
</ResponseField>

<ResponseField name="created_at" type="string">
  ISO 8601 timestamp of when the instruction was created.
</ResponseField>

<ResponseField name="updated_at" type="string">
  ISO 8601 timestamp of when the instruction was last updated.
</ResponseField>

***

## Need help?

We are very happy to help you make the most of Blnk, regardless of whether it is your first time or you are switching from another tool.

To ask questions or discuss issues, please [contact us](mailto:support@blnkfinance.com) or [join our Discord community](https://discord.gg/7WNv94zPpx).

**Connect your ledger to Blnk Cloud**

Sign up and manage your ledger with our back-office dashboard. You can invite teammates to collaborate and manage your ledger operations directly from the dashboard.
