---
schema_version: "1"
id: 3918d23f64f56ac419de7974df3da7ec5167e84816ec19fea440e4957a14a677
title: Enable Activation Codes With the SPI
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/commerce-cloud/retail-cloud/guides/activation-codes-via-spi.md
canonical_url: https://developer.salesforce.com/docs/commerce/retail-cloud/guide/activation-codes-via-spi.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 5701485d9c167b5ca2f5fef428fb12e2845f90d2c6bec1e15302bfeb9598ea93
products:
  - Point of Sale for Developers
  - Salesforce APIs
---
# Enable Activation Codes With the SPI

Point of Sale supports retrieving activation codes using an SPI. For merchants selling products through digital codes (for example, product downloads), this SPI allows Point of Sale to request the code from the merchant's server. The code can then be printed on the customer's receipt.

- Modern POS App Build: 10.4.1 or greater
- Platform Support: iPad & iPhone
- Offline Support: No

**note:** For details on this SPI, see [Activation Code SPI](https://developer.salesforce.com/docs/commerce/retail-cloud/references/activation-code-spi?meta=Summary) in the Point of Sale reference documentation.

For a comprehensive list of Point of Sale APIs and SPIs, see [Point of Sale API, SPI, and Webhook Overview](https://developer.salesforce.com/docs/commerce/retail-cloud/guide/retail-cloud-api-spi-webhook-specs.html).

## Configure Product Class

1.  In CMS, go to **Products** | **Product Class**.

2.  Configure a new class for activation codes. For more information, see [Set Up Non-Merchandise SKUs](https://help.salesforce.com/s/articleView?id=commerce.rt_pos_orders_custom_non_merchandise_sku.htm) in _Salesforce Help_.

3.  Turn on the **Requires Activation Code via External Source** setting.![The CMS shows the requiring activation code via external source flag.](https://developer.salesforce.com/docs/media/retail-cloud/rt-pos-orders-special-types-activation-code-product-class.png)

## Configure SPI

1.  In CMS, go to **Integrations** | **Custom Connectors.**.

2.  Click **Create**.

3.  For Connector Type, select **SPI**.

4.  For Endpoint Name, select **GENERATE_ACTIVATION_CODE**.

5.  For API Endpoint, provide the external endpoint to retrieve activation codes.

6.  For Integration Type, select **HTTP_POST**.

7.  Specify any required JSON headers. See [Point of Sale API, SPI, and Webhook Overview](https://developer.salesforce.com/docs/commerce/retail-cloud/guide/retail-cloud-api-spi-webhook-specs.html) for examples.

8.  Configure the rest of the fields as needed.

9.  Save your changes.
    ![The CMS shows SPI settings.](https://developer.salesforce.com/docs/media/retail-cloud/rt-pos-orders-special-types-activation-code-spi.png)

## Sample Request and Response

### Request

During checkout, if any product in the cart belongs to a Product Class with Requires Activation Code via External Source enabled, the app makes a single call to the Activation Code SPI. The request includes the `orderId`, `storeId`, `transactionId`, and `productList`. The `productList` includes `productId` and `orderItemId`.

```java
{
  "orderId": "string",
  "storeId": "string",
  "transactionId": "1-test-20240612131829-4-1",
  "productList": [
    {
      "productId": "string",
      "orderItemId": "It can have values like 1, 2, 3, etc... which represents line item number within the order."
   }
  ]
}

```

### Response

The response provides an activation code for each product quantity, with multiple quantities of the same item returned as an array. Each activation code has a maximum length of 32 characters. The response also includes a context code, serving as a reference to the activation code, with a maximum length of 32 characters.

```java
{
  "errorMessage": "Invalid request. Please check the request and try again.",
  "errorCode": "INTERNAL_ERROR",
  "serializedUnitDetailList": [
    {
      "activationCode": "string",
      "contextCode": "string",
      "orderItemId": "string"
    }
  ],
  "error": true
}

```

## Receipts

[Print](https://developer.salesforce.com/docs/commerce/retail-cloud/guide/rt-cms-layouts-templates-receipt.html) and [Email](https://developer.salesforce.com/docs/commerce/retail-cloud/guide/rt-cms-layouts-templates-email.html) tags can be used to print the activation code on a receipt.

<table>
<col />
<col />
<thead>
  <tr>
    <th>
      Email Receipt Tag
    </th>
    <th>
      Print Receipt Tag
    </th>
  </tr>
</thead>
<tbody>
  <tr>
    <td>
      {activationCode}
    </td>
    <td>
      :ps_p_actviation_code
    </td>
  </tr>
</tbody>
</table>

![An example receipt containing an activation code.](https://developer.salesforce.com/docs/media/retail-cloud/rt-pos-orders-special-types-activation-code-receipt.png)

The activation code is only printed on receipts and isn't displayed on the POS app. However, the Order History does display the product's context code, which is a reference to the activation code.

![The POS app shows an activation code in receipt detail details.](https://developer.salesforce.com/docs/media/retail-cloud/rt-pos-orders-special-types-activation-code-pos.png)

**important:** Offline orders don't display activation codes on the receipt, as the app can't access the SPI while offline. As a result, no codes appear on the printed receipt. Once the offline order is synced successfully, and the subsequent SPI call is also successful, the order is marked as successful. The order history then reflects the context codes, and reprinting the receipt includes the activation codes.

## Known Issues and Restrictions

- Activation codes aren't eligible for returns.
- Order edits aren't supported. If an order is edited and a product with an activation code is added, it doesn't trigger the SPI to retrieve the activation code.
- POS app doesn't restrict the fulfillment type of a product with an activation code.
- Activation codes aren't displayed in the POS UI.
- Offline support isn't available for the sale of items requiring digital codes.
- This feature isn't supported for all other fulfillment types (for example, Ship to Home).
