curl --request POST \
--url https://api.sandbox.nxos.io/v1/ledger/{ledger_key}/transaction \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"asset_moves": [
{
"source_account": {
"ref": "<string>",
"id": "<string>"
},
"destination_account": {
"ref": "<string>",
"id": "<string>"
},
"asset_code": "<string>",
"amount": "<string>",
"asset_move_ref": "<string>",
"type": "<string>",
"categories": [
"<string>"
],
"metadata": {}
}
],
"transaction_ref": "<string>"
}
'import requests
url = "https://api.sandbox.nxos.io/v1/ledger/{ledger_key}/transaction"
payload = {
"asset_moves": [
{
"source_account": {
"ref": "<string>",
"id": "<string>"
},
"destination_account": {
"ref": "<string>",
"id": "<string>"
},
"asset_code": "<string>",
"amount": "<string>",
"asset_move_ref": "<string>",
"type": "<string>",
"categories": ["<string>"],
"metadata": {}
}
],
"transaction_ref": "<string>"
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({
asset_moves: [
{
source_account: {ref: '<string>', id: '<string>'},
destination_account: {ref: '<string>', id: '<string>'},
asset_code: '<string>',
amount: '<string>',
asset_move_ref: '<string>',
type: '<string>',
categories: ['<string>'],
metadata: {}
}
],
transaction_ref: '<string>'
})
};
fetch('https://api.sandbox.nxos.io/v1/ledger/{ledger_key}/transaction', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sandbox.nxos.io/v1/ledger/{ledger_key}/transaction",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'asset_moves' => [
[
'source_account' => [
'ref' => '<string>',
'id' => '<string>'
],
'destination_account' => [
'ref' => '<string>',
'id' => '<string>'
],
'asset_code' => '<string>',
'amount' => '<string>',
'asset_move_ref' => '<string>',
'type' => '<string>',
'categories' => [
'<string>'
],
'metadata' => [
]
]
],
'transaction_ref' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.sandbox.nxos.io/v1/ledger/{ledger_key}/transaction"
payload := strings.NewReader("{\n \"asset_moves\": [\n {\n \"source_account\": {\n \"ref\": \"<string>\",\n \"id\": \"<string>\"\n },\n \"destination_account\": {\n \"ref\": \"<string>\",\n \"id\": \"<string>\"\n },\n \"asset_code\": \"<string>\",\n \"amount\": \"<string>\",\n \"asset_move_ref\": \"<string>\",\n \"type\": \"<string>\",\n \"categories\": [\n \"<string>\"\n ],\n \"metadata\": {}\n }\n ],\n \"transaction_ref\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.sandbox.nxos.io/v1/ledger/{ledger_key}/transaction")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"asset_moves\": [\n {\n \"source_account\": {\n \"ref\": \"<string>\",\n \"id\": \"<string>\"\n },\n \"destination_account\": {\n \"ref\": \"<string>\",\n \"id\": \"<string>\"\n },\n \"asset_code\": \"<string>\",\n \"amount\": \"<string>\",\n \"asset_move_ref\": \"<string>\",\n \"type\": \"<string>\",\n \"categories\": [\n \"<string>\"\n ],\n \"metadata\": {}\n }\n ],\n \"transaction_ref\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sandbox.nxos.io/v1/ledger/{ledger_key}/transaction")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"asset_moves\": [\n {\n \"source_account\": {\n \"ref\": \"<string>\",\n \"id\": \"<string>\"\n },\n \"destination_account\": {\n \"ref\": \"<string>\",\n \"id\": \"<string>\"\n },\n \"asset_code\": \"<string>\",\n \"amount\": \"<string>\",\n \"asset_move_ref\": \"<string>\",\n \"type\": \"<string>\",\n \"categories\": [\n \"<string>\"\n ],\n \"metadata\": {}\n }\n ],\n \"transaction_ref\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"transaction_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"asset_moves": [
{
"asset_move_ref": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"source_account": {
"ref": "<string>",
"id": "<string>"
},
"destination_account": {
"ref": "<string>",
"id": "<string>"
},
"asset_code": "<string>",
"amount": "<string>",
"type": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"decline_type": "<string>",
"categories": [
"<string>"
],
"metadata": {}
}
],
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"transaction_ref": "<string>"
}Create Transaction
The Record Transaction API endpoint is the core method for creating and executing financial transactions in the Nxos system. It allows you to create complex, multi-asset transactions consisting of one or more asset moves, all processed atomically. This endpoint supports various transaction types, from simple transfers to intricate multi-hop exchanges, and includes features like idempotency through transaction references and metadata support for both transactions and individual asset moves. Importantly, the asset moves within a transaction are executed sequentially in the order they’re included, allowing for self-funding chains where later moves can depend on the balance changes from earlier moves.
curl --request POST \
--url https://api.sandbox.nxos.io/v1/ledger/{ledger_key}/transaction \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"asset_moves": [
{
"source_account": {
"ref": "<string>",
"id": "<string>"
},
"destination_account": {
"ref": "<string>",
"id": "<string>"
},
"asset_code": "<string>",
"amount": "<string>",
"asset_move_ref": "<string>",
"type": "<string>",
"categories": [
"<string>"
],
"metadata": {}
}
],
"transaction_ref": "<string>"
}
'import requests
url = "https://api.sandbox.nxos.io/v1/ledger/{ledger_key}/transaction"
payload = {
"asset_moves": [
{
"source_account": {
"ref": "<string>",
"id": "<string>"
},
"destination_account": {
"ref": "<string>",
"id": "<string>"
},
"asset_code": "<string>",
"amount": "<string>",
"asset_move_ref": "<string>",
"type": "<string>",
"categories": ["<string>"],
"metadata": {}
}
],
"transaction_ref": "<string>"
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({
asset_moves: [
{
source_account: {ref: '<string>', id: '<string>'},
destination_account: {ref: '<string>', id: '<string>'},
asset_code: '<string>',
amount: '<string>',
asset_move_ref: '<string>',
type: '<string>',
categories: ['<string>'],
metadata: {}
}
],
transaction_ref: '<string>'
})
};
fetch('https://api.sandbox.nxos.io/v1/ledger/{ledger_key}/transaction', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sandbox.nxos.io/v1/ledger/{ledger_key}/transaction",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'asset_moves' => [
[
'source_account' => [
'ref' => '<string>',
'id' => '<string>'
],
'destination_account' => [
'ref' => '<string>',
'id' => '<string>'
],
'asset_code' => '<string>',
'amount' => '<string>',
'asset_move_ref' => '<string>',
'type' => '<string>',
'categories' => [
'<string>'
],
'metadata' => [
]
]
],
'transaction_ref' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.sandbox.nxos.io/v1/ledger/{ledger_key}/transaction"
payload := strings.NewReader("{\n \"asset_moves\": [\n {\n \"source_account\": {\n \"ref\": \"<string>\",\n \"id\": \"<string>\"\n },\n \"destination_account\": {\n \"ref\": \"<string>\",\n \"id\": \"<string>\"\n },\n \"asset_code\": \"<string>\",\n \"amount\": \"<string>\",\n \"asset_move_ref\": \"<string>\",\n \"type\": \"<string>\",\n \"categories\": [\n \"<string>\"\n ],\n \"metadata\": {}\n }\n ],\n \"transaction_ref\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.sandbox.nxos.io/v1/ledger/{ledger_key}/transaction")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"asset_moves\": [\n {\n \"source_account\": {\n \"ref\": \"<string>\",\n \"id\": \"<string>\"\n },\n \"destination_account\": {\n \"ref\": \"<string>\",\n \"id\": \"<string>\"\n },\n \"asset_code\": \"<string>\",\n \"amount\": \"<string>\",\n \"asset_move_ref\": \"<string>\",\n \"type\": \"<string>\",\n \"categories\": [\n \"<string>\"\n ],\n \"metadata\": {}\n }\n ],\n \"transaction_ref\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sandbox.nxos.io/v1/ledger/{ledger_key}/transaction")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"asset_moves\": [\n {\n \"source_account\": {\n \"ref\": \"<string>\",\n \"id\": \"<string>\"\n },\n \"destination_account\": {\n \"ref\": \"<string>\",\n \"id\": \"<string>\"\n },\n \"asset_code\": \"<string>\",\n \"amount\": \"<string>\",\n \"asset_move_ref\": \"<string>\",\n \"type\": \"<string>\",\n \"categories\": [\n \"<string>\"\n ],\n \"metadata\": {}\n }\n ],\n \"transaction_ref\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"transaction_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"asset_moves": [
{
"asset_move_ref": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"source_account": {
"ref": "<string>",
"id": "<string>"
},
"destination_account": {
"ref": "<string>",
"id": "<string>"
},
"asset_code": "<string>",
"amount": "<string>",
"type": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"decline_type": "<string>",
"categories": [
"<string>"
],
"metadata": {}
}
],
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"transaction_ref": "<string>"
}Headers
The Basic Authentication header. Format: "Basic {base64(orgID:apiKey)}"
Path Parameters
The key of the ledger. Examples:
- "123e4567-e89b-12d3-a456-426614174000"
- "id:123e4567-e89b-12d3-a456-426614174000"
- "ref:ledger:customer_a"
Body
The asset moves for the transaction
Show child attributes
Show child attributes
The reference of the transaction - needs to be unique for the transaction, can be anything from a UUID to a reference of your choice. This is the reference you will use to interact with the transaction. This reference also guarantees idempotency, so if you send the same transaction reference twice, the second request will be ignored.
1Response
The request has succeeded.
The unique internally assigned identifier of the transaction
The asset moves for the transaction
Show child attributes
Show child attributes
The created at timestamp
The updated at timestamp
The externally defined reference of the transaction