Assign to bills or invoices
POST
/partners/transactions/{uuid}/assign-to-bills-invoicesApplies a transaction as payment against one or more bills or invoices.
HMAC signature + Bearer access token
Try this requestPath parameters
uuiduuidrequiredThe UUID of the transaction (the payment).
Request body
matchingTypeenumrequiredWhether to apply against bills or invoices.
One of: bill, invoice
recordsarrayrequiredTargets to apply the transaction against.
iduuidrequiredUUID of the bill or invoice.
paymentAmountnumberrequiredAmount of this transaction to apply to the target.
withCautionbooleanWhen true, skips some reconciliation guards. Use sparingly.
Responses
200Transaction assigned.400Bad request — assignment amount exceeds the transaction or target balance.POST
https://api.getcount.com/partners/transactions/{uuid}/assign-to-bills-invoicesRequest
import crypto from 'node:crypto';
const BASE_URL = 'https://api.getcount.com';
const CLIENT_ID = process.env.COUNT_CLIENT_ID;
const CLIENT_SECRET = process.env.COUNT_CLIENT_SECRET;
const ACCESS_TOKEN = process.env.COUNT_ACCESS_TOKEN;
const method = 'POST';
const signingPath = '/transactions/3fa85f64-5717-4562-b3fc-2c963f66afa6/assign-to-bills-invoices';
const timestamp = Math.floor(Date.now() / 1000).toString();
const body = {
"matchingType": "invoice",
"records": [
{
"id": "f6a7b8c9-d0e1-2345-fabc-456789012345",
"paymentAmount": 150
}
],
"withCaution": false
};
const bodyString = JSON.stringify(body);
const bodyHash = crypto.createHash('sha256').update(bodyString).digest('hex');
const baseString = `${method}:${signingPath}:${timestamp}:${bodyHash}`;
const signature = crypto.createHmac('sha256', CLIENT_SECRET).update(baseString).digest('hex');
const response = await fetch(`${BASE_URL}/partners/transactions/3fa85f64-5717-4562-b3fc-2c963f66afa6/assign-to-bills-invoices`, {
method,
headers: {
'x-client-id': CLIENT_ID,
'x-timestamp': timestamp,
'x-signature': signature,
'Content-Type': 'application/json',
Authorization: `Bearer ${ACCESS_TOKEN}`,
},
body: bodyString,
});
console.log(await response.json());Response · 200
{
"status": "success",
"message": "Transaction assigned."
}