Skip to main content
POST
/
v1
/
subscriptions
Criação de uma nova assinatura
curl --request POST \
  --url https://api.malga.io/v1/subscriptions \
  --header 'Content-Type: application/json' \
  --header 'X-Api-Key: <api-key>' \
  --header 'X-Client-Id: <api-key>' \
  --data '
{
  "name": "Assinatura Premium com Eventos",
  "merchantId": "225d39bc-1fbb-480a-90bd-f0caad05d2d0",
  "customerId": "2a8b64ce-904c-4256-b79a-49525808609c",
  "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",
        "quantityHalf": 0,
        "batch": 1
      }
    }
  ],
  "recurrence": {
    "interval": "monthly",
    "cycles": 123,
    "startAt": "2025-07-30"
  },
  "paymentMethod": {
    "type": "credit",
    "card": {
      "cardId": "ebef4e7e-b5d3-49d8-ac8f-b973faaa3ac5",
      "cvv": "123"
    },
    "installments": 1
  },
  "referenceKey": "SUB-PREMIUM-001",
  "trial": {
    "endAt": "2025-08-15"
  },
  "splitRules": [
    {
      "sellerId": "5323ece6-816d-11ed-a1eb-0242ac120002",
      "percentage": 70,
      "amount": 5000,
      "processingFee": false,
      "chargeEntireFee": false,
      "chargeRemainderFee": false,
      "liable": true,
      "transactionOwner": true,
      "fares": {
        "mdr": 2.5,
        "fee": 0.3
      }
    }
  ]
}
'
import requests

url = "https://api.malga.io/v1/subscriptions"

payload = {
"name": "Assinatura Premium com Eventos",
"merchantId": "225d39bc-1fbb-480a-90bd-f0caad05d2d0",
"customerId": "2a8b64ce-904c-4256-b79a-49525808609c",
"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",
"quantityHalf": 0,
"batch": 1
}
}
],
"recurrence": {
"interval": "monthly",
"cycles": 123,
"startAt": "2025-07-30"
},
"paymentMethod": {
"type": "credit",
"card": {
"cardId": "ebef4e7e-b5d3-49d8-ac8f-b973faaa3ac5",
"cvv": "123"
},
"installments": 1
},
"referenceKey": "SUB-PREMIUM-001",
"trial": { "endAt": "2025-08-15" },
"splitRules": [
{
"sellerId": "5323ece6-816d-11ed-a1eb-0242ac120002",
"percentage": 70,
"amount": 5000,
"processingFee": False,
"chargeEntireFee": False,
"chargeRemainderFee": False,
"liable": True,
"transactionOwner": True,
"fares": {
"mdr": 2.5,
"fee": 0.3
}
}
]
}
headers = {
"X-Client-Id": "<api-key>",
"X-Api-Key": "<api-key>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {
'X-Client-Id': '<api-key>',
'X-Api-Key': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'Assinatura Premium com Eventos',
merchantId: '225d39bc-1fbb-480a-90bd-f0caad05d2d0',
customerId: '2a8b64ce-904c-4256-b79a-49525808609c',
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',
quantityHalf: 0,
batch: 1
}
}
],
recurrence: {interval: 'monthly', cycles: 123, startAt: '2025-07-30'},
paymentMethod: {
type: 'credit',
card: {cardId: 'ebef4e7e-b5d3-49d8-ac8f-b973faaa3ac5', cvv: '123'},
installments: 1
},
referenceKey: 'SUB-PREMIUM-001',
trial: {endAt: '2025-08-15'},
splitRules: [
{
sellerId: '5323ece6-816d-11ed-a1eb-0242ac120002',
percentage: 70,
amount: 5000,
processingFee: false,
chargeEntireFee: false,
chargeRemainderFee: false,
liable: true,
transactionOwner: true,
fares: {mdr: 2.5, fee: 0.3}
}
]
})
};

fetch('https://api.malga.io/v1/subscriptions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.malga.io/v1/subscriptions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Assinatura Premium com Eventos',
'merchantId' => '225d39bc-1fbb-480a-90bd-f0caad05d2d0',
'customerId' => '2a8b64ce-904c-4256-b79a-49525808609c',
'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',
'quantityHalf' => 0,
'batch' => 1
]
]
],
'recurrence' => [
'interval' => 'monthly',
'cycles' => 123,
'startAt' => '2025-07-30'
],
'paymentMethod' => [
'type' => 'credit',
'card' => [
'cardId' => 'ebef4e7e-b5d3-49d8-ac8f-b973faaa3ac5',
'cvv' => '123'
],
'installments' => 1
],
'referenceKey' => 'SUB-PREMIUM-001',
'trial' => [
'endAt' => '2025-08-15'
],
'splitRules' => [
[
'sellerId' => '5323ece6-816d-11ed-a1eb-0242ac120002',
'percentage' => 70,
'amount' => 5000,
'processingFee' => false,
'chargeEntireFee' => false,
'chargeRemainderFee' => false,
'liable' => true,
'transactionOwner' => true,
'fares' => [
'mdr' => 2.5,
'fee' => 0.3
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Api-Key: <api-key>",
"X-Client-Id: <api-key>"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.malga.io/v1/subscriptions"

payload := strings.NewReader("{\n \"name\": \"Assinatura Premium com Eventos\",\n \"merchantId\": \"225d39bc-1fbb-480a-90bd-f0caad05d2d0\",\n \"customerId\": \"2a8b64ce-904c-4256-b79a-49525808609c\",\n \"items\": [\n {\n \"name\": \"Ingresso VIP Mensal\",\n \"amount\": 29900,\n \"quantity\": 1,\n \"description\": \"Acesso VIP premium a eventos mensais\",\n \"sku\": \"VIP-EVENT-001\",\n \"risk\": \"Low\",\n \"categoryId\": \"entertainment\",\n \"locality\": \"São Paulo\",\n \"date\": \"2025-12-01\",\n \"type\": 1,\n \"genre\": \"Shows e Eventos\",\n \"tickets\": {\n \"quantityTicketSale\": 1,\n \"quantityEventHouse\": 0,\n \"convenienceFeeValue\": 15.5,\n \"quantityFull\": 1,\n \"quantityHalf\": 0,\n \"batch\": 1\n },\n \"location\": {\n \"street\": \"Av. Paulista\",\n \"number\": \"1000\",\n \"complement\": \"Centro de Convenções\",\n \"zipCode\": \"01310-100\",\n \"city\": \"São Paulo\",\n \"state\": \"SP\",\n \"country\": \"Brasil\",\n \"district\": \"Bela Vista\",\n \"reference\": \"Próximo ao MASP\",\n \"quantityHalf\": 0,\n \"batch\": 1\n }\n }\n ],\n \"recurrence\": {\n \"interval\": \"monthly\",\n \"cycles\": 123,\n \"startAt\": \"2025-07-30\"\n },\n \"paymentMethod\": {\n \"type\": \"credit\",\n \"card\": {\n \"cardId\": \"ebef4e7e-b5d3-49d8-ac8f-b973faaa3ac5\",\n \"cvv\": \"123\"\n },\n \"installments\": 1\n },\n \"referenceKey\": \"SUB-PREMIUM-001\",\n \"trial\": {\n \"endAt\": \"2025-08-15\"\n },\n \"splitRules\": [\n {\n \"sellerId\": \"5323ece6-816d-11ed-a1eb-0242ac120002\",\n \"percentage\": 70,\n \"amount\": 5000,\n \"processingFee\": false,\n \"chargeEntireFee\": false,\n \"chargeRemainderFee\": false,\n \"liable\": true,\n \"transactionOwner\": true,\n \"fares\": {\n \"mdr\": 2.5,\n \"fee\": 0.3\n }\n }\n ]\n}")

req, _ := http.NewRequest("POST", 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))

}
HttpResponse<String> response = Unirest.post("https://api.malga.io/v1/subscriptions")
.header("X-Client-Id", "<api-key>")
.header("X-Api-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Assinatura Premium com Eventos\",\n \"merchantId\": \"225d39bc-1fbb-480a-90bd-f0caad05d2d0\",\n \"customerId\": \"2a8b64ce-904c-4256-b79a-49525808609c\",\n \"items\": [\n {\n \"name\": \"Ingresso VIP Mensal\",\n \"amount\": 29900,\n \"quantity\": 1,\n \"description\": \"Acesso VIP premium a eventos mensais\",\n \"sku\": \"VIP-EVENT-001\",\n \"risk\": \"Low\",\n \"categoryId\": \"entertainment\",\n \"locality\": \"São Paulo\",\n \"date\": \"2025-12-01\",\n \"type\": 1,\n \"genre\": \"Shows e Eventos\",\n \"tickets\": {\n \"quantityTicketSale\": 1,\n \"quantityEventHouse\": 0,\n \"convenienceFeeValue\": 15.5,\n \"quantityFull\": 1,\n \"quantityHalf\": 0,\n \"batch\": 1\n },\n \"location\": {\n \"street\": \"Av. Paulista\",\n \"number\": \"1000\",\n \"complement\": \"Centro de Convenções\",\n \"zipCode\": \"01310-100\",\n \"city\": \"São Paulo\",\n \"state\": \"SP\",\n \"country\": \"Brasil\",\n \"district\": \"Bela Vista\",\n \"reference\": \"Próximo ao MASP\",\n \"quantityHalf\": 0,\n \"batch\": 1\n }\n }\n ],\n \"recurrence\": {\n \"interval\": \"monthly\",\n \"cycles\": 123,\n \"startAt\": \"2025-07-30\"\n },\n \"paymentMethod\": {\n \"type\": \"credit\",\n \"card\": {\n \"cardId\": \"ebef4e7e-b5d3-49d8-ac8f-b973faaa3ac5\",\n \"cvv\": \"123\"\n },\n \"installments\": 1\n },\n \"referenceKey\": \"SUB-PREMIUM-001\",\n \"trial\": {\n \"endAt\": \"2025-08-15\"\n },\n \"splitRules\": [\n {\n \"sellerId\": \"5323ece6-816d-11ed-a1eb-0242ac120002\",\n \"percentage\": 70,\n \"amount\": 5000,\n \"processingFee\": false,\n \"chargeEntireFee\": false,\n \"chargeRemainderFee\": false,\n \"liable\": true,\n \"transactionOwner\": true,\n \"fares\": {\n \"mdr\": 2.5,\n \"fee\": 0.3\n }\n }\n ]\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.malga.io/v1/subscriptions")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["X-Client-Id"] = '<api-key>'
request["X-Api-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Assinatura Premium com Eventos\",\n \"merchantId\": \"225d39bc-1fbb-480a-90bd-f0caad05d2d0\",\n \"customerId\": \"2a8b64ce-904c-4256-b79a-49525808609c\",\n \"items\": [\n {\n \"name\": \"Ingresso VIP Mensal\",\n \"amount\": 29900,\n \"quantity\": 1,\n \"description\": \"Acesso VIP premium a eventos mensais\",\n \"sku\": \"VIP-EVENT-001\",\n \"risk\": \"Low\",\n \"categoryId\": \"entertainment\",\n \"locality\": \"São Paulo\",\n \"date\": \"2025-12-01\",\n \"type\": 1,\n \"genre\": \"Shows e Eventos\",\n \"tickets\": {\n \"quantityTicketSale\": 1,\n \"quantityEventHouse\": 0,\n \"convenienceFeeValue\": 15.5,\n \"quantityFull\": 1,\n \"quantityHalf\": 0,\n \"batch\": 1\n },\n \"location\": {\n \"street\": \"Av. Paulista\",\n \"number\": \"1000\",\n \"complement\": \"Centro de Convenções\",\n \"zipCode\": \"01310-100\",\n \"city\": \"São Paulo\",\n \"state\": \"SP\",\n \"country\": \"Brasil\",\n \"district\": \"Bela Vista\",\n \"reference\": \"Próximo ao MASP\",\n \"quantityHalf\": 0,\n \"batch\": 1\n }\n }\n ],\n \"recurrence\": {\n \"interval\": \"monthly\",\n \"cycles\": 123,\n \"startAt\": \"2025-07-30\"\n },\n \"paymentMethod\": {\n \"type\": \"credit\",\n \"card\": {\n \"cardId\": \"ebef4e7e-b5d3-49d8-ac8f-b973faaa3ac5\",\n \"cvv\": \"123\"\n },\n \"installments\": 1\n },\n \"referenceKey\": \"SUB-PREMIUM-001\",\n \"trial\": {\n \"endAt\": \"2025-08-15\"\n },\n \"splitRules\": [\n {\n \"sellerId\": \"5323ece6-816d-11ed-a1eb-0242ac120002\",\n \"percentage\": 70,\n \"amount\": 5000,\n \"processingFee\": false,\n \"chargeEntireFee\": false,\n \"chargeRemainderFee\": false,\n \"liable\": true,\n \"transactionOwner\": true,\n \"fares\": {\n \"mdr\": 2.5,\n \"fee\": 0.3\n }\n }\n ]\n}"

response = http.request(request)
puts response.read_body
{
  "id": "019860b2-feb8-7edf-b5ba-0c48a7a8bd3f",
  "name": "Assinatura Premium com Eventos",
  "clientId": "e234eeb3-483d-4df2-87eb-1e2be5cdaccd",
  "merchantId": "225d39bc-1fbb-480a-90bd-f0caad05d2d0",
  "customerId": "2a8b64ce-904c-4256-b79a-49525808609c",
  "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",
        "quantityHalf": 0,
        "batch": 1
      }
    }
  ],
  "recurrence": {
    "interval": "monthly",
    "cycles": 12,
    "startAt": "2025-08-10",
    "endAt": "2026-08-10",
    "nextDueDate": "2025-07-30"
  },
  "paymentMethod": {
    "type": "credit",
    "card": {
      "cardId": "ebef4e7e-b5d3-49d8-ac8f-b973faaa3ac5"
    },
    "installments": 1
  },
  "trial": {
    "endAt": "2025-08-15"
  },
  "splitRules": [
    {
      "sellerId": "5323ece6-816d-11ed-a1eb-0242ac120002",
      "percentage": 70,
      "amount": 5000,
      "processingFee": false,
      "chargeEntireFee": false,
      "chargeRemainderFee": false,
      "liable": true,
      "transactionOwner": true,
      "fares": {
        "mdr": 2.5,
        "fee": 0.3
      }
    }
  ],
  "status": "created",
  "amount": 29900,
  "liveMode": true,
  "lastCycle": {
    "id": "01985cf8-9877-7c09-bbf6-2cceb3384a61",
    "customerId": "2a8b64ce-904c-4256-b79a-49525808609c",
    "merchantId": "225d39bc-1fbb-480a-90bd-f0caad05d2d0",
    "cycle": 1,
    "status": "authorized",
    "createdAt": "2025-07-30T20:14:12.599715Z",
    "paymentHistory": [
      {
        "id": "84ec50c5-1fb4-4d6b-bbff-fedc47ba9fa3",
        "createdAt": "2025-07-30T20:14:12.608115Z",
        "chargeId": "6f2a0713-c4cd-4e2d-8603-69855902676d",
        "status": "authorized"
      }
    ]
  },
  "createdAt": "2025-07-31T13:36:40.118822Z",
  "updatedAt": "2025-07-31T13:36:40.118822Z",
  "cancelAtPeriodEnd": true,
  "scheduledCancellationAt": "2025-12-31",
  "scheduledCancellationReason": "Cliente solicitou cancelamento"
}

Authorizations

X-Client-Id
string
header
required
X-Api-Key
string
header
required

Body

application/json
name
string
required

Nome da assinatura

Example:

"Assinatura Premium com Eventos"

merchantId
string<uuid>
required

Identificador do merchant

Example:

"225d39bc-1fbb-480a-90bd-f0caad05d2d0"

customerId
string<uuid>
required

Identificador do cliente

Example:

"2a8b64ce-904c-4256-b79a-49525808609c"

items
object[]
required
recurrence
object
required
paymentMethod
object
required
referenceKey
string

Chave de referência da assinatura no seu sistema

Example:

"SUB-PREMIUM-001"

trial
object

Configuração do período de trial (opcional)

splitRules
object[]

Regras de divisão de valores entre recebedores (opcional)

Response

201 - application/json

Created

id
string<uuid>

Identificador da assinatura

Example:

"019860b2-feb8-7edf-b5ba-0c48a7a8bd3f"

name
string

Nome da assinatura

Example:

"Assinatura Premium com Eventos"

clientId
string<uuid>

Identificador do client

Example:

"e234eeb3-483d-4df2-87eb-1e2be5cdaccd"

merchantId
string<uuid>

Identificador do merchant

Example:

"225d39bc-1fbb-480a-90bd-f0caad05d2d0"

customerId
string<uuid>

Identificador do cliente

Example:

"2a8b64ce-904c-4256-b79a-49525808609c"

referenceKey
string

Chave de referência da assinatura

Example:

"SUB-PREMIUM-001"

currency
string

Moeda da assinatura

Example:

"BRL"

items
object[]
recurrence
object
paymentMethod
object
trial
object

Informações do período de trial (se aplicável)

splitRules
object[]

Regras de divisão de valores entre recebedores

status
enum<string>

Status da assinatura

Available options:
created,
active,
paused,
canceled,
unpaid,
expired,
trialing
Example:

"created"

amount
integer
Example:

29900

liveMode
boolean

Indica se a assinatura está em modo de produção

Example:

true

lastCycle
object | null

Último cycle da assinatura. Sempre presente nas respostas individuais (GET, CREATE, UPDATE), pode ser null se não houver cycles.

createdAt
string<date-time>
Example:

"2025-07-31T13:36:40.118822Z"

updatedAt
string<date-time>
Example:

"2025-07-31T13:36:40.118822Z"

cancelAtPeriodEnd
boolean

Indica se a assinatura está agendada para cancelamento ao final do período atual

Example:

true

scheduledCancellationAt
string<date> | null

Data agendada para o cancelamento (formato YYYY-MM-DD). Quando definida, tem prioridade sobre trialEnd e nextDueDate para determinar a data efetiva de cancelamento

Example:

"2025-12-31"

scheduledCancellationReason
string | null

Motivo do cancelamento agendado (opcional)

Example:

"Cliente solicitou cancelamento"