> ## Documentation Index
> Fetch the complete documentation index at: https://docs.talkover.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Debt collection portfolio

> Send your debt portfolio and record payments and returns, one contract at a time

# Debt collection portfolio

These endpoints keep your workspace's collection portfolio up to date: you send the open contracts and, during the day, report each payment or withdrawal. The collection cadence uses this data to decide whom to collect from, and stops the moment a debt leaves collection.

**These endpoints never create a call.** The campaign decides whom to call.

> [!NOTE]
>
> Available only to **debt-collection workspaces in Brazil**. Talkover turns the API on environment by environment; while it is off, every call answers `403` and nothing is written. Ask your Talkover contact to turn it on or off.

## Endpoints

| What it does | Call |
| - | - |
| [Sends a portfolio page](https://docs.talkover.ai/en/api-reference/portfolio/send-debts.md), up to 500 contracts: writes the person, the phones and the contract | `POST /api/v1/portfolio/debts` |
| [Gets a contract](https://docs.talkover.ai/en/api-reference/portfolio/get-debt.md): status, open amount, installments, payments and returns | `GET /api/v1/portfolio/debts/{external_debt_id}` |
| [Records a payment](https://docs.talkover.ai/en/api-reference/portfolio/record-payment.md) (payment or agreement) on the contract or one installment | `POST /api/v1/portfolio/debts/{external_debt_id}/payments` |
| [Records a return](https://docs.talkover.ai/en/api-reference/portfolio/record-return.md): the creditor took the contract, or some installments, out of collection | `POST /api/v1/portfolio/debts/{external_debt_id}/return` |

## Typical flow

1. Once a day, send the whole portfolio in pages of up to 500 contracts.
2. During the day, record each payment or return as it happens. The cadence stops collecting that debt immediately.

## Authentication

Use the environment token, as in the rest of the API:

```bash theme={null}
Authorization: Bearer talq_your_environment_token_here
```

A user token with the `write` ability also works, together with the `X-Environment-Id` header holding the environment id.

## The contract id is the key

Each contract is identified by **its id in your system**, the `external_debt_id`. Sending the same id again updates the contract and never duplicates it. Case matters (`CTR-1a` and `CTR-1A` are two contracts). Another workspace's id is never visible to your token.

## Retrying is safe

All four endpoints can be repeated after a timeout, a dropped connection or a `500`:

* the same portfolio page sent again creates no new person, phone, contract or installment, and returns the same counts;
* the same payment or return sent again answers `200` with `created: false` and writes nothing.

Sending the whole portfolio every day is safe too: a contract that did not change records no new history.

## Limits

| Endpoint | Limit |
| - | - |
| Send portfolio | up to **500 contracts** per request and **60 requests per minute** per workspace |
| Get, payment and return | the API's default read and write limits; one contract per request |

Over the limit, the response is `429` with a `Retry-After` header (in seconds). Wait that long and resend the same request.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.