# Webhook events

A webhook delivery is a `POST` of one event as JSON. To set up an endpoint, verify signatures and handle retries, see
[Subscribe to webhooks](https://developers.exayard.com/guides/subscribe-to-webhooks.md). The [API reference](https://developers.exayard.com/api-reference)
has each event's full schema.

## The envelope

Every event has the same envelope:

```json
{
  "id": "evt_0123456789abcdef",
  "type": "assessment.completed",
  "created": 1791201600000,
  "organizationId": "js79m7b3kfqd3vqzwx0kpcnryx7h2k4e",
  "data": { "assessmentId": "...", "projectId": "...", "organizationId": "...", "partialFailure": false }
}
```

- `id`: the event id. Retries and resends of one event keep it, so use it to ignore a repeat.
- `type`: the event type, from the table below.
- `created`: when the event happened, Unix time in milliseconds.
- `organizationId`: the company the event came from.
- `data`: the event's own fields.
- `test`: present and `true` only on a [test event](https://developers.exayard.com/guides/subscribe-to-webhooks.md#send-a-test-event), whose id starts
  with `evt_test_` and whose fields hold sample values.

## Choosing events

When you register an endpoint, list the event types it should get, or `*` for every event, including types added
later.

## Every event type

A field marked with `?` can be left out.

An estimate or bid made in a [sandbox](https://developers.exayard.com/environments.md) sends `estimate.generated` or `bid.generated` with
`"sample": true` in `data`. Other companies' events leave `sample` out.

| Event | When it is sent | Fields in `data` |
| --- | --- | --- |
| `project.created` | A project was created. | `projectId`, `organizationId`, `name` |
| `project.updated` | A project's name, status or privacy changed. | `projectId`, `organizationId`, `changes` |
| `project.archived` | A project was archived. | `projectId`, `organizationId` |
| `assessment.started` | A takeoff started measuring. | `assessmentId`, `projectId`, `organizationId` |
| `assessment.completed` | A takeoff finished measuring. | `assessmentId`, `projectId`, `organizationId`, `partialFailure`, `sample?` |
| `assessment.cancelled` | A takeoff was cancelled. | `assessmentId`, `projectId`, `organizationId` |
| `assessment.failed` | A takeoff failed. | `assessmentId`, `projectId`, `organizationId`, `error`, `failureKind?`, `deliveredOutput?` |
| `estimate.generated` | An estimate document was created. | `projectId?`, `organizationId`, `output`, `sample?` |
| `bid.generated` | A bid document was created. | `projectId?`, `organizationId`, `bidDocumentId`, `sample?` |
| `bid.submitted` | A project's bid was marked submitted. | `projectId`, `organizationId`, `bidStatus`, `bidDueDate?`, `bidValue?`, `wonLostAt?`, `bidValueHolds?` |
| `bid.won` | A project's bid was won, by hand or by the client accepting it. | `projectId`, `organizationId`, `bidStatus`, `bidDueDate?`, `bidValue?`, `wonLostAt?` |
| `bid.lost` | A project's bid was marked lost. | `projectId`, `organizationId`, `bidStatus`, `bidDueDate?`, `bidValue?`, `wonLostAt?` |
| `bid.accepted` | A client accepted a bid from its share link. | `projectId?`, `organizationId`, `documentId`, `acceptedName`, `acceptedAt`, `selectedOptions?`, `optionsTotalCents?`, `totalCents?` |
| `bid.declined` | A client declined a bid from its share link. | `projectId?`, `organizationId`, `documentId`, `declinedName`, `reason?`, `declinedAt` |
| `bid.sent` | A bid was emailed to clients from Exayard. | `documentId`, `projectId?`, `organizationId`, `recipientCount` |
| `bid.viewed` | A client opened a bid, or another shared document, from its share link. | `documentId`, `projectId?`, `organizationId`, `templateType?`, `firstView`, `viewedAt` |
| `bid.commented` | A client commented on a bid, or another shared document, from its share link. | `commentId`, `documentId`, `projectId?`, `organizationId`, `templateType?`, `authorName`, `body`, `createdAt` |
| `file.processed` | An uploaded file finished processing. A file can send this more than once. | `fileId`, `projectId?`, `organizationId` |
| `addendum.uploaded` | An uploaded plan set replaced sheets of an earlier issue. | `projectId`, `organizationId`, `findingId`, `fileId?`, `sheetCodes` |
| `quote.requested` | A supplier quote was requested. | `quoteId`, `projectId`, `vendorId`, `organizationId` |
| `quote.received` | A supplier's quote was received. | `quoteId`, `projectId`, `vendorId`, `organizationId` |
| `quote.accepted` | A supplier's quote was accepted, or (Mercateer) a customer accepted a quote. A Mercateer quote carries only quoteId. | `quoteId`, `projectId?`, `vendorId?`, `organizationId?` |
| `quote.rejected` | A supplier's quote was rejected. | `quoteId`, `projectId`, `vendorId`, `organizationId` |
| `quote.expired` | A supplier's quote expired. | `quoteId`, `projectId`, `vendorId`, `organizationId` |
| `conversation.started` | A visitor started a chat on the website widget. | `conversationId`, `widgetId`, `projectId?`, `channel` |
| `conversation.handoff_requested` | A widget chat asked for a person. | `conversationId` |
| `conversation.closed` | A widget chat was closed. | `conversationId` |
| `lead.captured` | A website widget visitor left their contact details. | `contactId`, `widgetId`, `email?`, `name?` |
| `contact.created` | A contact was created. | `contactId`, `widgetId?` |
| `appointment.booked` | An appointment was booked or confirmed. | `appointmentId`, `scheduledStart?`, `via?` |
| `appointment.rescheduled` | An appointment was moved. | `appointmentId` |
| `appointment.cancelled` | An appointment was cancelled. | `appointmentId`, `reason?` |
| `call.completed` | A phone call was analyzed, missed calls included. | `callId` |
| `call.missed` | A phone call was missed (sent together with call.completed). | `callId` |
| `review.requested` | A review request went to a customer after a finished job. | `appointmentId`, `reviewRequestId` |
| `job.written_back` | A booked appointment was created as a job in the shop's field-service software. | `appointmentId`, `provider`, `externalJobId` |
| `payment.captured` | A payment succeeded. | `paymentId`, `quoteId?`, `appointmentId?`, `amountCents` |
| `payment.failed` | A payment failed. | `paymentId`, `quoteId?`, `appointmentId?`, `amountCents` |

## Events for an app

An [app's own endpoint](https://developers.exayard.com/guides/subscribe-to-webhooks.md#webhooks-for-an-app) gets the events above from each company
that installed the app, but only those the install's scopes can read:

- `project.*`: `read:projects`
- `assessment.*`: `read:assessments`
- `estimate.generated`: `read:estimates`
- `bid.*`: `read:bids`
- `file.processed`, `addendum.uploaded`: `read:files`
- `quote.*`, `payment.*`: `read:quotes`
- `conversation.*`: `read:conversations`
- `lead.captured`, `contact.created`, `review.requested`: `read:contacts`
- `appointment.*`, `job.written_back`: `read:appointments`
- `call.*`: `read:calls`

It also gets three events about its installs: `app.installed`, `app.scopes_approved` and `app.uninstalled`.
