---
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
  - `vars` object
  - `reference` string — Reference to attach to the generated transaction
  - `metadata` Metadata, nullable

## 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'
  - `errorMessage` string
  - `details` string
  - `transaction` Transaction
    - `timestamp` string, date-time, required
    - `postings` Posting[], required
      - `amount` integer, required
      - `asset` string, required
      - `destination` string, required
      - `source` string, required
    - `reference` string
    - `metadata` Metadata, nullable
    - `txid` integer, required
    - `preCommitVolumes` AggregatedVolumes
    - `postCommitVolumes` AggregatedVolumes

---

[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/a7dd5bee437d/schema)
