# Get Catalog Information

Return data from the specified catalog. If you omit the catalog ID, this API returns data from root catalogs. By default, all catalog data is returned in the results.

```nolang
GET /v2/cpq/catalogs?catalogId={catalog_ID}&ContextId={cart_ID}
```

For root catalogs, you can paginate the results to minimize client wait time by returning the data in a series of chunks (child catalogs are not paginated). To loop through paginated results, issue the first GET call, use the data returned in the **action** field to compose subsequent GET calls, and looping until the **action** field is empty, which indicates that the last page has been returned.

To override the default page size of 20, create a new record on the object named `VlocityAPIMetadata` and set the field `vlocity_cmt\_\_APIName\_\_c` to `getCatalogHierarchy`. In the field named `vlocity_cmt\_\_APIParams\_\_c`, add a key-value pair specified in curly brackets with the key set to `pagesize` and value set to the desired default page size (for example: {"pagesize":100}).

By default, root catalogs are returned sorted by ID. To retrieve root catalogs in a specific order, set the sortBy parameter to a comma-separated list of fields to be used to sort the results.

If the ContextId parameter is specified, the API returns the action and parameters required to retrieve the catalog products.

This API supports the guest user enhancements that Salesforce introduced with the Winter ‘21 release. To encrypt and decrypt data for guest users, use the `UserSecurity` class with this API. See Guest User Technical Details.

For additional information, ​see UserSecurity Class and CPQ and Digital Commerce Changes for Guest Users.

## Remote Method

```nolang
getCatalogHierarchy
```

## REST Handler

```nolang
APICatalogsCpqV2
```

## Apex Remote Service

```nolang
CpqAppHandler
```

## Apex Remote Input Map

```nolang
{
  "methodName": "getCatalogHierarchy",
  "catalogId": "a1T36000000j2lB",
  "cartId":"80136000000S4kq",
}
```

## Package

Communication (vlocity_cmt)

## API Parameters and Response Format

For API parameter names and descriptions, see [Cart-Based API Swagger Reference](https://developer.salesforce.com/docs/industries/cme/references/cpq?meta=Summary).

## Resource Information

| Response Format | JSON                                                                                        |
| --------------- | ------------------------------------------------------------------------------------------- |
| Resource URL    | `/services/apexrest/{namespace}/v2/cpq/catalogs?catalogId={catalog_ID}&ContextId={cart_ID}` |

## Examples

:::note
Retrieve All Root Catalogs

```nolang
GET /services/apexrest/vlocity_cmt/v2/cpq/catalogs
```
:::

:::note
Response

```nolang
{
  "totalSize": 2,
  "records": [
    {
      "displaySequence": -1,
      "attributes": {
        "type": "vlocity_cmt__Catalog__c",
        "url": "/services/data/v42.0/sobjects/vlocity_cmt__Catalog__c/a0D0a00000Ges3cEAB"
      },
      "Id": "a0D0a00000Ges3cEAB",
      "OwnerId": "0050a00000JIgxVAAT",
      "IsDeleted": false,
      "Name": "First",
      "CreatedDate": "2018-03-01T04:31:50.000+0000",
      "CreatedById": "0050a00000JIgxVAAT",
      "LastModifiedDate": "2018-03-01T04:59:18.000+0000",
      "LastModifiedById": "0050a00000JIgxVAAT",
      "SystemModstamp": "2018-03-03T01:04:14.000+0000",
      "LastViewedDate": "2018-03-05T11:06:51.000+0000",
      "LastReferencedDate": "2018-03-05T11:06:51.000+0000",
      "vlocity_cmt__CatalogCode__c": "Catalog_f",
      "vlocity_cmt__GlobalKey__c": "55d205fa-9271-c00f-1d33-8a21c62490ef",
      "vlocity_cmt__IsActive__c": true,
      "vlocity_cmt__IsCatalogRoot__c": true,
      "catalogId": "a0D0a00000Ges3cEAB",
      "catalogName": "First"
    },
    {
      "displaySequence": -1,
      "attributes": {
        "type": "vlocity_cmt__Catalog__c",
        "url": "/services/data/v42.0/sobjects/vlocity_cmt__Catalog__c/a0D0a00000Ges3hEAB"
      },
      "Id": "a0D0a00000Ges3hEAB",
      "OwnerId": "0050a00000JIgxVAAT",
      "IsDeleted": false,
      "Name": "Second",
      "CreatedDate": "2018-03-01T04:32:18.000+0000",
      "CreatedById": "0050a00000JIgxVAAT",
      "LastModifiedDate": "2018-03-01T04:59:40.000+0000",
      "LastModifiedById": "0050a00000JIgxVAAT",
      "SystemModstamp": "2018-03-03T01:04:14.000+0000",
      "LastViewedDate": "2018-03-01T08:12:34.000+0000",
      "LastReferencedDate": "2018-03-01T08:12:34.000+0000",
      "vlocity_cmt__GlobalKey__c": "85057565-e71e-2d6e-3713-3cd437750bcb",
      "vlocity_cmt__IsActive__c": true,
      "vlocity_cmt__IsCatalogRoot__c": true,
      "catalogId": "a0D0a00000Ges3hEAB",
      "catalogName": "Second"
    }
  ]
}
```
:::

:::note
Retrieve First Root Catalog

No sort order is specified in the following request:

```nolang
GET /services/apexrest/vlocity_cmt/v2/cpq/catalogs?pagesize=1
```
:::

:::note
Response

```nolang
{
  "totalSize": 1,
  "actions": {
    "nextcatalogs": {
      "rest": {
        "params": {},
        "method": "GET",
        "link": "/services/apexrest/vlocity_cmt/v2/cpq/catalogs/?offsetSize=1&pagesize=1&includeProducts=false"
      },
      "remote": {
        "params": {
          "includeProducts": false,
          "pagesize": 1,
          "offsetSize": 1,
          "methodName": "getCatalog"
        }
      },
      "client": {
        "params": {}
      }
    }
  },
  "records": [
    {
      "displaySequence": -1,
      "attributes": {
        "type": "vlocity_cmt__Catalog__c",
        "url": "/services/data/v42.0/sobjects/vlocity_cmt__Catalog__c/a0D0a00000Ges3cEAB"
      },
      "Id": "a0D0a00000Ges3cEAB",
      "OwnerId": "0050a00000JIgxVAAT",
      "IsDeleted": false,
      "Name": "First",
      "CreatedDate": "2018-03-01T04:31:50.000+0000",
      "CreatedById": "0050a00000JIgxVAAT",
      "LastModifiedDate": "2018-03-01T04:59:18.000+0000",
      "LastModifiedById": "0050a00000JIgxVAAT",
      "SystemModstamp": "2018-03-03T01:04:14.000+0000",
      "LastViewedDate": "2018-03-05T11:06:51.000+0000",
      "LastReferencedDate": "2018-03-05T11:06:51.000+0000",
      "vlocity_cmt__CatalogCode__c": "Catalog_f",
      "vlocity_cmt__GlobalKey__c": "55d205fa-9271-c00f-1d33-8a21c62490ef",
      "vlocity_cmt__IsActive__c": true,
      "vlocity_cmt__IsCatalogRoot__c": true,
      "catalogId": "a0D0a00000Ges3cEAB",
      "catalogName": "First"
    }
  ]
}
```
:::

:::note
Retrieve All Root Catalogs Sorted by Name

```nolang
/services/apexrest/vlocity_cmt/v2/cpq/catalogs?sortBy=Name_ASC
```
:::

:::note
Response

```nolang
{
  "totalSize": 2,
  "records": [
    {
      "displaySequence": -1,
      "attributes": {
        "type": "vlocity_cmt__Catalog__c",
        "url": "/services/data/v42.0/sobjects/vlocity_cmt__Catalog__c/a0D0a00000Ges3hEAB"
      },
      "Id": "a0D0a00000Ges3hEAB",
      "OwnerId": "0050a00000JIgxVAAT",
      "IsDeleted": false,
      "Name": "Second",
      "CreatedDate": "2018-03-01T04:32:18.000+0000",
      "CreatedById": "0050a00000JIgxVAAT",
      "LastModifiedDate": "2018-03-01T04:59:40.000+0000",
      "LastModifiedById": "0050a00000JIgxVAAT",
      "SystemModstamp": "2018-03-03T01:04:14.000+0000",
      "LastViewedDate": "2018-03-01T08:12:34.000+0000",
      "LastReferencedDate": "2018-03-01T08:12:34.000+0000",
      "vlocity_cmt__GlobalKey__c": "85057565-e71e-2d6e-3713-3cd437750bcb",
      "vlocity_cmt__IsActive__c": true,
      "vlocity_cmt__IsCatalogRoot__c": true,
      "catalogId": "a0D0a00000Ges3hEAB",
      "catalogName": "Second"
    },
    {
      "displaySequence": -1,
      "attributes": {
        "type": "vlocity_cmt__Catalog__c",
        "url": "/services/data/v42.0/sobjects/vlocity_cmt__Catalog__c/a0D0a00000Ges3cEAB"
      },
      "Id": "a0D0a00000Ges3cEAB",
      "OwnerId": "0050a00000JIgxVAAT",
      "IsDeleted": false,
      "Name": "First",
      "CreatedDate": "2018-03-01T04:31:50.000+0000",
      "CreatedById": "0050a00000JIgxVAAT",
      "LastModifiedDate": "2018-03-01T04:59:18.000+0000",
      "LastModifiedById": "0050a00000JIgxVAAT",
      "SystemModstamp": "2018-03-03T01:04:14.000+0000",
      "LastViewedDate": "2018-03-05T11:06:51.000+0000",
      "LastReferencedDate": "2018-03-05T11:06:51.000+0000",
      "vlocity_cmt__CatalogCode__c": "Catalog_f",
      "vlocity_cmt__GlobalKey__c": "55d205fa-9271-c00f-1d33-8a21c62490ef",
      "vlocity_cmt__IsActive__c": true,
      "vlocity_cmt__IsCatalogRoot__c": true,
      "catalogId": "a0D0a00000Ges3cEAB",
      "catalogName": "First"
    }
  ]
}
```
:::
