--- title: Consume the Case Assist API using Apex slug: '3315' canonical_url: https://docs.coveo.com/en/3315/ collection: coveo-for-salesforce source_format: adoc --- # Consume the Case Assist API using Apex > **Note** > > While this article remains available for backward compatibility purposes, we now recommend using [Coveo Quantic Case Assist components](https://docs.coveo.com/en/quantic/latest/reference/case-assist-components/) to leverage the Case Assist API. > The Quantic components can greatly simplify your implementation in general. [.version.c4sf.c4sf-edition.c4sf-pro-enterprise] [Pro and Enterprise editions](https://docs.coveo.com/en/l2590456#salesforce) > **Available since** > > This feature was introduced in the August 2020 release of Coveo for Salesforce version [4.7](https://docs.coveo.com/en/3236#august-2020-release-v4-7). The purpose of the Case Assist feature set is to improve the efficiency of customer service agents by streamlining the case creation process. It provides various tools to increase [case deflection](https://docs.coveo.com/en/2911/) and also helps end users create cases that are more accurate and complete. How can you leverage these features using Apex? The `CaseAssistApiClient` is the answer. It's a simple Apex client that lets you query the [Case Assist API](https://docs.coveo.com/en/3321/). The main advantage is that it handles all security details for you. That way, you can focus on other priorities. To query the Case Assist API, pass your [Case Assist ID](https://docs.coveo.com/en/3315#retrieving-your-case-assist-id) to the `CaseAssistApiClient` as follows: ```javascript CoveoV2.CaseAssistApiClient client = CoveoV2.CaseAssistApiClient.getClient('YOUR CASE ASSIST ID GOES HERE'); ``` If you don't already have a Case Assist configuration, see [Creating your Case Assist configuration](https://docs.coveo.com/en/3315#creating-your-case-assist-configuration). ## Creating your Case Assist configuration The preferred way of creating a Case Assist configuration is using the [Coveo Administration Console](https://docs.coveo.com/en/183/) (see [Manage Case Assist Configurations](https://docs.coveo.com/en/3328/)). However, you can also create it using the REST API, if necessary. ### Creating your Case Assist configuration using the REST API To create your Case Assist configuration, you need an access token and an organization ID. At a minimum, you're required to pass a name for your Case Assist configuration. For example: ```json { "name": "My config" } ``` You can then use the following snippet to issue a request: ```sh curl -X POST / --header 'Authorization: Bearer ' / --header 'Content-Type: application/json' / --header 'Accept: application/json' / -d '{ "name": "My config" }' / 'https://platform.cloud.coveo.com/rest/organizations//caseassists' ``` In the `Authorization` HTTP header: * Replace `` with a valid Coveo access token. See [Get your Coveo access token](https://docs.coveo.com/en/123/). In the request path: * Replace `` with the actual ID of the target Coveo organization. See [Retrieve the organization ID](https://docs.coveo.com/en/148/). ## Retrieving your Case Assist ID Once you've created your Case Assist configuration, you can [retrieve it using the Coveo Administration Console](https://docs.coveo.com/en/3328#retrieving-a-case-assist-id). You can also retrieve it using the REST API, if necessary. ### Retrieving your Case Assist ID using the REST API To find your Case Assist ID, first retrieve all the Case Assist configurations. Then, by finding the name of your Case Assist configuration, you'll be able to extract its ID. To retrieve all the Case Assist configurations: . Issue the following request: ```sh curl -X GET / --header 'Authorization: Bearer ' / --header 'Accept: application/json' / 'https://platform.cloud.coveo.com/rest/organizations//caseassists' ``` In the `Authorization` HTTP header: ** Replace `` with a valid Coveo access token. See [Get your Coveo access token](https://docs.coveo.com/en/123/). In the request path: ** Replace `` with the actual ID of the target Coveo organization. See [Retrieve the organization ID](https://docs.coveo.com/en/148/). The request returns a JSON document similar to this one: ```json { "configurations": [ { "id": "00000000-0000-0000-0000-000000000000", "name": "My config" } ], "totalCount": 1 } ``` Where: ** `00000000-0000-0000-0000-000000000000` represents your Case Assist ID. ** `My config` represents the name of your Case Assist configuration. ## Declaring the CaseAssistApiClient in Apex Once you have your Case Assist ID, you can now instantiate the `CaseAssistApiClient`. . In Salesforce, access the Developer Console. . Create the client instance as follows: ```javascript String caseAssistId = '00000000-0000-0000-0000-000000000000'; CoveoV2.CaseAssistApiClient client = CoveoV2.CaseAssistApiClient.getClient(caseAssistId); ``` > **Note** > > We strongly recommend storing the Case Assist ID in a Salesforce setting. > This will let you use different configurations in different environments. > It will also let you reference a different configuration without having to redeploy your Apex code. ## What's next? > **Available since** > > This feature was introduced in the October 2020 release of Coveo for Salesforce version [4.8](https://docs.coveo.com/en/3236#october-2020-release-v4-8). [Retrieve Case Classifications using Apex](https://docs.coveo.com/en/3325/) > **Available since** > > This feature was introduced in the August 2020 release of Coveo for Salesforce version [4.7](https://docs.coveo.com/en/3236#august-2020-release-v4-7). [Retrieve Document Suggestions using Apex](https://docs.coveo.com/en/3317/) ## Related documentation * [Manage Case Assist configurations using the Coveo Administration Console](https://docs.coveo.com/en/3328/) * [Coveo Quantic Case Assist components](https://docs.coveo.com/en/quantic/latest/reference/case-assist-components/) * [Log Case Assist events](https://docs.coveo.com/en/3437/) * [Coveo Customer Service API](https://docs.coveo.com/en/3321/)