> ## Documentation Index
> Fetch the complete documentation index at: https://docs.eazecustoms.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Apply template group

> Apply a template group to a shipment or specific declarations.

Apply a template group to a shipment and its linked declarations, or to specific declarations by ID. This overlays the template's default field values on the target declarations.

### Path parameters

<ParamField path="id" type="number" required>
  The unique template group ID.
</ParamField>

### Request payload

<ParamField body="shipmentId" type="integer">
  The ID of the shipment to apply templates to. Use this when applying to all declarations under a shipment.
</ParamField>

<ParamField body="declarationIds" type="array">
  Array of specific declaration IDs to apply the template group to. Use this when applying to specific declarations instead of a full shipment.
</ParamField>

<ParamField body="fieldOnlyIfEmpty" type="boolean" default="true">
  If `true`, only overrides fields that are currently empty/null. If `false`, overwrites all matching fields.
</ParamField>

<ParamField body="arrayMode" type="string" default="ifEmpty">
  Controls how array fields (e.g. documents) are applied. Allowed values: `ifEmpty`, `overwrite`, `replace`.
</ParamField>

<Tabs>
  <Tab title="Apply to shipment">
    ```json JSON Payload theme={null}
    {
      "shipmentId": 1057,
      "fieldOnlyIfEmpty": true,
      "arrayMode": "ifEmpty"
    }
    ```
  </Tab>

  <Tab title="Apply to declarations">
    ```json JSON Payload theme={null}
    {
      "declarationIds": [3047, 3046],
      "fieldOnlyIfEmpty": false,
      "arrayMode": "overwrite"
    }
    ```
  </Tab>
</Tabs>

<ResponseExample>
  ```json 201 Created theme={null}
  {
    "shipmentId": 1057,
    "applied": true,
    "declarationsUpdatedCount": 2,
    "message": "Template group applied successfully"
  }
  ```
</ResponseExample>
