# Delete, merge & follow-ups

These are the jobs board's housekeeping actions. Each one runs TruTec's own code as the user who created the API key, with the same rules as in the app.

## Delete a job

`DELETE /v1/jobs/{id}`

**Permission:** Write jobs and Delete records

Deletes the job with everything on it: takeoffs, estimates, proposals, photos, files, schedule, invoices and history. **It cannot be undone.** The key's user must be a workspace owner, or a member an owner allowed to delete jobs, and the workspace's **Prevent deleting jobs and records** switch must be off (`403` otherwise). A job the user can't see (members who only see their own jobs) is `404`.

```bash
curl -X DELETE "https://trutec.ai/api/v1/jobs/70415" \
  -H "X-API-Key: sk_your_api_key_here"
```

Returns `204` with no body.

## Merge two jobs

`POST /v1/jobs/{id}/merge`

**Permission:** Write jobs and Delete records

The job page's **Merge**, for a duplicate job. Everything on job `{id}` (takeoffs, estimates, proposals, photos, files, invoices, work orders, contacts, notes) moves to `into_job_id`. The kept job's own fields win, and its blank fields are filled from the duplicate. Then the duplicate is deleted. **It cannot be undone.** Same permission rules as deleting.

| Field | Type | Required | Description |
|---|---|---|---|
| `into_job_id` | integer | Yes | The job to keep. |

```bash
curl -X POST "https://trutec.ai/api/v1/jobs/70415/merge" \
  -H "X-API-Key: sk_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"into_job_id": 70412}'
```

Returns the kept job (the [job object](jobs.md)) in `data`, and `merged_job_id`.

## Follow-up sequence

A workspace can turn on an automatic **follow-up sequence** (Jobs › Automation): after a proposal goes out, its steps email the customer on set days until the job is won or lost, the customer replies (when set to stop on replies), or someone stops it.

!!! warning
    Starting a sequence means TruTec **will email the customer** on the sequence's days. Confirm before you start one.

### Get a job's sequence

`GET /v1/jobs/{id}/follow-up-sequence`

**Permission:** Read jobs

```json
{
  "data": {
    "job_id": 70412,
    "sequence_enabled": true,
    "running": true,
    "steps": 3,
    "through_day": 14
  }
}
```

`sequence_enabled` is whether the workspace has a sequence turned on; `running` is whether it's running on this job; `steps` is the open steps (or the sequence's steps when it isn't running) and `through_day` its last day.

### Start the sequence

`POST /v1/jobs/{id}/follow-up-sequence/start`

**Permission:** Write jobs

Starts the sequence on the job now, as when a bid went out outside TruTec. Returns the object above with `started_now`. Refused (`400`) when the workspace has no sequence turned on or the customer company is set to skip automatic follow-ups.

### Stop the sequence

`POST /v1/jobs/{id}/follow-up-sequence/stop`

**Permission:** Write jobs; the key's user must be a workspace owner

Closes the remaining steps; no more follow-up emails go out. Returns the object above with `steps_closed`.
