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": "5323ece6-816d-11ed-a1eb-0242ac120002",
"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: '5323ece6-816d-11ed-a1eb-0242ac120002',
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\": \"5323ece6-816d-11ed-a1eb-0242ac120002\",\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))
}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.
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": "5323ece6-816d-11ed-a1eb-0242ac120002",
"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: '5323ece6-816d-11ed-a1eb-0242ac120002',
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\": \"5323ece6-816d-11ed-a1eb-0242ac120002\",\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))
}Path Parameters
Id da assinatura que deseja atualizar
Body
Envie só os campos que quer alterar. referenceKey, recurrence.interval e trial não podem ser alterados
Nome da assinatura
1 - 100Identificador do merchant
Nova lista de itens, que substitui a atual. Não pode ser vazia
1Show child attributes
Show child attributes
Aceita só cycles e startAt. O intervalo não pode ser alterado; interval enviado aqui é ignorado sem erro
Show child attributes
Show child attributes
Nova lista de regras de split, que substitui a atual. Aceita só percentage. Não pode ser vazia
1Show child attributes
Show child attributes
Show child attributes
Show child attributes
true agenda o cancelamento; false remove o agendamento. Ao agendar com recurrence.cycles definido, cycles passa a ser o ciclo atual mais um; ao remover, volta ao valor anterior. Agendar em assinatura canceled ou expired devolve 409
true
Data do cancelamento agendado (YYYY-MM-DD). Exige cancelAtPeriodEnd igual a true, enviado agora ou já salvo, e não pode ser anterior a ontem (UTC). Sem esta data, o cancelamento acontece em trial.endDate ou, sem trial, em recurrence.nextDueDate
"2025-12-31"
Motivo do cancelamento agendado (opcional)
"Cliente solicitou cancelamento"
Response
Success
Identificador da assinatura
"019860b2-feb8-7edf-b5ba-0c48a7a8bd3f"
Nome da assinatura
"Assinatura Premium com Eventos"
Identificador do client
"e234eeb3-483d-4df2-87eb-1e2be5cdaccd"
Identificador do merchant
"225d39bc-1fbb-480a-90bd-f0caad05d2d0"
Identificador do cliente
"2a8b64ce-904c-4256-b79a-49525808609c"
Chave de referência da assinatura
"SUB-PREMIUM-001"
Moeda da assinatura
"BRL"
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Período de trial. Só vem quando a assinatura foi criada com trial
Show child attributes
Show child attributes
Regras de divisão de valores entre recebedores. Só vem quando a assinatura tem split
Show child attributes
Show child attributes
Status da assinatura
created, active, paused, canceled, unpaid, expired, trialing "created"
Valor de cada ciclo em centavos, a soma de amount vezes quantity dos itens
29900
Indica se a assinatura está em modo de produção
true
Último ciclo da assinatura. Sempre presente nas respostas individuais (GET, CREATE, UPDATE), pode ser null se não houver ciclos. Não traz items.
Show child attributes
Show child attributes
"2025-07-31T13:36:40.118822Z"
"2025-07-31T13:36:40.118822Z"
Indica se a assinatura tem cancelamento agendado. Enquanto for true, recurrence.cycles mostra o ciclo atual mais um, e o valor anterior volta quando o agendamento é removido
true
Data efetiva do cancelamento agendado (YYYY-MM-DD). Só vem quando cancelAtPeriodEnd é true. Sem data enviada, é trial.endDate ou, sem trial, recurrence.nextDueDate
"2025-12-31"
Motivo do cancelamento agendado. Só vem quando foi informado
"Cliente solicitou cancelamento"
Was this page helpful?