Criar assinatura no Recharge, por uma API

Cria uma assinatura em um endereço de um cliente e a retorna. O produto precisa de ao menos um plano no Recharge. Os campos de frequência, a data da primeira cobrança, a variante, a quantidade e o endereço são obrigatórios.

Identificador
recharge_create_subscription

A chamada

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
  }
}

Seu sistema envia o id da conexão do cliente e os argumentos da tool. Os headers são os mesmos de toda a API do Connect: o token do seu produto e o token do cliente.

Parâmetros

As descrições dos parâmetros seguem a documentação oficial do app, em inglês.

ParâmetroTipoObrigatórioDescrição
address_idintegerSimId 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_idobjectSimProduct 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.
quantityintegerSimNumber of units in each order.
next_charge_scheduled_atstringSimDate of the first charge, as YYYY-MM-DD.
order_interval_unitstringSimUnit of the order and charge frequencies.Valores: day, week, month
order_interval_frequencyintegerSimNumber of order_interval_unit between orders, such as 1 for a monthly order.
charge_interval_frequencyintegerSimNumber 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_monthintegerNãoDay of the month the orders are created on, when order_interval_unit is month.
order_day_of_weekintegerNãoDay of the week the orders are created on, when order_interval_unit is week.
expire_after_specific_number_of_chargesintegerNãoNumber of charges after which the subscription expires. Without it, the subscription runs until it is cancelled.
pricestringNãoPrice of one unit, such as 10.00.
product_titlestringNãoName of the product.
propertiesarrayNãoLine item properties of the subscription, such as a color or an engraving text.

Conexões possíveis

O seu cliente conecta a conta do Recharge uma vez, por um dos modos abaixo. A mesma conexão serve para todas as tools do toolkit.

Chave de API

O cliente cola a chave do app numa tela do Connect, ou o seu sistema envia a chave por POST /api/customer-toolkits, sem tela.

A resposta

Em caso de sucesso, o Connect preserva o status e o corpo da resposta do app. Erros HTTP retornados pelo app usam o envelope {error, api_error}; falhas de autenticação ou validação podem ocorrer antes da execução. O header X-Toolkit-Execution-Id identifica a execução registrada, consultável em GET /api/tools/executions/{uuid}.

Pronta para agentes de IA

O input desta tool é um JSON Schema, disponível em GET /api/tools/recharge_create_subscription. Ele vira a definição de tool do seu agente sem conversão.

Outras tools do Recharge

Ver as 12 tools

Toolkits da mesma categoria

Ver os 100 toolkits

Veja o Connect aplicado ao seu produto.

Teste por 15 dias sem cartão, ou mostre seu cenário ao nosso time.