Atualizar assinatura
curl --request PUT \
--url https://api.malga.io/v1/subscriptions/{id} \
--header 'Content-Type: application/json' \
--header 'X-Api-Key: <api-key>' \
--header 'X-Client-Id: <api-key>' \
--data '
{
"name": "<string>",
"merchantId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"items": [
{
"name": "<string>",
"amount": 2,
"quantity": 2,
"description": "<string>",
"sku": "<string>",
"categoryId": "<string>",
"locality": "<string>",
"date": "2023-12-25",
"type": 123,
"genre": "<string>",
"tickets": {
"quantityTicketSale": 123,
"quantityEventHouse": 123,
"convenienceFeeValue": 123,
"quantityFull": 123,
"quantityHalf": 123,
"batch": 123
},
"location": {
"street": "<string>",
"number": "<string>",
"complement": "<string>",
"zipCode": "<string>",
"city": "<string>",
"state": "<string>",
"country": "<string>",
"district": "<string>",
"reference": "<string>"
}
}
],
"recurrence": {
"cycles": 2,
"startAt": "2023-12-25"
},
"splitRules": [
{
"sellerId": "d98106e8-568a-44c3-94d0-0e0bbd8b7e08",
"percentage": 70,
"processingFee": false,
"chargeEntireFee": false,
"chargeRemainderFee": false,
"liable": true,
"fares": {
"mdr": 2.5,
"fee": 0.3
}
}
],
"cancelAtPeriodEnd": true,
"scheduledCancellationAt": "2025-12-31",
"scheduledCancellationReason": "Cliente solicitou cancelamento"
}
'const options = {
method: 'PUT',
headers: {
'X-Client-Id': '<api-key>',
'X-Api-Key': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: '<string>',
merchantId: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
items: [
{
name: '<string>',
amount: 2,
quantity: 2,
description: '<string>',
sku: '<string>',
categoryId: '<string>',
locality: '<string>',
date: '2023-12-25',
type: 123,
genre: '<string>',
tickets: {
quantityTicketSale: 123,
quantityEventHouse: 123,
convenienceFeeValue: 123,
quantityFull: 123,
quantityHalf: 123,
batch: 123
},
location: {
street: '<string>',
number: '<string>',
complement: '<string>',
zipCode: '<string>',
city: '<string>',
state: '<string>',
country: '<string>',
district: '<string>',
reference: '<string>'
}
}
],
recurrence: {cycles: 2, startAt: '2023-12-25'},
splitRules: [
{
sellerId: 'd98106e8-568a-44c3-94d0-0e0bbd8b7e08',
percentage: 70,
processingFee: false,
chargeEntireFee: false,
chargeRemainderFee: false,
liable: true,
fares: {mdr: 2.5, fee: 0.3}
}
],
cancelAtPeriodEnd: true,
scheduledCancellationAt: '2025-12-31',
scheduledCancellationReason: 'Cliente solicitou cancelamento'
})
};
fetch('https://api.malga.io/v1/subscriptions/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.malga.io/v1/subscriptions/{id}"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"merchantId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"items\": [\n {\n \"name\": \"<string>\",\n \"amount\": 2,\n \"quantity\": 2,\n \"description\": \"<string>\",\n \"sku\": \"<string>\",\n \"categoryId\": \"<string>\",\n \"locality\": \"<string>\",\n \"date\": \"2023-12-25\",\n \"type\": 123,\n \"genre\": \"<string>\",\n \"tickets\": {\n \"quantityTicketSale\": 123,\n \"quantityEventHouse\": 123,\n \"convenienceFeeValue\": 123,\n \"quantityFull\": 123,\n \"quantityHalf\": 123,\n \"batch\": 123\n },\n \"location\": {\n \"street\": \"<string>\",\n \"number\": \"<string>\",\n \"complement\": \"<string>\",\n \"zipCode\": \"<string>\",\n \"city\": \"<string>\",\n \"state\": \"<string>\",\n \"country\": \"<string>\",\n \"district\": \"<string>\",\n \"reference\": \"<string>\"\n }\n }\n ],\n \"recurrence\": {\n \"cycles\": 2,\n \"startAt\": \"2023-12-25\"\n },\n \"splitRules\": [\n {\n \"sellerId\": \"d98106e8-568a-44c3-94d0-0e0bbd8b7e08\",\n \"percentage\": 70,\n \"processingFee\": false,\n \"chargeEntireFee\": false,\n \"chargeRemainderFee\": false,\n \"liable\": true,\n \"fares\": {\n \"mdr\": 2.5,\n \"fee\": 0.3\n }\n }\n ],\n \"cancelAtPeriodEnd\": true,\n \"scheduledCancellationAt\": \"2025-12-31\",\n \"scheduledCancellationReason\": \"Cliente solicitou cancelamento\"\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("X-Client-Id", "<api-key>")
req.Header.Add("X-Api-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"id": "abecf6d6-153e-4fc9-8222-8be5441de581",
"name": "Assinatura Premium com Eventos",
"clientId": "567265cb-fa7f-419f-9c1c-8e878dd2faf7",
"merchantId": "90d64a51-d442-426c-bbf9-b66e000e5576",
"customerId": "b99e159e-27d5-4927-b46e-ae7348f20131",
"referenceKey": "SUB-PREMIUM-001",
"currency": "BRL",
"items": [
{
"name": "Ingresso VIP Mensal",
"amount": 29900,
"quantity": 1,
"description": "Acesso VIP premium a eventos mensais",
"sku": "VIP-EVENT-001",
"risk": "Low",
"categoryId": "entertainment",
"locality": "São Paulo",
"date": "2025-12-01",
"type": 1,
"genre": "Shows e Eventos",
"tickets": {
"quantityTicketSale": 1,
"quantityEventHouse": 0,
"convenienceFeeValue": 15.5,
"quantityFull": 1,
"quantityHalf": 0,
"batch": 1
},
"location": {
"street": "Av. Paulista",
"number": "1000",
"complement": "Centro de Convenções",
"zipCode": "01310-100",
"city": "São Paulo",
"state": "SP",
"country": "Brasil",
"district": "Bela Vista",
"reference": "Próximo ao MASP"
}
}
],
"recurrence": {
"interval": "monthly",
"cycles": 12,
"startAt": "2025-08-10",
"endAt": "2026-08-10",
"nextDueDate": "2025-07-30"
},
"paymentMethod": {
"type": "credit",
"card": {
"cardId": "bfb60d16-108c-440b-bdb8-bbe67140f936"
},
"installments": 1
},
"trial": {
"endDate": "2025-08-15"
},
"splitRules": [
{
"sellerId": "d98106e8-568a-44c3-94d0-0e0bbd8b7e08",
"percentage": 70,
"processingFee": false,
"chargeEntireFee": false,
"chargeRemainderFee": false,
"liable": true,
"fares": {
"mdr": 2.5,
"fee": 0.3
}
}
],
"status": "created",
"amount": 29900,
"liveMode": true,
"lastCycle": {
"id": "ae765755-c909-4d97-813c-9c71add4b182",
"customerId": "b99e159e-27d5-4927-b46e-ae7348f20131",
"merchantId": "90d64a51-d442-426c-bbf9-b66e000e5576",
"cycle": 1,
"attempts": 1,
"status": "authorized",
"amount": 29900,
"items": [
{
"name": "Ingresso VIP Mensal",
"amount": 29900,
"quantity": 1,
"description": "Acesso VIP premium a eventos mensais",
"sku": "VIP-EVENT-001",
"risk": "Low",
"categoryId": "entertainment",
"locality": "São Paulo",
"date": "2025-12-01",
"type": 1,
"genre": "Shows e Eventos",
"tickets": {
"quantityTicketSale": 1,
"quantityEventHouse": 0,
"convenienceFeeValue": 15.5,
"quantityFull": 1,
"quantityHalf": 0,
"batch": 1
},
"location": {
"street": "Av. Paulista",
"number": "1000",
"complement": "Centro de Convenções",
"zipCode": "01310-100",
"city": "São Paulo",
"state": "SP",
"country": "Brasil",
"district": "Bela Vista",
"reference": "Próximo ao MASP"
}
}
],
"scheduledAt": "2025-07-30",
"executedAt": "2025-07-30",
"nextAttemptAt": "2025-07-31",
"isEmulated": false,
"emulatedAt": "2023-11-07T05:31:56Z",
"createdAt": "2025-07-30T20:14:12.599715Z",
"paymentHistory": [
{
"id": "f9661d7d-92fc-468a-8223-bc51f2ce8661",
"createdAt": "2025-07-30T20:14:12.608115Z",
"executedAt": "2025-07-30T20:14:13.104331Z",
"chargeId": "e17e09a4-5d0c-40c6-a8c0-be2adc765608",
"attemptNumber": 1,
"status": "authorized",
"paymentMethod": {
"type": "credit",
"card": {
"cardId": "bfb60d16-108c-440b-bdb8-bbe67140f936"
},
"installments": 1
},
"error": {
"message": "Card declined",
"providerError": {
"declinedCode": "insufficient_funds",
"message": "<string>",
"networkDeniedMessage": "<string>",
"networkDeniedReason": "<string>",
"retryable": true
}
}
}
]
},
"createdAt": "2025-07-31T13:36:40.118822Z",
"updatedAt": "2025-07-31T13:36:40.118822Z",
"cancelAtPeriodEnd": true,
"scheduledCancellationAt": "2025-12-31",
"scheduledCancellationReason": "Cliente solicitou cancelamento"
}Subscriptions
Atualizar assinatura
Atualiza só os campos enviados. Os demais ficam como estão.
recurrenceaceita sócyclesestartAt. O intervalo não pode ser alterado:recurrence.intervalé ignorado sem erro e a resposta mantém o intervalo antigo. Para trocar o intervalo, cancele a assinatura e crie outra.referenceKeynão pode ser alterado. O campo é ignorado sem erro e a resposta mantém o valor original.trialnão pode ser alterado. Enviartrialdevolve400.splitRulesaceita sópercentage. Regra comamountdevolve400.startAtsó muda antes do primeiro ciclo. Depois dele, devolve400. Se a nova data for hoje ou ontem (UTC), o primeiro ciclo é cobrado na mesma chamada.- Cancelamento agendado. Com
cancelAtPeriodEnd: true, a assinatura precisa estaractive,paused,unpaid,trialingoucreated; emcanceledouexpired, devolve409.
Atenção: cycles precisa ser maior que a quantidade de ciclos já executados, e items e splitRules não podem ser listas vazias. Valide os valores antes de enviar.
PUT
/
v1
/
subscriptions
/
{id}
Atualizar assinatura
curl --request PUT \
--url https://api.malga.io/v1/subscriptions/{id} \
--header 'Content-Type: application/json' \
--header 'X-Api-Key: <api-key>' \
--header 'X-Client-Id: <api-key>' \
--data '
{
"name": "<string>",
"merchantId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"items": [
{
"name": "<string>",
"amount": 2,
"quantity": 2,
"description": "<string>",
"sku": "<string>",
"categoryId": "<string>",
"locality": "<string>",
"date": "2023-12-25",
"type": 123,
"genre": "<string>",
"tickets": {
"quantityTicketSale": 123,
"quantityEventHouse": 123,
"convenienceFeeValue": 123,
"quantityFull": 123,
"quantityHalf": 123,
"batch": 123
},
"location": {
"street": "<string>",
"number": "<string>",
"complement": "<string>",
"zipCode": "<string>",
"city": "<string>",
"state": "<string>",
"country": "<string>",
"district": "<string>",
"reference": "<string>"
}
}
],
"recurrence": {
"cycles": 2,
"startAt": "2023-12-25"
},
"splitRules": [
{
"sellerId": "d98106e8-568a-44c3-94d0-0e0bbd8b7e08",
"percentage": 70,
"processingFee": false,
"chargeEntireFee": false,
"chargeRemainderFee": false,
"liable": true,
"fares": {
"mdr": 2.5,
"fee": 0.3
}
}
],
"cancelAtPeriodEnd": true,
"scheduledCancellationAt": "2025-12-31",
"scheduledCancellationReason": "Cliente solicitou cancelamento"
}
'const options = {
method: 'PUT',
headers: {
'X-Client-Id': '<api-key>',
'X-Api-Key': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: '<string>',
merchantId: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
items: [
{
name: '<string>',
amount: 2,
quantity: 2,
description: '<string>',
sku: '<string>',
categoryId: '<string>',
locality: '<string>',
date: '2023-12-25',
type: 123,
genre: '<string>',
tickets: {
quantityTicketSale: 123,
quantityEventHouse: 123,
convenienceFeeValue: 123,
quantityFull: 123,
quantityHalf: 123,
batch: 123
},
location: {
street: '<string>',
number: '<string>',
complement: '<string>',
zipCode: '<string>',
city: '<string>',
state: '<string>',
country: '<string>',
district: '<string>',
reference: '<string>'
}
}
],
recurrence: {cycles: 2, startAt: '2023-12-25'},
splitRules: [
{
sellerId: 'd98106e8-568a-44c3-94d0-0e0bbd8b7e08',
percentage: 70,
processingFee: false,
chargeEntireFee: false,
chargeRemainderFee: false,
liable: true,
fares: {mdr: 2.5, fee: 0.3}
}
],
cancelAtPeriodEnd: true,
scheduledCancellationAt: '2025-12-31',
scheduledCancellationReason: 'Cliente solicitou cancelamento'
})
};
fetch('https://api.malga.io/v1/subscriptions/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.malga.io/v1/subscriptions/{id}"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"merchantId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"items\": [\n {\n \"name\": \"<string>\",\n \"amount\": 2,\n \"quantity\": 2,\n \"description\": \"<string>\",\n \"sku\": \"<string>\",\n \"categoryId\": \"<string>\",\n \"locality\": \"<string>\",\n \"date\": \"2023-12-25\",\n \"type\": 123,\n \"genre\": \"<string>\",\n \"tickets\": {\n \"quantityTicketSale\": 123,\n \"quantityEventHouse\": 123,\n \"convenienceFeeValue\": 123,\n \"quantityFull\": 123,\n \"quantityHalf\": 123,\n \"batch\": 123\n },\n \"location\": {\n \"street\": \"<string>\",\n \"number\": \"<string>\",\n \"complement\": \"<string>\",\n \"zipCode\": \"<string>\",\n \"city\": \"<string>\",\n \"state\": \"<string>\",\n \"country\": \"<string>\",\n \"district\": \"<string>\",\n \"reference\": \"<string>\"\n }\n }\n ],\n \"recurrence\": {\n \"cycles\": 2,\n \"startAt\": \"2023-12-25\"\n },\n \"splitRules\": [\n {\n \"sellerId\": \"d98106e8-568a-44c3-94d0-0e0bbd8b7e08\",\n \"percentage\": 70,\n \"processingFee\": false,\n \"chargeEntireFee\": false,\n \"chargeRemainderFee\": false,\n \"liable\": true,\n \"fares\": {\n \"mdr\": 2.5,\n \"fee\": 0.3\n }\n }\n ],\n \"cancelAtPeriodEnd\": true,\n \"scheduledCancellationAt\": \"2025-12-31\",\n \"scheduledCancellationReason\": \"Cliente solicitou cancelamento\"\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("X-Client-Id", "<api-key>")
req.Header.Add("X-Api-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"id": "abecf6d6-153e-4fc9-8222-8be5441de581",
"name": "Assinatura Premium com Eventos",
"clientId": "567265cb-fa7f-419f-9c1c-8e878dd2faf7",
"merchantId": "90d64a51-d442-426c-bbf9-b66e000e5576",
"customerId": "b99e159e-27d5-4927-b46e-ae7348f20131",
"referenceKey": "SUB-PREMIUM-001",
"currency": "BRL",
"items": [
{
"name": "Ingresso VIP Mensal",
"amount": 29900,
"quantity": 1,
"description": "Acesso VIP premium a eventos mensais",
"sku": "VIP-EVENT-001",
"risk": "Low",
"categoryId": "entertainment",
"locality": "São Paulo",
"date": "2025-12-01",
"type": 1,
"genre": "Shows e Eventos",
"tickets": {
"quantityTicketSale": 1,
"quantityEventHouse": 0,
"convenienceFeeValue": 15.5,
"quantityFull": 1,
"quantityHalf": 0,
"batch": 1
},
"location": {
"street": "Av. Paulista",
"number": "1000",
"complement": "Centro de Convenções",
"zipCode": "01310-100",
"city": "São Paulo",
"state": "SP",
"country": "Brasil",
"district": "Bela Vista",
"reference": "Próximo ao MASP"
}
}
],
"recurrence": {
"interval": "monthly",
"cycles": 12,
"startAt": "2025-08-10",
"endAt": "2026-08-10",
"nextDueDate": "2025-07-30"
},
"paymentMethod": {
"type": "credit",
"card": {
"cardId": "bfb60d16-108c-440b-bdb8-bbe67140f936"
},
"installments": 1
},
"trial": {
"endDate": "2025-08-15"
},
"splitRules": [
{
"sellerId": "d98106e8-568a-44c3-94d0-0e0bbd8b7e08",
"percentage": 70,
"processingFee": false,
"chargeEntireFee": false,
"chargeRemainderFee": false,
"liable": true,
"fares": {
"mdr": 2.5,
"fee": 0.3
}
}
],
"status": "created",
"amount": 29900,
"liveMode": true,
"lastCycle": {
"id": "ae765755-c909-4d97-813c-9c71add4b182",
"customerId": "b99e159e-27d5-4927-b46e-ae7348f20131",
"merchantId": "90d64a51-d442-426c-bbf9-b66e000e5576",
"cycle": 1,
"attempts": 1,
"status": "authorized",
"amount": 29900,
"items": [
{
"name": "Ingresso VIP Mensal",
"amount": 29900,
"quantity": 1,
"description": "Acesso VIP premium a eventos mensais",
"sku": "VIP-EVENT-001",
"risk": "Low",
"categoryId": "entertainment",
"locality": "São Paulo",
"date": "2025-12-01",
"type": 1,
"genre": "Shows e Eventos",
"tickets": {
"quantityTicketSale": 1,
"quantityEventHouse": 0,
"convenienceFeeValue": 15.5,
"quantityFull": 1,
"quantityHalf": 0,
"batch": 1
},
"location": {
"street": "Av. Paulista",
"number": "1000",
"complement": "Centro de Convenções",
"zipCode": "01310-100",
"city": "São Paulo",
"state": "SP",
"country": "Brasil",
"district": "Bela Vista",
"reference": "Próximo ao MASP"
}
}
],
"scheduledAt": "2025-07-30",
"executedAt": "2025-07-30",
"nextAttemptAt": "2025-07-31",
"isEmulated": false,
"emulatedAt": "2023-11-07T05:31:56Z",
"createdAt": "2025-07-30T20:14:12.599715Z",
"paymentHistory": [
{
"id": "f9661d7d-92fc-468a-8223-bc51f2ce8661",
"createdAt": "2025-07-30T20:14:12.608115Z",
"executedAt": "2025-07-30T20:14:13.104331Z",
"chargeId": "e17e09a4-5d0c-40c6-a8c0-be2adc765608",
"attemptNumber": 1,
"status": "authorized",
"paymentMethod": {
"type": "credit",
"card": {
"cardId": "bfb60d16-108c-440b-bdb8-bbe67140f936"
},
"installments": 1
},
"error": {
"message": "Card declined",
"providerError": {
"declinedCode": "insufficient_funds",
"message": "<string>",
"networkDeniedMessage": "<string>",
"networkDeniedReason": "<string>",
"retryable": true
}
}
}
]
},
"createdAt": "2025-07-31T13:36:40.118822Z",
"updatedAt": "2025-07-31T13:36:40.118822Z",
"cancelAtPeriodEnd": true,
"scheduledCancellationAt": "2025-12-31",
"scheduledCancellationReason": "Cliente solicitou cancelamento"
}Body
application/json
Envie só os campos que quer alterar. referenceKey, recurrence.interval e trial não podem ser alterados
Response
Success
Was this page helpful?