ledger.v2

Create a new transaction to a ledger

post/v2/{ledger}/transactions

Path parameters

ledgerstring required
Example:ledger001

Name of the ledger.

Query parameters

dryRunboolean
Example:true

Set the dryRun mode. dry run mode doesn't add the logs to the database or publish a message to the message broker.

forceboolean
Example:true

Disable balance checks when passing postings

schemaVersionstring
Example:v1.0.0

Schema version to use for validation

Headers

Idempotency-Keystring

Use an idempotency key

Request body

timestampstring date-time

The transaction time to record, letting you backdate or postdate the transaction. Defaults to current machine time if omitted. See bi-temporality

runtime'experimental-interpreter' | 'machine'

The numscript runtime used to execute the script. Uses "machine" by default, unless the "--experimental-numscript-interpreter" feature flag is passed.

referencestring

Optional caller-supplied identifier, unique within the ledger, used to deduplicate transactions

metadataV2Metadata required

Arbitrary key/value pairs attached to the resource. Metadata is bi-temporal, so a point-in-time query returns the metadata as it stood at that time

accountMetadataobject

Metadata to set on the accounts involved in the transaction, keyed by account address

forceboolean

When true, lets source accounts overdraft without bound, bypassing the balance check. Applies to the postings form only

Example request

{
  "postings": [
    {
      "amount": 100,
      "asset": "COIN",
      "destination": "users:002",
      "source": "users:001"
    }
  ],
  "script": {
    "template": "CUSTOMER_DEPOSIT",
    "plain": "vars {\naccount $user\n}\nsend [COIN 10] (\n\tsource = @world\n\tdestination = $user\n)\n",
    "vars": {
      "user": "users:042"
    }
  },
  "reference": "ref:001",
  "metadata": {
    "admin": "true"
  }
}

Response

OK

Example response

{
  "data": {
    "postings": [
      {
        "amount": 100,
        "asset": "COIN",
        "destination": "users:002",
        "source": "users:001"
      }
    ],
    "reference": "ref:001",
    "metadata": {
      "admin": "true"
    },
    "preCommitVolumes": {
      "orders:1": {
        "USD": {
          "input": 100,
          "output": 10,
          "balance": 90
        }
      },
      "orders:2": {
        "USD": {
          "input": 100,
          "output": 10,
          "balance": 90
        }
      }
    },
    "postCommitVolumes": {
      "orders:1": {
        "USD": {
          "input": 100,
          "output": 10,
          "balance": 90
        }
      },
      "orders:2": {
        "USD": {
          "input": 100,
          "output": 10,
          "balance": 90
        }
      }
    },
    "preCommitEffectiveVolumes": {
      "orders:1": {
        "USD": {
          "input": 100,
          "output": 10,
          "balance": 90
        }
      },
      "orders:2": {
        "USD": {
          "input": 100,
          "output": 10,
          "balance": 90
        }
      }
    },
    "postCommitEffectiveVolumes": {
      "orders:1": {
        "USD": {
          "input": 100,
          "output": 10,
          "balance": 90
        }
      },
      "orders:2": {
        "USD": {
          "input": 100,
          "output": 10,
          "balance": 90
        }
      }
    }
  }
}

Changes