> ## 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.

# Send portfolio

> Sends up to 500 open contracts: person, phones and debt

# Send portfolio

Writes one page of your portfolio: for each contract, the person (by CPF/CNPJ), their phones and the debt. No call is created. Available only to debt-collection workspaces in Brazil (see [Debt collection portfolio](https://docs.talkover.ai/en/api-reference/portfolio/overview.md)).

## Endpoint

```
POST /api/v1/portfolio/debts
```

## Request headers

**Authorization** `string` *required*

Bearer token. Format: `Bearer talq_your_environment_token_here`

**Content-Type** `string` *required*

`application/json`

## Request body

**debts** `array` *required*

A list of **1 to 500** contracts. Each item is an object; each object is one contract.

### Contract fields

Contract field names are lowercase and case-sensitive: `Installments` or `Due_Date` are not recognized and go to the free fields. Only the document (`cpf`, `CPF`…) and the phones accept any case.

| Field | Required | Format | Notes |
| - | - | - | - |
| `cpf` (or `cnpj`, `cpf_cnpj`, `cpfcnpj`, `document`, `documento`, `doc`) | yes | CPF or CNPJ, with or without mask | A leading zero lost by a spreadsheet is restored (`1234567890` = `01234567890`). Repeated sequences (`111.111.111-11`) are refused |
| `external_debt_id` | yes | text, up to 191 characters | The contract id in your system |
| `due_date` | yes, without `installments` | `YYYY-MM-DD` or `DD/MM/YYYY` | Contract due date |
| `overdue_amount` | yes, without `installments` or `installment_amount` | money | Overdue amount |
| `installment_amount` | no | money | Used as the overdue amount only when `overdue_amount` is absent |
| `name` (or `nome`, `nome_cliente`, `nome_completo`, `customer_name`, `full_name`) | no | text | Person's name |
| `to`, `phone`, `phone_1` … `phone_N` | no | phone, with or without `+55` | Each phone becomes a channel of the person. An international number not starting with `55` gets `55` prepended: send Brazilian phones only |
| `delinquent_since` | no | `YYYY-MM-DD` or `DD/MM/YYYY` | Since when the contract is delinquent. Does not change the due date |
| `installments` | no | list of installments | See [Installments](#installments) |
| `payment_deadline` | no | date | Payment deadline |
| `days_overdue` | no | integer ≥ 0 | Days overdue |
| `overdue_installments`, `installments_total` | no | integer from 0 to 65535 | Overdue installments and total installments |
| `credit_limit` | no | money | Credit limit |
| `creditor` | no | text, up to 191 | Creditor |
| `collection_phase`, `risk_class`, `payment_slip` | no | text, up to 64 | Collection phase, risk class, boleto line |
| `whatsapp_opt_in` | no | `sim`/`não`, `true`/`false`, `1`/`0` | Did the person agree to receive WhatsApp? See [WhatsApp opt-in](#whatsapp-opt-in) |
| `whatsapp_opt_in_at` | no | `YYYY-MM-DD` or `DD/MM/YYYY`, not in the future | When the person gave or withdrew consent |
| `whatsapp_opt_in_source` | no | text, up to 191 | Where consent was collected (`contract`, `app`, `site`) |
| `whatsapp_opt_in_category` | no | `reminder` or `payment` | What the person agreed to receive |
| any other field | no | any value | Stored on the contract and available to the agent during the call |

**Money** accepts both decimal separators: `1234.56`, `1234,56`, `1.234,56`, `1,234.56`, `1234`, with or without `R$`. `1.234` (one separator followed by exactly 3 digits) is ambiguous and refused: send `1234` or `1.234,00`. Negative values are refused.

### Installments

`installments` is optional. Each installment:

| Field | Format |
| - | - |
| `number` | integer from 1 to 65535, unique within the contract |
| `due_date` | `YYYY-MM-DD` or `DD/MM/YYYY` |
| `amount` | money: the installment amount |
| `outstanding_amount` | money: the open balance, from `0` to `amount` |

When the contract has installments:

* the contract's due date becomes the **oldest installment with a balance**;
* the overdue amount becomes the **sum of the open balances**;
* if all are paid, the contract is written with overdue amount `0.00`. This is not a payment record: to take the contract out of collection, use [Record payment](https://docs.talkover.ai/en/api-reference/portfolio/record-payment.md).

A contract sent **without** `installments` has no installments: installments from an earlier send are removed. To keep them, always send them. The same installment written another way (`175` and `175.00`, `10/07/2026` and `2026-07-10`) does not count as a change.

### WhatsApp opt-in

WhatsApp is only sent to people who agreed to receive it, and you, the creditor, report that consent.

* Consent applies to **every phone** on the row. If only one phone has consent, send that phone on a row with `whatsapp_opt_in` and the others on a row without the field.
* The latest send wins: `sim` after `não` grants again; `não` after `sim` revokes. Every change is kept in the history.
* An empty or absent field does not change what was already recorded.
* An empty category with `sim` means `reminder` (due-date reminders). An empty category with `não` revokes all categories.
* If the person replied "parar" (stop) to a message, nothing you send later resumes messages to that number.

## Examples

```bash theme={null}
curl -X POST "https://app.talkover.ai/api/v1/portfolio/debts" \
  -H "Authorization: Bearer talq_your_environment_token_here" \
  -H "Content-Type: application/json" \
  -d '{
    "debts": [
      {
        "cpf": "529.982.247-25",
        "name": "Maria Souza",
        "phone_1": "+5511999990001",
        "phone_2": "11999990002",
        "external_debt_id": "C-1",
        "creditor": "Loja Centro",
        "delinquent_since": "2026-08-10",
        "installments": [
          { "number": 1, "due_date": "2026-07-10", "amount": "175.00", "outstanding_amount": "0.00" },
          { "number": 2, "due_date": "2026-08-10", "amount": "175.00", "outstanding_amount": "175.00" }
        ],
        "whatsapp_opt_in": "sim",
        "whatsapp_opt_in_source": "contract",
        "store_code": "SP-04"
      }
    ]
  }'
```

### Portfolios over 500 contracts

Split into pages of up to 500 and send them one at a time. There is no batch to open or close: each page stands alone. Add up `written` from the responses and collect the `rejected` lists. `row` is the position **inside the page**: row 3 of page 2 is contract 503.

## Response

`200 OK` whenever the page was processed, **even with refused rows**.

```json theme={null}
{
  "success": true,
  "message": "3 of 4 debts written.",
  "data": {
    "received": 4,
    "written": 3,
    "without_phone": 1,
    "rejected": [
      {
        "row": 3,
        "external_debt_id": null,
        "reason": "external_debt_id_missing",
        "message": "Missing required column: external_debt_id"
      }
    ]
  }
}
```

**received** `integer`

Contracts received in the page.

**written** `integer`

Contracts written. The same `external_debt_id` twice in a page, with the same CPF, counts twice and the last one wins.

**without\_phone** `integer`

Contracts written without any usable phone. The contract links to the person who already has that CPF; if none exists, it stays without a person until a send with a phone.

**rejected** `array`

Refused rows, in page order. Each has `row` (position in `debts`, from 1), `external_debt_id` (as sent, or `null`), `reason` (stable code, use it for automation) and `message` (human text, may change).

### Why a row is refused

A refused row is not written; the rest of the page goes on. Reasons, in the order they are checked:

| `reason` | When |
| - | - |
| `document_missing` | the row has no CPF/CNPJ |
| `document_invalid` | the CPF/CNPJ is invalid |
| `installments_invalid` | `installments` is not a list; an installment lacks `number`, `due_date`, `amount` or `outstanding_amount`; `number` outside 1–65535 or repeated; invalid format; balance greater than amount |
| `delinquent_since_invalid` | `delinquent_since` is not a valid date |
| `due_date_missing` | no due date and no installments |
| `amount_missing` | no `overdue_amount` or `installment_amount`, and no installments |
| `<field>_invalid` | the field has an invalid format (`due_date_invalid`, `overdue_amount_invalid`, `days_overdue_invalid`) |
| `external_debt_id_missing` | no `external_debt_id` |
| `whatsapp_opt_in_invalid`, `whatsapp_opt_in_at_invalid`, `whatsapp_opt_in_source_invalid`, `whatsapp_opt_in_category_invalid` | a value that is not yes/no, an invalid or future date, a source over 191 characters, a category other than `reminder`/`payment` |
| `external_debt_id_conflict` | this `external_debt_id` already belongs, in your workspace, to another CPF/CNPJ, or an earlier row of the page used the same id with another CPF/CNPJ. The existing contract is not changed |

A phone on a do-not-call list does **not** refuse the row: the phone is stored and each campaign applies its own list when dialing.

## Error responses

Nothing from the request is written in these cases, except on `500`.

| Status | When |
| - | - |
| `401` | missing or invalid token |
| `403` | the API is not enabled for the workspace (`"The portfolio API is not enabled for this workspace."`), or the subscription is inactive |
| `422` | `debts` missing, empty, over 500 items, not a list, or with an item that is not an object |
| `429` | over the request limit; wait `Retry-After` and resend |
| `500` | unexpected failure. Part of the page may already be written: **resend the same page** |

```json theme={null}
{
  "success": false,
  "message": "The portfolio page could not be written. Resend the same page.",
  "error": "Internal error"
}
```


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