Create Payroll Template
POST /accounting/payroll-templates
Group: Accounting › Payroll Templates · Operation ID: createPayrollTemplate
Creates a payroll template with its categories and entity assignments. The name must be unique across payroll templates.
The name must be unique across payroll templates, and a clash fails with DUPLICATE_NAME. At least one category and at least one entity are required. Category names must be unique within the template, and at most one category may be netPay. entityIds is the complete set of entities the template serves. status is not an input. It is computed as 'active' when the template has both an active netPay and an active grossPay category, and 'inactive' otherwise. A category may use 'payrollCategoryByEmployee' aggregation only when groupBy is 'Employee'. The response contains only the new template's id. Read the record with GET accounting/payroll-templates/:id.
Open in the interactive reference
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
Api-Version |
header | "v1" |
yes | The API version this request targets, named by its public identifier. Required on every request; omitting it, or naming a version this company does not have, is answered with 400. This document describes version v1. |
Idempotency-Key |
header | string | no | An opaque caller-chosen string (1-255 characters) that makes this request safe to retry. Repeating the same key with an identical request body replays the original response instead of re-executing - but only once that original request succeeded; a failed attempt re-executes on retry. Repeating the key with a different body is answered with 422. A key still in flight is answered with 409 - as is a key whose original request was interrupted before it finished, for a few minutes afterwards, until that attempt is presumed dead. A completed response stays replayable for 24 hours. The key is scoped to the caller, not to the action: reusing it for a different action is answered with 409 or 422 rather than treated independently. On read actions this header is ignored. On write actions that cannot offer the guarantee it is answered with 400 IDEMPOTENCY_NOT_SUPPORTED rather than silently ignored. |
Request body
Required, application/json: createPayrollTemplateInput.
| Field | Type | Required | Description |
|---|---|---|---|
name |
string | yes | The name of the payroll template. Unique across all payroll templates. |
groupBy |
string | yes | How payroll lines are entered. One of 'Employee', 'Department' or 'Multi-level'. |
journalEntryDate |
string | yes | The date the journal entry uses. Accepted values: 'payrollDate', 'endDate'. |
journalEntryGroupBy |
string | yes | How journal lines are aggregated by default. One of 'account', 'accountAndPayrollCategory', 'payrollCategory' or 'payrollCategoryByEmployee'. |
description |
string | no | A free-form description of the template. |
clearingAccountId |
string | no | The clearing account used when posting. See id on GET accounting/accounts/:id. |
source |
string | no | The payroll system the template imports from. Accepted values: 'datev', 'datevEmployeePayroll', 'datevEmployeePayrollPersonLevel', 'rippling', 'lexware', 'briars', 'gusto', 'adpGLReport', 'adpPayrollHistory', 'sage', 'none'. |
entityIds |
array of string | yes | The complete set of legal entities this template serves. At least one is required. See id on GET base/entities. |
categories |
array of object | yes | The categories this template defines. At least one is required. Category names must be unique, and at most one category may be netPay. |
categories[].name |
string | yes | The name of the category. Unique within the template. |
categories[].subType |
string | yes | What the category represents. One of 'grossPay', 'deduction', 'netPay' or 'employer'. At most one netPay category per template. |
categories[].status |
string | no | Whether the category is usable. One of 'active' or 'inactive'. Defaults to 'active'. |
categories[].payee |
string | no | Who gets paid, as a payee code from your tenant's configured payee list, for example 'employee', 'payrollProvider', 'benefitsProvider' or 'taxOffice'. |
categories[].isManagedFromPayroll |
boolean | yes | Whether payment for this category is managed from payroll. Required, the category model has no default. |
categories[].debitAccountId |
string | no | The account debited for this category. See id on GET accounting/accounts/:id. |
categories[].creditAccountId |
string | no | The account credited for this category. See id on GET accounting/accounts/:id. |
categories[].debitJournalAggregation |
string | no | How debit journal lines are aggregated. One of 'account', 'accountAndPayrollCategory', 'payrollCategory' or 'payrollCategoryByEmployee'. Defaults to the template's setting. 'payrollCategoryByEmployee' requires groupBy 'Employee'. |
categories[].creditJournalAggregation |
string | no | How credit journal lines are aggregated. The same values and rule as the debit side apply. |
Example:
{
"name": "Germany monthly payroll",
"groupBy": "Employee",
"journalEntryDate": "payrollDate",
"journalEntryGroupBy": "account",
"description": "<description>",
"clearingAccountId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"source": "<source>",
"entityIds": [
"8f2c1d40-5a6b-4c7d-9e80-1f2a3b4c5d6e"
],
"categories": [
{
"name": "Gross Pay",
"subType": "grossPay",
"payee": "employee",
"isManagedFromPayroll": false,
"debitAccountId": "7c1a9e40-2b53-4d68-9f01-3a5b7c9d1e24"
},
{
"name": "Net Pay",
"subType": "netPay",
"payee": "employee",
"isManagedFromPayroll": false,
"creditAccountId": "7c1a9e40-2b53-4d68-9f01-3a5b7c9d1e24"
}
]
}
Response
200 Success
Under data (createPayrollTemplateOutput):
| Field | Type | Required | Description |
|---|---|---|---|
id |
string | yes | The unique identifier for the created payroll template. |
Response headers
Idempotency-Replayed— Present andtrueonly when this response replays a previously stored one for the same Idempotency-Key, rather than reflecting a live execution. Absent on a live response - never sent asfalse.
Errors
| Code | Status |
|---|---|
REFERENCE_NOT_FOUND |
400 |
DUPLICATE_NAME |
400 |
NO_CATEGORIES |
400 |
DUPLICATE_CATEGORY_NAME |
400 |
MULTIPLE_NET_PAY_CATEGORIES |
400 |
AGGREGATION_REQUIRES_EMPLOYEE_GROUPING |
400 |
NO_ENTITIES |
400 |
NO_CATEGORY_ACCOUNTS |
400 |
IDEMPOTENCY_KEY_CONFLICT |
409 |
IDEMPOTENCY_PAYLOAD_MISMATCH |
422 |
Statuses
400— Invalid request or business failure. Codes: REFERENCE_NOT_FOUND, DUPLICATE_NAME, NO_CATEGORIES, DUPLICATE_CATEGORY_NAME, MULTIPLE_NET_PAY_CATEGORIES, AGGREGATION_REQUIRES_EMPLOYEE_GROUPING, NO_ENTITIES, NO_CATEGORY_ACCOUNTS401— Missing or invalid access token403— Not authorized404— Not found409— The Idempotency-Key is still being processed by another request.422— The Idempotency-Key was already used with a different request payload.429— Too many requests500— Internal server error