COUNTCOUNT
Sign Up
TransactionsAssign to bills or invoices

Assign to bills or invoices

POST/partners/transactions/{uuid}/assign-to-bills-invoices

Applies a transaction as payment against one or more bills or invoices.

HMAC signature + Bearer access token
Try this request

Path parameters

uuiduuidrequired

The UUID of the transaction (the payment).

Request body

matchingTypeenumrequired

Whether to apply against bills or invoices.

One of: bill, invoice

recordsarrayrequired

Targets to apply the transaction against.

iduuidrequired

UUID of the bill or invoice.

paymentAmountnumberrequired

Amount of this transaction to apply to the target.

withCautionboolean

When true, skips some reconciliation guards. Use sparingly.

Responses

200Transaction assigned.
400Bad request — assignment amount exceeds the transaction or target balance.
POSThttps://api.getcount.com/partners/transactions/{uuid}/assign-to-bills-invoices
Request
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."
}