Syncs a transaction, optionally with allocations
import Fragment from '@fragment-dev/ts-node';
const client = new Fragment({
clientId: process.env['FRAGMENT_CLIENT_ID'],
clientSecret: process.env['FRAGMENT_CLIENT_SECRET'],
});
const response = await client.transactions.create(
{
account: {
external_id: 'acct_external_123',
id: 'ext_account_YWJjMTIz'
},
allocations: [],
amount: '-1000',
currency: 'USD',
external_id: 'bank_txn_123',
posted: '2026-02-12T00:00:00.000Z'
}
);{
"data": {
"id": "txn_dHhuX2ZyYWdfMDAx",
"external_id": "bank_txn_123",
"account": {
"id": "ext_account_YWJjMTIz",
"external_id": "acct_external_123"
},
"posted": "2026-02-12T00:00:00.000Z",
"currency": "USD",
"amount": "-1000",
"allocations": [
{
"invoice_id": "inv_abc123",
"amount": "1000",
"type": "invoice_payin",
"user": {
"id": "user_abc123",
"external_id": "user-ext-001"
}
}
],
"tags": [
{
"key": "region",
"value": "us-east"
}
],
"unallocated_amount": "-1000",
"created": "2026-02-12T00:00:00.000Z",
"modified": "2026-02-12T01:00:00.000Z",
"version": 1
}
}Updates allocations on an existing transaction
import Fragment from '@fragment-dev/ts-node';
const client = new Fragment({
clientId: process.env['FRAGMENT_CLIENT_ID'],
clientSecret: process.env['FRAGMENT_CLIENT_SECRET'],
});
const response = await client.transactions.createAllocations(
'txn_abc123',
{
allocation_updates: [
{
amount: '1000',
invoice_id: 'inv_abc123',
op: 'add',
type: 'invoice_payin',
user: { id: 'user_abc123' }
}
],
version: 1
}
);{
"data": {
"id": "txn_dHhuX2ZyYWdfMDAx",
"external_id": "bank_txn_123",
"account": {
"id": "ext_account_YWJjMTIz",
"external_id": "acct_external_123"
},
"posted": "2026-02-12T00:00:00.000Z",
"currency": "USD",
"amount": "-1000",
"allocations": [
{
"invoice_id": "inv_abc123",
"amount": "1000",
"type": "invoice_payin",
"user": {
"id": "user_abc123",
"external_id": "user-ext-001"
}
}
],
"tags": [
{
"key": "region",
"value": "us-east"
}
],
"unallocated_amount": "-1000",
"created": "2026-02-12T00:00:00.000Z",
"modified": "2026-02-12T01:00:00.000Z",
"version": 1
}
}Lists all transactions for the workspace
import Fragment from '@fragment-dev/ts-node';
const client = new Fragment({
clientId: process.env['FRAGMENT_CLIENT_ID'],
clientSecret: process.env['FRAGMENT_CLIENT_SECRET'],
});
const response = await client.transactions.list(
{
account: 'ext_account_YWJjMTIz',
reconciliation_status: 'reconciled'
}
);{
"data": [
{
"id": "txn_dHhuX2ZyYWdfMDAx",
"external_id": "bank_txn_123",
"account": {
"id": "ext_account_YWJjMTIz",
"external_id": "acct_external_123"
},
"posted": "2026-02-12T00:00:00.000Z",
"currency": "USD",
"amount": "-1000",
"allocations": [
{
"invoice_id": "inv_abc123",
"amount": "1000",
"type": "invoice_payin",
"user": {}
}
],
"tags": [
{
"key": "region",
"value": "us-east"
}
],
"unallocated_amount": "-1000",
"created": "2026-02-12T00:00:00.000Z",
"modified": "2026-02-12T01:00:00.000Z",
"version": 1
}
]
}Gets the version history of a transaction
import Fragment from '@fragment-dev/ts-node';
const client = new Fragment({
clientId: process.env['FRAGMENT_CLIENT_ID'],
clientSecret: process.env['FRAGMENT_CLIENT_SECRET'],
});
const response = await client.transactions.listHistory('txn_abc123');{
"data": [
{
"id": "txn_dHhuX2ZyYWdfMDAx",
"external_id": "bank_txn_123",
"account": {
"id": "ext_account_YWJjMTIz",
"external_id": "acct_external_123"
},
"posted": "2026-02-12T00:00:00.000Z",
"currency": "USD",
"amount": "-1000",
"allocations": [
{
"invoice_id": "inv_abc123",
"amount": "1000",
"type": "invoice_payin",
"user": {}
}
],
"tags": [
{
"key": "region",
"value": "us-east"
}
],
"unallocated_amount": "-1000",
"created": "2026-02-12T00:00:00.000Z",
"modified": "2026-02-12T01:00:00.000Z",
"version": 1
}
]
}Gets a transaction by ID or external ID
import Fragment from '@fragment-dev/ts-node';
const client = new Fragment({
clientId: process.env['FRAGMENT_CLIENT_ID'],
clientSecret: process.env['FRAGMENT_CLIENT_SECRET'],
});
const response = await client.transactions.retrieve('txn_abc123');{
"data": {
"id": "txn_dHhuX2ZyYWdfMDAx",
"external_id": "bank_txn_123",
"account": {
"id": "ext_account_YWJjMTIz",
"external_id": "acct_external_123"
},
"posted": "2026-02-12T00:00:00.000Z",
"currency": "USD",
"amount": "-1000",
"allocations": [
{
"invoice_id": "inv_abc123",
"amount": "1000",
"type": "invoice_payin",
"user": {
"id": "user_abc123",
"external_id": "user-ext-001"
}
}
],
"tags": [
{
"key": "region",
"value": "us-east"
}
],
"unallocated_amount": "-1000",
"created": "2026-02-12T00:00:00.000Z",
"modified": "2026-02-12T01:00:00.000Z",
"version": 1
}
}Updates a transaction (tags, allocations, or both)
import Fragment from '@fragment-dev/ts-node';
const client = new Fragment({
clientId: process.env['FRAGMENT_CLIENT_ID'],
clientSecret: process.env['FRAGMENT_CLIENT_SECRET'],
});
const response = await client.transactions.update(
'txn_abc123',
{
current_transaction_version: 1,
tags: { update: [{ key: 'region', value: 'eu-west-1' }] }
}
);{
"data": {
"id": "txn_dHhuX2ZyYWdfMDAx",
"external_id": "bank_txn_123",
"account": {
"id": "ext_account_YWJjMTIz",
"external_id": "acct_external_123"
},
"posted": "2026-02-12T00:00:00.000Z",
"currency": "USD",
"amount": "-1000",
"allocations": [
{
"invoice_id": "inv_abc123",
"amount": "1000",
"type": "invoice_payin",
"user": {
"id": "user_abc123",
"external_id": "user-ext-001"
}
}
],
"tags": [
{
"key": "region",
"value": "us-east"
}
],
"unallocated_amount": "-1000",
"created": "2026-02-12T00:00:00.000Z",
"modified": "2026-02-12T01:00:00.000Z",
"version": 1
}
}Searches transactions by filter criteria
import Fragment from '@fragment-dev/ts-node';
const client = new Fragment({
clientId: process.env['FRAGMENT_CLIENT_ID'],
clientSecret: process.env['FRAGMENT_CLIENT_SECRET'],
});
const response = await client.transactions.search(
{
filter: {
account: {
any: [
{
external_id: 'acct_external_123',
id: 'ext_account_YWJjMTIz'
}
]
}
}
}
);{
"data": [
{
"id": "txn_dHhuX2ZyYWdfMDAx",
"external_id": "bank_txn_123",
"account": {
"id": "ext_account_YWJjMTIz",
"external_id": "acct_external_123"
},
"posted": "2026-02-12T00:00:00.000Z",
"currency": "USD",
"amount": "-1000",
"allocations": [
{
"invoice_id": "inv_abc123",
"amount": "1000",
"type": "invoice_payin",
"user": {}
}
],
"tags": [
{
"key": "region",
"value": "us-east"
}
],
"unallocated_amount": "-1000",
"created": "2026-02-12T00:00:00.000Z",
"modified": "2026-02-12T01:00:00.000Z",
"version": 1
}
]
}Searches transaction allocations by filter criteria
import Fragment from '@fragment-dev/ts-node';
const client = new Fragment({
clientId: process.env['FRAGMENT_CLIENT_ID'],
clientSecret: process.env['FRAGMENT_CLIENT_SECRET'],
});
const response = await client.transactions.searchAllocations({ filter: { invoice_id: { any: ['inv_abc123'] } } });{
"data": [
{
"invoice_id": "inv_abc123",
"amount": "1000",
"type": "invoice_payin",
"user": {
"id": "user_abc123",
"external_id": "user-ext-001"
},
"id": "alloc_abc123",
"posted": "2026-02-12T00:00:00.000Z",
"transaction": {
"id": "txn_dHhuX2ZyYWdfMDAx",
"external_id": "bank_txn_123"
}
}
]
}