Credit notes

Create a credit note

POST/api/v1/invoices/{id}/credit-notes

Issues a credit note on an open or a paid invoice. Credit one amount, or the invoice's lines by a quantity or an amount each. The note takes the next CN- number and sends credit_note.created. On an open invoice the note lowers what your customer still has to pay by its amount. A note that leaves something to pay keeps the invoice open, lowers amountRemaining, sends invoice.updated, and the pay link then asks for what is left. A note that leaves nothing to pay settles the invoice the way a full payment does: the invoice becomes paid with no money paid, the subscription renews or starts or the upgrade applies, and invoice.paid is sent. While your customer has a payment on the invoice in progress the request answers 409 payment_in_progress and issues nothing: try again when that payment has completed. On a paid invoice the note gives part of what was paid back: creditedAmount goes to your customer's credit balance, which is refundable and pays their next invoice, and customer.balance.updated is sent; outOfBandAmount records money you paid back outside Flex Malipo. The amount is at most what the invoice's payment has left after refunds, refunds in progress and earlier credit notes. The invoice and its subscription do not change. A credit note never sends money to your customer's number: create a refund for that. A credit note is permanent. A void invoice takes no credit note. Send a unique Idempotency-Key. Repeating the request with the same key and body returns the original answer and issues nothing twice. A payment_in_progress or 503 answer is not kept, so you can send the same key again.

Authorization

bearerAuth
AuthorizationBearer <token>

An access token from POST /api/v1/oauth/token, sent as Authorization: Bearer <token>.

In: header

Path Parameters

id*string

The invoice's ID.

Formatuuid

Header Parameters

Idempotency-Key*string

A unique key you choose for this request: 1 to 255 visible ASCII characters, no spaces. A UUID works well. Never put personal data in it. Send the same key again to retry safely.

FlexMalipo-Version?"2026-11-06"

The API version to use for this request, a date such as 2026-11-06. Without it the request uses your default version for the mode of your key. An unknown version answers 400 api_version_invalid.

Value in

  • "2026-11-06"

Request Body

application/json

A credit note on an open or a paid invoice. Send amount or lines, not both. On a paid invoice, creditedAmount and outOfBandAmount say where the amount goes.

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "https://api-malipo.flex.co.tz/api/v1/invoices/497f6eca-6276-4993-bfeb-53cbbbba6f08/credit-notes" \  -H "Authorization: Bearer <token>" \  -H "Idempotency-Key: 5f1c1e0a-3b7e-4c8e-9d1a-2f6b8a4c7e11" \  -H "FlexMalipo-Version: 2026-11-06" \  -H "Content-Type: application/json" \  -d '{    "reason": "order_change"  }'
{  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",  "number": "CN-000007",  "livemode": true,  "invoiceId": "4f163819-178d-470c-a246-d6768476a6ec",  "invoice": {    "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",    "number": "INV-000042",    "livemode": true,    "subscriptionId": "d079718b-ff63-45dd-947b-4950c023750f",    "subscription": {      "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",      "livemode": true,      "customerId": "87d8e330-2878-4742-a86f-dbbb3bf522ac",      "customer": {        "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",        "livemode": true,        "name": "Amina Juma",        "email": "amina@example.com",        "phone": 255744553111,        "externalId": "user_8841",        "locale": "en",        "metadata": {          "property1": "string",          "property2": "string"        },        "zeroUsageInvoice": "follow",        "createdAt": "2019-08-24T14:15:22Z",        "updatedAt": "2019-08-24T14:15:22Z"      },      "status": "active",      "items": [        {          "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",          "priceId": "b245ceea-4bc7-4619-ae4c-559a1faf418e",          "price": {            "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",            "livemode": true,            "productId": "dcd53ddb-8104-4e48-8cc0-5df1088c6113",            "product": {              "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",              "livemode": true,              "name": "Pro plan",              "description": "Everything in Basic, plus reports.",              "active": true,              "metadata": {                "property1": "string",                "property2": "string"              },              "features": [                {                  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",                  "livemode": true,                  "lookupKey": "queues",                  "name": "Queues",                  "description": "string",                  "limit": 15,                  "limitPerSeat": true,                  "createdAt": "2019-08-24T14:15:22Z"                }              ],              "defaultPriceId": "c79663b6-9012-4d9a-bc6f-db5a00400fac",              "defaultPrice": {},              "createdAt": "2019-08-24T14:15:22Z",              "updatedAt": "2019-08-24T14:15:22Z",              "brandId": "0e9bcbb3-096e-49f9-aeea-7a13a201eff5"            },            "type": "RECURRING",            "unitAmount": 15000,            "unitAmountDecimal": 15000,            "currency": "TZS",            "interval": "MONTH",            "intervalCount": 1,            "maxPeriods": 12,            "active": true,            "lookupKey": "pro_monthly",            "metadata": {              "property1": "string",              "property2": "string"            },            "createdAt": "2019-08-24T14:15:22Z",            "updatedAt": "2019-08-24T14:15:22Z",            "usageType": "FLAT",            "meter": "08cfef1f-f291-40f5-b1b8-05ac0989f419",            "pricingModel": "PER_UNIT",            "tiers": [              {                "upTo": 1000,                "unitAmount": 3,                "unitAmountDecimal": 0.5,                "flatAmount": 2000              }            ],            "rates": [              {                "dimensions": {                  "network": "vodacom"                },                "unitAmount": 3,                "unitAmountDecimal": 3              }            ],            "subscriptionCount": 3          },          "usageType": "FLAT",          "quantity": 1,          "meterId": "e6fc0364-7430-4b9c-ab62-413ce7e2f3ee",          "nextPriceId": "93df8cb9-3a06-41a4-b6a9-9ff93f3029ef",          "nextQuantity": 0,          "pendingAdd": true,          "pendingRemove": true,          "startsAt": "2019-08-24T14:15:22Z",          "endsAt": "2019-08-24T14:15:22Z"        }      ],      "billingAnchor": "2019-08-24T14:15:22Z",      "paidThrough": "2019-08-24T14:15:22Z",      "trialEnd": "2019-08-24T14:15:22Z",      "canceledAt": "2019-08-24T14:15:22Z",      "accessEndsAt": "2019-08-24T14:15:22Z",      "createdAt": "2019-08-24T14:15:22Z",      "updatedAt": "2019-08-24T14:15:22Z",      "collectionMethod": "checkout",      "daysUntilDue": 30,      "cancelAtPeriodEnd": false,      "cancelAt": "2019-08-24T14:15:22Z",      "endedAt": "2019-08-24T14:15:22Z",      "cancellationDetails": {        "reason": "cancellation_requested",        "feedback": "too_expensive",        "comment": "string"      },      "metadata": {        "property1": "string",        "property2": "string"      },      "brandId": "0e9bcbb3-096e-49f9-aeea-7a13a201eff5",      "trialUsage": {        "mode": "free_up_to",        "amount": 5000,        "currency": "TZS"      }    },    "customerId": "87d8e330-2878-4742-a86f-dbbb3bf522ac",    "customer": {      "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",      "livemode": true,      "name": "Amina Juma",      "email": "amina@example.com",      "phone": 255744553111,      "externalId": "user_8841",      "locale": "en",      "metadata": {        "property1": "string",        "property2": "string"      },      "zeroUsageInvoice": "follow",      "createdAt": "2019-08-24T14:15:22Z",      "updatedAt": "2019-08-24T14:15:22Z"    },    "status": "open",    "price": "296c3962-8fad-4bbf-a476-e2a5d4fe62a6",    "quantity": 1,    "periodStart": "2019-08-24T14:15:22Z",    "unitAmount": 15000,    "currency": "TZS",    "periodsPaid": 0,    "amountPaid": 0,    "paidAt": "2019-08-24T14:15:22Z",    "voidedAt": "2019-08-24T14:15:22Z",    "paymentReversedAt": "2019-08-24T14:15:22Z",    "createdAt": "2019-08-24T14:15:22Z",    "payLink": "string",    "lines": [      {        "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",        "price": "296c3962-8fad-4bbf-a476-e2a5d4fe62a6",        "quantity": 1,        "periods": 3,        "unitAmount": 15000,        "amount": 45000,        "periodStart": "2019-08-24T14:15:22Z",        "periodEnd": "2019-08-24T14:15:22Z",        "kind": "period",        "description": "Unused time on Basic after 29 Nov 2026",        "meter": "08cfef1f-f291-40f5-b1b8-05ac0989f419",        "usageQuantity": 1250.5,        "unitAmountDecimal": 2.5      }    ],    "kind": "RENEWAL",    "expiresAt": "2019-08-24T14:15:22Z",    "dueAt": "2019-08-24T14:15:22Z",    "autoAdvance": true,    "version": 1,    "carriedLines": [      {        "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",        "description": "Prorated difference of an upgrade",        "amount": 100,        "currency": "TZS",        "createdAt": "2019-08-24T14:15:22Z"      }    ],    "creditApplied": 2000,    "amountRemaining": 13000,    "issuer": {      "name": "Kahawa Traders",      "legalName": "Kahawa Traders Limited",      "tin": 100149192,      "vrn": "10007379N",      "address": {        "line1": "Plot 12 Samora Avenue",        "line2": "string",        "poBox": 1234,        "city": "Ilala",        "region": "TZ-02",        "regionName": "Dar es Salaam",        "postalCode": 11101,        "country": "TZ"      }    },    "payments": [      {        "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",        "kind": "online_payment",        "method": "mobile_money",        "reference": "string",        "amount": 10000,        "paidAt": "2019-08-24T14:15:22Z",        "receiptNumber": "RCT-000012",        "refunds": [          {            "creditNoteNumber": "CN-000007",            "amount": 4000,            "refundedAt": "2019-08-24T14:15:22Z"          }        ],        "payment_method_details": {          "type": "mobile_money",          "mobile_money": {            "network": "mpesa",            "phone": "25574*****11",            "verified_name": "ASHA J JUMA"          },          "custom": {            "display_name": "Barter"          }        },        "transactionCode": "QJK4A7XMN2",        "issuer": {          "name": "Kahawa Traders",          "legalName": "Kahawa Traders Limited",          "tin": 100149192,          "vrn": "10007379N",          "address": {            "line1": "Plot 12 Samora Avenue",            "line2": "string",            "poBox": 1234,            "city": "Ilala",            "region": "TZ-02",            "regionName": "Dar es Salaam",            "postalCode": 11101,            "country": "TZ"          }        },        "paymentId": "0b6f3c1e-8f2a-4a51-9a57-6d1f0c2b7e93"      }    ]  },  "paymentId": "string",  "refundId": "ref_3f2a9c",  "amount": 10000,  "refundedAmount": 10000,  "creditedAmount": 0,  "outOfBandAmount": 0,  "prePaymentAmount": 0,  "currency": "TZS",  "reason": "reversal",  "memo": "Two seats removed from the November order",  "internalNote": "Agreed with the customer by phone",  "issuer": {    "name": "Kahawa Traders",    "legalName": "Kahawa Traders Limited",    "tin": 100149192,    "vrn": "10007379N",    "address": {      "line1": "Plot 12 Samora Avenue",      "line2": "string",      "poBox": 1234,      "city": "Ilala",      "region": "TZ-02",      "regionName": "Dar es Salaam",      "postalCode": 11101,      "country": "TZ"    }  },  "lines": [    {      "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",      "invoiceLineId": "01b48345-8495-4ed8-81ba-4399df639395",      "quantity": 1,      "amount": 2000    }  ],  "createdAt": "2019-08-24T14:15:22Z"}