Crear suscripción en Asaas, con una API

Crea una suscripción para un cliente, que genera un cobro por ciclo, el primero con vencimiento en nextDueDate. Los cobros aparecen en List payments con el filtro de suscripción.

Identificador
asaas_create_subscription

La llamada

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

{
  "customer_toolkit": "<connection UUID>",
  "arguments": {
    "customer": "<customer>",
    "billingType": "BOLETO",
    "value": 1,
    "nextDueDate": "<nextDueDate>",
    "cycle": "WEEKLY"
  }
}

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
customerstringSíId of the customer who pays, starting with cus_, from List customers or Create customer.
billingTypestringSíHow the customer pays each payment. UNDEFINED lets the payer choose among the methods enabled on the account.Valores: BOLETO, PIX, CREDIT_CARD, UNDEFINED
valuenumberSíAmount of each payment, in reais, for example 19.9.
nextDueDatestringSíDue date of the first payment, in YYYY-MM-DD.
cyclestringSíHow often a payment is generated. BIWEEKLY is every two weeks and BIMONTHLY every two months.Valores: WEEKLY, BIWEEKLY, MONTHLY, BIMONTHLY, QUARTERLY, SEMIANNUALLY, YEARLY
descriptionstringNoDescription of the subscription, shown to the payer.
endDatestringNoLast due date of the subscription, in YYYY-MM-DD. Without it and maxPayments, the subscription has no end.
maxPaymentsintegerNoMaximum number of payments the subscription generates.
externalReferencestringNoIdentifier of the subscription in your own system, usable as a filter in List subscriptions.
discountobjectNoDiscount for paying each payment early.
interestobjectNoInterest for paying after the due date. Leave it out to keep the interest set on the account, because sending it overrides that setting.
fineobjectNoFine for paying after the due date. Leave it out to keep the fine set on the account, because sending it overrides that setting.

Conexiones posibles

Tu cliente conecta su cuenta de Asaas 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/asaas_create_subscription. Se convierte en la definición de tool de tu agente sin conversión.

Otras tools de Asaas

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.