---
title: "Get template usage"
method: GET
path: "/v3/{ledgerName}/numscripts/{name}/usage"
tags: ["Numscript Library"]
---

# Get template usage

`GET /v3/{ledgerName}/numscripts/{name}/usage`

## Request

- Base URL: `http://localhost:9000`
- URL: `http://localhost:9000/v3/{ledgerName}/numscripts/{name}/usage`
- Auth: one of:
  - HTTP bearer
  - none

Returns the invocation counter and last-used timestamp for a Numscript template. Values are
materialised asynchronously by the `usagebuilder` subsystem from the FSM audit chain and may
lag the live FSM while the worker drains pending batches. A never-invoked template returns a
zero-valued response (not 404), so clients handle "never used" uniformly.

## Path parameters

- `ledgerName` string, required
- `name` string, required

## Headers

- `X-Consistency` 'linearizable' | 'stale'

## Response `200`

Template usage retrieved successfully

- GetTemplateUsageResponse
  - `data` TemplateUsage, required
    - `count` integer, required: Number of times the template has been invoked. `0` means never invoked (or the usagebuilder has not yet caught up to any invocation on this replica).
    - `lastUsed` string, date-time, nullable: Timestamp of the most recent invocation (ISO 8601). Absent when `count` is 0.

## Other responses

- `400`: Bad request
- `401`: Authentication required (missing or invalid JWT token)
- `403`: Insufficient permissions (missing required scope)
- `404`: Ledger not found (`LEDGER_NOT_FOUND`)
- `405`: Method not allowed
- `500`: Internal server error
- `503`: Service unavailable — the server cannot serve the request right now but an immediate retry can succeed. The `errorCode` field discriminates the cause: `NO_LEADER` (no elected Raft leader), `CACHE_HORIZON_EXCEEDED` (admission snapshot too old, retry against a fresh one), `UNAVAILABLE` (an internal forwarded stream was torn down mid-transfer), or the reason of any domain error of the unavailable kind (e.g. `INDEX_BUILDING`).

## Changes

- **2026-11-03** `f5e817eca038`: 1 info
  - api operation id `getNumscriptUsage` removed and replaced with `v3GetNumscriptUsage`
- **2026-10-08** `3da23d327316`: 3 info
  - the endpoint scheme security `BearerAuth` was added to the API
  - added the non-success response with the status `401`
  - added the non-success response with the status `403`
- **2026-10-08** `b3ee1959d86a`: 1 info
  - added the new optional `header` request parameter `X-Consistency`
- **2026-09-30** `b747efd5cd77`: 1 info
  - endpoint added
- **2026-09-29** `6ff73ac9a6bd`: 1 breaking
  - api path removed without deprecation

[Operation history](https://skmtc.dev/formancehq/apis/ledger-api/changes/v3/:ledgerName/numscripts/:name/usage/get.md)

---

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