Criar assinatura no Asaas, por uma API

Cria uma assinatura para um cliente, que gera uma cobrança por ciclo, a primeira com vencimento em nextDueDate. As cobranças aparecem em List payments com o filtro de assinatura.

Identificador
asaas_create_subscription

A chamada

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

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
customerstringSimId of the customer who pays, starting with cus_, from List customers or Create customer.
billingTypestringSimHow the customer pays each payment. UNDEFINED lets the payer choose among the methods enabled on the account.Valores: BOLETO, PIX, CREDIT_CARD, UNDEFINED
valuenumberSimAmount of each payment, in reais, for example 19.9.
nextDueDatestringSimDue date of the first payment, in YYYY-MM-DD.
cyclestringSimHow often a payment is generated. BIWEEKLY is every two weeks and BIMONTHLY every two months.Valores: WEEKLY, BIWEEKLY, MONTHLY, BIMONTHLY, QUARTERLY, SEMIANNUALLY, YEARLY
descriptionstringNãoDescription of the subscription, shown to the payer.
endDatestringNãoLast due date of the subscription, in YYYY-MM-DD. Without it and maxPayments, the subscription has no end.
maxPaymentsintegerNãoMaximum number of payments the subscription generates.
externalReferencestringNãoIdentifier of the subscription in your own system, usable as a filter in List subscriptions.
discountobjectNãoDiscount for paying each payment early.
interestobjectNãoInterest for paying after the due date. Leave it out to keep the interest set on the account, because sending it overrides that setting.
fineobjectNãoFine for paying after the due date. Leave it out to keep the fine set on the account, because sending it overrides that setting.

Conexões possíveis

O seu cliente conecta a conta do Asaas 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/asaas_create_subscription. Ele vira a definição de tool do seu agente sem conversão.

Outras tools do Asaas

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.