> For the complete documentation index, see [llms.txt](https://docs.cubu.com/guides/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cubu.com/guides/technical-guide/webhooks/webhooks-reference/service-webhooks/before-resolve.md).

# Before Resolve

Run custom code before resolving a case.

## Overview <a href="#overview" id="overview"></a>

The webhook is triggered **before** an agent resolves a case.&#x20;

You can use this webhook to perform the following tasks:

* Modify the case fields and tags.
* Set (or remove) the case’s customer.

## API <a href="#api" id="api"></a>

### URL <a href="#url" id="url"></a>

```
[base-url]/service/actions/beforeResolved
```

### Request Body <a href="#request-body" id="request-body"></a>

The webhook receives the following input:

* **caseId**: The case ID to be created.
* **parentCaseId:** The parent case ID (when applicable).
* **referenceDate**: The case’s reference date.
* **unitId**: The ID of the service’s parent unit.
* **serviceId**: The service used for creating the case.
* **serviceCategoryId:** Service category ID.
* **serviceTypeId:** Service type ID.
* **status:** The case's current status.
* **channel:** Communication channel (Face-to-face, Video, etc.).
* **language:** The preferred communication language.
* **ticket:** The ticket number
  * **prefix**
  * **number**
  * **suffix**
* **fields:** A Dictionary of `fieldTypeId` + `fieldValue` pairs.&#x20;
* **tagIds:** An array of tag IDs (for future use).
* **customerRecordId**: The ID of the customer record linked to the case.
* **useCustomerContactInfo (bool):** Indicates whether the linked customer record's contact information (phone number and email) is used as this case's contact information.
* **contactPhoneNumber**: The case's contact phone number.
* **contactEmail**: The case's contact email.
* **triggeredByUserId:** The ID of the user who triggered this action (when applicable). The value is `null` when a Kiosk or the S2S API triggers the operation.
* **triggeredByUserEmail:** The email address of the user who triggered this action (when applicable).
* **lockedByUserId**: When an active case is resolved, this field contains the user's ID to the user processing the case. This field is null if a case is resolved while waiting or pending.
* **appointment**
  * **date**: The appointment date
  * **cuIndex**: The calendar index (“Capacity Unit Index”)
  * **start**: The appointment start time. Represented as the number of minutes past midnight.
  * **timeLocal**: The appointment’s date and time in the service’s time zone.
  * **timeUtc**: The appointment’s date and time in the UTC time zone.
  * **timeZoneId**: The appointment’s service time zone.
  * **duration**: The appointment duration (in minutes).
  * **preventSelfCheckIn**: A boolean value indicating whether the customer can check in to this appointment using the kiosk.

### Response Body <a href="#response-body" id="response-body"></a>

The webhook returns the following data:

* **fields** (optional): A Dictionary of `fieldTypeId` + `fieldValue` pairs. Allows setting the case field. Return null to keep current field values.\
  **Important!** The list of fields returned from the webhook **replaces** the existing case fields. Return all the fields you want to keep in the case record. Return `null` to keep the original fields.\
  The webhook can set any of the case’s service category fields, the contact email, and the contact phone number.
* **tagIds**: An array of tag IDs. The parameter must include only tags defined within the associated service category.\
  Return `null` to keep the original tags.
* **removeCustomer** (boolean): when True, the case's customer is removed (if applicable).
* **customerRecordId** (GUID, optional): The ID of the customer record to link to the case. When the webhook returns null, the original customer remains unchanged (unless removeCustomer is true).
* **useCustomerContactInfo** (bool): Indicates whether to use the customer's contact information for this case.
* **contactPhoneNumber**: The contact phone number for this case record. Leave null to keep the current phone number (must be null when the `useCustomerContactInfo` parameter is true).
* **contactEmail**: The contact email for this case record. Leave null to keep the current email (must be null when the `useCustomerContactInfo` parameter is true).

You can use this webhook to set the case’s **contact phone number** and **contact email** by returning the corresponding fields in the fields array.
