Types of Actions

There are two types of API Extension actions: HTTP actions and Embedded actions.

HTTP Actions

These actions act on the HTTP request-response protocol associated with an API endpoint. That is, they occur before and after an API operation executes, and you can use them to modify the request or response associated with the operation.

You can identify an HTTP action by the 'http' prefix.

HTTP Action OccurrenceRequestResponse
before

Read/Write

These actions can read and write the incoming HTTP request.

Write

These actions can shortcut the response and provide their own response or add response headers that persist through the operation. They cannot read the response because it is blank at this stage of the process.

after

Read

These actions can read the request but cannot modify it.

Read/Write

These actions can read and write the response generated by Kibo.

The following example read/writes the HTTP response after the ChangePassword API operation runs:

  • http.commerce.customer.accounts.changePassword.after

HTTP actions also include storefront HTTP actions, which don't correspond to an API operation, but instead run before or after a shopper requests a specific page on your storefront, such as the checkout page, the My Account page, a CMS page, etc.

Embedded Actions

These actions retrieve information about and respond to Kibo microservice operations. They might, for example, provide you access to the microservice that manages orders, or the microservice that manages carts. In addition to providing read access to the microservice object, these actions provide special exec methods that allow you to manipulate the microservice object in predetermined ways. The exact methods provided vary depending on the type of action and the object in question. In general, embedded actions with a before occurrence run when the request for the microservice is made, and can persist changes to Kibo. Actions with an after occurrence run after the microservice operation completes, and cannot persist changes to Kibo (but are suitable for monitoring or and other information-gathering tasks).

You can identify an embedded action by the 'embedded' prefix.

The following example runs when a request to add an item to a cart is made:

  • embedded.commerce.carts.addItem.before