--- name: Syncro API plumbing — headers, endpoints, response shapes, idempotency description: Technical mechanics for talking to the Syncro API — required Content-Type header, the no-idempotency rule (always GET before retry), response wrappers, the add_line_item endpoint shape, HTML rendering, and the (now historical) timer_entry response shape. metadata: type: feedback --- Rules only. Incident detail, verbatim quotes, ticket numbers, and dates live in [[feedback_syncro_history]] — read on-demand when judging an edge case. Billing/product rules: [[feedback_syncro_billing]]. Workflow rules: [[feedback_syncro_workflow]]. --- ## 1. Content-Type header is required on every POST/PUT Always include `-H "Content-Type: application/json"`. Without it, curl sends `application/x-www-form-urlencoded` and Syncro returns a **400 HTML page** (not JSON). Applies to comments, tickets, line items, estimates, updates. Ticket comment payloads also need the `subject` field: ```json {"subject":"...","body":"...","hidden":true,"do_not_email":true} ``` --- ## 2. No idempotency — ALWAYS GET before retrying any POST Syncro has **no idempotency on any endpoint**. One `POST` always creates one record, regardless of whether the client saw an error. A jq parse error, curl error, timeout, or weird-looking response does NOT mean the POST failed — verify first. **Verification before retry:** - Comments: `GET /tickets/{id}` and search `.ticket.comments[] | select(.subject == "…")`. Check ALL comments, not just `[-3:]`. - Tickets: `GET /customers/{id}/tickets` before retrying. - Line items: `GET /tickets/{id}` → `.ticket.line_items[]`. **Response wrappers — CRITICAL for jq:** - `POST /tickets` → `{"ticket": {...}}` → use `.ticket.id`. - `POST /comment` → `{"comment": {...}}` → use `.comment.id`. **Hardening:** Write payload JSON to a temp file (e.g. `tmp/syncro_comment.json`) before posting. Avoids shell quoting/encoding failures that masquerade as POST failures on requests that actually succeeded. Comments cannot be deleted via API — duplicates require manual GUI removal. --- ## 3. HTML formatting in comments Use `
` for line breaks. Do **NOT** use `