Skip to main content
Tapipay can collect your debts through bank direct debit without declaring a payment method on each debt: collection is governed by the payment method each end user registers once.
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
productName is not accepted on POST /v2/debts: products are never created from this endpoint. Sending it returns 400 INVALID_REQUEST. The paymentMethods, paymentMethod, and autopay fields are not accepted either (400 INVALID_REQUEST): the method used for automatic collection is defined by the user’s subscription to the product, never by the debt body. In general, POST /v2/debts rejects any field outside its contract with a 400 that names the field in details[].field. See the accepted fields in Debts.

Create several debts in one request

The same endpoint accepts up to 50 debts per request through the debts 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.
How it behaves:
The batch 207 and 422 do not use the error envelope: they have no error object, but data, errors[], and requestId. If your code reads error.code on any 4xx, account for this format. The errors[] entries have no details.
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}.
When several debts in the batch belong to the same debtor or product, that information is resolved once for the whole request. Grouping a user’s debts in the same batch makes the request faster.

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.
To subscribe the user to a product, use POST /adhesions: see Subscribe and unsubscribe a product.
If your integration read autopay from the POST /v2/debts response to decide anything, review it before this release: the field is gone, so debt.autopay becomes undefined and a check like if (!debt.autopay) starts returning true every time. On GET /debts and GET /debts/{id} the field still exists, but it is a flag on the debt itself: it never meant “there is an active direct debit agreement”.

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
Each method has these fields: 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.
If the 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

Add include=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
With 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
This is how it behaves:
  • 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 with POST /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 with POST /adhesions/cancel and 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 in deactivatedAdhesions. adhesionCancellationIncomplete comes as true when that check did not finish:
    • If pendingAdhesions lists products, those adhesions may still be active on the deleted method. For each one, cancel it with POST /adhesions/cancel or, if you want the product to keep being charged automatically, adhere it again with POST /adhesions: it moves to the new default.
    • If pendingAdhesions is 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.
    Retrying the deletion does not help: it responds 404.
  • 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 in newDefaultExternalPaymentMethodId. What counts is the last time each account was registered: if the user registered again an account they already had, that date counts, not its createdAt. If none is left, it comes as null: until the user registers another account, payment orders without externalPaymentMethodId fail through the order creation webhook with PAYMENT_METHOD_REQUIRED.
  • Payment orders: the ones already created with this method follow their course. A new order with this externalPaymentMethodId fails through the order creation webhook with PAYMENT_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
The response of both endpoints carries only 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.
To subscribe, the user must already have registered their bank account on the enrollment page (not through the API). The adhesion uses the user’s default account, which must be of type 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 productId or externalProductId that does not exist returns 404 RESOURCE_NOT_FOUND and the debt is not created.