---
title: "Set opening balance · Opening Balance · COUNT Partner API"
description: "Drafts and publishes the opening balance in one call. POST /partners/opening-balance"
canonical: "https://developers.getcount.com/reference/opening-balance/set-opening-balance"
source: "https://developers.getcount.com/reference/opening-balance/set-opening-balance"
---
[Opening Balance](https://developers.getcount.com/reference/opening-balance) / Set opening balance

# Set opening balance

POST `/partners/opening-balance`

Drafts and publishes the opening balance in one call.

HMAC signature + Bearer access token

[Try this request](https://developers.getcount.com/tools/try-it?method=POST&path=%2Fpartners%2Fopening-balance&body=%7B%0A++%22replaceExisting%22%3A+true%2C%0A++%22rows%22%3A+%5B%0A++++%7B%0A++++++%22accountUuid%22%3A+%22c8d9e0f1-a2b3-4567-cdef-789012345678%22%2C%0A++++++%22debit%22%3A+12500%2C%0A++++++%22credit%22%3A+0%0A++++%7D%2C%0A++++%7B%0A++++++%22accountUuid%22%3A+%22d4e5f6a7-b8c9-0123-defa-234567890123%22%2C%0A++++++%22debit%22%3A+0%2C%0A++++++%22credit%22%3A+12500%0A++++%7D%0A++%5D%0A%7D)

[Workspace](https://developers.getcount.com/reference/workspace) [Chart of Accounts](https://developers.getcount.com/reference/chart-of-accounts) [Journal Entries](https://developers.getcount.com/reference/journal-entries)

#### Request body

`rows` array required

Non-empty array of `{ accountUuid, debit, credit }`. Debits must equal credits.

`accountUuid` uuid required

Account UUID from the chart of accounts.

`debit` number required

Debit amount (max 2 decimal places).

`credit` number required

Credit amount (max 2 decimal places).

`replaceExisting` boolean

When true, replaces an existing draft or published opening balance. Required to overwrite.

#### Responses

`200` Opening balance published.

`400` Validation failed, unbalanced rows, or workspace is no longer onboarding.

`409` An opening balance already exists and replaceExisting was not true.

`401` Missing or invalid HMAC signature, expired timestamp, or invalid Bearer token. [Troubleshoot](https://developers.getcount.com/getting-started/errors#error-401)

`403` The credential does not have access to this workspace or resource. [Troubleshoot](https://developers.getcount.com/getting-started/errors#error-403)

`429` Rate limit exceeded (100 requests per minute per clientId). Retry after the Retry-After header. [Troubleshoot](https://developers.getcount.com/getting-started/errors#error-429)

[Previous GET Get opening balance](https://developers.getcount.com/reference/opening-balance/get-opening-balance)

POST `https://api.getcount.com/partners/opening-balance`

Request

```javascript
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

```json
{
  "status": "success",
  "message": "Opening balance published successfully."
}
```
