Important change. Creating a debt no longer enables direct debit. Enrollment is managed per product, separately from debt creation, and
POST /v2/debts no longer returns autopay, autopayReason or autopayInstrument. See What’s new.How it works
The model relies on three pieces:Products
Every debt belongs to a product (for example “Tuition”). Direct debit is managed per product: when a user enrolls, they enroll the whole product.
User's bank account
The user registers their bank account once through the Tapipay enrollment page (not via API). That account is used to collect the debts of the products the user is subscribed to.
Debts v2
You create debts via API referencing the product. The response tells you whether automatic collection is active and why.
On
POST /v2/debts the debt does not declare a payment method: the paymentMethods and autopay fields are not accepted and return 400 INVALID_REQUEST (they only apply to subscriptions). The method used for collection is defined by the user’s enrollment in the product, never by the debt body.Prerequisites
- Your company must have direct debit enabled (configured with your Tapi account executive).
- Your products must exist before creating debts. You can create them with your own identifier (
externalProductId) so you never store Tapi IDs.
Create a debt
Product identity travels through exactly one of these two fields (never both):
The rest of the contract matches creating a debt: amount, due date, debtor.
201 response
Create several debts in one request
The same endpoint accepts up to 50 debts per request through thedebts envelope. Each item has the same contract as a single debt plus a mandatory externalRequestId, unique within the batch: it is the idempotency key of each debt (the Idempotency-Key header is not used in this mode).
If the body carries debts, only debts is accepted at the top level: any other root field returns 400. A JSON array at the root, without the { "debts": [...] } envelope, also returns 400.
422 response
Debts in a batch are created independently: one failing in the collections system does not stop the others. The
code values in errors[] are the same the endpoint returns for a single debt. An externalRequestId that already existed does not create a new debt. To see the stored debt, read it with GET /debts/{debtId}.How to know whether a debt will be collected automatically
POST /v2/debts does not report the direct debit status. Creating the debt and enrolling in the product are two separate things:
- If the user is already enrolled in that product, the debt is collected automatically on its due date.
- If they are not, the debt is paid through its
paymentUrl, like any other. The debt is always created: not being enrolled is not an error.
POST /adhesions: see Subscribe and unsubscribe a product.
Query a user’s payment methods
GET /payment-methods lists the payment methods a user registered for direct debit. externalClientId is required, must be exactly the same identifier used at enrollment, and does not accept the characters ', ", \, ;. If your client has several companies, also send companyCode. The response is not paginated.
The first account the user registers becomes the default one. The ones they register afterwards are additional: the default does not change while it remains active. The default account is the one used by adhesions and by payment orders that do not specify externalPaymentMethodId. If it is deleted, see Delete a payment method.
200 response
bankAccount has:
If the account data cannot be retrieved at that moment,
bankAccount comes as null (or only bankName comes as null) and the rest of the method comes as usual. It is not an error: query again later if you need that data.externalClientId has no registered methods or does not exist, the response is 200 with data: []. These are the possible errors:
Active adhesions of each method
Addinclude=activeAdhesionsCount so that each method carries activeAdhesionsCount: the number of active adhesions with that method. They are the ones that get cancelled if you delete it with DELETE /payment-methods/{externalPaymentMethodId}. If there are more than 10, that deletion answers 422 BUSINESS_RULE_VIOLATION and cancels none; the count still shows the total. Without the parameter, the response does not carry the field.
Response 200
include=activeAdhesionsCount, externalClientId only accepts letters, digits, _, and -, up to 100 characters, the same as in DELETE /payment-methods/{externalPaymentMethodId}.
Delete a payment method
DELETE /payment-methods/{externalPaymentMethodId} deletes one of the user’s payment methods. externalPaymentMethodId is the one returned by GET /payment-methods. externalClientId goes in the query and is required: the same identifier used at enrollment, with only letters, digits, _, and -, up to 100 characters (stricter than in GET /payment-methods). If your client has several companies, also send companyCode.
Response 200
-
Adhesions: the adhesions that used that method are cancelled first. They come in
deactivatedAdhesions. They do not move to another method on their own: if you want those products to keep being charged automatically, adhere again withPOST /adhesions. If any of them cannot be cancelled, the method is not deleted. If the method has more than 10 active adhesions, none is cancelled: cancel some of them withPOST /adhesions/canceland retry. -
Adhesions created during the deletion: if the method was the default one, after deleting it there is a check for any new adhesion created on it in the meantime (for example, with
POST /adhesions). The ones found are cancelled in the same request and also come indeactivatedAdhesions.adhesionCancellationIncompletecomes astruewhen that check did not finish:- If
pendingAdhesionslists products, those adhesions may still be active on the deleted method. For each one, cancel it withPOST /adhesions/cancelor, if you want the product to keep being charged automatically, adhere it again withPOST /adhesions: it moves to the new default. - If
pendingAdhesionsis empty, it was not possible to verify whether any is left. One can only be left if an adhesion was created for that user at the same moment the method was being deleted. If that happened, do the same with that product.
404. - If
-
Default method: if the deleted method was the default one (
wasDefault: true), the method the user registered most recently among the remaining ones becomes the default and comes innewDefaultExternalPaymentMethodId. What counts is the last time each account was registered: if the user registered again an account they already had, that date counts, not itscreatedAt. If none is left, it comes asnull: until the user registers another account, payment orders withoutexternalPaymentMethodIdfail through the order creation webhook withPAYMENT_METHOD_REQUIRED. -
Payment orders: the ones already created with this method follow their course. A new order with this
externalPaymentMethodIdfails through the order creation webhook withPAYMENT_METHOD_INACTIVE.
Subscribe and unsubscribe a product
A user’s adhesion to a product is managed with two endpoints. While the adhesion is active, the debts of that product are collected automatically with the user’s payment method.
Both take the same body and only accept these fields. Any other one returns
400 INVALID_REQUEST with the field in details[].field:
You must send one of
productId or externalProductId (not both, not neither). Unlike POST /v2/debts, the product is required here.
201 response
externalClientId, productId, status (ACTIVE or INACTIVE), and createdAt. createdAt can be null if the adhesion that was just written could not be read back: the adhesion is registered anyway. The response does not include the payment method.
How POST /adhesions behaves
The endpoint is idempotent: repeating the call does not duplicate the adhesion.
If the user had an old adhesion that was not tied to any product, it is cancelled when the product is subscribed. This way the same debt is not collected twice.
BANK_ACCOUNT (a CLABE or a debit card). If the user has no active default account, or your company does not have direct debit enabled, the response is 422 NO_ACTIVE_PAYMENT_METHOD: ask them to register their account and retry.
How POST /adhesions/cancel behaves
It deactivates the user’s adhesion to that product and responds 200 with status: INACTIVE. Repeating the cancellation on an adhesion that is already inactive also responds 200. It does not modify the user’s registered account: to subscribe again, call POST /adhesions.
Errors
Rules to keep in mind
- Nonexistent product: a
productIdorexternalProductIdthat does not exist returns404 RESOURCE_NOT_FOUNDand the debt is not created.

