# Create Partner Sale

### Description

This service records a sale transaction for the authenticated partner. Each sale is associated directly with the partner's account and the specific party (customer) involved in the transaction.

***

### Request

#### Restrictions

* Authentication: Requires a successful partner login.
* Ownership: The `credentialPrincipal` (the party/customer) must be owned by the logged-in partner.
* Date Validation: The `saleDate` must be the current date or earlier. Future dates are not permitted.

#### Endpoint

```
POST https://<server-url>/api/v4/partner/sale
```

#### Parameters

| **Parameter**  | **Location**   | **Description**                                   |
| -------------- | -------------- | ------------------------------------------------- |
| `touchpoint`   | Query / Header | The identifier for the touchpoint.                |
| `token`        | Query / Header | The authentication token for the partner session. |
| `Content-Type` | Header         | Must be `application/json`.                       |

#### Product Identification Logic

> How to identify the SKU:
>
> There are two ways to specify the product in a sale. You cannot use both in the same request.
>
> 1. Standard Way: Use `partnerSkuCode`. This is the recommended method as it applies configured unit equivalences.
> 2. Legacy Way: Use `skuCodeKey` + `skuCode`. Note that this method bypasses the partner SKU record, meaning no equivalences are applied to the quantity calculation.

#### Request Body Fields

| **Field**             | **Type** | **Description**                                              |
| --------------------- | -------- | ------------------------------------------------------------ |
| `credentialPrincipal` | String   | Required. The unique identifier of the customer/party.       |
| `partnerSkuCode`      | String   | Conditional. The internal code of the partner SKU.           |
| `skuCodeKey`          | String   | Conditional. The SKU Reference code (Legacy).                |
| `skuCode`             | String   | Conditional. The SKU code (Legacy).                          |
| `quantity`            | Decimal  | Required. The number of units sold.                          |
| `amount`              | Decimal  | Required. The total monetary value of the sale.              |
| `saleDate`            | String   | Required. Format: `yyyy-MM-dd`.                              |
| `transactionId`       | String   | Required. Your internal unique ID for this transaction.      |
| `salesOrigin`         | String   | Code representing the origin of the sale.                    |
| `currency`            | String   | ISO currency code (e.g., "USD").                             |
| `vendorId`            | Integer  | The internal Thalamus ID for the vendor.                     |
| `description1-10`     | String   | Optional metadata fields for additional transaction details. |

Typical Body Example:

```
{
    "credentialPrincipal": "22222222",
    "partnerSkuCode": "pa6_termo",
    "quantity": 4,
    "amount": 43912.4,
    "saleDate": "2026-04-01",
    "transactionId": "TXN-2026-0001"
}
```

***

### Response

#### ✅ Successful Response: `201 Created`

JSON

```
{
	"message": "OK"
}
```

***

### ❌ Unsuccessful Response

#### `400 Bad Request`

| **Error Code**              | **Field**             | **Description**                                            |
| --------------------------- | --------------------- | ---------------------------------------------------------- |
| `InvalidRoleForLoggedParty` | `partner`             | User is not logged in as a Partner.                        |
| `InvalidPrincipal`          | `credentialPrincipal` | The party does not exist or is not owned by this partner.  |
| `sku.missingData`           | `partnerSkuCode`      | No SKU identification provided.                            |
| `sku.cannotUseBoth`         | `partnerSkuCode`      | Both standard and legacy identification methods were sent. |
| `sku.requiredTogether`      | `skuCodeKey+skuCode`  | One of the two legacy reference fields is missing.         |
| `code.notFound`             | `currency`            | The provided currency code is invalid.                     |
| `field.lengthExceeded`      | `descriptionX`        | The description field exceeds the character limit.         |
| `invalidId`                 | `vendorId`            | The `vendorId` does not match an existing record.          |
| `BeforeTodayRequired`       | `saleDate`            | The sale date is in the future.                            |
| `field.invalid.format`      | `saleDate`            | Date is not in `yyyy-MM-dd` format.                        |
| `InvalidJson`               | N/A                   | The request body is malformed.                             |
