# Making a new invoice from Api2

**URL:** <https://forum.manager.io/t/making-a-new-invoice-from-api2/53122>\
**Category:** Uncategorized\
**Created:** [April 25, 2024, 4:55am UTC](https://forum.manager.io/t/making-a-new-invoice-from-api2/53122 "2024-04-25T04:55:59Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Noiemany](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.manager.io/noiemany/32/49182_2.png) [@Noiemany](https://forum.manager.io/u/Noiemany)\
**Post date:** [April 25, 2024, 4:55am UTC](https://forum.manager.io/t/making-a-new-invoice-from-api2/53122/1 "2024-04-25T04:55:59Z")

</div>

I’m seeking expertise in accessing inventory data using item codes to determine available quantities and proficiency in using API2 to generate new sales invoices.

My goal is to integrate a point-of-sale (POS) system with a manager to automate the creation of invoices based on daily sales transactions.

If you have any knowledge, guidance, or assistance to offer, I would greatly appreciate your support in achieving this integration.

---

<div class="post-metadata">

**Author:** ![mohamedbreky](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.manager.io/mohamedbreky/32/62492_2.png) [@mohamedbreky](https://forum.manager.io/u/mohamedbreky)\
**Post date:** [April 25, 2024, 5:04am UTC](https://forum.manager.io/t/making-a-new-invoice-from-api2/53122/2 "2024-04-25T05:04:52Z")

</div>

facing the same issue here

when creating an invoice you must add the items with the “key” not with their item code, and to get the key there is another request yo have to make

im trying to create it with the item code but no luck, which as a workaround i have to make a DB to match both item codes and manager item key

here is an example on how to get the inventory items key with all the parameters (item code, etc…):

METHOD:GET

[http://localhost:55667/api2/inventory-items?fields=Image&fields=ItemCode&fields=ItemName&fields=ControlAccount&fields=Division&fields=Description&fields=SalePrice&fields=PurchasePrice&fields=UnitName&fields=QtyOnHand&fields=QtyToDeliver&fields=QtyAvailable&fields=QtyToReceive&fields=QtyToBeAvailable&fields=QtyDesired&fields=QtyToOrder&fields=Obsolete\_QtyToReceive&fields=Obsolete\_QtyOnHand&fields=Obsolete\_QtyToDeliver&fields=QtyOwned&fields=AverageCost&fields=TotalCost&fields=Timestamp](http://localhost:55667/api2/inventory-items?fields=Image&fields=ItemCode&fields=ItemName&fields=ControlAccount&fields=Division&fields=Description&fields=SalePrice&fields=PurchasePrice&fields=UnitName&fields=QtyOnHand&fields=QtyToDeliver&fields=QtyAvailable&fields=QtyToReceive&fields=QtyToBeAvailable&fields=QtyDesired&fields=QtyToOrder&fields=Obsolete_QtyToReceive&fields=Obsolete_QtyOnHand&fields=Obsolete_QtyToDeliver&fields=QtyOwned&fields=AverageCost&fields=TotalCost&fields=Timestamp)

put this in postman and delete unnecessary ones

to create an invoice with multi items:

use this

POST

[http://localhost:55667/api2/sales-invoice-form](http://localhost:55667/api2/sales-invoice-form)

JSON DATA:

```auto
{
    "image": null,
    "attachment": "False",
    "edit": null,
    "view": null,
    "issueDate": "2024-04-1",
    "reference": null,
    "customer": null,
    "description": null,
    "invoiceAmount": {
        "value": 1000.00,
        "currency": null
    },
    "balanceDue": {
        "value": 0.0,
        "currency": null
    },
    "status": "PaidInFull",
    "Lines": [
        {
            "Item": "324db506-6cd8-4c7d-8736-c446e2de5982",
            "Qty": 99.0,
            "SalesUnitPrice": 10.0
        },
        {
            "Item": "324db506-6cd8-4c7d-8736-c446e2de5982",
            "Qty":1 ,
            "SalesUnitPrice":9
            },
            {"Item": "0f8b8a4f-da5e-446e-83a4-386ec743287c",
            "Qty":12 ,
            "SalesUnitPrice": 8 }
    ]
}

```

use api v1 to get more accurate examples for your entity

---

<div class="post-metadata">

**Author:** ![Mabaega](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.manager.io/mabaega/32/47471_2.png) [@Mabaega](https://forum.manager.io/u/Mabaega)\
**Post date:** [April 25, 2024, 5:44am UTC](https://forum.manager.io/t/making-a-new-invoice-from-api2/53122/3 "2024-04-25T05:44:29Z")

</div>

We can get Inventoy Items data with the `term`

~~http ://127.0.0.1:55667/api2/inventory-items?term=MyItemCode~~

For the json structure, we can get it from Api1, or from BatchUpdate column and compile it into json.

_Just tried it, the term cannot be used to search for ItemCode. It looks like we have to take all Inventory item data and create a dictionary of ItemCode, ItemName_

---

<div class="post-metadata">

**Author:** ![lubos](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.manager.io/lubos/32/62798_2.png) [@lubos](https://forum.manager.io/u/lubos)\
**Post date:** [April 25, 2024, 11:39pm UTC](https://forum.manager.io/t/making-a-new-invoice-from-api2/53122/4 "2024-04-25T23:39:09Z")

</div>

> [@Mabaega](#):
>
> the term cannot be used to search for ItemCode

It should work for any column but you need to specify which columns you want to retrieve. Then `term` parameter will search across those columns only.

---

<div class="post-metadata">

**Author:** ![Mabaega](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.manager.io/mabaega/32/47471_2.png) [@Mabaega](https://forum.manager.io/u/Mabaega)\
**Post date:** [April 26, 2024, 12:12am UTC](https://forum.manager.io/t/making-a-new-invoice-from-api2/53122/5 "2024-04-26T00:12:24Z")

</div>

Previously I thought so

My Items

```auto
{
  "business": {
    "name": "Mailjet_Themes"
  },
  "skip": 0,
  "pageSize": 50,
  "totalRecords": 5,
  "inventoryItems": [
    {
      "key": "83e8f32b-b465-4f3b-8607-97fc330e6256",
      "itemCode": null,
      "itemName": "Item 1"
    },
    {
      "key": "6368bd2a-2ff1-4d5b-aa34-97554f4cabda",
      "itemCode": "ITM-00",
      "itemName": "Item Vat 0%"
    },
    {
      "key": "fcfa1eb0-4d6e-4961-9b64-e1e045ad836c",
      "itemCode": "ITM-09",
      "itemName": "Item Vat 9%"
    },
    {
      "key": "150d36d1-4be6-445b-baaa-e03fdffa2092",
      "itemCode": "ITM-15",
      "itemName": "Item Vat 15%"
    },
    {
      "key": "e739607c-2813-4738-8bd0-487e3fdb7e00",
      "itemCode": "ITM-Exm",
      "itemName": "Item Exempt"
    }
  ]
}

```

FetchData

```auto
https://{subdomain}.manager.io/api2/inventory-items?term=ITM-15&fields=ItemCode&fields=ItemName

```

Result

```auto
{
  "business": {
    "name": "Mailjet_Themes"
  },
  "skip": 0,
  "pageSize": 50,
  "totalRecords": 0,
  "inventoryItems": []
}

```

---

<div class="post-metadata">

**Author:** ![Noiemany](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.manager.io/noiemany/32/49182_2.png) [@Noiemany](https://forum.manager.io/u/Noiemany)\
**Post date:** [April 26, 2024, 1:40am UTC](https://forum.manager.io/t/making-a-new-invoice-from-api2/53122/6 "2024-04-26T01:40:23Z")

</div>

I would like to extend my sincere gratitude to each and every one of you. Your contributions and support have been invaluable, and I am truly grateful for your assistance.

Thank you,
