---
title: "Apply a task template to a trip"
---

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

# Apply a task template to a trip

Path: Nicer API › Notes and tasks

`POST /crm/task-templates/{templateId}/apply`

URL: `https://api.nicer.travel/crm/task-templates/{templateId}/apply`

Applies one of the agency's task templates (templateId from GET /crm/settings, taskTemplates) to a trip: each step of the template becomes a task of the trip, dated its offsetDays from the trip's start, end or creation (undated when the trip lacks that date), with origin TEMPLATE, all written at once. Every task is assigned to the caller, to assignedUserId, or with assignedUserId null to the trip's advisor. Publishes crm.task-changed.v1 with action CREATED for each task, and answers them all, in the template's order, with nextToken null. The caller must be the trip's advisor of record or an agency admin. Requires an Idempotency-Key header: a retry with the same key and body answers the same tasks. Errors: 400 ERROR_BODY_VALIDATION, 400 CRM_TASK_TEMPLATE_NOT_FOUND for a template the agency does not have, 404 ERROR_ITEM_NOT_FOUND for a trip the caller may not write about, 409 CRM_IDEMPOTENCY_CONFLICT for a key used with another body, and for a template already applied to the trip.

## Authentication

- `bearerAuth`, http bearer, header `Authorization`, format `JWT`

## Path parameters

- `templateId` (`crm.taskTemplates.apply.path.templateId`; string, required)

## Header parameters

- `Idempotency-Key` (`crm.taskTemplates.apply.header.Idempotency-Key`; string, required) — Unique key (8–255 chars) per request; replays return the original result.
- `x-nicer-company` (`crm.taskTemplates.apply.header.x-nicer-company`; string, required) — Company context. Authentication and tenant membership are validated by the API.
- `X-Nicer-CRM-Contract` (`crm.taskTemplates.apply.header.X-Nicer-CRM-Contract`; string, required)
  - one of `"resource"` · example: `"resource"`

## Request body

_Required._

- `travelersTripId` (`crm.taskTemplates.apply.travelersTripId`; string, required) — The trip (TT…) the tasks are for. Each task is dated from the trip's start, end or creation, as its step says.
  - minLength: `1`
- `assignedUserId` (`crm.taskTemplates.apply.assignedUserId`; any of, optional) — The user id of the advisor or admin every task goes to. Left out, the caller; null, the trip's advisor, or nobody when the trip has none.
  - any of the following: `string`, `null`

## Example request

```json
{
  "travelersTripId": "TT01JD4Q9W0Y5X3M2K8B7N6P4R1T"
}
```

## Code samples

### JavaScript SDK

```javascript
import { createClient } from "@nicertravel/sdk";

const nicer = createClient({
  baseUrl: "https://api.nicer.travel",
  token: process.env.NICER_TOKEN,
  headers: { "Idempotency-Key": process.env.NICER_IDEMPOTENCY_KEY, "x-nicer-company": process.env.NICER_COMPANY },
});

await nicer.crm.taskTemplates.apply({
  "templateId": "string",
  "travelersTripId": "TT01JD4Q9W0Y5X3M2K8B7N6P4R1T"
});
```

### Nicer CLI

```bash
nicer crm task-templates apply --template-id 'string' --company "$NICER_COMPANY" --input - <<'JSON'
{
  "travelersTripId": "TT01JD4Q9W0Y5X3M2K8B7N6P4R1T"
}
JSON
```

### cURL

```bash
curl --request POST \
  --url 'https://api.nicer.travel/crm/task-templates/<templateId>/apply' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --header 'Idempotency-Key: string' \
  --header 'X-Nicer-CRM-Contract: resource' \
  --header 'x-nicer-company: string' \
  --data '
{
  "travelersTripId": "TT01JD4Q9W0Y5X3M2K8B7N6P4R1T"
}
'
```

### TypeScript

```typescript
const url = 'https://api.nicer.travel/crm/task-templates/<templateId>/apply';
const options = {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Idempotency-Key': 'string',
    'x-nicer-company': 'string',
    'X-Nicer-CRM-Contract': 'resource',
    Authorization: 'Bearer <token>'
  },
  body: JSON.stringify({travelersTripId: 'TT01JD4Q9W0Y5X3M2K8B7N6P4R1T'})
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://api.nicer.travel/crm/task-templates/<templateId>/apply"

payload = { "travelersTripId": "TT01JD4Q9W0Y5X3M2K8B7N6P4R1T" }
headers = {
    "Content-Type": "application/json",
    "Idempotency-Key": "string",
    "x-nicer-company": "string",
    "X-Nicer-CRM-Contract": "resource",
    "Authorization": "Bearer <token>"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

## Responses

### 200

OK

#### Example

```json
{
  "items": [
    {
      "assignedUserId": "string",
      "associatedTripItineraryId": "string",
      "companyName": "string",
      "completed": true,
      "completedAt": "2019-08-24T14:15:22Z",
      "createdAt": "2019-08-24T14:15:22Z",
      "createdBy": "string",
      "lastModifiedBy": "string",
      "notes": "string",
      "origin": "ANNIVERSARY",
      "taskId": "string",
      "tentativeDate": "2019-08-24",
      "title": "string",
      "travelerId": "string",
      "travelerName": "string",
      "travelersTripId": "string",
      "tripName": "string",
      "updatedAt": "2019-08-24T14:15:22Z"
    }
  ],
  "nextToken": "string"
}
```

- `items` (`crm.taskTemplates.apply.response.200.items`; array of object, required) — The items of this page.
  - `assignedUserId` (`crm.taskTemplates.apply.response.200.items.assignedUserId`; any of, required) — The advisor or admin who should do it; null when nobody is assigned.
    - any of the following: `string`, `null`
  - `associatedTripItineraryId` (`crm.taskTemplates.apply.response.200.items.associatedTripItineraryId`; any of, required) — The itinerary (TI…) of the trip the task is about, when it has one; null otherwise.
    - any of the following: `string`, `null`
  - `companyName` (`crm.taskTemplates.apply.response.200.items.companyName`; string, required) — The agency the task belongs to.
  - `completed` (`crm.taskTemplates.apply.response.200.items.completed`; boolean, required) — Whether the task is done.
  - `completedAt` (`crm.taskTemplates.apply.response.200.items.completedAt`; any of, required) — When the task was marked done; null while it is open.
    - any of the following: `string`, `null`
  - `createdAt` (`crm.taskTemplates.apply.response.200.items.createdAt`; string, required) — When the task was created.
    - format: `date-time` · pattern: `^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$`
  - `createdBy` (`crm.taskTemplates.apply.response.200.items.createdBy`; string, required) — The user id of who created it, or SYSTEM for the CRM.
  - `lastModifiedBy` (`crm.taskTemplates.apply.response.200.items.lastModifiedBy`; string, required) — The user id of who changed it last, or SYSTEM for the CRM.
  - `notes` (`crm.taskTemplates.apply.response.200.items.notes`; any of, required) — More about it; null when there is none.
    - any of the following: `string`, `null`
  - `origin` (`crm.taskTemplates.apply.response.200.items.origin`; string, required) — How the task was made.
    - one of `"ANNIVERSARY"`, `"BIRTHDAY"`, `"DOCUMENT_EXPIRY"`, `"MANUAL"`, `"TEMPLATE"`
  - `taskId` (`crm.taskTemplates.apply.response.200.items.taskId`; string, required) — The task's id: what updateTask and deleteTask take.
  - `tentativeDate` (`crm.taskTemplates.apply.response.200.items.tentativeDate`; any of, required) — When it should be done, as a date; null when undated.
    - any of the following: `string`, `null`
  - `title` (`crm.taskTemplates.apply.response.200.items.title`; string, required) — What to do, in a few words.
  - `travelerId` (`crm.taskTemplates.apply.response.200.items.travelerId`; any of, required) — The traveler the task is about; null for a task about a trip. A task is about one traveler or one trip.
    - any of the following: `TravelerId`, `null`
  - `travelerName` (`crm.taskTemplates.apply.response.200.items.travelerName`; any of, required) — The traveler's name as the agency knows them, read when the task is answered; null for a task about a trip.
    - any of the following: `string`, `null`
  - `travelersTripId` (`crm.taskTemplates.apply.response.200.items.travelersTripId`; any of, required) — The trip (TT…) the task is about; null for a task about a traveler.
    - any of the following: `string`, `null`
  - `tripName` (`crm.taskTemplates.apply.response.200.items.tripName`; any of, required) — The trip's name, read when the task is answered; null for a task about a traveler or a trip without a name.
    - any of the following: `string`, `null`
  - `updatedAt` (`crm.taskTemplates.apply.response.200.items.updatedAt`; string, required) — When the task last changed.
    - format: `date-time` · pattern: `^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$`
- `nextToken` (`crm.taskTemplates.apply.response.200.nextToken`; any of, required) — Send it back as nextToken to read the next page; null on the last page.
  - any of the following: `string`, `null`

### 400

Request failed. `errorCode` is stable; `errorMessage` is for humans.

#### Example

```json
{
  "errorCode": "string",
  "errorMessage": "string"
}
```

- `errorCode` (`crm.taskTemplates.apply.response.400.errorCode`; string, required)
- `errorMessage` (`crm.taskTemplates.apply.response.400.errorMessage`; string, required)

### 401

Request failed. `errorCode` is stable; `errorMessage` is for humans.

#### Example

```json
{
  "errorCode": "string",
  "errorMessage": "string"
}
```

- `errorCode` (`crm.taskTemplates.apply.response.401.errorCode`; string, required)
- `errorMessage` (`crm.taskTemplates.apply.response.401.errorMessage`; string, required)

### 403

Request failed. `errorCode` is stable; `errorMessage` is for humans.

#### Example

```json
{
  "errorCode": "string",
  "errorMessage": "string"
}
```

- `errorCode` (`crm.taskTemplates.apply.response.403.errorCode`; string, required)
- `errorMessage` (`crm.taskTemplates.apply.response.403.errorMessage`; string, required)


Source: https://docs.nicer.travel/api/Notes-and-tasks/crm.taskTemplates.apply/index.md
