# Save with a template

`POST /api/v1/forms/{kind}`

Saves a deal or a ticket and its open blocks in one request. **Deal:** company (created as a prospect if missing; a similar name returns `409 similar` — pick the existing record or send `confirm_new: true`), name, type, owner, value, close date; blocks product and quantity, quote (recorded in offer history), forecast, source, decision makers (`contact_ids`), trial, first tasks (`tasks`), extra fields (`cf`) and custom object links (`co`). Without stage rules the template's starting stage is used. **Ticket:** the company may be unregistered (the ticket keeps the company name), contact (`contact_id` or `contact_name` + `email` + `phone`), subject, description, type (`kind`, the template's type when empty), priority (standard resolution time; the template's time when the priority matches the template), assignee (without `assigned_to` the template's rule applies: the team member with the fewest open tickets, the account owner, the creator or a given user), category; blocks product / lot, order, project, channel, site visit (a task for the assignee) and extra fields. Without `blocks` the template's open blocks and defaults are applied. An empty required block returns `400 invalid`.

## Path parameters

| Field | Type | Description |
|---|---|---|
| `kind` (required) | string | Form. Values: `opp`, `ticket` |

## Body

| Field | Type | Description |
|---|---|---|
| `template_id` | integer | Template (`/forms/{kind}/config` → `templates[].id`); the user's default when empty. |
| `customer_id / customer` | integer / string | Company id or name (one is required for a deal). |
| `blocks` | array<string> | Open blocks (e.g. `urun`, `teklif`, `gorev`, `co:uretim_hatti`); their fields go in the body under `blocks[].fields[].k` keys (`product`, `potential_kg`, `offer_price` …). |
| `name / type / user_id / value / currency / close_date` | string | Deal core: name, type, owner, annual value, currency, close date (YYYY-MM-DD). |
| `subject / detail / kind / priority / category / assigned_to` | string | Ticket core: subject (required for a ticket), description, type, priority (`Düşük`, `Normal`, `Yüksek`, `Acil`), category, assignee. |
| `contact_ids` | array<integer> | The deal's decision makers (the company's contacts). |
| `tasks` | array | First tasks: `"Numune gönder \| 5 \| Görev"` (title \| days \| kind) or `{title, days, kind}`. |
| `cf` | object | Extra fields: `{field key: value}` (Settings › Custom fields). |
| `co` | object | Custom object links: `{object key: record id}`. |
| `confirm_new` | boolean | Create even if a similarly named company exists. |

## Response

```json 200
{
  "customer_created": false,
  "message": "Fırsat açıldı: #55 Hat 3 şişirme projesi · Alize Paketleme San. ve Tic. A.Ş.",
  "ok": true,
  "opp": {
    "bant": 0,
    "base_currency": "EUR",
    "close_date": "2027-01-04",
    "cur_sym": "€",
    "currency": "EUR",
    "customer": "Alize Paketleme San. ve Tic. A.Ş.",
    "customer_city": "İstanbul",
    "customer_id": 1,
    "days_in_stage": 0,
    "detail_status": "",
    "fc": "Pipeline",
    "health": {
      "grade": "success",
      "label": "sağlıklı",
      "score": 100
    },
    "health_color": "g",
    "health_manual": false,
    "health_note": "",
    "id": 55,
    "initials": "AP",
    "is_account": false,
    "is_open": true,
    "last_update": "2026-10-06",
    "lifetime_left": 180,
    "line": "",
    "name": "Hat 3 şişirme projesi",
    "next_step": "Karar verici / yetkili kişiyi belirle (Authority)",
    "offer_price": 1.85,
    "owner": {
      "full_name": "Deniz Aksoy",
      "id": 1,
      "role": "admin",
      "role_label": "Yönetici",
      "username": "admin"
    },
    "payment_days": 60,
    "potential_kg": 15000.0,
    "prob": 0.1,
    "probability": null,
    "product": "PU-SL 200 Solventsiz Laminasyon Yapıştırıcısı",
    "product_id": 1,
    "pu": "€/kg",
    "rid": "006ib7dvC23Bvtw",
    "sla_days": 30,
    "sla_left": 30,
    "source": "Bayi / distribütör",
    "stage": "Qualify",
    "stage_label": "Qualify",
    "start_date": "2026-10-06",
    "trend": "",
    "trend_label": "Otomatik",
    "type": "Yeni Müşteri",
    "unit": "kg",
    "unit_code": "kg",
    "value": 333000.0,
    "value_base": 333000.0,
    "value_short": "333K"
  },
  "parts": [
    "fırsat #55",
    "teklif kaydı"
  ],
  "tasks": 2,
  "template_id": 1
}
```
