# Apex Class

You can know more about Apex class [here](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_dev_guide.htm). To Create an Apex Class

* Click on settings icon

![](/files/-MXYie9g0exx2OM2U_Jc)

* Then click on Setup option from the dropdown

![](/files/-MXYj0n9LyhiRAM_Qxns)

* Search for Apex Classes option and click on it

![](/files/-MXXfqhyorewCdeU82VB)

* Click on New button

![](/files/-MXYjUnecx65udp3Uzm8)

* Copy and paste the below code snippet. The code snippet checks the Salesforce data and if there is any change/update in the customer information then it updates to CustomFit

```
public class CustomFitWebHook {
    
  public static String jsonContent(List<Object> triggerNew, List<Object> triggerOld) {
    String newObjects = '[]';
    if (triggerNew != null) {
      newObjects = JSON.serialize(triggerNew);
    }
    String oldObjects = '[]';
    if (triggerOld != null) {
      oldObjects = JSON.serialize(triggerOld);
    }
    String userId = JSON.serialize(UserInfo.getUserId());
    String instanceURL = JSON.serialize(URL.getOrgDomainUrl().toExternalForm());


    String content = '{"new": ' + newObjects + ', "old": ' + oldObjects + ', "userId": ' + userId + ', "instanceURL": ' + instanceURL + '}';
    return content;
  }
  @future(callout=true) public static void callout(String content) {
    Http h = new Http();
    HttpRequest req = new HttpRequest();
    req.setEndpoint('https://api.customfit.ai/v1/salesforce/webhooks');
    req.setMethod('POST');
    req.setHeader('Content-Type', 'application/json');
    req.setBody(content);
    h.send(req);
  }
}

```

* Click on Save button

![](/files/-MXYk2mqj5rtSUwrbbwh)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doc.customfit.ai/integrations/salesforce/apex-class.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
