Set opening balance
POST
/partners/opening-balanceDrafts and publishes the opening balance in one call.
HMAC signature + Bearer access token
Try this requestRequest body
rowsarrayrequiredNon-empty array of `{ accountUuid, debit, credit }`. Debits must equal credits.
accountUuiduuidrequiredAccount UUID from the chart of accounts.
debitnumberrequiredDebit amount (max 2 decimal places).
creditnumberrequiredCredit amount (max 2 decimal places).
replaceExistingbooleanWhen true, replaces an existing draft or published opening balance. Required to overwrite.
Responses
200Opening balance published.400Validation failed, unbalanced rows, or workspace is no longer onboarding.409An opening balance already exists and replaceExisting was not true.401Missing or invalid HMAC signature, expired timestamp, or invalid Bearer token. Troubleshoot403The credential does not have access to this workspace or resource. Troubleshoot429Rate limit exceeded (100 requests per minute per clientId). Retry after the Retry-After header. TroubleshootPOST
https://api.getcount.com/partners/opening-balanceRequest
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 = '/opening-balance';
const timestamp = Math.floor(Date.now() / 1000).toString();
const body = {
"replaceExisting": true,
"rows": [
{
"accountUuid": "c8d9e0f1-a2b3-4567-cdef-789012345678",
"debit": 12500,
"credit": 0
},
{
"accountUuid": "d4e5f6a7-b8c9-0123-defa-234567890123",
"debit": 0,
"credit": 12500
}
]
};
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/opening-balance`, {
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": "Opening balance published successfully."
}