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

# accounts-payable

# Tango AP Inbound (Payment Confirmation) API

> Generated from `Tango AP Inbound API Integration Design Specification V1.2.docx` in SharePoint folder `02 Lease Integrations`. OAS spec: `ap-inbound-api.yaml`

## Overview

Async REST API for posting AP **check confirmations** back to Tango after the client issues lease payments. Tango updates the Payments tab; payment status transitions to `PAID` or `VOID`.

**Owner:** Tango Analytics
**Spec version:** 1.2
**Status:** Draft (auto-generated — needs review)

## Base URLs

| Environment | URL |
| - | - |
| Production | `https://api.tangoanalytics.com` |
| Test (SIT/UAT) | `https://testapi.tangoanalytics.com` |

## Authentication

Headers `x-client` + `x-api-key`, required on every call.

## Endpoints

| Method | Path | Summary |
| - | - | - |
| PUT | `/v1/leasemgmt/payments` | Submit AP payment confirmations (async). |
| GET | `/v1/batch/status?gu_id=...` | Poll processing status. |

### `PUT /v1/leasemgmt/payments`

```json theme={null}
{
  "records": [
    {
      "lease_payment_id": "80285",
      "invoice_header_id": "80285",
      "invoice_id": "80285",
      "invoice_number": "92492-023",
      "payment_status": "PAID",
      "check_number": "23499",
      "check_amount": "309.00",
      "check_date": "07/16/2020",
      "applied_amount": "309.00",
      "reconcile_date": ""
    }
  ]
}
```

**Response — 200 OK**

```json theme={null}
{ "status": "OK/Error", "status_message": "", "gu_id": "cc70b809-5142-4ebe-9dcc-6ca59fa01122" }
```

### `GET /v1/batch/status?gu_id=...`

Three response shapes (`PROCESSING` / `COMPLETED` / `ERROR`). On error, `record_key` is `lease_payment_id`; multiple errors for the same record are returned comma-separated.

## Integration logic

* `lease_payment_id` is the record key — must already exist in Tango (it's the same ID Tango sent in AP Outbound).
* Check Amount and Applied Amount may differ.
* A payment can be `VOID` either before the check is issued OR after it was `PAID` (retraction).
* Alternatively, the business may keep history by creating a credit invoice manually and marking the original payment `VOID`.

## Data model

| Field | Type | Required | Notes |
| - | - | - | - |
| `lease_payment_id` | NUMBER | ✅ | Tango unique payment ID |
| `invoice_header_id` | NUMBER | – | Tango unique invoice header ID |
| `invoice_id` | VARCHAR | – | |
| `invoice_number` | VARCHAR | – | |
| `payment_status` | VARCHAR | ✅ | `PAID` / `VOID` |
| `check_number` | VARCHAR | ✅ | Check or EFT |
| `check_amount` | NUMBER | ✅ | |
| `check_date` | DATE `MM/DD/YYYY` | ✅ | |
| `applied_amount` | NUMBER | – | |
| `reconcile_date` | DATE `MM/DD/YYYY` | – | |

## Validations

1. `invoice_header_id` is NULL → `Invoice_header_id is null`
2. `lease_payment_id` does not exist → `lease_payment_id does not exist in Tango`
3. `payment_status` is NULL → `payment_status is null`
4. `payment_status` not in (`PAID`, `VOID`) → `payment_status does not match expected value`
5. `check_number` is NULL → `check_number is null`
6. `check_date` is NULL → `check_date is null`
7. `check_date` format not `MM/DD/YYYY` → `check_date does not match expected format`

## Open Questions / Assumptions

* [ ] **Sample JSON sends numeric fields as strings** (`"check_amount": "309.00"`). Schema uses `number`; consumers may need to coerce.
* [ ] **No explicit response for synchronous errors** at PUT — assumed errors flow through the polled status response.
* [ ] **Lookup codes** for payment statuses, etc., are `<TBD>` in source Appendix.

## Changelog

| Ver | Date | Description | Author |
| - | - | - | - |
| 0.1 | — | Initial Draft | Michael Phoenix |
| 0.2 | 04/15/2021 | Updated Data Mappings & API Architecture | Shalmali Patil |
| 0.3 | 07/18/2022 | Updated Request & Integration Status | Olivia Aneye |
| 0.4 | 07/29/2022 | Updated Request, Integration Status & Error Conditions | Olivia Aneye |
| 0.5 | 08/22/2022 | Updated formatting | Jasmin Thasleem |
| 0.6 | 11/16/2022 | Updated Integration Status | Jasmin Thasleem |
| 0.7 | 12/09/2022 | Updated Data Mapping (client label) | Jasmin Thasleem |
| 0.8 | 12/15/2022 | Updated Data Mapping | Jasmin Thasleem |
| 0.9 | 09/19/2023 | Reformatted; Data Mapping types | Jasmin Thasleem |
| 1.0 | 01/18/2023 | Addition of invoice\_header\_id | Shanmugam Muthaiah |
| 1.1 | 06/20/2025 | Required column for lease\_payment\_id | Rahma Ouedraogo |
| 1.2 | 04/22/2026 | Updated API Architecture | Jasmin Thasleem |
