Skip to main content
A debt (Debt) is a one-time charge to a known debtor: a fixed amount charged to an identified person or entity, with a due date and configurable payment methods. It is the most common use case of the API. You specify who pays, how much, and when it is due. Tapipay resolves all of the complexity internally (your organization, the modalities, and the internal data of the collections system) and returns a clean contract with the payment URL ready to share.

When to use a debt

Debt

A single charge to someone you know: an invoice, an installment, a one-time service.

Subscription

If the charge repeats over time (monthly payments, installments).

Payment link

If you do not know the debtor in advance (donations, one-off sales).

Create a debt

To create a debt you need, at a minimum, to identify the debtor, the amount, and the due date. The optional Idempotency-Key header is used as the debt’s externalRequestId, and the resulting debtId is debt_<key> (in the example, debt_INV-2026-001). If you don’t send it, the backend generates the externalRequestId. See Idempotency.

Identify the debtor

You must send one of these two fields (not both, not neither): See Contacts for details on the reusable debtor.
A contact may have more than one identifier. If you reference it by a secondary one, the debt is created with its primary identifier and contact.externalClientId in the response returns that value, not the one you sent.

Main fields

number
required
Amount in pesos, with up to 2 decimal places (minimum 0.01). For example, 1500.50 equals $1,500.50 MXN.
string
required
Due date in YYYY-MM-DD format. It must be a valid calendar date (2026-02-30 returns 400). It is not validated to be in the future.
string
default:"MXN"
Currency code. Allowed values: MXN, ARS, PEN, COP, CLP, USD. Default MXN.
string
Description visible to the debtor. It must be a string (any other type returns 400).
string
ID of an existing Tapi product, in prd_<number> format (for example, prd_12985). Any other format returns 400 INVALID_REQUEST. Mutually exclusive with externalProductId (sending both returns 400); never creates a product. See Products.
string
Your identifier of an existing product. Mutually exclusive with productId; never creates a product. It does not accept the characters ', ", \, ; (400).
boolean
default:"true"
Enables partial payments. With true, the debt moves to PARTIALLY_PAID until it is settled. Only the literal true or false is accepted: "true", 1, etc. return 400 with details[].
boolean
default:"true"
If false, the debt cannot be paid after the dueDate. Only the literal true or false is accepted, same as allowPartialPayments.
string
default:"CLOSED"
How the amount is collected. CLOSED registers the exact amount: the payment provider rejects any other amount at payment. OPEN lets the debtor choose the amount within a range defined by the modality configuration of your company. It accepts CLOSED or OPEN (in upper or lower case); any other value, including PARTIAL, returns 400 with details[]. See Fixed or open amount.
boolean
default:"false"
If true, the debt keeps being offered to the debtor after a payment: each payment is added to the same debt (no new debt is created) and its status stays PAID from the moment it is settled. Only the literal true or false is accepted (any other value returns 400 with details[]); null is read as the default. See Recurring debts.
object
Data of your own system that you want to store on the debt. It must be a flat object (a scalar, such as a string or a number, returns 400) and it cannot use the reserved keys Tapipay writes internally: description, paymentMethods, productName, externalProductId, debtExpirationDate, overduePayment, allowPartialPayments, recurringDebt. If any of them is present, the API responds 400 INVALID_REQUEST with details[].field = additionalData.
POST /v2/debts only accepts these body fields: externalClientId, contactData, amount, currency, dueDate, description, allowOverduePayment, allowPartialPayments, amountType, recurring, additionalData, productId, externalProductId. Any other one, including autopay, paymentMethods, productName, and paymentMethod, returns 400 INVALID_REQUEST with the field in details[].field. A JSON array at the root (without the { "debts": [...] } envelope) also returns 400.
The debt does not declare a payment method: automatic collection is governed by the user’s enrollment in the product, which is managed separately from debt creation. Referencing a product (productId/externalProductId) is what makes a debt collectible automatically. The paymentMethods and autopay fields only apply to subscriptions. See Direct debit for the full picture.
You never send or receive internal system data (organization, modalities, generationData). You work only with business concepts.

The response

The creation and query response includes paymentUrl (the URL ready to share with your debtor; it is null only if the portal integration fails) and amountPaid (the accumulated amount paid). The creation response (POST /v2/debts) does not include autopay: creating a debt no longer enables or evaluates automatic collection. The query responses (GET /debts, GET /debts/{id}) do include it, but it is a flag on the debt itself and does not mean there is an active direct debit agreement. See Direct debit and What’s new.
  • debtId is always debt_ + externalRequestId.
  • description is returned on creation and on reads (GET /debts/{id}, GET /debts) when the debt has one; otherwise the field is absent.
  • contact.contactId carries the con_ prefix, also when the contact is created inline.
  • amountType (CLOSED or OPEN) is in every debt response: creation, reads, PATCH, and cancellation.
  • recurring is only in the creation response of POST /v2/debts, with false if you did not send it. Reads (GET /debts/{id}, GET /debts) do not include it.
  • date-time values come in UTC with milliseconds and Z. See API conventions.
The paymentUrl is a deep link that points directly to that specific debt. It is an opaque URL: share it as-is with your debtor, and don’t parse it or build it by hand (its format may change). Debts generated by a subscription also carry their own deep link (you see it in GET /subscriptions/{id}/debts).

Lifecycle

Retrieve and list

GET /debts/{id} accepts the debtId (debt_...) or the externalRequestId without prefix. It also returns cancelled debts (status: CANCELLED). GET /debts returns your debts from newest to oldest, paginated with page and limit (see API conventions). It does not include cancelled debts: to read a cancelled one, use GET /debts/{id}.
  • They accept a date (YYYY-MM-DD) or an RFC 3339 date-time. Any other format returns 400.
  • A date alone covers the full UTC day, included at both ends: createdAtFrom=2026-09-24 starts at 00:00:00.000Z and createdAtTo=2026-09-24 ends at 23:59:59.999Z. With the same date in both, you get the debts of that day.
  • A date-time is converted to UTC and the filter has daily precision: the full UTC day that contains it is included. A createdAtTo at exactly 00:00:00Z does not include that day.
  • Without createdAtTo, the range runs until today. A future createdAtFrom without createdAtTo returns an empty list.
  • createdAtFrom later than createdAtTo returns 400.

Fixed or open amount

amountType defines what is registered in the payment provider and takes precedence over allowPartialPayments.
  • allowPartialPayments only decides how payments are accounted for. OPEN with allowPartialPayments: true (the default) is valid: payments accumulate and the response still reports OPEN.
  • CLOSED with the default allowPartialPayments (true) behaves as it always has.
  • In an OPEN debt, amountPaid is the sum of the payments received, because amount does not reflect what was collected.
  • PARTIAL is not a public value of amountType: sending it returns 400.

Recurring debts

A debt created with recurring: true keeps being offered to the debtor after a payment. It is meant for charges that are paid more than once against the same debt.
  • Each payment is added to the same debt: no new debt is created.
  • The status stays PAID from the moment the debt is settled and does not change with later payments.
  • amountPaid is the larger of the amount settled according to the status and the sum of the payments received, so it can exceed amount. In an OPEN debt, amountPaid is always the sum of the payments.
  • A recurring debt in PAID can be cancelled with POST /debts/{id}/cancel. PAID debts that are not recurring cannot.
recurring is not the autopay field of subscriptions: it does not enable any automatic collection.

Update and cancel

You can only update a debt in PENDING status. Attempting it in another status, including a cancelled debt, returns 422 BUSINESS_RULE_VIOLATION.Editable fields: amount and dueDate. Send at least one: an empty body or any other field returns 400 INVALID_REQUEST. dueDate uses the YYYY-MM-DD format, must be a valid calendar date, and cannot be earlier than today. amount must stay within the range your collection setup allows. companyCode in the body is taken as context, not as a field to modify.The PATCH does not modify allowPartialPayments. The response carries dueDate as YYYY-MM-DD and amountPaid with the current amount paid.
You can cancel a debt in PENDING, PARTIALLY_PAID, or OVERDUE status. A PAID debt can only be cancelled if it is recurring; otherwise it returns 422 BUSINESS_RULE_VIOLATION.Cancelling a debt that is already cancelled is idempotent: it returns 200 with the debt in CANCELLED, without cancelling it again. If the debt is still active after the cancellation was requested, the API returns 409 RESOURCE_CONFLICT instead of answering 200.The endpoint takes no body (if you send one, it is ignored). The cancelled debt can still be read with GET /debts/{id}, but it no longer appears in GET /debts.
Cancels up to 50 debts in one request. Each id is the same one POST /debts/{id}/cancel accepts, with or without the debt_ prefix. Each debt follows the same rule as the single cancellation and is resolved on its own: one that fails does not stop the others.
If an item is invalid (no id, repeated, extra fields, and so on), the API returns 400 INVALID_REQUEST and cancels no debt. Each error.details entry carries the item’s index.The response carries the cancelled debts in data, in the order you sent them and with paymentUrl set to null, including the ones that were already cancelled. The ones that were not cancelled come in errors, with their index, the id exactly as you sent it, code, and message (see Errors). The status sums up the batch:
  • 200: every debt was cancelled. errors is not present.
  • 207: some were cancelled.
  • 422: none was cancelled and none has INTERNAL_ERROR (for example, they do not exist, cannot be cancelled in their status, or could not be looked up).
  • 500: none was confirmed as cancelled and at least one has INTERNAL_ERROR, a failure on our side. It does not mean they were not cancelled.
On a 500, or an INTERNAL_ERROR or RESOURCE_CONFLICT in errors, retry the same batch: it is safe, because a debt that was already cancelled comes back in data.

Errors

On top of the general catalog, these are the most common error causes in the debt endpoints and the error.code each one returns. The error.message is informational and may change: branch your logic on the status, error.code, and error.details[].field, not on the text. In POST /debts/cancel, each debt that was not cancelled comes in errors with one of these code values: Some real messages, for reference only: When the failure is not a validation one, the API keeps the real status instead of always turning it into a 500, so you can also get a 409 RESOURCE_CONFLICT or a 422 BUSINESS_RULE_VIOLATION outside the cases in the table. These errors carry no error.details, because they do not point at a specific field of your payload.

Endpoints

Try it in the API Reference

Explore each endpoint with its interactive playground.