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

# ap-outbound-api

# Tango AP Outbound API

> Generated from `Tango AP Outbound API Integration Design Specification V1.4.docx` in SharePoint folder `02 Lease Integrations`.
> OAS spec: [`ap-outbound-api.yaml`](./ap-outbound-api.yaml)

## Overview

Async REST API used by the client to fetch approved lease payments from Tango. Two-call pattern: GET initiating call returns a `gu_id`; GET on `/v1/batch/status` with that `gu_id` (and optional `page_no`) returns paginated payment records (5000/page).

**Owner:** Tango Analytics
**Spec version:** 1.4
**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`.

## Endpoints

| Method | Path | Summary |
| - | - | - |
| GET | `/v1/leasemgmt/payments` | Initiate AP export — returns `gu_id`. |
| GET | `/v1/batch/status?gu_id=...&page_no=...` | Retrieve paginated records. |

### `GET /v1/leasemgmt/payments`

Optional query params:

| Param | Description |
| - | - |
| `calendar_year` | 4-digit fiscal year |
| `calendar_month` | Fiscal period |
| `country` | 3-digit country code |
| `financial_group` | Drop-down value |

**Response — 200 OK**

```json theme={null}
{ "status": "OK/Error", "status_message": "", "gu_id": "721c54c4-c7aa-4fa1-8fdfd6-c0cee161694d" }
```

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

Default `page_no = 1`, page size 5000. Header carries `total_records`, `total_pages`, `page_size`, `page_no`.

Null fields are **omitted** from the JSON.

## Integration logic

* Only approved batches and payments associated with Active leases are returned.
* Zero-dollar payments are excluded.
* `pay_id` == `lease_payment_id` in the AP Inbound payload (reconciliation key).
* After successful export the payments are flagged accordingly in Tango.

## Data model

Required fields per the source data-mapping table (✅ = required):

| Field | Type | Req | Notes |
| - | - | - | - |
| `pay_id` | NUMBER | ✅ | Round-trips as `lease_payment_id` in AP Inbound |
| `lease_num` | VARCHAR | ✅ | |
| `status` | VARCHAR | ✅ | Lease status |
| `term_status` | VARCHAR | ✅ | |
| `loc_num` | VARCHAR | ✅ | |
| `year` | NUMBER | ✅ | Fiscal year (NOT calendar) |
| `mon` | NUMBER | ✅ | Fiscal period (NOT calendar) |
| `ven_num` | VARCHAR | ✅ | Vendor number |
| `category` | VARCHAR | ✅ | Payment category |
| `type` | VARCHAR | ✅ | Payment type |
| `effective_date` / `applies_from_date` / `applies_to_date` | DATE | ✅ | `MM/DD/YYYY` |
| `due_date` / `creation_date` | DATE | – | |
| `gross` / `tax1` / `tax2` / `total_tax` / `net` | NUMBER | – | |
| `pay_status` / `tax_rate` / `currency` / `pay_currency` | VARCHAR | – | |
| `consumption` / `consum_uom` / `account_string` | VARCHAR | – | |
| `inv_num` / `inv_id` / `remit_message` / `gl_acc` | VARCHAR | – | |
| `country` / `legal_entity` | VARCHAR | – | |
| `seg1`–`seg6` / `seg1_gl`–`seg6_gl` | VARCHAR | – | Segments / GL segments |
| `cattr1`–`cattr16` | VARCHAR | – | Custom attributes |
| `payext2`–`payext8` | VARCHAR | – | Payment extensions |
| `supplier_number` | VARCHAR | – | Added in v1.3 |

## Open Questions / Assumptions

* [ ] **No synchronous error response shape** documented for the initial GET — assumed it returns the same envelope without a `gu_id`.
* [ ] **`year` and `mon` field types**: the data mapping says NUMBER, but the response example wraps them in quotes (`"year": "2020"`). Treated as integers in the schema.
* [ ] **Lookup codes** are `<TBD>` in source Appendix.
* [ ] **`payext1`** is missing from the JSON sample (jumps from `cattr16` to `payext2`); confirmed via mapping table that there is no `payext1` field.
* [ ] **Pagination**: page size 5000 appears non-configurable.

## Changelog

| Ver | Date | Description | Author |
| - | - | - | - |
| 0.1–1.3 | 2020-2025 | (see source doc) | Various |
| 1.4 | 04/22/2026 | Updated API Architecture | Jasmin Thasleem |
