---
title: "Get a code rule's draft"
method: GET
path: "/v25-10-beta/agentic-logic/rules/{ruleId}/draft"
tags: ["Agentic Logic"]
---

# Get a code rule's draft

`GET /v25-10-beta/agentic-logic/rules/{ruleId}/draft`

## Request

- Base URL: `https://api.intelligems.io`
- URL: `https://api.intelligems.io/v25-10-beta/agentic-logic/rules/{ruleId}/draft`
- Auth: API key in header `intelligems-access-token`
- TypeScript: <https://skmtc.dev/intelligems/apis/intelligems-external-api-v25-10-beta/docs/v25-10-beta/agentic-logic/rules/:ruleId/draft/get.ts> (a function with typed inputs; its response is checked against the schema)

```http
GET /v25-10-beta/agentic-logic/rules/{ruleId}/draft
```

Gets the saved draft (source, user tests, dependencies) of a code rule. Secret
values never appear in a draft: rule source references organization secrets by
sentinel name only.

Use the `intelligems-access-token` header. The token selects the organization; do not send `orgId`. The organization must have Agentic Logic enabled.

**Rate Limit:** 50 requests per 30s window, refilling 25 tokens every 30s.

## Path parameters

- `ruleId` string, uuid, required

## Response `200`

OK

- object
  - `draft` object, nullable, required: The rule's single mutable draft (exactly one per rule, overwritten on save). Source and user tests live in S3; dependencies live on the row.
    - `ruleId` string, required: Owning rule id (uuid).
    - `source` string, nullable, required: Draft rule source code, or null when nothing has been saved yet.
    - `userTestSuite` string, nullable, required: User-authored test suite saved with the draft, or null when none exists.
    - `generatedTestSuite` string, nullable, required: The AI-generated test suite carried with the draft, or null when none has been generated yet. Reused across publishes and dry runs: the publish pipeline regenerates it only when the rule's inputs or contract surface have moved, and writes the result back here.
    - `dependencies` object[], required: Always empty for a draft saved under the current contract. Agentic Logic rules run with no third-party npm packages — rules read commerce state through the injected SDK — so the field only ever carries what an older draft stored.
      - `name` string, required: npm package name.
      - `version` string, required: Requested semver range.
    - `updatedByUserId` string, nullable, required: User who last saved the draft, or null.
    - `updatedByUser` object, nullable, required: Display summary for the user who last saved the draft, or null when the user is not known.
      - `name` string, required
    - `lastUpdateTs` number, required: Last save time, Unix epoch-ms.
    - `origin` 'chat' | 'manual', nullable, required: How the draft source came to be: 'chat' when applied from the workspace AI chat and untouched since, 'manual' when a person authored or last edited it, null for drafts saved before provenance was recorded.
    - `graph` object, nullable, required: The rule's graph artifact: a renderer-agnostic node/edge description of the rule's selection logic, versioned alongside the code. Carries NO geometry — layout is computed client-side. Produced deterministically for template rules and emitted by the authoring agent for custom-code rules, then verified by the graph_consistency gate.
      - `version` 1, required: Graph wire-format version. Currently 1.
      - `nodes` object[], required: Graph nodes, at most RULE_GRAPH_MAX_NODES. Large inputs must be aggregated into node meta, never expanded per item.
        - `id` string, required: Stable node id, unique within the graph. For kind 'branch', MUST equal the attempt() base label (a static string literal in the code). Runtime attempt instances are drill-in data on the node, never nodes of their own.
        - `kind` 'input' | 'branch' | 'generator' | 'filter' | 'sort' | 'limit' | 'exclusions' | 'output' | 'fallback-terminal', required: 'input' | 'branch' | 'generator' | 'filter' | 'sort' | 'limit' | 'exclusions' | 'output' | 'fallback-terminal'. Branch nodes mirror attempt() bases; pipeline kinds describe the flow inside or after a branch, while Exclusions is the platform-owned final filter.
        - `label` string, required: Short card title shown on the node.
        - `summary` string: One plain-language sentence describing what the node does.
        - `branchId` string: Owning branch node id, set ONLY on generator/filter/sort/limit nodes that run inside that branch; absent for shared pipeline nodes and always absent on 'input', 'branch', 'exclusions', 'output' and 'fallback-terminal' nodes — a branch never names itself.
        - `meta` object: Kind-specific structured details (e.g. generator source, aggregate itemCount + sampleItems, limit N). Aggregates belong here — never one node per item.
          - `itemCount` integer: Aggregate count of items the node covers (e.g. a generator drawing from a 1000-product list).
          - `sampleItems` string[]: Up to five representative item names for drill-in display; never the full list.
          - `condition` string: Plain-language matching clause for branch/filter nodes, phrased for a merchant ('in stock right now', 'cart contains a tagged cover-up'). The MATCHING card body.
          - `conditionSubject` 'cart' | 'delivery' | 'shipping' | 'customer' | 'page' | 'order' | 'time': Which request context a branch node's condition chip is about — 'cart' (the default when absent), 'delivery' (request.shipping.delivery: selected option, local pickup, cost, carrier, transit days), 'shipping' (gap, threshold, tiers, state), 'customer' (ordersCount, tags), 'page' (request.pageProduct), 'order' (request.order), 'time' (request.evaluatedAt). Drives the row-header sentence; absent on always-matching branches and on every non-branch node.
          - `sortKey` string: Plain-language sort criterion for sort nodes ('Best sellers'). The SORTED BY card body.
          - `limit` integer: Maximum number of items a limit node lets through. Rendered as 'UP TO n products'.
      - `edges` object[], required: Directed edges between node ids, at most RULE_GRAPH_MAX_EDGES.
        - `from` string, required: Source node id.
        - `to` string, required: Target node id.
        - `kind` 'flow' | 'fallback', required: 'flow' = data/control flow; 'fallback' = taken when the source produced nothing (branch miss or empty output). Fallback edges may only terminate at a branch or the fallback-terminal.
    - `contentFingerprint` string, nullable, required: SHA-256 identity of the code workspace (source, user tests, generated tests). Equal draft and active-version fingerprints mean the draft has nothing to apply. Null for template rules, and for rows not yet fingerprinted.

## Other responses

- `429`: Too Many Requests

---

[API](https://skmtc.dev/intelligems/apis/intelligems-external-api-v25-10-beta.md) - [All operations](https://skmtc.dev/intelligems/apis/intelligems-external-api-v25-10-beta/llms.txt) - [OpenAPI document](https://skmtc.dev/intelligems/apis/intelligems-external-api-v25-10-beta/revisions/7b769b2f90b1?raw)
