Voucher Collections

Voucher collections are used to group and organize accounting vouchers into named sets. This is useful for organizing vouchers by period, project, import batch, or any other logical grouping that makes sense for your workflow.

Endpoints

Method Endpoint Description
GET /voucher-collections List voucher collections
POST /voucher-collections Create a voucher collection
POST/PUT /voucher-collections/{id} Update a voucher collection

Query Parameters

The GET /voucher-collections endpoint supports the following query parameters:

Parameter Type Required Description
client_account_id integer Yes Filter by client account ID. Must be one of the user’s eligible client accounts; leaving it out returns 403 voucher.client_account_access_denied
with string No Comma-separated list of relations to include: vouchers

The response uses the paginated envelope, but page and per_page are not read: the endpoint always returns the first 100 collections, in no guaranteed order. meta.pages can still be above 1 while meta.page stays 1, so don’t loop on meta.page < meta.pages here: every request returns the same first page.

Attributes

Attribute Type Description
id integer The unique ID of the voucher collection
created_at datetime The date and time when the collection was created
created_by_id integer The ID of the user that created the collection
updated_at datetime The date and time when the collection was last updated
updated_by_id integer The ID of the user that last updated the collection
client_account_id integer The ID of the client account this collection belongs to
name string The display name of the collection (max 150 characters)
description string An extended description of the collection (max 1000 characters)

Relationships

Relationship Type Description
vouchers Voucher[] The vouchers that belong to this collection

Request Body (POST / PUT)

When creating or updating a voucher collection, send a JSON object with the following fields:

Field Type Required Description
client_account_id integer Yes (POST) The client account this collection belongs to. It cannot be changed after creation; on update, send the current value or leave it out
name string No Display name (max 150 characters)
description string No Extended description (max 1000 characters)

Example Request

curl -X POST "https://api.snapbooks.com/v2/voucher-collections" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "client_account_id": 7,
    "name": "Q1 2024 Import",
    "description": "Vouchers imported from legacy system for Q1 2024"
  }'

Example Response

{
    "id": 1,
    "created_at": "2024-03-20T14:00:00Z",
    "created_by_id": 7,
    "updated_at": null,
    "updated_by_id": null,
    "client_account_id": 7,
    "name": "Q1 2024 Import",
    "description": "Vouchers imported from legacy system for Q1 2024"
}

Error Responses

Code HTTP Status Description
common.serialization_error 400 The body is not a JSON object, or client_account_id is not a number
common.validation_error 400 The body is empty or not valid JSON
voucher.collection_client_account_immutable 400 PUT: the body’s client_account_id differs from the collection’s
voucher.client_account_access_denied 403 GET: client_account_id is missing or outside your eligible accounts
voucher.collection_access_denied 403 PUT: no access to the collection. POST: the body’s client_account_id is missing or outside your eligible accounts
voucher.collection_not_found 404 Voucher collection not found

Send the body as JSON (Content-Type: application/json); any other content type is rejected with 415 and the code common.internal_error. A non-integer number in client_account_id is truncated (7.9 becomes 7), so send whole numbers.

Notes

  • The authenticated user must have access to the specified client account.
  • The client_account_id is required when creating a collection and cannot be changed after creation.
  • Only the fields you send are changed on update; name and description can be set to null.
  • The created_by_id and updated_by_id fields are automatically set to the authenticated user’s ID.
  • Use the with parameter to include related vouchers: ?with=vouchers.
  • All dates are returned in ISO 8601 format.