Developers
Add actions without a server
Actions in your page
Define an action in your frontend and the agent can call it. It runs in the visitor's browser, with the
session they already have in your product, so it calls your API the way your app does. There is nothing to
host and no extra sign-in. An action marked readOnly runs straight away; any other waits for
the visitor to allow it. What run returns is what the agent is told, and when it throws, the
agent is told why.
BindKit.defineAction('getOrder', {
title: 'Look up order',
description: 'Finds an order by its number.',
parameters: {
type: 'object',
properties: { number: { type: 'string', description: 'The order number' } },
required: ['number'],
},
readOnly: true,
run: async ({ number }) => (await fetch(`/api/orders/${number}`)).json(),
})
BindKit.defineAction('openSettings', {
description: 'Takes the customer to a page of their settings.',
parameters: { type: 'object', properties: { section: { type: 'string', enum: ['billing', 'payouts'] } } },
run: ({ section }) => {
location.assign(`/settings/${section}`)
return { opened: section }
},
})
In React, pass the same objects by name to <BindKit actions={{ getOrder: { ... } }} />.
The agent only uses the actions of the page the visitor is on, so define them where they make sense.
BindKit.defineAction(name, null) removes one. Page actions are not available in the sandboxed
integration yet.
The REST API you already have
In the dashboard, open APIs and add your API's base URL and the Authorization header BindKit sends. Import its operations from an OpenAPI description, JSON or YAML, or add them one by one. Each one starts switched off; turn on the ones your agents may use. GET requests only read, so they run straight away; anything else asks the visitor first.
The header usually lets BindKit act as your account, so tell your API whose data it is. For a value such
as a user ID in the path, choose Customer's user ID: BindKit fills it in from the visitor
your site signed in, the agent can't change it, and the action is only offered to signed-in visitors.
Every request also carries x-bindkit-user-id, x-bindkit-user-email and
x-bindkit-user-token, which your API can check the way an
MCP server does.