# Create Or Update Products

## OpenAPI Specification

```yaml
openapi: 3.0.1
info:
  title: ''
  description: ''
  version: 1.0.0
paths:
  /v3/Products:
    post:
      summary: Create Or Update Products
      deprecated: false
      description: สร้างและ แก้ไขสินค้า
      tags:
        - Venio/Product
      parameters:
        - name: Content-Type
          in: header
          description: ''
          required: true
          example: application/json
          schema:
            type: string
        - name: Ocp-Apim-Subscription-Key
          in: header
          description: รหัส subscription key ลูกค้า
          required: true
          example: <Your Subscription-Key>
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                products:
                  type: array
                  items:
                    type: object
                    properties:
                      productCode:
                        type: string
                        description: รหัสสินค้า [ไม่ต้องกรอก ถ้าเป็น multi-SKU]
                      productBarcode:
                        type: string
                        description: รหัสบาร์โค้ด
                      productName:
                        type: string
                        description: ชื่อสินค้า
                      productDescription:
                        type: string
                        description: รายละเอียดสินค้า
                      category:
                        type: string
                        description: >-
                          หมวดหมู่หลัก [ถ้ามีการส่งข้อมูลมาไม่ตรงกับระบบ
                          ทางระบบจะทำการสร้าง Category ให้]
                      subCategory:
                        type: string
                        description: >-
                          หมวดหมู่รอง [ถ้ามีการส่งข้อมูลมาไม่ตรงกับระบบ
                          ทางระบบจะทำการสร้าง Category ให้]
                      sub_SubCategory:
                        type: string
                        description: >-
                          หมวดหมู่ย่อย [ถ้ามีการส่งข้อมูลมาไม่ตรงกับระบบ
                          ทางระบบจะทำการสร้าง Category ให้]
                      cost:
                        type: number
                        description: >-
                          ต้นทุนสินค้า [ระบบจะไม่ Required และไม่สนใจ ถ้าเป็น
                          Multi SKU]
                      prices:
                        type: array
                        items:
                          type: object
                          properties:
                            priceTierName:
                              type: string
                              description: ชื่อระดับราคา
                            regularPrice:
                              type: number
                              description: ราคาปกติ
                            salePrice:
                              type: number
                              description: ราคาลด
                            vatValue:
                              type: number
                              description: >-
                                ภาษีมูลค่าเพิ่ม [ถ้าไม่มีอยู๋ในระบบ
                                จะทำการสร้างให้]
                            useDefaultVat:
                              type: boolean
                              description: >-
                                <p>ใช้ภาษีมูลค่าเพิ่ม ที่เป็นค่าเริ่มต้น
                                [<br>False = ไม่ใช้ Vat default , <br>True = ใช้
                                Vat default] <br>ค่า Vat จะเป็นตาม Set Defult
                                Vat</p>
                          x-apidog-orders:
                            - priceTierName
                            - regularPrice
                            - salePrice
                            - vatValue
                            - useDefaultVat
                        description: รายการรายละเอียดราคาสินค้า
                      productUnitName:
                        type: string
                        description: >-
                          หน่วยสินค้า [ถ้าใส่ค่า Unit ไม่ตรงกับระบบ จะแสดง
                          error]
                      productWeight:
                        type: number
                        description: ' น้ำหนักสินค้า'
                      productWeightUnit:
                        type: string
                        description: "หน่วยน้ำหนักสินค้า\_[ระบบ\_Default\_ให้\_มี\_\"gram\"\_,\_\"kilogram\"]"
                      productTag:
                        type: array
                        items:
                          type: string
                        description: >-
                          ป้ายกำกับสินค้า [ถ้าไม่ตรงกับในระบบ จะสร้าง productTag
                          ให้ใหม่]
                      productImage:
                        type: array
                        items:
                          type: string
                        description: ' รูปสินค้า ให้ส่งเป็น PublicUrl'
                      trackInventory:
                        type: boolean
                        description: >-
                          จัดการข้อมูลคลังสินค้า [true = อนุญาตให้จัดการ , false
                          = ไม่อนุญาตให้จัดการ]
                      useWarranty:
                        type: boolean
                        description: >-
                          การรับประกันสินค้า [true = รับประกัน , false =
                          ไม่รับประกัน]
                      timeWarrantyValue:
                        type: integer
                        description: ' ระยะเวลาการรับประกันสินค้า'
                      timeWarrantyUnit:
                        type: string
                        description: >-
                          หน่วยเวลาการรับประกันสินค้า [y = year ,m = month ,d =
                          day]
                      warrantyNote:
                        type: string
                        description: ' บันทึกการรับประกันสินค้า'
                      visibility:
                        type: boolean
                        description: true = ทำรายการขายได้ , false = ทำรายการขายไม่ได้]
                      active:
                        type: boolean
                        description: สถานะสินค้า [true = ใช้งาน , false = ไม่ใช้งาน]
                      productVariant:
                        type: array
                        items:
                          type: object
                          properties:
                            productCode:
                              type: string
                              description: ' รหัสสินค้า [ระบบ Required เมื่อเป็น สินค้า Multi SKU หรือไม่มี Product Code ด้านบน]'
                            productName:
                              type: string
                              description: ชื่อสินค้า
                            productBarcode:
                              type: string
                              description: รหัสบาร์โค้ด
                            productDescription:
                              type: string
                              description: รายละเอียดสินค้า
                            cost:
                              type: number
                              description: ต้นทุนสินค้า [ระบบ Required เมื่อเป็น Multi SKU]
                            prices:
                              type: array
                              items:
                                type: object
                                properties:
                                  priceTierName:
                                    type: string
                                    description: ชื่อระดับราคา
                                  regularPrice:
                                    type: number
                                    description: ราคาปกติ
                                  salePrice:
                                    type: number
                                    description: ราคาลด
                                  vat:
                                    type: number
                                    description: >-
                                      ภาษีมูลค่าเพิ่ม [ถ้าไม่มีอยู๋ในระบบ
                                      จะทำการสร้างให้]
                                x-apidog-orders:
                                  - priceTierName
                                  - regularPrice
                                  - salePrice
                                  - vat
                              description: รายการรายละเอียดราคาสินค้า
                            productImage:
                              type: array
                              items:
                                type: string
                              description: รูปสินค้า ให้ส่งเป็น PublicUrl
                            qty:
                              type: integer
                              description: จำนวนสินค้า
                            lowStockAlert:
                              type: integer
                              description: ' แจ้งเตือนเมื่อสต็อกคงเหลือ'
                            active:
                              type: boolean
                              description: สถานะสินค้า [true = ใช้งาน , false = ไม่ใช้งาน]
                            attribute:
                              type: array
                              items:
                                type: object
                                properties:
                                  attributeName:
                                    type: string
                                    description: >-
                                      หมวดหมู่คุณสมบัติ เช่น สี
                                      [ถ้าไม่ตรงกับในระบบ จะแสดง Error]
                                  attributeValueName:
                                    type: string
                                    description: ' คุณสมบัติ เช่น แดง [ถ้าไม่ตรงกับในระบบ จะแสดง Error]'
                                x-apidog-orders:
                                  - attributeName
                                  - attributeValueName
                              description: รายการคุณสมบัติสินค้า
                          x-apidog-orders:
                            - productCode
                            - productName
                            - productBarcode
                            - productDescription
                            - cost
                            - prices
                            - productImage
                            - qty
                            - lowStockAlert
                            - active
                            - attribute
                          required:
                            - productCode
                            - productName
                            - prices
                            - active
                            - attribute
                        description: >-
                          ระบบ Required เมื่อเป็น สินค้า Multi SKU หรือไม่มี
                          Product Code ด้านบน
                      brandName:
                        type: string
                      warehouses:
                        type: object
                        properties:
                          warehouseCode:
                            type: string
                            description: รหัสคลัง
                          qty:
                            type: number
                            description: จำนวนสินค้าแยกตามคลัง
                          lowStockAlert:
                            type: number
                            description: แจ้งเตือนเมื่อจำนวนสินค้าเหลือ
                        x-apidog-orders:
                          - warehouseCode
                          - qty
                          - lowStockAlert
                        required:
                          - warehouseCode
                          - qty
                          - lowStockAlert
                        description: ข้อมูลสินค้าแยกตามคลัง
                    x-apidog-orders:
                      - productCode
                      - productBarcode
                      - productName
                      - productDescription
                      - category
                      - subCategory
                      - sub_SubCategory
                      - cost
                      - prices
                      - productUnitName
                      - productWeight
                      - productWeightUnit
                      - productTag
                      - productImage
                      - trackInventory
                      - useWarranty
                      - timeWarrantyValue
                      - timeWarrantyUnit
                      - warrantyNote
                      - visibility
                      - active
                      - productVariant
                      - brandName
                      - warehouses
                    required:
                      - productCode
                      - productName
                      - category
                      - cost
                      - prices
                      - productUnitName
                      - trackInventory
                      - useWarranty
                      - visibility
                      - active
                      - warehouses
              required:
                - products
              x-apidog-orders:
                - products
            example: |-
              {
                  "products": [
                      {
                          "productCode": "<string>", // Required if no product sku
                          "productBarcode": "<string>",
                          "productName": "<string>", // Required
                          "productDescription": "<string>",
                          "category": "<string>", // Required
                          "subCategory": "<string>",
                          "sub_SubCategory": "<string>",
                          "cost": 0.0, // Required
                          "prices": [
                              {
                                  "priceTierName": "<string>", // Required
                                  "regularPrice": 0.0, // Required
                                  "salePrice": 0.0,
                                  "vatValue": 0.0,
                                  "useDefaultVat": true
                              }
                          ], // Required
                          "productUnitName": "<string>", // Required
                          "productWeight": 0.0,
                          "productWeightUnit": "<string>",
                          "productTag": [
                              "string"
                          ],
                          "productImage": [
                              "<string>"
                          ],
                          "trackInventory": true, // Required
                          "useWarranty": false, // Required
                          "timeWarrantyValue": 0,
                          "timeWarrantyUnit": "<string>", // [y = year ,m = month ,d = day]
                          "warrantyNote": "<string>",
                          "visibility": true, // Required
                          "active": true, // Required
                          "brandName": "<string>",
                          "productVariant": [
                              {
                                  "productCode": "<string>", // Required
                                  "productName": "<string>", // Required
                                  "productBarcode": "<string>",
                                  "productDescription": "<string>",
                                  "cost": 0.0,
                                  "prices": [
                                      {
                                          "priceTierName": "<string>",
                                          "regularPrice": 0.0,
                                          "salePrice": 0.0,
                                          "vat": 0.0
                                      }
                                  ], // Required
                                  "productImage": [
                                      "<string>"
                                  ],
                                  "qty": 0,
                                  "lowStockAlert": 0,
                                  "active": "<boolean>", // Required
                                  "attribute": [
                                      {
                                          "attributeName": "<string>", // Required
                                          "attributeValueName": "<string>" // Required
                                      }
                                  ] // Required
                              }
                          ],
                          "warehouses": [
                              {
                                  "warehouseCode": "WH001",
                                  "qty": 70,
                                  "lowStockAlert": 5
                              },
                              {
                                  "warehouseCode": "WH002",
                                  "qty": 30,
                                  "lowStockAlert": 3
                              }
                          ]
                      }
                  ]
              }
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: object
                    properties:
                      code:
                        type: string
                        description: "<p>สถานะของ\_Business\_Code\_ถ้า<br>Success\_=\_1000<br>Error\_1\_ตัว\_=\_4001<br>Error\_มากกว่า\_1\_ตัว\_=\_4002\_\_\_\_<br>หรือเป็น\_Subcode\_ที่ต้องการจะแสดงเพื่อสื่อความหมายของ\_Error\_โดย\_subcode\_จะเป็นตัวเดียวกับ\_business\_error\_code\_หรือไม่ก็ได้\_เพื่อความสะดวกในการแสดงผล<p>"
                      description:
                        type: string
                        description: คำอธิบายข้อความที่จะแสดง
                    x-apidog-orders:
                      - code
                      - description
                    required:
                      - code
                      - description
                  data:
                    type: object
                    properties:
                      ticketId:
                        type: integer
                        description: เลขที่ตั๋ว
                    x-apidog-orders:
                      - ticketId
                    required:
                      - ticketId
                x-apidog-orders:
                  - status
                  - data
                required:
                  - status
                  - data
              examples:
                '1':
                  summary: Success (200)
                  value:
                    status:
                      code: '1000'
                      description: Success
                    data:
                      ticketId: 284
                '2':
                  summary: Unauthorized (401)
                  value:
                    statusCode: 401
                    message: >-
                      Access denied due to invalid subscription key. Make sure
                      to provide a valid key for an active subscription.
                '3':
                  summary: Bad Request (400)
                  value:
                    errors:
                      products[0].productTag:
                        - >-
                          Error converting value "miniral water" to type
                          'System.Collections.Generic.List`1[System.String]'.
                          Path 'products[0].productTag', line 19, position 41.
                    type: https://tools.ietf.org/html/rfc7231#section-6.5.1
                    title: One or more validation errors occurred.
                    status: 400
                    extensions:
                      traceId: 00-fbeda93da7e3d6d82c8c14996bad65c5-9008669817772575-00
                '4':
                  summary: Server Error (500)
                  value:
                    status:
                      code: E9905
                      description: Success
                    data: >-
                      An error occurred while saving the entity changes. See the
                      inner exception for details.
          headers: {}
          x-apidog-name: Success
        '400':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  errors:
                    type: object
                    properties:
                      item:
                        type: string
                        description: ชื่อfieldเปลี่ยนตามerrorที่พบเจอและคำบรรยาย
                        nullable: true
                    description: รายการ error ที่เกิดขึ้น
                    x-apidog-orders:
                      - item
                  type:
                    type: string
                    description: รายละเอียดประเภท ของ httpstatuscodeที่เจอ error
                  title:
                    type: string
                    description: คำบรรย้าย error
                  status:
                    type: integer
                    description: |-
                      สถานะ code ของ httpเช่น
                      200 Ok
                      201 Created
                      400 BadRequest
                      401 Unauthorized
                      404 Record not found
                      500 Internal Server Error
                  extensions:
                    type: object
                    properties:
                      traceId:
                        type: string
                        description: รหัส traceId
                        nullable: true
                    x-apidog-orders:
                      - traceId
                    description: รายละเอียด extensions
                x-apidog-orders:
                  - errors
                  - type
                  - title
                  - status
                  - extensions
                required:
                  - errors
                  - type
                  - title
                  - status
                  - extensions
          headers: {}
          x-apidog-name: Bad Request
        '401':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  statusCode:
                    type: integer
                    description: |-
                      สถานะ code ของ httpเช่น
                      200 Ok
                      201 Created
                      400 BadRequest
                      401 Unauthorized
                      404 Record not found
                      500 Internal Server Error
                  message:
                    type: string
                    description: คำบรรยาย error
                x-apidog-orders:
                  - statusCode
                  - message
                required:
                  - statusCode
                  - message
          headers: {}
          x-apidog-name: Unauthorized
        '500':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: object
                    properties:
                      code:
                        type: string
                        description: "<p>สถานะของ\_Business\_Code\_ถ้า<br>Success\_=\_1000<br>Error\_1\_ตัว\_=\_4001<br>Error\_มากกว่า\_1\_ตัว\_=\_4002\_\_\_\_<br>หรือเป็น\_Subcode\_ที่ต้องการจะแสดงเพื่อสื่อความหมายของ\_Error\_โดย\_subcode\_จะเป็นตัวเดียวกับ\_business\_error\_code\_หรือไม่ก็ได้\_เพื่อความสะดวกในการแสดงผล<p>"
                      description:
                        type: string
                        description: คำบรรยาย code
                    x-apidog-orders:
                      - code
                      - description
                    required:
                      - code
                      - description
                  data:
                    type: string
                    description: คำบรรยาย error ที่เกิดขึ้น
                x-apidog-orders:
                  - status
                  - data
                required:
                  - status
                  - data
          headers: {}
          x-apidog-name: Server Error
      security:
        - bearer: []
      x-apidog-folder: Venio/Product
      x-apidog-status: developing
      x-run-in-apidog: https://app.apidog.com/web/project/351895/apis/api-3590384-run
components:
  schemas: {}
  securitySchemes:
    bearerAuth:
      type: jwt
      scheme: bearer
      bearerFormat: JWT
      description: ใส่ JWT Token ในรูปแบบ Bearer {token}
    bearer:
      type: http
      scheme: bearer
servers:
  - url: https://api.gofive.co.th
    description: Production
security:
  - bearerAuth: []
    x-apidog:
      schemeGroups:
        - id: uyL_cJmK7q60QJZRTi5ot
          schemeIds:
            - bearerAuth
      required: true
      use:
        id: uyL_cJmK7q60QJZRTi5ot
      scopes:
        uyL_cJmK7q60QJZRTi5ot:
          bearerAuth: []

```
