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

# Apply template

> Instantiate a task from a template. Template fields supply defaults; body fields override.

```
POST https://www.wiseyield.co/api/v1/templates/{id}/apply
```

### Authentication

Requires a key with the `tasks:write` scope.

### Path parameters

<ParamField path="id" type="string" required>Template UUID. Template must be `isActive=true`.</ParamField>

### Request body

All fields optional. Override template defaults by passing them here.

<ParamField body="farmId" type="string">
  UUID. **Required if the template doesn't have a bound farm.** Must be owned by the user.
</ParamField>

<ParamField body="title" type="string">Defaults to template's `name`.</ParamField>
<ParamField body="description" type="string">Defaults to template's `description`.</ParamField>
<ParamField body="priority" type="string">One of `low`, `medium`, `high`, `urgent`. Defaults to template's `priority`.</ParamField>
<ParamField body="dueDate" type="string">ISO 8601 datetime.</ParamField>
<ParamField body="startDate" type="string">ISO 8601 datetime.</ParamField>
<ParamField body="assignedTo" type="string">Defaults to template's `defaultAssignee`.</ParamField>
<ParamField body="fieldName" type="string">Free-text field reference (denormalized).</ParamField>
<ParamField body="estimatedDuration" type="string">Defaults to template's `estimatedDuration`.</ParamField>
<ParamField body="notes" type="string">Free text.</ParamField>

### Response

Returns the newly-created task wrapped under `data`. See [Get task](/api-reference/tasks/get-task) for the task shape.

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST 'https://www.wiseyield.co/api/v1/templates/aaaaaaaa.../apply' \
    -H "Authorization: Bearer $WISEYIELD_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "farmId": "11111111-2222-3333-4444-555555555555",
      "dueDate": "2026-06-15T08:00:00.000Z"
    }'
  ```
</RequestExample>

## Errors

| Status                    | When                                                                                                              |
| ------------------------- | ----------------------------------------------------------------------------------------------------------------- |
| `400 INVALID_ID`          | `{id}` is not a valid UUID                                                                                        |
| `400 VALIDATION_ERROR`    | Body validation failed, OR `farmId` is required and wasn't provided                                               |
| `401`                     | Missing, malformed, expired, or revoked API key                                                                   |
| `403 INSUFFICIENT_SCOPE`  | Key lacks `tasks:write` scope                                                                                     |
| `404 NOT_FOUND`           | Template doesn't exist, is inactive, or is neither user-owned nor global; OR resolved `farmId` isn't owned by you |
| `429 RATE_LIMIT_EXCEEDED` | Per-user rate limit reached                                                                                       |
| `5xx`                     | Server error                                                                                                      |
