Crear suscripción en Recharge, con una API

Crea una suscripción en una dirección de un cliente y la devuelve. El producto necesita al menos un plan en Recharge. Los campos de frecuencia, la fecha del primer cargo, la variante, la cantidad y la dirección son obligatorios.

Identificador
recharge_create_subscription

La llamada

POST https://connect.reportei.com/api/tools/recharge_create_subscription/execute
Authorization: Bearer <merchant token>
x-customer-token: <customer token>
Content-Type: application/json
Accept: application/json

{
  "customer_toolkit": "<connection UUID>",
  "arguments": {
    "address_id": 1,
    "external_variant_id": {},
    "quantity": 1,
    "next_charge_scheduled_at": "<next_charge_scheduled_at>",
    "order_interval_unit": "day",
    "order_interval_frequency": 1,
    "charge_interval_frequency": 1
  }
}

Tu sistema envía el id de la conexión de tu cliente y los argumentos de la tool. Los headers son los mismos de toda la API de Connect: el token de tu producto y el token de tu cliente.

Parámetros

Las descripciones de los parámetros siguen la documentación oficial de la app, en inglés.

ParámetroTipoObligatorioDescripción
address_idintegerSíId of an address of the customer, from the addresses of Get customer with include addresses, or the address_id of a subscription in List subscriptions.
external_variant_idobjectSíProduct variant in the store platform. The variant id comes from external_variant_id of a subscription in List subscriptions, or from the product page in the store admin.
quantityintegerSíNumber of units in each order.
next_charge_scheduled_atstringSíDate of the first charge, as YYYY-MM-DD.
order_interval_unitstringSíUnit of the order and charge frequencies.Valores: day, week, month
order_interval_frequencyintegerSíNumber of order_interval_unit between orders, such as 1 for a monthly order.
charge_interval_frequencyintegerSíNumber of order_interval_unit between charges. Equal to order_interval_frequency when each order is paid on its own; a multiple of it for a prepaid subscription.
order_day_of_monthintegerNoDay of the month the orders are created on, when order_interval_unit is month.
order_day_of_weekintegerNoDay of the week the orders are created on, when order_interval_unit is week.
expire_after_specific_number_of_chargesintegerNoNumber of charges after which the subscription expires. Without it, the subscription runs until it is cancelled.
pricestringNoPrice of one unit, such as 10.00.
product_titlestringNoName of the product.
propertiesarrayNoLine item properties of the subscription, such as a color or an engraving text.

Conexiones posibles

Tu cliente conecta su cuenta de Recharge una sola vez, con uno de los modos de abajo. La misma conexión sirve para todas las tools del toolkit.

Clave de API

Tu cliente pega la clave de la app en una pantalla de Connect, o tu sistema envía la clave con POST /api/customer-toolkits, sin pantalla.

La respuesta

Si la llamada tiene éxito, Connect conserva el status y el cuerpo de la respuesta de la app. Los errores HTTP devueltos por la app usan el objeto {error, api_error}; la autenticación o validación pueden fallar antes de la ejecución. El header X-Toolkit-Execution-Id identifica la ejecución registrada, disponible en GET /api/tools/executions/{uuid}.

Lista para agentes de IA

El input de esta tool es un JSON Schema, disponible en GET /api/tools/recharge_create_subscription. Se convierte en la definición de tool de tu agente sin conversión.

Otras tools de Recharge

Ver las 12 tools

Toolkits de la misma categoría

Ver los 100 toolkits

Mira Connect aplicado a tu producto.

Pruébalo durante 15 días sin tarjeta, o cuéntale tu caso a nuestro equipo.