---
title: "Execute a Numscript"
method: POST
path: "/{ledger}/script"
tags: ["ledger.v1"]
deprecated: true
---

# Execute a Numscript

`POST /{ledger}/script`

> **Deprecated.**

This route is deprecated, and has been merged into `POST /{ledger}/transactions`.

## Path parameters

- `ledger` string, required

## Query parameters

- `preview` boolean

## Request body

- Script
  - `plain` string, required — The Numscript program to execute
  - `vars` object — Values bound to the script's declared variables, keyed by variable name
  - `reference` string — Reference to attach to the generated transaction
  - `metadata` Metadata, nullable — Arbitrary key/value pairs attached to the resource

## Response `200`

On success, it will return a 200 status code, and the resulting transaction under the `transaction` field.

On failure, it will also return a 200 status code, and the following fields:

  - `details`: contains a URL. When there is an error parsing Numscript, the result can be difficult to read—the provided URL will render the error in an easy-to-read format.
  - `errorCode` and `error_code` (deprecated): contains the string code of the error
  - `errorMessage` and `error_message` (deprecated): contains a human-readable indication of what went wrong, for example that an account had insufficient funds, or that there was an error in the provided Numscript.

- ScriptResponse
  - `errorCode` 'INTERNAL' | 'INSUFFICIENT_FUND' | 'VALIDATION' | 'CONFLICT' | 'NO_SCRIPT' | 'COMPILATION_FAILED' | 'METADATA_OVERRIDE' | 'NOT_FOUND' | 'TIMEOUT' — Machine-readable error code identifying the failure
  - `errorMessage` string — Human-readable description of the error
  - `details` string — Optional link carrying additional context about the error, such as a Numscript playground URL reproducing it
  - `transaction` Transaction — A transaction recorded in the ledger, carrying its postings and metadata
    - `timestamp` string, date-time, required — The transaction time: when the transaction is considered to have occurred. See [bi-temporality](https://docs.formance.com/modules/ledger/working-with/bi-temporality)
    - `postings` Posting[], required — The fund movements making up the transaction
      - `amount` integer, required — Amount to move, as an arbitrary-precision integer expressed in the asset's smallest unit
      - `asset` string, required — The asset being moved, optionally carrying a scale suffix such as USD/2
      - `destination` string, required — Address of the account credited by this posting
      - `source` string, required — Address of the account debited by this posting
    - `reference` string — Optional caller-supplied identifier, unique within the ledger, used to deduplicate transactions
    - `metadata` Metadata, nullable — Arbitrary key/value pairs attached to the resource
    - `txid` integer, required — Unique sequential identifier for this transaction within the ledger
    - `preCommitVolumes` AggregatedVolumes — Volumes aggregated per account and per asset
    - `postCommitVolumes` AggregatedVolumes — Volumes aggregated per account and per asset

---

[API](https://skmtc.dev/formancehq/apis/ledger-api.md) · [All operations](https://skmtc.dev/formancehq/apis/ledger-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/formancehq/ledger-api/revisions/fe945da1b75d/schema)
