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

# Create or update sales

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

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

Creates or updates sales (loans, for mortgage companies) in bulk, keyed by your own `pid`. A new `pid` creates a sale and a known `pid` updates it, so resending a batch never creates duplicates. A `200` or `201` means the records were queued, not that the sale changed: confirm with `GET /v1/sales/{pid}` after processing, and read the Posting Sales guide before building a bulk sync.

**Before you call:**

- Not available to SequiPay companies (`403`).
- Know your company's vertical (Solar, Turf, Roofing, Pest, Fiber or Mortgage). It decides which fields are required (see `PostSaleRecord` and the Vertical Labels page). No endpoint returns it, so ask your Sequifi admin.
- Look up the values you will send: product `id` from `GET /v1/products`, milestone ids from `GET /v1/milestones?product=<id>`, custom field ids from `GET /v1/custom-fields?type=sales`, and user ids or emails from `GET /v1/users`.
- Set `"partial_success": true` so one bad record does not reject the whole request.

**What happens:**

- Every `pid` is checked first. A missing, non-string, too long (over 255 characters) or duplicate `pid` rejects the whole request with `400`, even with `partial_success`. Leading and trailing spaces are trimmed.
- A new `pid` must pass every check: required fields, formats, custom fields and your vertical's required fields. It is queued as a new sale.
- A known `pid` is an update: only the fields you send are merged into the sale, and no field is required. A field you leave out, including the product, closer, setter and location, keeps its current value. Milestone dates are the exception: the list you send replaces the sale's list.
- Accepted records are saved together and then processed in the background: the sale is created or updated and commissions are recalculated. This usually takes minutes; a large run can take an hour or more, and a sale whose payroll is being finalized waits until that payroll completes.
- Processing can still reject a queued record, for example a milestone date earlier than `customer_signoff`, or a change to a paid milestone, product, closer or setter. No API reports this: the sale stays missing or unchanged in `GET /v1/sales/{pid}`.
- People, product, milestone and custom field values are matched as described on each `PostSaleRecord` field. Unknown top-level fields are dropped and listed in `data.warnings[]`.
- A product that matches nothing is listed in `data.warnings[]`. A new sale then goes to your company's default product (its lowest-numbered product), and an update keeps the sale's current product.
- `data.warnings[]` is not a complete list of what was not applied. An unmatched closer, setter or email leaves that person off the sale and is not reported. Check `data.sales[]`: `closer1_id` should be present.

**Idempotency and retries:**

- `pid` is the key. A retried batch never creates a second sale; if the first attempt was saved, the retry takes the update path.
- `400`: nothing was saved. Fix every record listed in `data.errors` (`Record [i]` is the position in your `data` array) and resend. Without `partial_success`, checks run in stages and stop at the first stage with errors, so new errors can appear on the next attempt.
- `500`, `502`, `503`, `504` or a timeout: resend the same batch after a pause (for example 2, 4, 8 and 16 seconds). A `504` can arrive after the batch was saved; resending it is safe.
- With `partial_success`, an update (known `pid`) that fails a format check is listed in `rejected[]` and is not saved. Fix it and resend it.
- Send one request at a time. Two requests in flight with the same new `pid` can both queue it.
- Recommended size and pace: up to 200 records per request and no more than 30 requests a minute. These are not enforced per request, but larger batches risk the 29-second gateway timeout.

**Formats:**

- `pid` is a string. A JSON number such as `12345` is rejected; send `"12345"`.
- Dates are `YYYY-MM-DD` and must be real calendar dates. A date such as `2026-02-30` or `2026-13-01` in `milestone_dates`, `customer_signoff`, `last_service_date`, `date_cancelled` or `scheduled_install` is rejected with a 400.
- Numbers can be JSON numbers or numeric strings. `kw` and `gross_account_value` also accept `$`, commas and spaces; a value that cannot be read is saved as `0`, and so is `null` on an update. `kw` keeps every decimal you send (up to 10), so a battery adder sent as `0.00001` is saved as `0.00001`; exponent form such as `1e-5` is accepted.
- `card_on_file` and `auto_pay` must be JSON booleans.
- In the response, dates in `data.sales[]` are timestamps such as `2026-05-01T00:00:00.000Z`.

**Errors:**

- `400 Bad Request: Expected a JSON object with a "data" array`: the body is not a JSON object.
- `400 Bad Request: "data" must be a non-empty array of records`.
- `400 Validation Failed`: `data.errors[]` lists each problem as `Record [i]: <message> (field: <name>)`.
- `400 Custom Field Validation Failed`: an unknown custom field, or a number or date field with a wrong value, on a new record without `partial_success`.
- `401`: missing, invalid or expired token. The body is `{"message": "Unauthorized"}`.
- `403 Forbidden: This endpoint is not available for SequiPay companies`.
- `404 Record not found`: rare. A held copy was cleared while the request ran; nothing was saved. Resend.
- `500 Database Connection Error`, `Database Insert Error`, `Database Execution Error` or `Internal Server Error`: nothing was saved. Resend.

**Common mistakes:**

- Sending `sale_date`, `trigger_date`, `product_code` or `mp_base_payment_amount`. They are accepted and ignored, with no warning. The sale date goes in `customer_signoff`.
- Sending only the milestone that changed. `milestone_dates` replaces the sale's dates and is read by position: send every milestone of the product's schema, in order, with `milestone_date: null` for the ones not reached yet.
- Sending the schema `id` from `GET /v1/milestones` as `milestone_id`. Send the ids from its `milestones[]` array.
- Expecting `rep_email` to set the rep. It assigns no one; use `closer_email` or `closer1_id`.
- Sending `data_source_type`. Leave it out.
- Treating `201` as success without reading the body. With `partial_success`, a batch in which every record was rejected still returns `201` with `recordsProcessed: 0`.

**Related:**

- The Posting Sales guide: the full bulk-sync procedure, including how to confirm each sale.
- `GET /v1/sales/{pid}`: confirm a sale after processing.
- `GET /v1/products`, `GET /v1/milestones`, `GET /v1/custom-fields?type=sales`, `GET /v1/users`: the values to send.

## Request body

- `data` (array of object, **required**): The sales to create or update, one record each. At least one record. Each `pid` may appear only once.
  - `pid` (string, **required**): Your unique id for the sale, as a string (a JSON number is rejected). Leading and trailing spaces are trimmed. At most 255 characters and unique within the request. The same `pid` always refers to the same sale. Max length: 255. Example: `SALE-10482`.
  - `customer_name` (string, **required**): Customer (borrower) name, 2 to 255 characters. Max length: 255. Example: `Alex Morgan`.
  - `customer_signoff` (string (date), **required**): The sale date (the closing date for Mortgage), `YYYY-MM-DD`. Required on every vertical. Milestone dates may not be earlier than this date, or processing rejects the record. Only the pattern is checked: an impossible date is rolled forward (`2026-02-30` is saved as `2026-03-02`) and a month above 12 is saved empty, so validate dates before sending. Example: `2026-05-01`.
  - `customer_email` (string (email)) Example: `alex.morgan@example.com`.
  - `customer_phone` (string) Example: `555-010-4821`.
  - `customer_address` (string) Example: `1200 Desert Willow Rd`.
  - `customer_address_2` (string) Example: `Unit 4`.
  - `customer_city` (string) Example: `Phoenix`.
  - `customer_state` (string): Customer state. Required for Solar, for Turf unless your company is configured without it, and for Mortgage only if your company is configured to require it; 2 to 100 characters when required. Example: `AZ`.
  - `customer_zip` (string) Example: `85001`.
  - `location_code` (string): Location (office region) code, usually the state code. Required under the same rules as `customer_state`, 2 to 100 characters. If you leave it out, Sequifi uses the state code for a full state name in `customer_state` (exact spelling), or `customer_state` as sent. Example: `AZ`.
  - `homeowner_id` (string): Your customer or homeowner id. Saved as sent. Example: `HO-55120`.
  - `sale_product_name` (string): The product name or a product code. Matched case-insensitively but otherwise exactly (spaces count). Tried before `product_id`. On a new record, a value that matches nothing puts the sale on your company's default product and adds a warning to `data.warnings[]`. Example: `Solar Rooftop`.
  - `product_id` (integer | string): The integer product `id` from `GET /v1/products` (a name or code string also works). Matching order: `sale_product_name`, or this value when that is absent, as a product name, then as a product code (any code in `product_codes` on `GET /v1/products`); then this value as the `id` of an active product. A number that is also a product code matches the code. If nothing matches, a new record goes to your company's default product (its lowest-numbered product), an update keeps the sale's current product, and either way `data.warnings[]` says so. Inactive products do not match by `id`. Example: `12`.
  - `kw` (number): Required for Turf and Roofing (square feet). Optional for Solar (kW): a solar sale without it is created with `0`, and commission calculates once it is sent. A number or numeric string; `$`, commas and spaces are removed. A value that cannot be read is saved as `0`, and so is `null` on an update. Example: `7.2`.
  - `gross_account_value` (number): Required for Roofing, Pest and Fiber (the loan amount for Mortgage). A number or numeric string; `$`, commas and spaces are removed. A value that cannot be read is saved as `0`, and so is `null` on an update. Example: `27720`.
  - `epc` (number): Gross price per unit (gross revenue for Mortgage). A number or numeric string, saved with 4 decimals. Example: `3.85`.
  - `net_epc` (number): Net price per unit (Solar, Turf, Roofing), saved as sent. For Mortgage, the fee as a fraction (`0.0325` for 3.25%); Sequifi multiplies it by 100 when saving. Ignored for Pest, Fiber and other verticals. Example: `3.2`.
  - `adders` (number): Adders total (the broker fee for Mortgage). A number or numeric string. Example: `1100`.
  - `adders_description` (string): Text describing the adders. Example: `Critter guard, main panel upgrade`.
  - `dealer_fee_amount` (number): Dealer fee in dollars. A number or numeric string. Example: `4158`.
  - `dealer_fee_percentage` (number): Dealer fee as a fraction. A number or numeric string. Example: `0.15`.
  - `install_partner` (string): Installer, service provider or broker name. Saved as sent. Example: `Brightline Solar`.
  - `service_schedule` (string): Service schedule (loan type for Mortgage). Free text, saved as sent. Example: `Quarterly`.
  - `length_of_agreement` (string): Length of the service agreement. Free text, saved as sent. Max length: 255. Example: `12 months`.
  - `initial_service_cost` (number): Up-front service cost in dollars. Example: `149`.
  - `subscription_payment` (number): Recurring subscription payment in dollars. Example: `62.5`.
  - `card_on_file` (boolean): Whether a payment card is on file. Must be a JSON boolean. Example: `true`.
  - `auto_pay` (boolean): Whether autopay is on. Must be a JSON boolean. Example: `true`.
  - `service_completed` (integer): Number of services completed. A whole number. Example: `1`.
  - `bill_status` (string): Billing status label. Free text, saved as sent. Max length: 255. Example: `Current`.
  - `balance_age` (integer): Age of the outstanding balance in days. A whole number. Example: `0`.
  - `last_service_date` (string (date)): Date of the most recent service, `YYYY-MM-DD`. Example: `2026-04-21`.
  - `date_cancelled` (string (date)): Cancellation date, `YYYY-MM-DD`. A sale with this date reads back with `job_status` `Cancelled`. Example: `2026-08-01`.
  - `scheduled_install` (string (date), nullable): Planned install date, `YYYY-MM-DD`. Not a milestone. On an update, `null` clears it; leave the field out to keep it. Example: `2026-05-20`.
  - `job_status` (string): Your status label, saved on the sale. `GET /v1/sales` does not return it: its `job_status` is calculated from the sale's dates. Max length: 255. Example: `Installed`.
  - `external_job_status` (string): Your system's status label (for example a loan status). Saved as sent. Max length: 255. Example: `Clear to Close`.
  - `proposal_id` (string): Your proposal id. Saved as sent. Max length: 255. Example: `PROP-2026-0042`.
  - `closer1_id` (integer): Closer 1 user id from `GET /v1/users`. Checked first for closer 1. Must be a whole number. Only the first id field present (`closer1_id`, then `rep_id`, then `sub_dealer_eid`) is tried; if it matches no user, matching moves to `closer_email`. A JSON number is matched to the user id; a numeric string is tried as an employee id first. Dismissed or terminated users can be matched. Example: `4821`.
  - `rep_id` (integer): Closer 1 user id or numeric employee id, used only when `closer1_id` is absent. Must be a whole number, else `400`. Example: `4821`.
  - `sub_dealer_eid` (string): Closer 1 employee id (text allowed), used only when `closer1_id` and `rep_id` are absent. Example: `EMP-0042`.
  - `closer_email` (string (email)): Closer 1 email, tried when no id field matched. Matched without regard to case against each user's primary and additional emails; when two users share an email, the user with the higher id is matched. Must be a valid email. An email that matches no user leaves closer 1 empty; the sale still processes and the response does not warn. Example: `jordan.reyes@example.com`.
  - `closer1_email` (string (email)): Same as `closer_email`; used only when `closer_email` is absent. Example: `jordan.reyes@example.com`.
  - `closer1_flexible_id` (string): A flexible id stored on the user's profile in Sequifi, exact match. Tried last for closer 1, after the id fields and the email. Useful when your system knows reps only by its own id. Max length: 255. Example: `4e62e3a9b1b74693a7c62209f35fd651`.
  - `rep_email` (string (email)): Saved as the sale's rep email. It does not assign anyone: use `closer_email` or `closer1_id` to set closer 1. On a new record it is saved only when closer 1 was matched (closer 1's email is used when you leave it out). Example: `jordan.reyes@example.com`.
  - `closer2_id` (integer): Closer 2 user id, tried before `closer2_email` and `closer2_flexible_id`. Must be a whole number. Example: `4822`.
  - `closer2_email` (string (email)): Closer 2 email, matched like `closer_email`. Must be a valid email. No match leaves closer 2 empty (unchanged on an update), without a warning. Example: `avery.stone@example.com`.
  - `closer2_flexible_id` (string): Closer 2 flexible id, tried after `closer2_id` and `closer2_email`. Max length: 255. Example: `c3a5f7b9d1e3a5c7b9d1e3a5c7b9d1e3`.
  - `setter1_id` (integer): Setter 1 user id, tried before `setter_email` and `setter1_flexible_id`. Must be a whole number. Example: `5310`.
  - `setter_email` (string (email)): Setter 1 email, matched like `closer_email`. Must be a valid email. No match leaves setter 1 empty (unchanged on an update), without a warning. Example: `casey.lee@example.com`.
  - `setter1_flexible_id` (string): Setter 1 flexible id, tried after `setter1_id` and `setter_email`. Max length: 255. Example: `8a91c5f0d2e34a1b9c3e5f7a8b1d2c4e`.
  - `setter2_id` (integer): Setter 2 user id, tried before `setter2_email` and `setter2_flexible_id`. Must be a whole number. Example: `5311`.
  - `setter2_email` (string (email)): Setter 2 email, matched like `closer_email`. Must be a valid email. Example: `quinn.hall@example.com`.
  - `setter2_flexible_id` (string): Setter 2 flexible id, tried after `setter2_id` and `setter2_email`. Max length: 255. Example: `b2f4d6e8a0c2e4f6a8b0c2d4e6f8a0b2`.
  - `milestone_dates` (array of object): Milestone dates for the sale's product, one entry per milestone. `milestone_id` is the milestone id from `GET /v1/milestones` (`milestones[].id`, not the schema `id`); a value that is not a milestone id is read as a position (1 = first milestone). Nothing checks that the milestone belongs to the sale's product. Sequifi sorts the entries into milestone order and saves them by position with no gaps: entry 1 becomes the first milestone, entry 2 the second. Sending only the third milestone saves its date as the first milestone and clears the rest, so send one entry for every milestone in the product's schema, in order, with `milestone_date: null` for those not reached yet. The list replaces the sale's milestone dates: a milestone you leave out is treated as removed, and removing or changing a paid milestone gets the record rejected during processing. On an update, `[]`, `null` or any value that is not a list clears every milestone date; leave the field out to keep them. Each entry's `product_id` is required but not used: the sale's product comes from `sale_product_name` or `product_id` on the record.
    - `product_id` (integer, **required**): The sale's product `id`. Required, but not used. Example: `12`.
    - `milestone_id` (integer, **required**): The milestone id (`milestones[].id` from `GET /v1/milestones`). A value that is not a milestone id is read as a position (1 = first milestone). Minimum: 1. Example: `41`.
    - `milestone_date` (string (date), nullable): `YYYY-MM-DD`, or `null` (or `""`) for a milestone not reached yet. Only the pattern is checked. Example: `2026-05-08`.
  - `m1_date` (string (date)): Legacy. The first milestone's date, `YYYY-MM-DD`, used on a new record only when no `milestone_dates` entry is the first milestone. Ignored on updates. Use `milestone_dates`. Example: `2026-05-08`.
  - `custom_field_values` (object): Values for your company's sales custom fields, keyed by field `id` from `GET /v1/custom-fields?type=sales` (as a string key such as `"7"`) or by the exact field name (capitals and spaces must match). Prefer ids. `number` fields take a number and `date` fields take `YYYY-MM-DD`; on a new record, a wrong value or an unknown key returns `400` (or a `rejected[]` entry with `partial_success`). Text values are never rejected. A select field takes one option label; a multi-select field takes a JSON array or one string separated by semicolons (`"Roof; Attic"`). Values are trimmed, de-duplicated and given the configured option's capitals (`shingle` is saved as `Shingle`); a value that is not a configured option is saved as sent. `null` and `""` are skipped, so a value cannot be cleared through the API. On an update, values merge into the sale's existing values, and an unknown field name (dropped) or a wrong-typed value (saved as sent) is listed in `data.warnings[]`. Archived fields still accept values. Do not send values for fields with `is_calculated: true`.
  - `external_workers` (array of any | any): Extra people credited on the sale (for example a second loan officer or a disclosure desk). Leave the field out to keep the current list; `[]` removes all of them; a list replaces the people for each `type` it mentions and keeps the other types. Each entry is matched by email (primary or additional), else by exact full name in `first last` order (capitals and extra spaces ignored; `last first` does not match; when two users share a name, the lower id wins). An entry that matches no one is skipped without a warning. Checked on new records and updates; a malformed entry returns `400`.
    - `email` (string (email)): The person's email. Send `email`, `name` or both; email is tried first. Example: `dana.kim@example.com`.
    - `name` (string): Full name in `first last` order. Max length: 255. Example: `Sam Ortiz`.
    - `type` (integer, **required**): 1 self-gen, 2 closer, 3 setter. One of: `1`, `2`, `3`. Example: `2`.
  - `data_source_type` (string): Leave this out. Sequifi labels sales sent through this API `Marketplace API`. A value you send replaces that label on this copy of the sale, and an empty string is rejected. Max length: 255. Example: `Marketplace API`.
- `partial_success` (boolean): `true` (or the string `"true"`) checks each record on its own: valid records are queued and invalid ones come back in `data.rejected[]`. Any other value, or leaving it out, rejects the whole request with `400` at the first check stage that finds an error. Errors in the body shape or in a `pid` reject the whole request either way. Recommended for every request. Default: `false`.

Example (single_solar): One Solar sale (works for a new sale and for an update)

```json
{
  "partial_success": true,
  "data": [
    {
      "pid": "SALE-10482",
      "customer_name": "Alex Morgan",
      "customer_signoff": "2026-05-01",
      "customer_email": "alex.morgan@example.com",
      "customer_phone": "555-010-4821",
      "customer_address": "1200 Desert Willow Rd",
      "customer_city": "Phoenix",
      "customer_state": "AZ",
      "customer_zip": "85001",
      "location_code": "AZ",
      "product_id": 12,
      "kw": 7.2,
      "epc": 3.85,
      "net_epc": 3.2,
      "gross_account_value": 27720,
      "adders": 1100,
      "dealer_fee_amount": 4158,
      "dealer_fee_percentage": 0.15,
      "install_partner": "Brightline Solar",
      "closer_email": "jordan.reyes@example.com",
      "setter_email": "casey.lee@example.com",
      "milestone_dates": [
        {
          "product_id": 12,
          "milestone_id": 41,
          "milestone_date": "2026-05-08"
        },
        {
          "product_id": 12,
          "milestone_id": 42,
          "milestone_date": null
        }
      ],
      "custom_field_values": {
        "7": "Shingle",
        "9": 18
      }
    }
  ]
}
```

Example (batch_partial_success): Two Solar sales in one request, with partial_success

```json
{
  "partial_success": true,
  "data": [
    {
      "pid": "SALE-10483",
      "customer_name": "Jamie Carter",
      "customer_signoff": "2026-05-03",
      "customer_state": "AZ",
      "location_code": "AZ",
      "product_id": 12,
      "kw": 8.4,
      "closer1_id": 4821,
      "milestone_dates": [
        {
          "product_id": 12,
          "milestone_id": 41,
          "milestone_date": null
        },
        {
          "product_id": 12,
          "milestone_id": 42,
          "milestone_date": null
        }
      ]
    },
    {
      "pid": "SALE-10484",
      "customer_name": "Riley Nguyen",
      "customer_signoff": "2026-05-04",
      "customer_state": "NV",
      "location_code": "NV",
      "product_id": 12,
      "kw": 6.1,
      "closer_email": "jordan.reyes@example.com",
      "milestone_dates": [
        {
          "product_id": 12,
          "milestone_id": 41,
          "milestone_date": "2026-05-11"
        },
        {
          "product_id": 12,
          "milestone_id": 42,
          "milestone_date": null
        }
      ]
    }
  ]
}
```

Example (pest_sale): One Pest sale

```json
{
  "partial_success": true,
  "data": [
    {
      "pid": "PC-55120",
      "customer_name": "Taylor Brooks",
      "customer_signoff": "2026-04-14",
      "customer_state": "TX",
      "gross_account_value": 899,
      "product_id": 5,
      "closer_email": "riley.chen@example.com",
      "service_schedule": "Quarterly",
      "length_of_agreement": "12 months",
      "initial_service_cost": 149,
      "subscription_payment": 62.5,
      "card_on_file": true,
      "auto_pay": true,
      "service_completed": 1,
      "bill_status": "Current",
      "balance_age": 0,
      "last_service_date": "2026-04-21",
      "milestone_dates": [
        {
          "product_id": 5,
          "milestone_id": 17,
          "milestone_date": "2026-04-21"
        }
      ]
    }
  ]
}
```

## Example request

```bash
curl -X POST "https://marketplace-api.sequifi.com/v1/sales" \
  -H "Authorization: Bearer $SEQUIFI_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"partial_success":true,"data":[{"pid":"SALE-10482","customer_name":"Alex Morgan","customer_signoff":"2026-05-01","customer_email":"alex.morgan@example.com","customer_phone":"555-010-4821","customer_address":"1200 Desert Willow Rd","customer_city":"Phoenix","customer_state":"AZ","customer_zip":"85001","location_code":"AZ","product_id":12,"kw":7.2,"epc":3.85,"net_epc":3.2,"gross_account_value":27720,"adders":1100,"dealer_fee_amount":4158,"dealer_fee_percentage":0.15,"install_partner":"Brightline Solar","closer_email":"jordan.reyes@example.com","setter_email":"casey.lee@example.com","milestone_dates":[{"product_id":12,"milestone_id":41,"milestone_date":"2026-05-08"},{"product_id":12,"milestone_id":42,"milestone_date":null}],"custom_field_values":{"7":"Shingle","9":18}}]}'
```

## Responses

### 200: Every saved record was an update; no new record was queued.

- `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): The `data` object returned by `POST /v1/sales` with `200` or `201`.
  - `requestedBy` (string): Your company's Sequifi handle.
  - `recordsInserted` (integer): New sales queued. Updates to sales Sequifi already has count in `recordsPatched`.
  - `recordsPatched` (integer): Updates merged into a held copy.
  - `recordsProcessed` (integer): `recordsInserted` plus `recordsPatched`. `0` means nothing was saved. With `partial_success`, a rejected update is still counted here.
  - `recordsRejected` (integer): Number of entries in `rejected`. Returned only with `partial_success`.
  - `rejected` (array of object): Records that failed a check. Returned only with `partial_success`.
    - `index` (integer): Position of the record in your `data` array, starting at 0.
    - `pid` (string, nullable): The record's `pid`.
    - `messages` (array of string): The problems, without the `Record [i]:` prefix.
  - `warnings` (array of string): Returned only when not empty. Lists fields that were ignored (unknown top-level fields), products that matched nothing, and, on updates, custom field values that were dropped or saved with the wrong type. It does not list unmatched people.
  - `sales` (array of object): The latest queued copy of each `pid` in the request (rejected new records have none). This is the copy waiting for processing, not the processed sale.
    - `id` (integer): Id of this queued copy. Not the sale `id` that `GET /v1/sales` returns.
    - `pid` (string): Your sale id.
    - `customer_name` (string): Customer name.
    - `customer_signoff` (string (date-time)): Sale date as a midnight UTC timestamp, for example `2026-05-01T00:00:00.000Z`.
    - `product_id` (integer): The matched product `id`. Compare it with the product you sent to catch a default-product fallback.
    - `product_code` (string): The matched product code, in lower case.
    - `product` (string): The matched product name.
    - `closer1_id` (integer): The matched closer 1 user id. Missing when no closer was matched.
    - `closer2_id` (integer): The matched closer 2 user id.
    - `setter1_id` (integer): The matched setter 1 user id. Missing when no setter was matched.
    - `setter2_id` (integer): The matched setter 2 user id.
    - `sales_rep_email` (string): The sale's rep email.
    - `data_source_type` (string): The sale's source label, normally `Marketplace API`.
    - `custom_field_values` (object): Custom field values on this copy, keyed by field name. Always present; `{}` when there are none.

Example (all_updates): Two updates

```json
{
  "status": 200,
  "message": "Sales Data Updated Successfully",
  "data": {
    "requestedBy": "acme",
    "recordsInserted": 0,
    "recordsPatched": 2,
    "recordsProcessed": 2,
    "recordsRejected": 0,
    "rejected": [],
    "sales": [
      {
        "id": 90415,
        "pid": "SALE-10483",
        "customer_name": "Jamie Carter",
        "customer_signoff": "2026-05-03T00:00:00.000Z",
        "product_id": 12,
        "closer1_id": 4821,
        "data_source_type": "Marketplace API",
        "custom_field_values": {}
      },
      {
        "id": 90416,
        "pid": "SALE-10484",
        "customer_name": "Riley Nguyen",
        "customer_signoff": "2026-05-04T00:00:00.000Z",
        "product_id": 12,
        "closer1_id": 4821,
        "data_source_type": "Marketplace API",
        "custom_field_values": {}
      }
    ]
  }
}
```

Example (update_with_warning): Update with an unknown custom field name dropped

```json
{
  "status": 200,
  "message": "Sales Data Updated Successfully",
  "data": {
    "requestedBy": "acme",
    "recordsInserted": 0,
    "recordsPatched": 1,
    "recordsProcessed": 1,
    "recordsRejected": 0,
    "rejected": [],
    "warnings": [
      "Record [0]: custom_field_values field name \"Roof Typ\" does not exist and was ignored. Send the numeric field id from GET /v1/custom-fields?type=sales."
    ],
    "sales": [
      {
        "id": 90417,
        "pid": "SALE-10482",
        "customer_name": "Alex Morgan",
        "customer_signoff": "2026-05-01T00:00:00.000Z",
        "product_id": 12,
        "closer1_id": 4821,
        "data_source_type": "Marketplace API",
        "custom_field_values": {
          "Roof Type": "Shingle"
        }
      }
    ]
  }
}
```

### 201: New records queued, or every record rejected. Check `recordsProcessed` and `rejected[]`.

- `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): The `data` object returned by `POST /v1/sales` with `200` or `201`.
  - `requestedBy` (string): Your company's Sequifi handle.
  - `recordsInserted` (integer): New sales queued. Updates to sales Sequifi already has count in `recordsPatched`.
  - `recordsPatched` (integer): Updates merged into a held copy.
  - `recordsProcessed` (integer): `recordsInserted` plus `recordsPatched`. `0` means nothing was saved. With `partial_success`, a rejected update is still counted here.
  - `recordsRejected` (integer): Number of entries in `rejected`. Returned only with `partial_success`.
  - `rejected` (array of object): Records that failed a check. Returned only with `partial_success`.
    - `index` (integer): Position of the record in your `data` array, starting at 0.
    - `pid` (string, nullable): The record's `pid`.
    - `messages` (array of string): The problems, without the `Record [i]:` prefix.
  - `warnings` (array of string): Returned only when not empty. Lists fields that were ignored (unknown top-level fields), products that matched nothing, and, on updates, custom field values that were dropped or saved with the wrong type. It does not list unmatched people.
  - `sales` (array of object): The latest queued copy of each `pid` in the request (rejected new records have none). This is the copy waiting for processing, not the processed sale.
    - `id` (integer): Id of this queued copy. Not the sale `id` that `GET /v1/sales` returns.
    - `pid` (string): Your sale id.
    - `customer_name` (string): Customer name.
    - `customer_signoff` (string (date-time)): Sale date as a midnight UTC timestamp, for example `2026-05-01T00:00:00.000Z`.
    - `product_id` (integer): The matched product `id`. Compare it with the product you sent to catch a default-product fallback.
    - `product_code` (string): The matched product code, in lower case.
    - `product` (string): The matched product name.
    - `closer1_id` (integer): The matched closer 1 user id. Missing when no closer was matched.
    - `closer2_id` (integer): The matched closer 2 user id.
    - `setter1_id` (integer): The matched setter 1 user id. Missing when no setter was matched.
    - `setter2_id` (integer): The matched setter 2 user id.
    - `sales_rep_email` (string): The sale's rep email.
    - `data_source_type` (string): The sale's source label, normally `Marketplace API`.
    - `custom_field_values` (object): Custom field values on this copy, keyed by field name. Always present; `{}` when there are none.

Example (created): One new sale queued

```json
{
  "status": 201,
  "message": "Sales Data Processed Successfully",
  "data": {
    "requestedBy": "acme",
    "recordsInserted": 1,
    "recordsPatched": 0,
    "recordsProcessed": 1,
    "recordsRejected": 0,
    "rejected": [],
    "sales": [
      {
        "id": 90412,
        "pid": "SALE-10482",
        "customer_name": "Alex Morgan",
        "customer_signoff": "2026-05-01T00:00:00.000Z",
        "customer_state": "AZ",
        "location_code": "AZ",
        "kw": "7.2",
        "gross_account_value": 27720,
        "product_id": 12,
        "product_code": "sol-roof",
        "product": "Solar Rooftop",
        "closer1_id": 4821,
        "setter1_id": 5310,
        "sales_rep_email": "jordan.reyes@example.com",
        "sales_rep_name": "Jordan Reyes",
        "data_source_type": "Marketplace API",
        "custom_field_values": {
          "Roof Type": "Shingle",
          "Panel Count": 18
        }
      }
    ]
  }
}
```

Example (partial_success_mixed): One record queued, one rejected

```json
{
  "status": 201,
  "message": "Sales Data Processed Successfully",
  "data": {
    "requestedBy": "acme",
    "recordsInserted": 1,
    "recordsPatched": 0,
    "recordsProcessed": 1,
    "recordsRejected": 1,
    "rejected": [
      {
        "index": 1,
        "pid": "SALE-10484",
        "messages": [
          "Customer State is required for Solar (field: customer_state)"
        ]
      }
    ],
    "sales": [
      {
        "id": 90413,
        "pid": "SALE-10483",
        "customer_name": "Jamie Carter",
        "customer_signoff": "2026-05-03T00:00:00.000Z",
        "product_id": 12,
        "product_code": "sol-roof",
        "product": "Solar Rooftop",
        "closer1_id": 4821,
        "data_source_type": "Marketplace API",
        "custom_field_values": {}
      }
    ]
  }
}
```

### 400: Nothing was saved. Fix the records in `data.errors[]` and resend.

Example (invalid_payload): The body is not a JSON object with a data array

```json
{
  "status": 400,
  "message": "Bad Request: Expected a JSON object with a \"data\" array",
  "data": {}
}
```

### 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": {}
}
```

### 404: Rare. A held copy was cleared mid-request; nothing was saved. Resend.

```json
{
  "status": 404,
  "message": "Record not found",
  "data": {
    "details": "pid \"SALE-10482\" row missing at merge time"
  }
}
```

### 500: Server error; nothing was saved. Resend the same batch.

Example (db_connection): Sequifi could not reach your company's data

```json
{
  "status": 500,
  "message": "Database Connection Error",
  "data": {
    "details": "Connection timed out"
  }
}
```
