# \_add

Create a new Stock item

### Parameters

#### id (optional)

Integer ID for the stock item. If this is provided, the server will try to update the existing stock item instead of creating a new one.

#### name

String. The human-readable name of the Stock item.

#### code

String. The stock code for this item.

Codes must be unique, so if you try to create a new stock item with an existing stock code, then the existing item will be updated instead.

#### nominal (optional)

Integer nominal code for accounting purposes. Defaults to 0 if not supplied.

#### cost

Float cost of one of the stock item. How much you bought it for.

#### amount

Float. How many of the item are you adding to database.

#### price

Float price of the stock. How much you sell the product for.

#### description (optional)

String description of the Stock item.

#### notes (optional)

String notes about the Stock item. You could include details of where it was purchased, any special instructions for working with it, etc.

#### supplier (optional)

String name of the Supplier. Must match an existing Supplier.

### Example

```
FM_api('Stock_add',
	[
		'name'=>'1kg 1.75mm PLA Filament',
		'code'=>'PLA001',
		'nominal'=>'1',
		'cost'=>'12.99',
		'price'=>'15.99',
		'amount'=>'3',
		'description'=>'PLA filament for 3D printers'
	]
);
```

### Result

```
{"ok":1,"id":"7"}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.fieldmotion.com/fieldmotion-api-docs/stock/_add.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
