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
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
page integer No Page number for pagination (default: 1)
per_page integer No Number of items per page (default: 100)
with string No Comma-separated list of relations to include: vouchers

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
name string No Display name (max 150 characters)
description string No Extended description (max 1000 characters)

Example Request

curl -X POST "https://api.snapbooks.no/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"
}

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.
  • 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.