Skip to content
中文

Sub-tickets and dependencies

Split large work into sub-tickets and use dependencies to say what comes first. Sub-tickets are a hierarchy (a ticket has at most one parent); a dependency is a block (A is blocked by B means A should not start until B is done). The two do not affect each other.

Prerequisites as in the quickstart: PRAXIS_API_KEY, curl, jq, and the BASE and TAG variables.

1. Create a parent and children

Pass parent at creation to put the ticket under a parent.

终端窗口
export BASE="${PRAXIS_API_BASE:-https://api.deepraxis.com}"
export TAG=$(date +%s)
post() { curl --fail-with-body -sS -X POST "$BASE$1" -H "Authorization: Bearer $PRAXIS_API_KEY" -H "Content-Type: application/json" -d "$2"; }
EPIC=$(post /ticket/v1/tickets "$(jq -n --arg t "docs-example-epic-$TAG" '{title: $t, type: "feature"}')" | jq -er .number)
CHILD_A=$(post /ticket/v1/tickets "$(jq -n --arg t "docs-example-child-a-$TAG" --argjson p "$EPIC" '{title: $t, type: "task", parent: $p}')" | jq -er .number)
CHILD_B=$(post /ticket/v1/tickets "$(jq -n --arg t "docs-example-child-b-$TAG" '{title: $t, type: "task"}')" | jq -er .number)

Expected: CHILD_A has parent equal to EPIC; CHILD_B has parent null.

2. Attach an existing ticket

终端窗口
post "/ticket/v1/tickets/$EPIC/sub_tickets" "{\"child\": $CHILD_B}" | jq '.sub_tickets_summary'
curl --fail-with-body -sS "$BASE/ticket/v1/tickets/$EPIC/sub_tickets" \
-H "Authorization: Bearer $PRAXIS_API_KEY" | jq '[.tickets[] | {number, parent}]'

Expected: HTTP 200 returning the parent, with sub_tickets_summary {"total": 2, "completed": 0, "percent_completed": 0}; both listed children have parent equal to EPIC.

A ticket has only one parent. If the child already has another parent, add "replace_parent": true to the body to move it; without it you get 422 SUB_TICKET_LIMIT. A ticket cannot go under itself or one of its descendants (400 INVALID_PARAMS). Detach with DELETE /ticket/v1/tickets/{number}/sub_tickets/{child}.

3. Declare a dependency

CHILD_B is blocked by CHILD_A:

终端窗口
post "/ticket/v1/tickets/$CHILD_B/dependencies/blocked_by" "{\"blocked_by\": $CHILD_A}" | jq '.ticket_dependencies_summary'
curl --fail-with-body -sS "$BASE/ticket/v1/tickets/$CHILD_B/dependencies/blocked_by" \
-H "Authorization: Bearer $PRAXIS_API_KEY" | jq '[.tickets[].number]'
curl --fail-with-body -sS "$BASE/ticket/v1/tickets/$CHILD_A/dependencies/blocking" \
-H "Authorization: Bearer $PRAXIS_API_KEY" | jq '[.tickets[].number]'

Expected: blocked_by and total_blocked_by are both 1; the two lists are [CHILD_A] and [CHILD_B]. blocked_by counts only blockers that are still open; total_blocked_by includes closed ones.

Dependencies cannot form a cycle: making CHILD_A blocked by CHILD_B returns 422 DEPENDENCY_CYCLE.

4. Read progress

Close CHILD_A, then read the parent:

终端窗口
curl --fail-with-body -sS -X PATCH "$BASE/ticket/v1/tickets/$CHILD_A" \
-H "Authorization: Bearer $PRAXIS_API_KEY" -H "Content-Type: application/json" \
-d '{"state": "closed", "state_reason": "completed"}' > /dev/null
curl --fail-with-body -sS "$BASE/ticket/v1/tickets/$EPIC" \
-H "Authorization: Bearer $PRAXIS_API_KEY" | jq '.sub_tickets_summary'

Expected: {"total": 2, "completed": 1, "percent_completed": 50}.

The same with the SDK

import { Praxis } from '@deepraxis/sdk';
const praxis = new Praxis({
apiKey: process.env.PRAXIS_API_KEY!,
baseUrl: process.env.PRAXIS_API_BASE ?? 'https://api.deepraxis.com',
});
const tag = Date.now().toString(36);
const epic = await praxis.ticket.tickets.create({ body: { title: `docs-example-epic-${tag}`, type: 'feature' } });
const a = await praxis.ticket.tickets.create({ body: { title: `docs-example-child-a-${tag}`, type: 'task', parent: epic.number } });
const b = await praxis.ticket.tickets.create({ body: { title: `docs-example-child-b-${tag}`, type: 'task' } });
await praxis.ticket.tickets.subTickets.create({ path: { number: epic.number }, body: { child: b.number } });
const blocked = await praxis.ticket.tickets.dependencies.blockedBy.create({
path: { number: b.number },
body: { blocked_by: a.number },
});
console.log(blocked.ticket_dependencies_summary);
await praxis.ticket.tickets.update({ path: { number: a.number }, body: { state: 'closed', state_reason: 'completed' } });
const summary = (await praxis.ticket.tickets.retrieve({ path: { number: epic.number } })).sub_tickets_summary;
console.log(summary);

Clean up

终端窗口
curl --fail-with-body -sS -X DELETE "$BASE/ticket/v1/tickets/$CHILD_B/dependencies/blocked_by/$CHILD_A" -H "Authorization: Bearer $PRAXIS_API_KEY" > /dev/null
for n in $CHILD_B $EPIC; do
curl --fail-with-body -sS -X PATCH "$BASE/ticket/v1/tickets/$n" -H "Authorization: Bearer $PRAXIS_API_KEY" \
-H "Content-Type: application/json" -d '{"state": "closed", "state_reason": "not_planned"}' > /dev/null
done

Related tickets and duplicates

POST /ticket/v1/tickets/{number}/relations adds a “related” link with body {"relates_to": <number>}; it has no direction and no blocking meaning. To mark a ticket as a duplicate, close it and name the original: {"state": "closed", "state_reason": "duplicate", "duplicate_of": <number>}; without duplicate_of you get 400.

Limits and errors →