# Get a SalesOrder By Id

## OpenAPI Specification

```yaml
openapi: 3.0.1
info:
  title: ''
  description: ''
  version: 1.0.0
paths:
  /v2/salesorder/{id}:
    get:
      summary: Get a SalesOrder By Id
      deprecated: false
      description: ดึงข้อมูล saleorder โดย saleorderId
      tags:
        - Venio/SalesOrder
      parameters:
        - name: id
          in: path
          description: รหัสsaleOrderId
          required: true
          example: 0
          schema:
            type: integer
        - 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
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: object
                    properties:
                      code:
                        type: string
                      description:
                        type: string
                    required:
                      - code
                      - description
                    x-apidog-orders:
                      - code
                      - description
                    x-apidog-ignore-properties: []
                  data:
                    type: object
                    properties:
                      salesOrderId:
                        type: number
                      salesOrderSubject:
                        type: string
                      customerCode:
                        type: string
                      customerId:
                        type: integer
                      salesOrderNo:
                        type: string
                      salesOrderStatus:
                        type: integer
                        description: >-
                          <p>สถานะใบสั่งขาย<br>Draft= 1<br>Open= 2<br>Completed
                          = 3<br>Rejected = 4<br>Cancelled = 5</p>
                      salesOrderDate:
                        type: string
                      recipientName:
                        type: string
                      recipientAddress:
                        type: string
                      recipient:
                        type: object
                        properties:
                          name:
                            type: string
                            description: ชื่อผู้รับ (Same data from recipientName)
                          country:
                            type: string
                            description: ประเทศ
                          province:
                            type: string
                            description: จังหวัด
                          district:
                            type: string
                            description: อำเภอ
                          subDistrict:
                            type: string
                            description: ตำบล
                          zipCode:
                            type: string
                            description: รหัสไปรษณี
                          phone:
                            type: string
                            description: เบอร์โทรศัพท์
                          email:
                            type: string
                          address:
                            type: string
                            description: ที่อยู่เพิ่มเติม (Same data from recipientAddress)
                        x-apidog-orders:
                          - name
                          - country
                          - province
                          - district
                          - subDistrict
                          - zipCode
                          - phone
                          - email
                          - address
                        x-apidog-ignore-properties: []
                      headerTemplateId:
                        type: integer
                      warehouseCode:
                        type: string
                        description: รหัสคลังสินค้า
                        nullable: true
                      salesorderDetails:
                        type: array
                        items:
                          type: object
                          properties:
                            productCode:
                              type: string
                            productName:
                              type: string
                            price:
                              type: integer
                            qty:
                              type: integer
                            productDescription:
                              type: string
                            discountValue:
                              type: integer
                              description: >-
                                เมื่อ DiscountBasisType = 360002 (ต่อหน่วย)
                                จะเป็นส่วนลดต่อหน่วย, เมื่อ = 360001 (ต่อรายการ)
                                จะเป็นส่วนลดของทั้งบรรทัด
                            discountType:
                              type: boolean
                            discountLevel:
                              type: integer
                              description: |-
                                ระดับการคิดส่วนลดของรายการสินค้า
                                1 = Unit: ส่วนลดต่อหน่วยสินค้า
                                2 = Item: ส่วนลดต่อรายการสินค้า
                              enum:
                                - 1
                                - 2
                              default: 2
                            totalPrice:
                              type: integer
                            productUnitName:
                              type: string
                            isShipping:
                              type: boolean
                              description: สินค้ามีการจัดส่งหรือไม่
                            warehouseCode:
                              type: string
                              description: รหัสคลังสินค้า
                              nullable: true
                            discountBasisType:
                              type: integer
                              enum:
                                - 360001
                                - 360002
                              x-apidog-enum:
                                - value: 360001
                                  name: PerItem
                                  description: คิดส่วนลดแบบต่อรายการ/ทั้งบรรทัด
                                - value: 360002
                                  name: PerUnit
                                  description: คิดส่วนลดแบบต่อหน่วย
                          x-apidog-orders:
                            - productCode
                            - productName
                            - price
                            - qty
                            - productDescription
                            - discountValue
                            - discountType
                            - discountLevel
                            - totalPrice
                            - productUnitName
                            - isShipping
                            - warehouseCode
                            - discountBasisType
                          required:
                            - discountBasisType
                          x-apidog-ignore-properties: []
                      discountName:
                        type: string
                      discountValue:
                        type: integer
                      discountType:
                        type: boolean
                      paymentTerm:
                        type: string
                      remark:
                        type: string
                      staffCode:
                        type: string
                      vatCalculation:
                        type: boolean
                      subTotal:
                        type: integer
                      subTotalWithDiscount:
                        type: integer
                      grandTotal:
                        type: integer
                      payment:
                        type: object
                        properties:
                          valueType:
                            type: integer
                          periods:
                            type: array
                            items:
                              type: object
                              properties:
                                periodNo:
                                  type: integer
                                value:
                                  type: integer
                                valuePercent:
                                  type: integer
                                isPaid:
                                  type: boolean
                              required:
                                - periodNo
                                - value
                                - valuePercent
                                - isPaid
                              x-apidog-orders:
                                - periodNo
                                - value
                                - valuePercent
                                - isPaid
                              x-apidog-ignore-properties: []
                        required:
                          - valueType
                          - periods
                        x-apidog-orders:
                          - valueType
                          - periods
                        x-apidog-ignore-properties: []
                      privateNote:
                        type: string
                      invoiceInfo:
                        type: object
                        properties:
                          id:
                            type: integer
                          integrationPlatform:
                            type: integer
                            description: Shopee - 400020, NocNoc - 400027
                          integrationBuyerId:
                            type: string
                            description: Identify for buyer depends on marketplace platform
                          type:
                            type: integer
                            description: Business - 13002, Individual - 13001
                          customerName:
                            type: string
                          taxId:
                            type: string
                          isEtax:
                            type: boolean
                          isHeadOffice:
                            type: boolean
                          branch:
                            type: string
                          branchCode:
                            type: string
                          country:
                            type: string
                          province:
                            type: string
                          district:
                            type: string
                          subDistrict:
                            type: string
                          zipCode:
                            type: string
                          phone:
                            type: string
                          address:
                            type: string
                        required:
                          - id
                          - integrationPlatform
                          - integrationBuyerId
                          - type
                          - customerName
                          - taxId
                          - isEtax
                          - isHeadOffice
                          - branch
                          - branchCode
                          - country
                          - province
                          - district
                          - subDistrict
                          - zipCode
                          - phone
                          - address
                        x-apidog-orders:
                          - id
                          - integrationPlatform
                          - integrationBuyerId
                          - type
                          - customerName
                          - taxId
                          - isEtax
                          - isHeadOffice
                          - branch
                          - branchCode
                          - country
                          - province
                          - district
                          - subDistrict
                          - zipCode
                          - phone
                          - address
                        x-apidog-ignore-properties: []
                      shippingDocumentUrl:
                        type: string
                      trackingNo:
                        type: string
                        description: For sale order from marketplace integration
                      discounts:
                        type: array
                        items:
                          $ref: >-
                            #/components/schemas/SalesOrder.SalesOrderDiscountDto
                        description: >-
                          Array ของส่วนลดสำหรับ order ที่มีส่วนลดหลายแบบ (จาก
                          3rd party)
                      integrationPlatform:
                        type: integer
                        enum:
                          - 400020
                          - 400021
                          - 400027
                          - 400031
                          - 400032
                        description: >-
                          Enum platform id, not null ถ้าเป็น order ที่มาจาก 3rd
                          party platform
                        nullable: true
                    required:
                      - salesOrderId
                      - salesOrderSubject
                      - customerId
                      - salesOrderNo
                      - salesOrderStatus
                      - salesOrderDate
                      - recipientName
                      - recipientAddress
                      - headerTemplateId
                      - salesorderDetails
                      - discountValue
                      - discountType
                      - paymentTerm
                      - remark
                      - staffCode
                      - vatCalculation
                      - subTotal
                      - subTotalWithDiscount
                      - grandTotal
                      - payment
                    x-apidog-orders:
                      - salesOrderId
                      - salesOrderSubject
                      - customerCode
                      - customerId
                      - salesOrderNo
                      - salesOrderStatus
                      - salesOrderDate
                      - recipientName
                      - recipientAddress
                      - recipient
                      - headerTemplateId
                      - warehouseCode
                      - salesorderDetails
                      - discountName
                      - discountValue
                      - discountType
                      - paymentTerm
                      - remark
                      - staffCode
                      - vatCalculation
                      - subTotal
                      - subTotalWithDiscount
                      - grandTotal
                      - payment
                      - privateNote
                      - invoiceInfo
                      - shippingDocumentUrl
                      - trackingNo
                      - discounts
                      - integrationPlatform
                    x-apidog-ignore-properties: []
                required:
                  - status
                  - data
                x-apidog-orders:
                  - status
                  - data
                x-apidog-ignore-properties: []
              examples:
                '1':
                  summary: OK (200)
                  value:
                    status:
                      code: '1000'
                      description: Success
                    data:
                      salesOrderId: 0
                      salesOrderSubject: string
                      customerCode: L000001
                      customerId: 1234
                      salesOrderNo: string
                      salesOrderStatus: 3
                      salesOrderDate: 2023-01-23T00:00:00+0700
                      recipientName: string
                      recipientAddress: string
                      recipient:
                        name: string
                        country: string
                        province: string
                        district: string
                        subDistrict: string
                        zipCode: string
                        phone: string
                        email: string
                      headerTemplateId: 1
                      warehouseCode: WH001
                      salesorderDetails:
                        - productCode: string
                          productName: string
                          price: 456
                          qty: 1
                          productDescription: string
                          discountValue: 0
                          discountType: true
                          discountLevel: 2
                          totalPrice: 456
                          productUnitName: string
                          isShipping: true
                          warehouseCode: WH001
                      discountName: string
                      discountValue: 5
                      discountType: false
                      paymentTerm: string
                      remark: string
                      staffCode: string
                      vatCalculation: true
                      subTotal: 456
                      subTotalWithDiscount: 451
                      grandTotal: 451
                      payment:
                        valueType: 1
                        periods:
                          - periodNo: 1
                            value: 10
                            valuePercent: 50
                            isPaid: false
                          - periodNo: 2
                            value: 10
                            valuePercent: 50
                            isPaid: false
                      privateNote: string
                      invoiceInfo:
                        id: 2
                        integrationPlatform: 400027
                        integrationBuyerId: string
                        type: 13001
                        customerName: string
                        taxId: string
                        isEtax: false
                        isHeadOffice: true
                        branch: string
                        branchCode: string
                        province: string
                        district: string
                        subDistrict: string
                        zipCode: string
                        phone: string
                        address: string
                      shippingDocumentUrl: string
                      trackingNo: string
                      discounts:
                        - discountName: string
                          discountValue: 5
                          discountType: false
                        - discountName: string
                          discountValue: 10
                          discountType: false
                      integrationPlatform: 400027
                '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: Forbidden (403)
                  value:
                    data:
                      authenticationSchemes: []
                    hasError: true
                    errorMessage: Invalid access rights
                    statusCode: 9503
                    httpStatusCode: 403
                '4':
                  summary: Bad Request (400)
                  value:
                    data:
                      value: SaleOrder id "12296778" doesn't exist.
                      statusCode: 400
                    hasError: true
                    errorMessage: Invalid parameters entered
                    statusCode: 1102
                    httpStatusCode: 400
          headers: {}
          x-apidog-name: OK
        '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
                required:
                  - statusCode
                  - message
                x-apidog-orders:
                  - statusCode
                  - message
                x-apidog-ignore-properties: []
          headers: {}
          x-apidog-name: Unauthorized
        '403':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  statusCode:
                    type: integer
                    description: "<p>สถานะของ\_Business\_Code\_ถ้า<br>Success\_=\_1000<br>Error\_1\_ตัว\_=\_4001<br>Error\_มากกว่า\_1\_ตัว\_=\_4002\_\_\_\_<br>หรือเป็น\_Subcode\_ที่ต้องการจะแสดงเพื่อสื่อความหมายของ\_Error\_โดย\_subcode\_จะเป็นตัวเดียวกับ\_business\_error\_code\_หรือไม่ก็ได้\_เพื่อความสะดวกในการแสดงผล<p>"
                  httpStatusCode:
                    type: integer
                    description: |-
                      สถานะ  code ของ httpเช่น
                      200 Ok
                      201 Created
                      400 BadRequest
                      401 Unauthorized
                      404 Record not found
                      500 Internal Server Error
                  errorMessage:
                    type: string
                    description: คำอธิบายเกี่ยวกับ error
                  hasError:
                    type: boolean
                    description: |-
                      มี error ไหม
                      true = มี
                      false = ไม่มี
                  data:
                    type: object
                    properties:
                      authenticationSchemes:
                        type: array
                        items:
                          type: string
                        description: ค่า Enum ของ authenticationSchemes
                    required:
                      - authenticationSchemes
                    description: |-
                      ข้อมูลที่จะแสดง ไม่จำกัดรูปแบบว่าจะเป็นเช่นไร 
                      ตอนเรียกออกมาสามารเป็น Array และ Object ได้
                    x-apidog-orders:
                      - authenticationSchemes
                    x-apidog-ignore-properties: []
                description: ' กรณีที่คนที่ดูไม่มี permission view data '
                required:
                  - statusCode
                  - httpStatusCode
                  - errorMessage
                  - hasError
                  - data
                x-apidog-orders:
                  - statusCode
                  - httpStatusCode
                  - errorMessage
                  - hasError
                  - data
                x-apidog-ignore-properties: []
          headers: {}
          x-apidog-name: Forbidden
      security:
        - bearer: []
          x-apidog:
            schemeGroups:
              - id: oTVf8pOJh6IUxm2T2A5U2
                schemeIds:
                  - bearer
            required: true
            use:
              id: oTVf8pOJh6IUxm2T2A5U2
            scopes:
              oTVf8pOJh6IUxm2T2A5U2:
                bearer: []
      x-apidog-folder: Venio/SalesOrder
      x-apidog-status: released
      x-run-in-apidog: https://app.apidog.com/web/project/351895/apis/api-3607026-run
components:
  schemas:
    SalesOrder.SalesOrderDiscountDto:
      type: object
      properties:
        discountName:
          type: string
          description: ชื่อส่วนลด
        discountValue:
          type: integer
          description: ส่วนลด
        discountType:
          type: boolean
          description: |-
            ส่วนลดเป็น % หรือไม่
            true = เป็น
            false = ไม่
      required:
        - discountName
        - discountValue
        - discountType
      x-apidog-orders:
        - discountName
        - discountValue
        - discountType
      x-apidog-ignore-properties: []
      x-apidog-folder: ''
  securitySchemes:
    bearerAuth:
      type: jwt
      scheme: bearer
      bearerFormat: JWT
      description: ใส่ JWT Token ในรูปแบบ Bearer {token}
    bearer:
      type: bearer
      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: []

```
