DesenvolvedoresReferência da APIAssinaturas

Cancelar assinatura

POST
/subscriptions/{subscriptionId}/cancel

Cancela a assinatura. period_end (padrão) mantém o acesso até o fim do período já pago; immediately encerra agora, revoga os benefícios e cancela as faturas em aberto. Com fatura vencida, só immediately é aceito. Em ambos, a cobrança no gateway para.

Chave: Só chave secreta (chamada pelo servidor).

Escopo: subscriptions:write.

Idempotência: aceita o cabeçalho Idempotency-Key.

Autorização

chaveSecreta
headerAutorizaçãoBearer <chave de API>

Chave secreta (sk_…). Use só no servidor; requisições de navegador (com Origin) são recusadas.

Parâmetros de caminho

subscriptionId*string
Formatouuid

Cabeçalhos

Idempotency-Key?string

De 1 a 255 caracteres visíveis. Repetir a chamada com a mesma chave devolve a mesma resposta por 24 horas.

Corpo da requisição

application/json
  1. body
mode?string

period_end: o cliente mantém o acesso até o fim do período pago. immediately: encerra agora e revoga os benefícios.

Padrão"period_end"
Value in"period_end""immediately"
reason?string
Tamanholength <= 500

Corpo da resposta

Sucesso.

application/json
  1. response
data*
meta*
curl -X POST 'https://minepag.com.br/api/v1/subscriptions/497f6eca-6276-4993-bfeb-53cbbbba6f08/cancel' \  -H 'Content-Type: application/json' \  -d '{}'
{  "data": {    "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",    "status": "pending",    "billingMode": "provider_managed",    "customer": {      "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",      "email": "string",      "name": "string"    },    "productId": "dcd53ddb-8104-4e48-8cc0-5df1088c6113",    "productName": "string",    "priceId": "b245ceea-4bc7-4619-ae4c-559a1faf418e",    "priceName": "string",    "interval": "day",    "intervalCount": -9007199254740991,    "quantity": -9007199254740991,    "unitAmount": -9007199254740991,    "currency": "BRL",    "orderId": "b3e1eced-f2bd-4d8c-9765-fbc9d1d222d5",    "currentPeriodStart": "2019-08-24T14:15:22Z",    "currentPeriodEnd": "2019-08-24T14:15:22Z",    "nextBillingAt": "2019-08-24T14:15:22Z",    "trialEndsAt": "2019-08-24T14:15:22Z",    "cancelAtPeriodEnd": true,    "cancelledAt": "2019-08-24T14:15:22Z",    "endedAt": "2019-08-24T14:15:22Z",    "createdAt": "2019-08-24T14:15:22Z"  },  "meta": {    "requestId": "string"  }}