<!-- Generated by scripts/build-docs.js. Edit docs/swagger.yaml or docs/guides/, then run `npm run docs:build`. -->

# List sales

`GET https://marketplace-api.sequifi.com/v1/sales`

Module: Sales · operationId: `listSales` · Auth: `Authorization: Bearer <token>`
Web page: https://apidocs.sequifi.com/#/api/list-sales

Lists your company's processed sales (loans, for mortgage companies) with people, product, milestone dates, commission totals and custom field values. Use it to read sales back, or to poll for changes with `updated_after`. Decimal fields come back as strings and dates as timestamps such as `2026-05-01T00:00:00.000Z`, so compare dates on their first 10 characters.

**Before you call:**

- Not available to SequiPay companies (`403`).
- A sale sent with `POST /v1/sales` appears here only after Sequifi has processed it.

**What happens:**

- Read-only. Sequifi loads every sale that matches your filters, then returns the page you asked for. An unfiltered call on a company with many sales is slow and can hit the 29-second gateway timeout (`504`); pass a date filter on large pulls.
- `job_status` is calculated when you read it: `Clawback`, else `Cancelled` (has `date_cancelled`), else `Serviced` (has any milestone date), else `Pending`. A `job_status` you sent with the sale is not returned.
- `all_milestone[]` has one entry per commission line, so the same milestone can repeat (for example once for the closer and once for the setter). An extra `Recon` entry appears when reconciliation is on. Each entry has a payroll `status`.
- `milestone_dates[]` lists each milestone date once, in the shape you POST, including on sales with no `all_milestone[]` entries.
- `commission_lines[]` lists every commission and override line with its payroll status: `paid`, `approved`, `pending` or `do_not_pay`. Before you send a milestone date, check that milestone's lines here so you don't create a second pending line.
- `custom_field_values` is keyed by field name and shows the sale's current values, including edits made in the app. A field deleted from your configuration is left out.

**Filtering and paging:**

- Filters combine with AND. An unknown parameter returns `400` with `invalid_params` and `allowed_params`.
- `page` defaults to 1 and `per_page` to 50, with no maximum. Neither is validated: `0`, a negative number or text returns `200` with an empty or unexpected page, not an error.
- Default order is newest sale first. `start_date` and `end_date` apply only when both are sent.
- To crawl or poll without skipping rows, use `sort_val=ASC` with `updated_after` (the newest `updated_at` you have seen) and `per_page=200`.
- `search` and `customer_name` treat `%` and `_` as wildcards.

**Formats:**

- Dates (`customer_signoff`, `date_cancelled`, `last_service_date`, milestone `date`) are midnight UTC timestamps, for example `2026-05-01T00:00:00.000Z`. `created_at` and `updated_at` are UTC timestamps.
- `kw`, `epc`, `adders`, `total_override`, the dealer fee fields and the pest and fiber fields are strings. `total_commission` is a string with 2 decimals. `gross_account_value`, milestone `value` and `last_payment` are numbers.
- `projected_commission` and `projected_override` are flags (`1` projected, `0` final), not amounts.
- Mortgage `net_epc` is returned multiplied by 100, so it does not equal the value you sent.
- The list uses `requested_by` and `Sales` (capital S). `GET /v1/sales/{pid}` uses `requestedBy` and `sale`.

**Errors:**

- `400 Invalid query parameter(s)`: an unknown parameter.
- `400 date_from must be in YYYY-MM-DD format` (or `date_to`): not a real `YYYY-MM-DD` date.
- `400 updated_after must be a date (YYYY-MM-DD) or ISO 8601 timestamp` (same for `updated_before`, `created_after`, `created_before`).
- `401`: missing, invalid or expired token. The body is `{"message": "Unauthorized"}`.
- `403 Forbidden: This endpoint is not available for SequiPay companies`.
- `500 Database Connection Error` or `Internal Server Error`: retry later.

**Common mistakes:**

- Reading an empty page caused by a bad `page` or `per_page` as "no sales".
- Comparing `job_status` with the value you sent.
- Comparing dates without cutting them to `YYYY-MM-DD`.
- Expecting `product_id=1` to return only that product: it also returns sales with no product.

**Related:**

- `GET /v1/sales/{pid}`: one sale.
- `POST /v1/sales`: create or update sales.
- `GET /v1/users/{id}/commissions`: rates to reconcile commissions against custom field values.

## Query parameters

- `page` (integer): Page number, starting at 1. Not validated: `0`, a negative number or text returns an empty or unexpected page. Default: `1`. Minimum: 1.
- `per_page` (integer): Sales per page. Default 50, no maximum. Not validated: `0` returns an empty `Sales` array with `last_page: null`. Default: `50`. Minimum: 1.
- `start_date` (string (date)): Start of an inclusive range (`YYYY-MM-DD`), used only together with `end_date`; one alone is ignored. Filters `customer_signoff`, or a milestone date when `milestone_date=true`. The format is not checked. Example: `2026-01-01`.
- `end_date` (string (date)): End of the inclusive range started by `start_date` (`YYYY-MM-DD`). Example: `2026-06-30`.
- `milestone_date` (boolean): `true` or `1` makes `start_date` and `end_date` filter a milestone date instead of `customer_signoff`. Name the milestone with `sale_type`. Default: `false`.
- `sale_type` (string): With `milestone_date=true`: the milestone `name` or `trigger_date_label` (from `GET /v1/milestones`) whose date must fall in the range. `Cancel Date` filters the cancellation date instead. Example: `Install`.
- `date_from` (string (date)): Sales with `customer_signoff` on or after this date. Must be a real `YYYY-MM-DD` date, else `400`. Example: `2026-01-01`.
- `date_to` (string (date)): Sales with `customer_signoff` on or before this date. Must be a real `YYYY-MM-DD` date, else `400`. Example: `2026-06-30`.
- `updated_after` (string): Sales changed at or after this time. Send `YYYY-MM-DD` (midnight UTC) or an ISO 8601 timestamp; a timestamp without a zone is read as UTC. For polling, pass the newest `updated_at` you have seen. Distinct from `date_from`, which filters the sale date. Example: `2026-05-06T13:43:14Z`.
- `updated_before` (string): Sales changed at or before this time. A bare `YYYY-MM-DD` covers the whole day (through 23:59:59 UTC). Example: `2026-05-31`.
- `created_after` (string): Sales created at or after this time. Same formats as `updated_after`. Example: `2026-05-01`.
- `created_before` (string): Sales created at or before this time. A bare `YYYY-MM-DD` covers the whole day (through 23:59:59 UTC). Example: `2026-05-31`.
- `date_filter` (string): Only sales that have a given date set: a milestone `name` or `trigger_date_label`, `Cancel Date`, or for pest companies `Service Completion Date` or `Initial Service Date`. Example: `Install`.
- `pid` (string): Exact pid. Use this instead of `GET /v1/sales/{pid}` when the pid contains `/`. Example: `SALE-10482`.
- `search` (string): Partial match on pid, customer name, closer 1 name or setter 1 name. `%` and `_` act as wildcards.
- `customer_name` (string): Partial match on the customer name. `%` and `_` act as wildcards.
- `customer_state` (string): Exact match on the customer state. Example: `AZ`.
- `product_id` (string): Integer product `id` from `GET /v1/products`. `null` or `unassigned` returns sales with no product; `all` applies no filter. `1` also returns sales with no product. Example: `12`.
- `product_name` (string): Case-insensitive partial match on the returned `product_name` (`Name - CODE`).
- `install_partner` (string): Case-insensitive partial match on the install partner. Surrounding quotes and spaces are removed, and `%` and `_` match literally. Example: `Brightline Solar`.
- `data_source_type` (string): Exact match on the sale's source label. No filter applies unless you send it, and `all` also means no filter. Sales sent through this API carry `Marketplace API`. Example: `Marketplace API`.
- `job_status` (string): Case-insensitive. Uses the same calculation as the returned `job_status`. Other values match an older stored status that is not kept up to date. One of: `Pending`, `Cancelled`, `Serviced`, `Clawback`.
- `is_exempted` (integer): `1` for sales exempted from clawback, `0` for the rest. One of: `0`, `1`.
- `office_id` (integer): Sales where closer 1 or 2, or setter 1 or 2, is a user whose current office is this one (not the office at the time of the sale). `all` applies no filter.
- `user_id` (integer): Sales where this user is closer 1 or 2, or setter 1 or 2. With `office_id`, the user must also be in that office.
- `closer1_id` (integer): Exact closer 1 user id.
- `setter1_id` (integer): Exact setter 1 user id.
- `sort` (string): Sorts all matching sales before paging. `product` is `product_name` and `status` is `job_status`. Values compare as text, so `last_payment` sorts `100` before `20`. Other values are ignored. One of: `last_payment`, `product_name`, `product`, `job_status`, `status`, `customer_name`.
- `sort_val` (string): `ASC` or `DESC` (default), case-insensitive. Also sets the default order (oldest or newest sale first) when `sort` is not sent. One of: `ASC`, `DESC`. Default: `"DESC"`.

## Example request

```bash
curl -X GET "https://marketplace-api.sequifi.com/v1/sales" \
  -H "Authorization: Bearer $SEQUIFI_TOKEN"
```

## Responses

### 200: One page of sales.

- `status` (integer): The HTTP status code, repeated. Example: `200`.
- `message` (string): Short text. Wording varies by endpoint; branch on the HTTP status, not on this text. Example: `success`.
- `data` (object)
  - `requested_by` (string): Name of the API credential that made the call.
  - `current_page` (integer): Page returned, as sent.
  - `per_page` (integer): Page size used.
  - `total` (integer): Number of sales that match the filters.
  - `last_page` (integer, nullable): Last page number. `0` when nothing matches; `null` when `per_page` is `0`.
  - `Sales` (array of object): The sales on this page.
    - `id` (integer): Sequifi's sale id. Not the `id` in the `POST /v1/sales` response.
    - `pid` (string): Your sale id, as sent on `POST /v1/sales`.
    - `customer_name` (string): Customer (borrower) name.
    - `data_source_type` (string, nullable): Where the sale came from. `Marketplace API` for sales sent through this API.
    - `job_status` (string): Calculated when you read it, in this order: `Clawback` when a clawback is shown on the sale, else `Cancelled` when `date_cancelled` is set, else `Serviced` when any milestone date is set, else `Pending`. A `job_status` you sent is not returned. One of: `Pending`, `Serviced`, `Cancelled`, `Clawback`.
    - `product_id` (integer, nullable): The product `id`. When Sequifi recorded an original product for the sale, this and the other product fields show that original product.
    - `product_code` (string, nullable): The product code.
    - `product_name` (string): `Name - CODE`, or `Sale product name (Name) - CODE` when the product name you sent differs. Empty when the sale has no product.
    - `org_product_id` (string, nullable): The product code (despite the field name).
    - `customer_state` (string, nullable): Customer state.
    - `customer_address` (string, nullable): Street address, as sent on `POST /v1/sales`.
    - `customer_address_2` (string, nullable): Second address line, such as a unit number.
    - `customer_city` (string, nullable): Customer city.
    - `customer_zip` (string, nullable): Customer ZIP code.
    - `customer_phone` (string, nullable): Customer phone number, as sent.
    - `customer_email` (string, nullable): Customer email address.
    - `last_milestone` (object, nullable): The milestone line with the latest date (ties go to the larger amount). `null` when no milestone has a date.
      - `name` (string): Milestone name.
      - `trigger` (string): Label of the date that triggers the milestone.
      - `value` (number): Amount of this line in dollars.
      - `date` (string (date-time)): Milestone date as a midnight UTC timestamp.
    - `last_payment` (number): The amount of `last_milestone`, or `0` when no milestone has a date.
    - `all_milestone` (array of object): One entry per commission line on the sale, so the same milestone can appear more than once (for example once for the closer and once for the setter). A sale with no commission lines has none. An extra entry named `Recon` is added when reconciliation is on.
      - `name` (string, nullable): Milestone name, or `Recon` for the reconciliation entry.
      - `trigger` (string, nullable): Label of the date that triggers the milestone. `null` for `Recon`.
      - `milestone_id` (integer, nullable): The milestone's id, the same `milestone_id` you send in `milestone_dates[]`. `null` for `Recon`.
      - `value` (number): Amount of this line in dollars.
      - `date` (string (date-time), nullable): Milestone date as a midnight UTC timestamp, or `null` when not reached.
      - `is_projected` (integer): `1` when the amount is projected, `0` when final.
      - `status` (string, nullable): Payroll status of this rep's pay for the milestone. When the rep has more than one line for it (for example an M2 and an M2 update), the least settled one wins, in this order: `pending`, `approved`, `paid`, `do_not_pay`. `projected` when there is no line yet and the milestone is projected; `null` when there is no line and the milestone has a date, and for `Recon`. See `SaleCommissionLine`. One of: `paid`, `approved`, `pending`, `do_not_pay`, `projected`, `null`.
    - `milestone_dates` (array of object): The sale's milestone dates in the shape `POST /v1/sales` takes, one entry per milestone. Includes dates on sales that have no `all_milestone[]` entries.
      - `product_id` (integer, nullable): Product id.
      - `milestone_id` (integer): Milestone id.
      - `milestone_date` (string (date), nullable): `YYYY-MM-DD`, or `null` when the milestone has no date.
    - `commission_lines` (array of object): Every commission and override line on the sale, with its payroll status. Empty when the sale has none.
      - `type` (string) One of: `commission`, `override`.
      - `milestone` (string, nullable): Milestone the line pays on, such as `m1`, `m2` or `m2 update`.
      - `milestone_id` (integer, nullable): Milestone id for commission lines. `null` for overrides.
      - `user_id` (integer): The user paid by this line.
      - `amount` (number): Amount in dollars. `0` when the line has no amount.
      - `status` (string): `paid`: settled on a payroll that ran, or marked paid. `approved`: on a payroll that is finalized or being paid. `pending`: on an open payroll, or not on a payroll yet. `do_not_pay`: closed without paying the rep. One of: `paid`, `approved`, `pending`, `do_not_pay`.
      - `pay_period_from` (string (date), nullable)
      - `pay_period_to` (string (date), nullable)
    - `total_commission` (string): Total commission in dollars with 2 decimals, including reconciliation.
    - `projected_commission` (integer): `1` when the commission amounts are still projected, `0` when final. A flag, not an amount.
    - `total_override` (string): Total override in dollars.
    - `projected_override` (integer): `1` when the override amounts are still projected, `0` when final.
    - `kw` (string, nullable): System size in kW (square feet for Turf and Roofing), as text.
    - `epc` (string, nullable): Gross price per unit, as text with 4 decimals.
    - `net_epc` (number, nullable): Net price per unit. For Mortgage it is returned multiplied by 100, so it does not equal the value you sent.
    - `adders` (string, nullable): Adders total, as text.
    - `gross_account_value` (number, nullable): Gross account value (loan amount for Mortgage) in dollars.
    - `service_completed` (string, nullable): Number of services completed, as text.
    - `date_cancelled` (string (date-time), nullable): Cancellation date as a midnight UTC timestamp.
    - `customer_signoff` (string (date-time), nullable): Sale date (closing date for Mortgage) as a midnight UTC timestamp, for example `2026-05-01T00:00:00.000Z`. Compare the first 10 characters with the date you sent.
    - `install_partner` (string, nullable): Installer, service provider or broker.
    - `service_schedule` (string, nullable): Service schedule (loan type for Mortgage).
    - `length_of_agreement` (string, nullable): Length of the service agreement.
    - `initial_service_cost` (string, nullable): Up-front service cost, as text.
    - `subscription_payment` (string, nullable): Recurring subscription payment, as text.
    - `card_on_file` (string, nullable): Whether a card is on file, as stored text.
    - `auto_pay` (string, nullable): Whether autopay is on, as stored text.
    - `bill_status` (string, nullable): Billing status label.
    - `balance_age` (string, nullable): Age of the outstanding balance in days, as text.
    - `last_service_date` (string (date-time), nullable): Last service date as a midnight UTC timestamp.
    - `dealer_fee_amount` (string, nullable): Dealer fee in dollars, as text.
    - `dealer_fee_percentage` (string, nullable): Dealer fee as a fraction, as text.
    - `is_exempted` (integer): `1` when the sale is exempt from clawback, else `0`.
    - `sales_type` (string): Sale type label, for example `Sales`.
    - `created_at` (string (date-time)): When Sequifi created the sale (UTC).
    - `updated_at` (string (date-time)): When Sequifi last changed the sale (UTC). Use it with `updated_after` to poll.
    - `mark_account_status_name` (string, nullable): `Clawed Back` when a clawback is shown, `Paid` when any commission on the sale has been paid, else `null`. One of: `Clawed Back`, `Paid`, `null`.
    - `closer1_detail` (object, nullable): Closer 1, or `null`.
      - `id` (integer): User id.
      - `first_name` (string): First name.
      - `last_name` (string): Last name.
      - `dismiss` (integer): `1` when the user is dismissed.
      - `terminate` (integer): `1` when the user is terminated.
      - `contract_ended` (integer): `1` when the user's contract has ended.
      - `stop_payroll` (integer): `1` when payroll is stopped for the user.
    - `closer2_detail` (object, nullable): Closer 2, or `null`.
      - `id` (integer): User id.
      - `first_name` (string): First name.
      - `last_name` (string): Last name.
      - `dismiss` (integer): `1` when the user is dismissed.
      - `terminate` (integer): `1` when the user is terminated.
      - `contract_ended` (integer): `1` when the user's contract has ended.
      - `stop_payroll` (integer): `1` when payroll is stopped for the user.
    - `setter1_detail` (object, nullable): Setter 1, or `null`.
      - `id` (integer): User id.
      - `first_name` (string): First name.
      - `last_name` (string): Last name.
      - `dismiss` (integer): `1` when the user is dismissed.
      - `terminate` (integer): `1` when the user is terminated.
      - `contract_ended` (integer): `1` when the user's contract has ended.
      - `stop_payroll` (integer): `1` when payroll is stopped for the user.
    - `setter2_detail` (object, nullable): Setter 2, or `null`.
      - `id` (integer): User id.
      - `first_name` (string): First name.
      - `last_name` (string): Last name.
      - `dismiss` (integer): `1` when the user is dismissed.
      - `terminate` (integer): `1` when the user is terminated.
      - `contract_ended` (integer): `1` when the user's contract has ended.
      - `stop_payroll` (integer): `1` when payroll is stopped for the user.
    - `custom_field_values` (object): The sale's current custom field values keyed by field name (as in `GET /v1/custom-fields?type=sales`), including edits made in the app. Values are returned as stored: numbers as numbers, dates as `YYYY-MM-DD`, multi-select values as arrays. `{}` when the sale has none; fields deleted from your configuration are left out.

```json
{
  "status": 200,
  "message": "Successfully",
  "data": {
    "requested_by": "acme",
    "current_page": 1,
    "per_page": 50,
    "total": 1,
    "last_page": 1,
    "Sales": [
      {
        "id": 7731,
        "pid": "SALE-10482",
        "customer_name": "Alex Morgan",
        "data_source_type": "Marketplace API",
        "job_status": "Serviced",
        "product_id": 12,
        "product_code": "SOL-ROOF",
        "product_name": "Solar Rooftop - SOL-ROOF",
        "org_product_id": "SOL-ROOF",
        "customer_state": "AZ",
        "customer_address": "1200 Desert Willow Rd",
        "customer_address_2": null,
        "customer_city": "Phoenix",
        "customer_zip": "85001",
        "customer_phone": "555-010-4821",
        "customer_email": "alex.morgan@example.com",
        "last_milestone": {
          "name": "Site Survey",
          "trigger": "Site Survey Date",
          "value": 500,
          "date": "2026-05-08T00:00:00.000Z"
        },
        "last_payment": 500,
        "all_milestone": [
          {
            "name": "Site Survey",
            "trigger": "Site Survey Date",
            "milestone_id": 41,
            "value": 500,
            "date": "2026-05-08T00:00:00.000Z",
            "is_projected": 0,
            "status": "paid"
          },
          {
            "name": "Install",
            "trigger": "Install Date",
            "milestone_id": 42,
            "value": 750,
            "date": null,
            "is_projected": 1,
            "status": "projected"
          }
        ],
        "milestone_dates": [
          {
            "product_id": 12,
            "milestone_id": 41,
            "milestone_date": "2026-05-08"
          },
          {
            "product_id": 12,
            "milestone_id": 42,
            "milestone_date": null
          }
        ],
        "commission_lines": [
          {
            "type": "commission",
            "milestone": "m1",
            "milestone_id": 41,
            "user_id": 101,
            "amount": 500,
            "status": "paid",
            "pay_period_from": "2026-05-04",
            "pay_period_to": "2026-05-10"
          }
        ],
        "total_commission": "1250.00",
        "projected_commission": 1,
        "total_override": "0",
        "projected_override": 1,
        "kw": "7.2",
        "epc": "3.8500",
        "net_epc": 3.2,
        "adders": "1100",
        "gross_account_value": 27720,
        "service_completed": null,
        "date_cancelled": null,
        "customer_signoff": "2026-05-01T00:00:00.000Z",
        "install_partner": "Brightline Solar",
        "service_schedule": null,
        "length_of_agreement": null,
        "initial_service_cost": null,
        "subscription_payment": null,
        "card_on_file": null,
        "auto_pay": null,
        "bill_status": null,
        "balance_age": null,
        "last_service_date": null,
        "dealer_fee_amount": "4158",
        "dealer_fee_percentage": "0.15",
        "is_exempted": 0,
        "sales_type": "Sales",
        "created_at": "2026-05-01T16:05:43.000Z",
        "updated_at": "2026-05-08T18:12:09.000Z",
        "mark_account_status_name": "Paid",
        "closer1_detail": {
          "id": 4821,
          "first_name": "Jordan",
          "last_name": "Reyes",
          "dismiss": 0,
          "terminate": 0,
          "contract_ended": 0,
          "stop_payroll": 0
        },
        "closer2_detail": null,
        "setter1_detail": {
          "id": 5310,
          "first_name": "Casey",
          "last_name": "Lee",
          "dismiss": 0,
          "terminate": 0,
          "contract_ended": 0,
          "stop_payroll": 0
        },
        "setter2_detail": null,
        "custom_field_values": {
          "Roof Type": "Shingle",
          "Panel Count": 18
        }
      }
    ]
  }
}
```

### 400: Unknown query parameter or invalid date filter.

Example (invalid_query_param): Unknown query parameter

```json
{
  "status": 400,
  "message": "Invalid query parameter(s)",
  "data": {
    "invalid_params": [
      "filter"
    ],
    "allowed_params": [
      "per_page",
      "page",
      "pid",
      "search",
      "start_date",
      "end_date",
      "milestone_date",
      "sale_type",
      "office_id",
      "user_id",
      "customer_name",
      "product_id",
      "product_name",
      "customer_state",
      "install_partner",
      "date_filter",
      "data_source_type",
      "closer1_id",
      "setter1_id",
      "job_status",
      "date_from",
      "date_to",
      "is_exempted",
      "sort",
      "sort_val",
      "updated_after",
      "updated_before",
      "created_after",
      "created_before"
    ]
  }
}
```

### 401: Missing, invalid or expired token. The body has only `message`.

```json
{
  "message": "Unauthorized"
}
```

### 403: SequiPay companies cannot use this endpoint.

```json
{
  "status": 403,
  "message": "Forbidden: This endpoint is not available for SequiPay companies",
  "data": {}
}
```

### 500: Server error. Retry later.

Example (internal): Unexpected error

```json
{
  "status": 500,
  "message": "Internal Server Error",
  "data": {}
}
```
