Importer des écritures de banque

Important : 10 transactions max par payload.

Si vous souhaitez importer 100 transactions : vous devez scinder ces transactions en 10 array de 10 transactions (chuncks de 10 transactions) et exécuter pour chacun des chunks la requête :

var myHeaders = new Headers();

myHeaders.append("Authorization", "Bearer <token>");
myHeaders.append("Content-Type", "application/json");

// we import 2 transactions :
// first of 74.25€ 
// second of 33$ 
//
// credit is not null as transaction real amount is positive
// debit is null as transaction real amont is not négative

const randomStr = "1ms3e0ksq33"; // random uniq string
const cashFlowId = myCashflows[0]['id']; // cf "Lister  les comptes" et choisir votre `cashflow` et son id

var raw = JSON.stringify({
data: [ // chunk of 10 transactions MAX
  {
	  received_at: "2026-07-27T12:00:00Z",
    currency:	"EUR", // string ISO
    foreign_currency:	null, // if your locale currency is different than transaction currency : str  otherwise: null
    amount:	7425, //int, real transaction amount * 100 
		original_amount:	7425, // int same has amount
    cashflow_source_id:	cashFlowId, //int id of the cashflow 
    credit:	74.25, // if real amount > 0  : int | float real transaction amount ex : 74.25 otherwise null, 
    debit:	null, // if real amount < 0  : int | float real transaction amount otherwise null, 
    details:	"Pour test", // str
    label:	"Virement FACXXX1", // str
    metadata: {
      csv_imported_at:	"2026-07-27T12:54:03Z", // this will allow you to remove imported transaction
			csv_imported_id:	randomStr // str
    },
	  author_user_id: 1, // optional int | null logged user id
  },
  {
    received_at: "2026-07-27T12:00:00Z",
    currency:	"USD", // string ISO
    foreign_currency:	"USD", // if your locale currency is different than transaction currency : str  otherwise: null
		amount:	3300, //int, real transaction amount * 100,
    original_amount:	3300, // int same has amount
    cashflow_source_id:	cashFlowId, //int id of the cashflow 
    credit:	33, // if real amount > 0  : int | float real transaction amount ex : 74.25 otherwise null, 
    debit:	null, // if real amount < 0  : int | float real transaction amount otherwise null, 
    details:	"Pour test", // str
    label:	"Virement FACXXX2", // str
    metadata: {
      csv_imported_at:	"2026-07-27T12:54:03Z", // this will allow you to remove imported transaction
			csv_imported_id:	randomStr // str
    },
	  author_user_id: 1, // optional int | null logged user id
  }
]
});

var requestOptions = {
		method: 'POST',
		headers: myHeaders,
		body: raw,
		redirect: 'follow'
};

fetch("https://api.sinao.app/v1/apps/:appId/transactions/batch", requestOptions)
		.then(response => response.text())
		.catch(error => console.log('error', error));