# Create Partner Stock

### Description

This service allows an authenticated partner to register stock for a specific SKU. Stock can be identified either by the internal `partnerSkuCode` or by the Thalamus `skuCodeKey` and `skuCode` pair.

***

### Request

#### Restrictions

* Authentication: Requires a successful partner login.
* Role Validation: The party must have the "Partner" role.
* Date Validation: `stockDate` cannot be in the future and must be today or earlier.

#### Endpoint

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

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

#### Request Body Fields

| **Field**                        | **Type** | **Description**                                                            |
| -------------------------------- | -------- | -------------------------------------------------------------------------- |
| `partnerSkuCode`                 | String   | Conditional. The internal code of the partner SKU.                         |
| `skuCodeKey`                     | String   | Conditional. The Reference Code of an SKU.                                 |
| `skuCode`                        | String   | Conditional. The value of the Reference Code.                              |
| `quantity`                       | Number   | Required. The quantity of stock to add.                                    |
| `amount`                         | Decimal  | The amount associated with this stock entry.                               |
| `stockDate`                      | String   | Required. Date stock is available (`yyyy-MM-dd`). Cannot be a future date. |
| `expirationDate`                 | String   | Date when stock expires (`yyyy-MM-dd`).                                    |
| `description`                    | String   | Primary description for the stock entry.                                   |
| `description2` - `description40` | String   | Optional. Additional description fields (up to 40 total).                  |

> #### ⚠️ Identification Logic
>
> You must provide exactly one of the following identification methods. Sending both or neither will result in an error:
>
> 1. Way 1: Use only `partnerSkuCode`.
> 2. Way 2: Use `skuCodeKey` AND `skuCode` together.

#### Body Examples

Example 1: Using Partner SKU Code

```
{  
   "partnerSkuCode": "EAN_12345",
   "quantity": 100,
   "amount": 12.10,
   "stockDate": "2026-03-25",
   "description": "Weekly restock",
   "expirationDate": "2026-06-25"
}
```

Example 2: Using SKU Reference Pair

```
{  
   "skuCodeKey": "ReferenceCode02",
   "skuCode": "cod2",
   "quantity": 50,
   "amount": 15.00,
   "stockDate": "2026-03-28",
   "description": "Special batch entry"
}
```

***

### Response

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

JSON

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

***

### ❌ Unsuccessful Response

#### `400 Bad Request`

| **Error Code**                       | **Message**                                               | **Description**                                                |
| ------------------------------------ | --------------------------------------------------------- | -------------------------------------------------------------- |
| `InvalidRoleForLoggedParty`          | The party must have the role of partner.                  | The user is logged in but lacks partner privileges.            |
| `field.required`                     | Field required                                            | A mandatory field (`quantity`, `stockDate`, etc.) is missing.  |
| `partnerStock.missingPartnerSkuCode` | The partnerSkuCode was not found                          | The provided `partnerSkuCode` does not exist for this partner. |
| `partnerStock.nowBefore`             | StockDate must be before current date.                    | You cannot register stock for a future date.                   |
| `field.invalid.format`               | Date type fields must have the format yyyy-MM-dd          | The date provided does not follow the required format.         |
| `partnerStock.searchByBoth`          | Cannot search by both SKU and partner SKU simultaneously. | You provided `partnerSkuCode` AND the `skuCode` pair.          |
| `partnerStock.requiredTogether`      | Both skuCodeKey and skuCode are required together.        | One of the two SKU reference fields is missing.                |
| `partnerStock.oneSearchCriterion`    | At least one search criterion is required.                | No SKU identification was provided in the body.                |
| `partnerStock.invalidSKUCode`        | The SkuCode was not found.                                | The Thalamus `skuCode` provided does not exist.                |
