# Create item POST https://api-sandbox.payabli.com/api/LineItem/{entry} Content-Type: application/json Adds products and services to an entrypoint's catalog. These are used as line items for invoicing and transactions. In the response, "responseData" displays the item's code. Reference: https://docs.payabli.com/developers/api-reference/lineitem/add-item-to-entrypoint-catalog ## OpenAPI Specification ```yaml openapi: 3.1.1 info: title: Add item to entrypoint catalog version: endpoint_lineItem.AddItem paths: /LineItem/{entry}: post: operationId: add-item summary: Add item to entrypoint catalog description: >- Adds products and services to an entrypoint's catalog. These are used as line items for invoicing and transactions. In the response, "responseData" displays the item's code. tags: - - subpackage_lineItem parameters: - name: entry in: path description: >- The paypoint's entrypoint identifier. [Learn more](/developers/api-reference/api-overview#entrypoint-vs-entry) required: true schema: type: string - name: requestToken in: header required: true schema: type: string - name: idempotencyKey in: header description: >- A unique ID you can include to prevent duplicating objects or transactions if a request is sent more than once. This key isn't generated in Payabli, you must generate it yourself. required: false schema: type: string responses: '200': description: Success content: application/json: schema: $ref: '#/components/schemas/type_:PayabliApiResponse6' '400': description: Bad request/ invalid data content: {} '401': description: Unauthorized request. content: {} '500': description: Internal API Error content: {} '503': description: Database connection error content: {} requestBody: content: application/json: schema: $ref: '#/components/schemas/type_:LineItem' components: schemas: type_:ItemCommodityCode: type: string type_:ItemDescription: type: string type_:ItemProductCode: type: string type_:ItemProductName: type: string type_:ItemUnitofMeasure: type: string type_:LineItem: type: object properties: itemCategories: type: array items: type: string description: Array of tags classifying item or product. itemCommodityCode: $ref: '#/components/schemas/type_:ItemCommodityCode' itemCost: type: number format: double description: Item or product price per unit. itemDescription: $ref: '#/components/schemas/type_:ItemDescription' itemMode: type: integer description: >- Internal class of item or product: value '0' is only for invoices, '1' for bills, and '2' is common for both. itemProductCode: $ref: '#/components/schemas/type_:ItemProductCode' itemProductName: $ref: '#/components/schemas/type_:ItemProductName' itemQty: type: integer description: Quantity of item or product. itemUnitOfMeasure: $ref: '#/components/schemas/type_:ItemUnitofMeasure' required: - itemCost - itemQty type_:IsSuccess: type: boolean type_:PageIdentifier: type: string type_:Responsedatanonobject: oneOf: - type: string - type: integer type_:ResponseText: type: string type_:PayabliApiResponse6: type: object properties: isSuccess: $ref: '#/components/schemas/type_:IsSuccess' pageIdentifier: $ref: '#/components/schemas/type_:PageIdentifier' responseData: $ref: '#/components/schemas/type_:Responsedatanonobject' description: >- If `isSuccess` = true, this contains the line item identifier. If `isSuccess` = false, this contains the reason of the error. responseText: $ref: '#/components/schemas/type_:ResponseText' required: - responseText ``` ## SDK Code Examples ```python AddItem from payabli import payabli client = payabli( api_key="YOUR_API_KEY", ) client.line_item.add_item( entry="47cae3d74", item_product_code="M-DEPOSIT", item_product_name="Materials deposit", item_description="Deposit for materials", item_commodity_code="010", item_unit_of_measure="SqFt", item_cost=12.45, item_qty=1, item_mode=0, ) ``` ```typescript AddItem import { PayabliClient } from "@payabli/sdk-node"; const client = new PayabliClient({ apiKey: "YOUR_API_KEY" }); await client.lineItem.addItem("47cae3d74", { body: { itemProductCode: "M-DEPOSIT", itemProductName: "Materials deposit", itemDescription: "Deposit for materials", itemCommodityCode: "010", itemUnitOfMeasure: "SqFt", itemCost: 12.45, itemQty: 1, itemMode: 0 } }); ``` ```go AddItem import ( context "context" option "github.com/payabli/sdk-go/option" sdkgo "github.com/payabli/sdk-go" sdkgoclient "github.com/payabli/sdk-go/client" ) client := sdkgoclient.NewClient( option.WithApiKey( "", ), ) response, err := client.LineItem.AddItem( context.TODO(), "47cae3d74", &sdkgo.AddItemRequest{ Body: &sdkgo.LineItem{ ItemProductCode: sdkgo.String( "M-DEPOSIT", ), ItemProductName: sdkgo.String( "Materials deposit", ), ItemDescription: sdkgo.String( "Deposit for materials", ), ItemCommodityCode: sdkgo.String( "010", ), ItemUnitOfMeasure: sdkgo.String( "SqFt", ), ItemCost: 12.45, ItemQty: 1, ItemMode: sdkgo.Int( 0, ), }, }, ) ``` ```csharp AddItem using PayabliApi; var client = new PayabliApiClient("API_KEY"); await client.LineItem.AddItemAsync( "47cae3d74", new AddItemRequest { Body = new LineItem { ItemProductCode = "M-DEPOSIT", ItemProductName = "Materials deposit", ItemDescription = "Deposit for materials", ItemCommodityCode = "010", ItemUnitOfMeasure = "SqFt", ItemCost = 12.45, ItemQty = 1, ItemMode = 0, }, } ); ``` ```ruby AddItem require 'uri' require 'net/http' url = URI("https://api-sandbox.payabli.com/api/LineItem/47cae3d74") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["requestToken"] = '' request["Content-Type"] = 'application/json' request.body = "{\n \"itemCost\": 12.45,\n \"itemQty\": 1,\n \"itemCommodityCode\": \"010\",\n \"itemDescription\": \"Deposit for materials\",\n \"itemMode\": 0,\n \"itemProductCode\": \"M-DEPOSIT\",\n \"itemProductName\": \"Materials deposit\",\n \"itemUnitOfMeasure\": \"SqFt\"\n}" response = http.request(request) puts response.read_body ``` ```java AddItem HttpResponse response = Unirest.post("https://api-sandbox.payabli.com/api/LineItem/47cae3d74") .header("requestToken", "") .header("Content-Type", "application/json") .body("{\n \"itemCost\": 12.45,\n \"itemQty\": 1,\n \"itemCommodityCode\": \"010\",\n \"itemDescription\": \"Deposit for materials\",\n \"itemMode\": 0,\n \"itemProductCode\": \"M-DEPOSIT\",\n \"itemProductName\": \"Materials deposit\",\n \"itemUnitOfMeasure\": \"SqFt\"\n}") .asString(); ``` ```php AddItem request('POST', 'https://api-sandbox.payabli.com/api/LineItem/47cae3d74', [ 'body' => '{ "itemCost": 12.45, "itemQty": 1, "itemCommodityCode": "010", "itemDescription": "Deposit for materials", "itemMode": 0, "itemProductCode": "M-DEPOSIT", "itemProductName": "Materials deposit", "itemUnitOfMeasure": "SqFt" }', 'headers' => [ 'Content-Type' => 'application/json', 'requestToken' => '', ], ]); echo $response->getBody(); ``` ```swift AddItem import Foundation let headers = [ "requestToken": "", "Content-Type": "application/json" ] let parameters = [ "itemCost": 12.45, "itemQty": 1, "itemCommodityCode": "010", "itemDescription": "Deposit for materials", "itemMode": 0, "itemProductCode": "M-DEPOSIT", "itemProductName": "Materials deposit", "itemUnitOfMeasure": "SqFt" ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api-sandbox.payabli.com/api/LineItem/47cae3d74")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```