FeaturesApprovals and push

receipt

Read the record of how a command ended

Commands such as messages, controls (interrupt, pause, resume, close, terminate, recovery decisions, profile changes), push requests and decisions, and account and key management leave a receipt. A receipt holds who did it (actor), what they did (operation, target_ref), and how it ended (status, result, error). For an asynchronous command, the response's receipt_status is accepted, and you read the receipt again to see whether it finished. The scope is sessions:read.

statusMeaning
acceptedReceived and not finished yet
succeededFinished. The outcome is in result
failedRejected or failed. The reason is in error and result.refusal
unknownThe outcome cannot be known

Read

Call receipts.get (GET /v1/receipts/{id}) with the response's receipt_id. Read the receipts of the request made in Reject.

const pr = await werft.sessions.pushRequests.get(sessionId, second.id);
for (const id of [pr.request_receipt_id, pr.resolution_receipt_id]) {
  if (!id) continue;
  const receipt = await werft.receipts.get(id);
  const result = receipt.result as { action?: string | null } | null;
  console.log(receipt.operation, receipt.status, result?.action);
}
request_push succeeded null
resolve_push succeeded reject

For a refused request, error.details.receipt_id in the error body points to that receipt. This means a refusal is recorded too.

Approval and rejection receipts written by a server from before the rename have the operation decide_push and the value in result.decision. A repeated attempt's refusal is already_decided. Past receipts read as they were written.

Wait until it finishes

The receipt of an asynchronous control changes from accepted to succeeded or failed. Check for both so the loop stops even if another outcome arrives while waiting. The SDK's waitForReceipt waits until the value is no longer accepted.

import { waitForReceipt } from "@werft-ai/sdk";

const { revision } = await werft.sessions.get(sessionId);
const paused = await werft.sessions.pause(sessionId, {
  expected_revision: revision,
  reason: "lunch",
});
const receipt = await waitForReceipt(werft, paused.receipt_id);
const state = receipt.result as { resulting_admission_state?: string } | null;
console.log(receipt.operation, receipt.status, state?.resulting_admission_state);
pause succeeded paused

A receipt never contains secret values. A receipt in someone else's scope is 404.

Next steps

  • GitHub: open a PR from the pushed branch and comment on it

On this page