Create a payroll template

Operation ID: createPayrollTemplate

Group: Accounting › Payroll Templates

Open in the interactive reference

POST /accounting/payroll-templates

Retry-safe: A write that accepts Idempotency-Key: repeating a request with the same key replays the stored answer instead of executing twice.

Creates a payroll template with its categories and entity assignments. The template serves the legal entities in entityIds, and each category names the debit and credit accounts for one kind of payroll amount.

The name must be unique within the tenant, or the request fails with DUPLICATE_NAME. Send at least one category and at least one legal entity. Category names must be unique within the template, and at least one category must name a debit or credit account.

status isn't an input. The template is 'active' when it has an active netPay category and an active grossPay category, and 'inactive' otherwise.

The response contains only the new template's id. To see the template, use GET accounting/payroll-templates/:id.

Parameters

Name In Type Required Description
Api-Version header string · 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. Example: "Germany monthly payroll".
groupBy string yes How payroll lines are entered. Accepted values: 'Employee', 'Department', 'Multi-level'. Example: "Employee".
journalEntryDate string yes The date the journal entry uses. Accepted values: 'payrollDate', 'endDate'. Example: "payrollDate".
journalEntryGroupBy string yes How journal lines are aggregated by default. Accepted values: 'account', 'accountAndPayrollCategory', 'payrollCategory', 'payrollCategoryByEmployee'. Example: "account".
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<string> yes The complete set of legal entities this template serves. At least one is required. See id on GET base/entities. Example: ["8f2c1d40-5a6b-4c7d-9e80-1f2a3b4c5d6e"].
categories array<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. Example: [{"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"}].
categories[].name string yes The name of the category. Unique within the template.
categories[].subType string yes What the category represents. Accepted values: 'grossPay', 'deduction', 'netPay', 'employer'. At most one netPay category per template.
categories[].status string no Whether the category is usable. Accepted values: 'active', '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. Accepted values: 'account', 'accountAndPayrollCategory', 'payrollCategory', '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.
categories[].debitTags array<object> no Tags stamped on every journal line this category debits, at most one per dimension. Supported dimension: 'vendor'. Requires debitJournalAggregation to be above 'account'.
categories[].debitTags[].dimension string yes The tag dimension. Accepted values: 'vendor'.
categories[].debitTags[].id string yes The tagged record. For 'vendor', see id on GET accounting/vendors/:id.
categories[].creditTags array<object> no Tags stamped on every journal line this category credits. The same values and rules as the debit side apply.
categories[].creditTags[].dimension string yes The tag dimension. Accepted values: 'vendor'.
categories[].creditTags[].id string yes The tagged record. For 'vendor', see id on GET accounting/vendors/:id.
{
  "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. Example: "d4a1c7e0-2b93-4f56-8071-9e3a5c8b1d42".
{
  "data": {
    "id": "d4a1c7e0-2b93-4f56-8071-9e3a5c8b1d42"
  },
  "diagnostics": [
    {
      "code": "<code>",
      "message": "<message>",
      "severity": "error",
      "path": [
        "<path>"
      ],
      "details": "<details>"
    }
  ]
}

Response headers

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
TAGS_REQUIRE_CATEGORY_AGGREGATION 400
INVALID_CATEGORY_TAG 400
IDEMPOTENCY_KEY_CONFLICT 409
IDEMPOTENCY_PAYLOAD_MISMATCH 422

Statuses