{
  "openapi": "3.1.0",
  "info": {
    "title": "HelpWell REST API",
    "version": "1.0.0",
    "description": "Wire a website or app to HelpWell from its server: contacts, custom fields, tags, consent, events, form submissions, segments and newsletters, and help article updates from a coding agent. Authenticate with a workspace API key (Settings → API keys) as `Authorization: Bearer <key>`. Never call it from a browser. A key acts in its own workspace; one that was also granted other workspaces names the target with the `HelpWell-Workspace` header or the `workspace` query parameter."
  },
  "servers": [
    {
      "url": "https://app.helpwell.ai/api/v1"
    }
  ],
  "security": [
    {
      "apiKey": []
    }
  ],
  "tags": [
    {
      "name": "Contacts"
    },
    {
      "name": "Events"
    },
    {
      "name": "Forms"
    },
    {
      "name": "Segments"
    },
    {
      "name": "Newsletters"
    },
    {
      "name": "Fields"
    },
    {
      "name": "Knowledge base"
    }
  ],
  "paths": {
    "/contacts": {
      "post": {
        "tags": [
          "Contacts"
        ],
        "operationId": "upsertContact",
        "summary": "Create or update a contact",
        "description": "Creates or updates the contact for `externalId` (hosted products) or `sourceId` (a product on its own install). Attributes merge and `null` removes one. Never subscribes anyone by itself: send `subscribe` for a double opt-in email, or `consent` for a choice the person made that you recorded.",
        "security": [
          {
            "apiKey": [
              "contacts:write"
            ]
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          },
          {
            "$ref": "#/components/parameters/Workspace"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ContactUpsert"
              },
              "example": {
                "productId": "prd_7d2f19c4",
                "externalId": "user_123",
                "email": "ada@example.com",
                "name": "Ada Lovelace",
                "tags": {
                  "add": [
                    "app-user"
                  ]
                },
                "attributes": {
                  "plan": "trial",
                  "seats": 3,
                  "trial_ends": "2026-11-01"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "contact": {
                      "$ref": "#/components/schemas/Contact"
                    },
                    "subscription": {
                      "$ref": "#/components/schemas/Subscription"
                    }
                  },
                  "required": [
                    "contact"
                  ]
                },
                "example": {
                  "contact": {
                    "id": "6f1c2b8e-3d4a-4f5b-9c7d-2a1e0b9f8c3d",
                    "productId": "prd_7d2f19c4",
                    "sourceId": "con_01JBW3Q8M2",
                    "email": "ada@example.com",
                    "name": "Ada Lovelace",
                    "consent": {
                      "status": "unknown",
                      "source": null,
                      "at": null
                    },
                    "tags": [
                      "app-user"
                    ],
                    "attributes": {
                      "plan": "trial",
                      "seats": 3,
                      "trial_ends": "2026-11-01"
                    },
                    "createdAt": "2026-10-05T14:03:11.000Z",
                    "updatedAt": "2026-10-05T14:03:11.000Z"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PlanLimit"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/IdempotencyMismatch"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "get": {
        "tags": [
          "Contacts"
        ],
        "operationId": "findContacts",
        "summary": "Find contacts by email, externalId or sourceId",
        "security": [
          {
            "apiKey": [
              "contacts:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "productId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Required when the key can use more than one product."
          },
          {
            "name": "email",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "email"
            },
            "example": "ada@example.com"
          },
          {
            "name": "externalId",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Your stable user id (hosted products)."
          },
          {
            "name": "sourceId",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "A product on its own install: its contact id."
          },
          {
            "$ref": "#/components/parameters/Workspace"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Contact"
                      }
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "id": "6f1c2b8e-3d4a-4f5b-9c7d-2a1e0b9f8c3d",
                      "productId": "prd_7d2f19c4",
                      "sourceId": "con_01JBW3Q8M2",
                      "email": "ada@example.com",
                      "name": "Ada Lovelace",
                      "consent": {
                        "status": "unknown",
                        "source": null,
                        "at": null
                      },
                      "tags": [
                        "app-user"
                      ],
                      "attributes": {
                        "plan": "trial",
                        "seats": 3,
                        "trial_ends": "2026-11-01"
                      },
                      "createdAt": "2026-10-05T14:03:11.000Z",
                      "updatedAt": "2026-10-05T14:03:11.000Z"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/contacts/consent": {
      "post": {
        "tags": [
          "Contacts"
        ],
        "operationId": "setConsentInBulk",
        "summary": "Set marketing consent for many contacts",
        "description": "Sets marketing consent for contacts named by `contactIds`, `emails` or a saved `segmentId` (optionally one `productId`), with the `source` where they agreed or asked to stop. Subscribing never overrides an unsubscribe, a bounce, a spam complaint or a suppression: those contacts are skipped and counted in `skipped`. Automations triggered by Subscribed start only with `startAutomations: true`. Unsubscribing suppresses each address. Up to 1,000 contacts finish in the request (200); a larger change runs in the background (202): read its progress with GET /contacts/consent/{jobId}. Send `expected` to have the request refused (409) if the selection no longer has that many contacts.",
        "security": [
          {
            "apiKey": [
              "contacts:write"
            ]
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          },
          {
            "$ref": "#/components/parameters/Workspace"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BulkConsentInput"
              },
              "example": {
                "segmentId": "seg_123",
                "status": "subscribed",
                "source": "Existing customer, opted in at signup",
                "startAutomations": false,
                "expected": 10327
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Finished",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "job": {
                      "$ref": "#/components/schemas/ConsentJob"
                    }
                  }
                },
                "example": {
                  "job": {
                    "id": "cj_8d2f…",
                    "status": "done",
                    "consent": "subscribed",
                    "source": "API: Existing customer, opted in at signup · key hwk_ab12cd34",
                    "startAutomations": false,
                    "total": 10327,
                    "processed": 10327,
                    "changed": 10100,
                    "skipped": [
                      {
                        "reason": "unsubscribed",
                        "label": "unsubscribed earlier",
                        "count": 150
                      },
                      {
                        "reason": "bounced",
                        "label": "bounced",
                        "count": 60
                      },
                      {
                        "reason": "already_subscribed",
                        "label": "already subscribed",
                        "count": 17
                      }
                    ],
                    "skippedTotal": 227,
                    "createdAt": "2026-10-06T18:00:00Z",
                    "finishedAt": "2026-10-06T18:02:10Z"
                  }
                }
              }
            }
          },
          "202": {
            "description": "Running",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "job": {
                      "$ref": "#/components/schemas/ConsentJob"
                    }
                  }
                },
                "example": {
                  "job": {
                    "id": "cj_8d2f…",
                    "status": "running",
                    "consent": "subscribed",
                    "source": "API: Existing customer, opted in at signup · key hwk_ab12cd34",
                    "startAutomations": false,
                    "total": 10327,
                    "processed": 500,
                    "changed": 488,
                    "skipped": [
                      {
                        "reason": "unsubscribed",
                        "label": "unsubscribed earlier",
                        "count": 12
                      }
                    ],
                    "skippedTotal": 12,
                    "createdAt": "2026-10-06T18:00:00Z",
                    "finishedAt": null
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/IdempotencyMismatch"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/contacts/consent/{jobId}": {
      "parameters": [
        {
          "name": "jobId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          },
          "example": "cj_8d2f…"
        }
      ],
      "get": {
        "tags": [
          "Contacts"
        ],
        "operationId": "getConsentJob",
        "summary": "Get a bulk consent change",
        "description": "A bulk consent change’s progress and outcome: `queued`, `running`, `done` or `failed`, how many contacts it covers, changed and skipped (by reason).",
        "security": [
          {
            "apiKey": [
              "contacts:read"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "job": {
                      "$ref": "#/components/schemas/ConsentJob"
                    }
                  }
                },
                "example": {
                  "job": {
                    "id": "cj_8d2f…",
                    "status": "done",
                    "consent": "subscribed",
                    "source": "API: Existing customer, opted in at signup · key hwk_ab12cd34",
                    "startAutomations": false,
                    "total": 10327,
                    "processed": 10327,
                    "changed": 10100,
                    "skipped": [
                      {
                        "reason": "unsubscribed",
                        "label": "unsubscribed earlier",
                        "count": 150
                      },
                      {
                        "reason": "bounced",
                        "label": "bounced",
                        "count": 60
                      },
                      {
                        "reason": "already_subscribed",
                        "label": "already subscribed",
                        "count": 17
                      }
                    ],
                    "skippedTotal": 227,
                    "createdAt": "2026-10-06T18:00:00Z",
                    "finishedAt": "2026-10-06T18:02:10Z"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/Workspace"
          }
        ]
      }
    },
    "/contacts/{contactId}": {
      "parameters": [
        {
          "name": "contactId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          },
          "example": "6f1c2b8e-3d4a-4f5b-9c7d-2a1e0b9f8c3d"
        }
      ],
      "get": {
        "tags": [
          "Contacts"
        ],
        "operationId": "getContact",
        "summary": "Get a contact",
        "security": [
          {
            "apiKey": [
              "contacts:read"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "contact": {
                      "$ref": "#/components/schemas/Contact"
                    }
                  }
                },
                "example": {
                  "contact": {
                    "id": "6f1c2b8e-3d4a-4f5b-9c7d-2a1e0b9f8c3d",
                    "productId": "prd_7d2f19c4",
                    "sourceId": "con_01JBW3Q8M2",
                    "email": "ada@example.com",
                    "name": "Ada Lovelace",
                    "consent": {
                      "status": "unknown",
                      "source": null,
                      "at": null
                    },
                    "tags": [
                      "app-user"
                    ],
                    "attributes": {
                      "plan": "trial",
                      "seats": 3,
                      "trial_ends": "2026-11-01"
                    },
                    "createdAt": "2026-10-05T14:03:11.000Z",
                    "updatedAt": "2026-10-05T14:03:11.000Z"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/Workspace"
          }
        ]
      },
      "delete": {
        "tags": [
          "Contacts"
        ],
        "operationId": "deleteContact",
        "summary": "Permanently delete a contact",
        "description": "Deletes the contact and everything about them, as Contacts → Delete contact does. An unsubscribe or bounce is kept only as a salted hash.",
        "security": [
          {
            "apiKey": [
              "contacts:delete"
            ]
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          },
          {
            "$ref": "#/components/parameters/Workspace"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "deleted": {
                      "type": "boolean"
                    },
                    "id": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "deleted": true,
                  "id": "6f1c2b8e-3d4a-4f5b-9c7d-2a1e0b9f8c3d"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/IdempotencyMismatch"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/contacts/{contactId}/email-status": {
      "get": {
        "tags": [
          "Contacts"
        ],
        "operationId": "contactEmailStatus",
        "summary": "Read recent email delivery receipts and address suppression",
        "description": "Returns up to 20 messages, newest first, with provider events and suppression. Optionally restrict messages to one workflow. Provider acceptance is distinct from delivery, opens and bounces. Message bodies and private links are not returned.",
        "security": [
          {
            "apiKey": [
              "contacts:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "contactId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "workflowId",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/Workspace"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "contactId": {
                      "type": "string"
                    },
                    "checkedAt": {
                      "type": "string"
                    },
                    "suppression": {
                      "type": [
                        "object",
                        "null"
                      ]
                    },
                    "messages": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  }
                },
                "example": {
                  "contactId": "6f1c2b8e-3d4a-4f5b-9c7d-2a1e0b9f8c3d",
                  "checkedAt": "2026-10-23T16:00:00Z",
                  "suppression": null,
                  "messages": []
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/contacts/{contactId}/tags": {
      "parameters": [
        {
          "name": "contactId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          },
          "example": "6f1c2b8e-3d4a-4f5b-9c7d-2a1e0b9f8c3d"
        }
      ],
      "post": {
        "tags": [
          "Contacts"
        ],
        "operationId": "changeTags",
        "summary": "Add and remove tags",
        "security": [
          {
            "apiKey": [
              "contacts:write"
            ]
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          },
          {
            "$ref": "#/components/parameters/Workspace"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "add": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "maxLength": 40
                    },
                    "maxItems": 100,
                    "description": "Tags to add."
                  },
                  "remove": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "maxLength": 40
                    },
                    "maxItems": 100,
                    "description": "Tags to remove."
                  }
                }
              },
              "example": {
                "add": [
                  "beta"
                ],
                "remove": [
                  "trial"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "contact": {
                      "$ref": "#/components/schemas/Contact"
                    }
                  }
                },
                "example": {
                  "contact": {
                    "id": "6f1c2b8e-3d4a-4f5b-9c7d-2a1e0b9f8c3d",
                    "productId": "prd_7d2f19c4",
                    "sourceId": "con_01JBW3Q8M2",
                    "email": "ada@example.com",
                    "name": "Ada Lovelace",
                    "consent": {
                      "status": "unknown",
                      "source": null,
                      "at": null
                    },
                    "tags": [
                      "app-user",
                      "beta"
                    ],
                    "attributes": {
                      "plan": "trial",
                      "seats": 3,
                      "trial_ends": "2026-11-01"
                    },
                    "createdAt": "2026-10-05T14:03:11.000Z",
                    "updatedAt": "2026-10-05T14:03:11.000Z"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/IdempotencyMismatch"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/events": {
      "post": {
        "tags": [
          "Events"
        ],
        "operationId": "trackEvent",
        "summary": "Track an event",
        "description": "Records something a contact did. Known product telemetry names (page.visited, login.succeeded, article.viewed and the like) are kept as they are; any other name is a custom event that journeys, goals and segments match by name. Billing, email, form and journey names are reserved. Events can start active journeys.",
        "security": [
          {
            "apiKey": [
              "events:write"
            ]
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          },
          {
            "$ref": "#/components/parameters/Workspace"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EventInput"
              },
              "example": {
                "productId": "prd_7d2f19c4",
                "externalId": "user_123",
                "name": "project_created",
                "id": "project-981",
                "data": {
                  "template": "blank",
                  "collaborators": 2
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Already recorded with this id",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EventResult"
                }
              }
            }
          },
          "201": {
            "description": "Recorded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EventResult"
                },
                "example": {
                  "event": {
                    "id": "project-981",
                    "name": "project_created",
                    "contactId": "6f1c2b8e-3d4a-4f5b-9c7d-2a1e0b9f8c3d",
                    "duplicate": false
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/IdempotencyMismatch"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/forms/submit": {
      "post": {
        "tags": [
          "Forms"
        ],
        "operationId": "submitForm",
        "summary": "Submit a form",
        "description": "A form on your site, verified by your server. HelpWell applies its form rules: a ticked consent box on a form with double opt-in (the default) sends a confirmation email, and nobody is subscribed until they confirm.",
        "security": [
          {
            "apiKey": [
              "forms:write"
            ]
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          },
          {
            "$ref": "#/components/parameters/Workspace"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FormSubmission"
              },
              "example": {
                "productId": "prd_7d2f19c4",
                "formId": "newsletter",
                "formName": "Newsletter",
                "formType": "newsletter",
                "email": "ada@example.com",
                "name": "Ada Lovelace",
                "consent": {
                  "state": "granted",
                  "text": "Email me product news. Unsubscribe any time."
                },
                "page": {
                  "url": "https://example.com/blog"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Already received with this id",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FormResult"
                }
              }
            }
          },
          "201": {
            "description": "Received",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FormResult"
                },
                "example": {
                  "submission": {
                    "id": "sub_4c1d2e",
                    "status": "confirmation_sent",
                    "duplicate": false
                  },
                  "contactId": "6f1c2b8e-3d4a-4f5b-9c7d-2a1e0b9f8c3d"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/IdempotencyMismatch"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/segments": {
      "get": {
        "tags": [
          "Segments"
        ],
        "operationId": "listSegments",
        "summary": "List saved segments",
        "security": [
          {
            "apiKey": [
              "segments:read"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "count": {
                            "type": "integer"
                          },
                          "createdAt": {
                            "type": "string",
                            "format": "date-time"
                          }
                        }
                      }
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "id": "seg_trials",
                      "name": "Active trials",
                      "count": 182,
                      "createdAt": "2026-09-12T09:30:00.000Z"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/Workspace"
          }
        ]
      }
    },
    "/campaigns": {
      "get": {
        "tags": [
          "Newsletters"
        ],
        "operationId": "listCampaigns",
        "summary": "List newsletters (read-only)",
        "security": [
          {
            "apiKey": [
              "campaigns:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "draft",
                "ready",
                "scheduled",
                "sending",
                "sent",
                "cancelled"
              ]
            },
            "example": "sent"
          },
          {
            "$ref": "#/components/parameters/Workspace"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Campaign"
                      }
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "id": "cmp_october",
                      "name": "October product news",
                      "status": "sent",
                      "productId": "prd_7d2f19c4",
                      "subject": "What shipped in October",
                      "scheduledAt": "2026-10-01T15:00:00.000Z",
                      "createdAt": "2026-09-28T11:12:00.000Z",
                      "recipients": 4210
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/fields": {
      "get": {
        "tags": [
          "Fields"
        ],
        "operationId": "listFields",
        "summary": "List contact fields",
        "description": "Every contact field in the workspace: HelpWell’s own, the ones your app sends or defined in Settings → Fields and events, and the read-only ones Stripe and enrichment keep. `set` says where `POST /contacts` writes a field (`attributes.<key>`, `email`, `name`, `tags` or `consent`); null means only HelpWell or an integration writes it.",
        "security": [
          {
            "apiKey": [
              "contacts:read"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Field"
                      }
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "key": "email",
                      "label": "Email",
                      "type": "text",
                      "source": "helpwell",
                      "locked": true,
                      "set": "email"
                    },
                    {
                      "key": "seats",
                      "label": "Seats",
                      "type": "number",
                      "source": "app",
                      "locked": true,
                      "set": "attributes.seats",
                      "description": "Paid seats on the account"
                    },
                    {
                      "key": "stripe.mrr",
                      "label": "MRR",
                      "type": "number",
                      "source": "stripe",
                      "locked": true,
                      "set": null,
                      "unit": "cents"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/Workspace"
          }
        ]
      },
      "post": {
        "tags": [
          "Fields"
        ],
        "operationId": "defineField",
        "summary": "Define a custom field",
        "description": "Creates a custom field before your app sends its first value, so segments and journeys can use it now and imports follow its type. Writing a value with `POST /contacts` also creates a field (its type is guessed); defining it first locks the type. A field already locked to the same type is returned as it is (200); a different type is refused with 409, because a person chose it.",
        "security": [
          {
            "apiKey": [
              "contacts:write"
            ]
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          },
          {
            "$ref": "#/components/parameters/Workspace"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FieldInput"
              },
              "example": {
                "key": "seats",
                "label": "Seats",
                "type": "number",
                "description": "Paid seats on the account"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Already defined with this type",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "field": {
                      "$ref": "#/components/schemas/Field"
                    },
                    "created": {
                      "type": "boolean"
                    }
                  }
                },
                "example": {
                  "field": {
                    "key": "seats",
                    "label": "Seats",
                    "type": "number",
                    "source": "app",
                    "locked": true,
                    "set": "attributes.seats",
                    "description": "Paid seats on the account"
                  },
                  "created": false
                }
              }
            }
          },
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "field": {
                      "$ref": "#/components/schemas/Field"
                    },
                    "created": {
                      "type": "boolean"
                    }
                  }
                },
                "example": {
                  "field": {
                    "key": "seats",
                    "label": "Seats",
                    "type": "number",
                    "source": "app",
                    "locked": true,
                    "set": "attributes.seats",
                    "description": "Paid seats on the account"
                  },
                  "created": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/IdempotencyMismatch"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/knowledge/articles": {
      "get": {
        "tags": [
          "Knowledge base"
        ],
        "operationId": "listKnowledgeArticles",
        "summary": "Read the help articles",
        "description": "Every help article of a hosted product as its whole Markdown file, front matter included, with its collections and the screenshots articles may show. The HelpWell docs workflow gives this to your coding agent before it updates the articles.",
        "security": [
          {
            "apiKey": [
              "knowledge:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "productId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Required when the key can use more than one product.",
            "example": "prd_7d2f19c4"
          },
          {
            "$ref": "#/components/parameters/Workspace"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "product": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        }
                      }
                    },
                    "collections": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "title": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "articles": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "path": {
                            "type": "string",
                            "description": "Where the article is kept, like billing/download-invoices.md."
                          },
                          "slug": {
                            "type": "string"
                          },
                          "title": {
                            "type": "string"
                          },
                          "collection": {
                            "type": "string"
                          },
                          "description": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "published",
                              "draft"
                            ]
                          },
                          "markdown": {
                            "type": "string",
                            "description": "The whole file, front matter included."
                          }
                        }
                      }
                    },
                    "screenshots": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "ref": {
                            "type": "string",
                            "description": "How an article shows it: ![What it shows](<ref>)."
                          },
                          "path": {
                            "type": "string",
                            "description": "The page of the app it shows."
                          }
                        }
                      }
                    }
                  }
                },
                "example": {
                  "product": {
                    "id": "prd_7d2f19c4",
                    "name": "Acme"
                  },
                  "collections": [
                    {
                      "id": "billing",
                      "title": "Billing"
                    }
                  ],
                  "articles": [
                    {
                      "path": "billing/download-invoices.md",
                      "slug": "billing/download-invoices",
                      "title": "Download your invoices",
                      "collection": "billing",
                      "description": "Get a PDF of any invoice.",
                      "status": "published",
                      "markdown": "---\ntitle: Download your invoices\ndescription: Get a PDF of any invoice.\nstatus: published\n---\n\nOpen **Billing** and choose **Download**."
                    }
                  ],
                  "screenshots": [
                    {
                      "ref": "../_screenshots/billing.png",
                      "path": "/settings/billing"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/knowledge/proposals": {
      "post": {
        "tags": [
          "Knowledge base"
        ],
        "operationId": "proposeArticles",
        "summary": "Send updated and new articles",
        "description": "Up to 100 articles your coding agent wrote: `update` for an article that exists (keep its path) and `new` for one that does not. They wait in Knowledge base → Code updates for review, or are published at once when the product publishes code-driven updates automatically. Articles that did not change, and images that are neither screenshots nor already in the article, are left out. Send screenshots first.",
        "security": [
          {
            "apiKey": [
              "knowledge:write"
            ]
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "repository",
                  "proposals"
                ],
                "properties": {
                  "productId": {
                    "type": "string",
                    "description": "Required when the key can use more than one product."
                  },
                  "repository": {
                    "type": "string",
                    "description": "The repository the change is from, like acme/app."
                  },
                  "mode": {
                    "type": "string",
                    "enum": [
                      "update",
                      "build"
                    ]
                  },
                  "baseSha": {
                    "type": "string"
                  },
                  "headSha": {
                    "type": "string"
                  },
                  "agent": {
                    "type": "string",
                    "description": "Who wrote them, like claude-code or codex."
                  },
                  "summary": {
                    "type": "string",
                    "description": "What changed for customers."
                  },
                  "proposals": {
                    "type": "array",
                    "maxItems": 100,
                    "items": {
                      "type": "object",
                      "required": [
                        "kind",
                        "path",
                        "markdown"
                      ],
                      "properties": {
                        "kind": {
                          "type": "string",
                          "enum": [
                            "update",
                            "new"
                          ]
                        },
                        "path": {
                          "type": "string",
                          "description": "<collection-folder>/<slug>.md"
                        },
                        "markdown": {
                          "type": "string",
                          "description": "The whole file: front matter, then the body."
                        },
                        "title": {
                          "type": "string"
                        },
                        "collection": {
                          "type": "string"
                        },
                        "reason": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              },
              "example": {
                "productId": "prd_7d2f19c4",
                "repository": "acme/app",
                "baseSha": "9f2c1e7",
                "headSha": "4b8d0a3",
                "mode": "update",
                "agent": "claude-code",
                "summary": "Invoices can be downloaded as CSV too.",
                "proposals": [
                  {
                    "kind": "update",
                    "path": "billing/download-invoices.md",
                    "reason": "CSV downloads are new.",
                    "markdown": "---\ntitle: Download your invoices\nstatus: published\n---\n\nOpen **Billing**, choose **Download**, then PDF or CSV."
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Filed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "batchId": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "review",
                        "published",
                        "unchanged"
                      ]
                    },
                    "proposals": {
                      "type": "integer"
                    },
                    "skipped": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                },
                "example": {
                  "batchId": "cub_5e0a",
                  "status": "review",
                  "proposals": 1,
                  "skipped": []
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/Workspace"
          }
        ]
      }
    },
    "/knowledge/screenshots": {
      "post": {
        "tags": [
          "Knowledge base"
        ],
        "operationId": "uploadScreenshot",
        "summary": "Send a screenshot",
        "description": "One PNG of up to 6 MB, base64-encoded, kept at `_screenshots/<name>.png`. Articles show it as `![What it shows](../_screenshots/<name>.png)`. Sending the same picture again changes nothing.",
        "security": [
          {
            "apiKey": [
              "knowledge:write"
            ]
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "name",
                  "png"
                ],
                "properties": {
                  "productId": {
                    "type": "string",
                    "description": "Required when the key can use more than one product."
                  },
                  "name": {
                    "type": "string",
                    "description": "Letters, digits and dashes are kept."
                  },
                  "path": {
                    "type": "string",
                    "description": "The page of the app it shows, like /settings/billing."
                  },
                  "png": {
                    "type": "string",
                    "description": "The PNG, base64-encoded."
                  }
                }
              },
              "example": {
                "productId": "prd_7d2f19c4",
                "name": "billing",
                "path": "/settings/billing",
                "png": "iVBORw0KGgo…"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Kept",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "name": {
                      "type": "string"
                    },
                    "ref": {
                      "type": "string"
                    },
                    "changed": {
                      "type": "boolean"
                    }
                  }
                },
                "example": {
                  "name": "billing",
                  "ref": "../_screenshots/billing.png",
                  "changed": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/Workspace"
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "apiKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "hwk_…",
        "description": "A workspace API key. Scopes: contacts:read (read contacts), contacts:write (write contacts), contacts:delete (delete contacts), events:write (track events), forms:write (submit forms), segments:read (read segments), campaigns:read (read newsletters), knowledge:read (read the knowledge base), knowledge:write (propose articles)."
      }
    },
    "parameters": {
      "Workspace": {
        "name": "HelpWell-Workspace",
        "in": "header",
        "required": false,
        "description": "The workspace id to act in. Default: the key’s own workspace. Only for a key that was granted access to other workspaces (Settings → API keys); otherwise 403 workspace_not_allowed. The `workspace` query parameter does the same.",
        "schema": {
          "type": "string"
        }
      },
      "IdempotencyKey": {
        "name": "Idempotency-Key",
        "in": "header",
        "required": false,
        "description": "A unique value per logical write (1 to 200 visible ASCII characters). A retry with the same key and body gets the first answer for 24 hours; the same key with another body is refused with 422.",
        "schema": {
          "type": "string",
          "maxLength": 200
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Bad Request",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Unauthorized",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "PlanLimit": {
        "description": "Plan Limit",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Forbidden": {
        "description": "Forbidden",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "NotFound": {
        "description": "Not Found",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Conflict": {
        "description": "Conflict",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "IdempotencyMismatch": {
        "description": "Idempotency Mismatch",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "RateLimited": {
        "description": "Rate Limited",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Error": {
        "description": "Error",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error",
          "requestId"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string",
                "description": "unauthorized, insufficient_scope, workspace_not_allowed, workspace_conflict, product_not_allowed, product_required, validation_failed, invalid_json, contact_required, contact_not_found, ambiguous_contact, reserved_event, event_too_large, opted_out, suppressed, plan_limit, workspace_inactive, idempotency_mismatch, idempotency_in_progress, rate_limited, not_found, conflict, internal…"
              },
              "message": {
                "type": "string"
              },
              "details": {}
            }
          },
          "requestId": {
            "type": "string"
          }
        }
      },
      "Contact": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "HelpWell’s contact id."
          },
          "productId": {
            "type": "string",
            "description": "Required when the key can use more than one product."
          },
          "sourceId": {
            "type": "string",
            "description": "The product’s own contact id."
          },
          "email": {
            "type": [
              "string",
              "null"
            ]
          },
          "name": {
            "type": [
              "string",
              "null"
            ]
          },
          "consent": {
            "type": "object",
            "properties": {
              "status": {
                "type": "string",
                "enum": [
                  "unknown",
                  "subscribed",
                  "unsubscribed"
                ]
              },
              "source": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "at": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              }
            }
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "attributes": {
            "type": "object",
            "additionalProperties": true
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "ContactUpsert": {
        "type": "object",
        "additionalProperties": false,
        "description": "Send exactly one identity: externalId, sourceId or prospectId. Prospects are CRM-only leads, never authenticated users, and require explicit consent or double opt-in to subscribe.",
        "properties": {
          "productId": {
            "type": "string",
            "description": "Required when the key can use more than one product."
          },
          "externalId": {
            "type": "string",
            "description": "Your stable user id; the same as the widget identity’s sub.",
            "maxLength": 200
          },
          "sourceId": {
            "type": "string",
            "description": "For a product on its own install: its contact id.",
            "maxLength": 150
          },
          "prospectId": {
            "type": "string",
            "description": "Stable pre-account lead id. Use the returned contact.id for events. A later account with the same email preserves this contact and its history.",
            "maxLength": 140
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "name": {
            "type": "string",
            "maxLength": 200
          },
          "attributes": {
            "type": "object",
            "description": "Custom fields: strings, numbers, booleans or lists of strings; null removes one. Up to 100.",
            "additionalProperties": true
          },
          "tags": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "add": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "maxItems": 100
              },
              "remove": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "maxItems": 100
              }
            }
          },
          "subscribe": {
            "type": "object",
            "description": "Send a double opt-in confirmation email. Needs email marketing.",
            "additionalProperties": false,
            "required": [
              "method"
            ],
            "properties": {
              "method": {
                "const": "double_opt_in"
              },
              "consentText": {
                "type": "string",
                "description": "The words beside the box they ticked.",
                "maxLength": 1000
              }
            }
          },
          "consent": {
            "type": "object",
            "description": "A choice the person made that you recorded. Subscribing needs when they agreed; existing opt-outs and suppressions always win.",
            "additionalProperties": false,
            "required": [
              "status",
              "source"
            ],
            "properties": {
              "status": {
                "type": "string",
                "enum": [
                  "subscribed",
                  "unsubscribed"
                ]
              },
              "source": {
                "type": "string",
                "description": "Where they made the choice.",
                "maxLength": 200
              },
              "timestamp": {
                "type": "string",
                "description": "When they made it. Required to subscribe.",
                "format": "date-time"
              },
              "text": {
                "type": "string",
                "description": "The wording they agreed to.",
                "maxLength": 1000
              }
            }
          },
          "phone": {
            "type": "string",
            "description": "A mobile number in E.164 form, like +15551234567. Ten-digit numbers are taken as US numbers.",
            "maxLength": 40
          },
          "smsConsent": {
            "type": "object",
            "description": "Express consent to journey texts for this product, recorded with the exact words they agreed to. A phone number alone is never consent. STOP always wins.",
            "additionalProperties": false,
            "required": [
              "status"
            ],
            "properties": {
              "status": {
                "type": "string",
                "enum": [
                  "subscribed",
                  "unsubscribed"
                ]
              },
              "text": {
                "type": "string",
                "description": "The exact consent words beside the box they ticked. Required to subscribe.",
                "maxLength": 2000
              },
              "version": {
                "type": "string",
                "description": "Your version of that wording.",
                "maxLength": 100
              },
              "source": {
                "type": "string",
                "description": "Where they agreed, such as signup-form.",
                "maxLength": 100
              },
              "timestamp": {
                "type": "string",
                "description": "When they agreed. Defaults to now.",
                "format": "date-time"
              }
            }
          }
        }
      },
      "BulkConsentInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "status",
          "source"
        ],
        "properties": {
          "contactIds": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "maxItems": 10000,
            "description": "These contacts (HelpWell ids)."
          },
          "emails": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "email"
            },
            "maxItems": 10000,
            "description": "Every contact with one of these addresses."
          },
          "segmentId": {
            "type": "string",
            "description": "Everyone in this saved segment."
          },
          "productId": {
            "type": "string",
            "description": "Only this product’s contacts."
          },
          "status": {
            "type": "string",
            "enum": [
              "subscribed",
              "unsubscribed"
            ]
          },
          "source": {
            "type": "string",
            "description": "Where these people agreed, or asked to stop.",
            "minLength": 5,
            "maxLength": 400
          },
          "startAutomations": {
            "type": "boolean",
            "default": false,
            "description": "Start automations triggered by Subscribed for the contacts subscribed."
          },
          "expected": {
            "type": "integer",
            "minimum": 0,
            "description": "Refuse (409) unless the selection has exactly this many contacts."
          }
        }
      },
      "ConsentJob": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "running",
              "done",
              "failed"
            ]
          },
          "consent": {
            "type": "string",
            "enum": [
              "subscribed",
              "unsubscribed"
            ]
          },
          "source": {
            "type": "string"
          },
          "startAutomations": {
            "type": "boolean"
          },
          "total": {
            "type": "integer"
          },
          "processed": {
            "type": "integer"
          },
          "changed": {
            "type": "integer"
          },
          "skipped": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "reason": {
                  "type": "string",
                  "enum": [
                    "already_subscribed",
                    "already_unsubscribed",
                    "unsubscribed",
                    "bounced",
                    "complained",
                    "suppressed",
                    "no_email",
                    "removed"
                  ]
                },
                "label": {
                  "type": "string"
                },
                "count": {
                  "type": "integer"
                }
              }
            }
          },
          "skippedTotal": {
            "type": "integer"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "finishedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Subscription": {
        "type": "object",
        "properties": {
          "method": {
            "type": "string",
            "enum": [
              "double_opt_in",
              "consent"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "confirmation_sent",
              "pending_confirmation",
              "received",
              "subscribed",
              "unsubscribed",
              "already_subscribed"
            ]
          }
        }
      },
      "EventInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "name"
        ],
        "properties": {
          "productId": {
            "type": "string",
            "description": "Required when the key can use more than one product."
          },
          "contactId": {
            "type": "string"
          },
          "externalId": {
            "type": "string"
          },
          "sourceId": {
            "type": "string"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "id": {
            "type": "string",
            "description": "A stable id for this occurrence; a repeat is recorded once.",
            "pattern": "^[A-Za-z0-9_.:-]{1,100}$"
          },
          "name": {
            "type": "string",
            "pattern": "^[A-Za-z][A-Za-z0-9_.:-]{0,79}$"
          },
          "data": {
            "type": "object",
            "description": "Up to 50 keys and 8 KB of JSON.",
            "additionalProperties": true
          }
        }
      },
      "EventResult": {
        "type": "object",
        "properties": {
          "event": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "contactId": {
                "type": "string"
              },
              "duplicate": {
                "type": "boolean"
              }
            }
          }
        }
      },
      "FormSubmission": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "formId",
          "formName",
          "email"
        ],
        "properties": {
          "productId": {
            "type": "string",
            "description": "Required when the key can use more than one product."
          },
          "id": {
            "type": "string",
            "description": "A stable id for this submission.",
            "pattern": "^[A-Za-z0-9_.:-]{1,120}$"
          },
          "formId": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_.:-]{1,120}$"
          },
          "formName": {
            "type": "string",
            "maxLength": 200
          },
          "formType": {
            "type": "string",
            "description": "contact, newsletter, lead_magnet, waitlist, webinar, feedback, custom and so on.",
            "pattern": "^[a-z_]{1,40}$"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "name": {
            "type": "string"
          },
          "externalId": {
            "type": "string"
          },
          "sourceId": {
            "type": "string"
          },
          "fields": {
            "type": "object",
            "additionalProperties": true
          },
          "attributes": {
            "type": "object",
            "additionalProperties": true
          },
          "consent": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "state"
            ],
            "properties": {
              "state": {
                "type": "string",
                "enum": [
                  "granted",
                  "denied",
                  "none"
                ]
              },
              "text": {
                "type": [
                  "string",
                  "null"
                ],
                "maxLength": 2000
              }
            }
          },
          "page": {
            "type": "object",
            "properties": {
              "url": {
                "type": "string"
              },
              "path": {
                "type": "string"
              }
            }
          },
          "referrer": {
            "type": "string"
          },
          "utm": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "submittedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "FormResult": {
        "type": "object",
        "properties": {
          "submission": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "status": {
                "type": "string",
                "enum": [
                  "received",
                  "subscribed",
                  "pending_confirmation",
                  "confirmation_sent",
                  "confirmed",
                  "expired"
                ]
              },
              "duplicate": {
                "type": "boolean"
              }
            }
          },
          "contactId": {
            "type": "string"
          }
        }
      },
      "Field": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string",
            "description": "The field’s key: `seats`, or `stripe.mrr` for a Stripe field."
          },
          "label": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": [
              "text",
              "number",
              "money",
              "date",
              "boolean",
              "list",
              "event"
            ]
          },
          "source": {
            "type": "string",
            "description": "Who writes it.",
            "enum": [
              "helpwell",
              "app",
              "stripe",
              "leadfuze",
              "computed"
            ]
          },
          "locked": {
            "type": "boolean",
            "description": "Locked by a person or fixed by HelpWell; otherwise guessed."
          },
          "set": {
            "type": [
              "string",
              "null"
            ],
            "description": "Where POST /contacts writes it: attributes.<key>, email, name, tags or consent. Null: read-only."
          },
          "unit": {
            "type": "string",
            "description": "Stripe’s units: cents, or Unix seconds."
          },
          "description": {
            "type": "string"
          }
        }
      },
      "FieldInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "key",
          "label",
          "type"
        ],
        "properties": {
          "key": {
            "type": "string",
            "description": "A letter, then letters, digits or underscores; 60 at most.",
            "pattern": "^[a-zA-Z][a-zA-Z0-9_]{0,59}$"
          },
          "label": {
            "type": "string",
            "description": "What people see in HelpWell.",
            "maxLength": 80
          },
          "type": {
            "type": "string",
            "enum": [
              "text",
              "number",
              "money",
              "date",
              "boolean",
              "list",
              "event"
            ]
          },
          "description": {
            "type": "string",
            "maxLength": 300
          }
        }
      },
      "Campaign": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "ready",
              "scheduled",
              "sending",
              "sent",
              "cancelled"
            ]
          },
          "productId": {
            "type": [
              "string",
              "null"
            ]
          },
          "subject": {
            "type": [
              "string",
              "null"
            ]
          },
          "scheduledAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "recipients": {
            "type": [
              "integer",
              "null"
            ]
          }
        }
      }
    }
  }
}