# Contacts and Payments API

> Mark Edesy Collect debtors paid, promised or stopped, and set payment status from your payment system with the payment webhook endpoint.

Source: https://edesy.in/docs/collect/api/contacts-and-payments

These endpoints change a debtor's payment status. Any status other than pending cancels the debtor's next scheduled call. Use the per-contact endpoints from your own tools, or the payment webhook endpoint from your payment system. Each takes the debtor's contact ID, which you get from the campaign's contact list.

## Find the contact ID

```bash
curl "https://voice-api.edesy.in/v1/campaigns/CAMPAIGN_ID/contacts?page=1&per_page=50" \
  -H "Authorization: Bearer sk_your_api_key"
```

The response has `data` (contacts, each with `id`, `phone_number` and `payment_status`) and `meta` (`total`, `page`, `per_page`).

## Mark one debtor

```
POST /v1/collect/contacts/:id/paid
POST /v1/collect/contacts/:id/promised
POST /v1/collect/contacts/:id/stop
```

No body. Response:

```json
{ "status": "ok", "payment_status": "promised" }
```

## Payment webhook

```
POST /v1/collect/webhooks/payment
```

| Field | Type | Required | Description |
|---|---|---|---|
| `contact_id` | uuid | Yes | The debtor's contact ID |
| `status` | string | No | `paid` (default), `promised`, `stopped` or `pending` |

```bash
curl -X POST https://voice-api.edesy.in/v1/collect/webhooks/payment \
  -H "Authorization: Bearer sk_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"contact_id": "CONTACT_ID"}'
```

```json
{ "status": "ok" }
```

Idempotent: repeating the same status is safe. It authenticates with your API key like the other endpoints. See [Payment Webhook and Razorpay](https://edesy.in/docs/collect/payments/payment-webhook-razorpay) for wiring it to your payment gateway.

## Errors

| Status | When |
|---|---|
| `400` | Invalid contact ID or status |
| `404` | Contact not found in your workspace |
