# Create or Update Contract

## OpenAPI Specification

```yaml
openapi: 3.0.1
info:
  title: ''
  description: ''
  version: 1.0.0
paths:
  /v1/contract:
    post:
      summary: Create or Update Contract
      deprecated: false
      description: ''
      tags:
        - Venio/Contract
      parameters:
        - name: Content-Type
          in: header
          description: ''
          required: true
          example: application/json
          schema:
            type: string
        - name: Ocp-Apim-Subscription-Key
          in: header
          description: รหัส subscriptionของลูกค้า
          required: true
          example: <Your-Subscription-Key>
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              properties:
                contractNo:
                  type: string
                  description: หมายเลขสัญญา
                  nullable: true
                contractName:
                  type: string
                  description: ชื่อสัญญา
                customerCode:
                  type: string
                  description: รหัสลูกค้า
                contractType:
                  type: string
                  description: ประเภทสัญญา
                contractValue:
                  type: integer
                  description: มูลค่าสัญญา
                  nullable: true
                dateStart:
                  type: string
                  description: วันที่เริ่ม
                dateEnd:
                  type: string
                  description: วันที่สิ้นสุด
                description:
                  type: string
                  description: รายละเอียด
                owner:
                  type: string
                  description: ผู้รับผิดชอบ
                contractService:
                  type: object
                  x-apidog-refs:
                    01JYH12NJGE57CVGNG1FSHVBFD: &ref_0
                      $ref: '#/components/schemas/ContractServiceDto'
                      x-apidog-overrides:
                        contractServiceId: null
                  x-apidog-orders:
                    - 01JYH12NJGE57CVGNG1FSHVBFD
                  properties: {}
                  description: Service Agreement
                  nullable: true
              required:
                - contractName
                - customerCode
                - contractType
                - dateStart
                - dateEnd
                - owner
              x-apidog-orders:
                - contractNo
                - contractName
                - contractType
                - contractValue
                - customerCode
                - dateStart
                - dateEnd
                - description
                - owner
                - contractService
              $ref: '#/components/schemas/CreateUpdateContractDto'
            example:
              contractNo: CONT250600006
              contractName: test contract open api 3
              customerCode: L000308
              contractType: MA
              contractValue: 2000
              dateStart: '2025-06-18 00:00:00'
              dateEnd: '2026-06-18 21:37:51'
              dealNo: string
              note: null
              owner: UAT007
              contractService:
                subject: test frequency open api
                frequency: 260001
                numberOfTimes: 1
                agreementNote: null
              attachmentIds: []
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/ContractDto'
                  statusCode:
                    type: integer
                  httpStatusCode:
                    type: integer
                required:
                  - data
                  - statusCode
                  - httpStatusCode
                x-apidog-orders:
                  - data
                  - statusCode
                  - httpStatusCode
                x-apidog-ignore-properties: []
              example:
                status:
                  code: '1000'
                  description: Success
                data:
                  contractNo: string
                  contractType: 3204
                  statusId: 1602
                  contractName: string
                  owner: string
                  dateStart: 2025-06-18T00:00:00+0700
                  dateEnd: 2026-06-18T00:00:00+0700
                  contractValue: 2000
                  contractServices:
                    - contractServiceId: 37881
                      frequency: 260001
                      subject: string
                      numberOfTimes: 1
                      isActive: true
                    - contractServiceId: 37902
                      frequency: 260001
                      subject: string
                      numberOfTimes: 1
                      isActive: true
                    - contractServiceId: 37903
                      frequency: 260001
                      subject: string
                      numberOfTimes: 1
                      isActive: true
                  attachments: []
                  contractTypeName: string
                  customerCode: string
                  customerName: string
                  statusTypeId: 1
                  customerType: 0
                  dealNo: string
          headers: {}
          x-apidog-name: Success
        '400':
          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:
                      errors:
                        type: array
                        items:
                          type: object
                          properties:
                            subCode:
                              type: string
                            description:
                              type: string
                          x-apidog-orders:
                            - subCode
                            - description
                          x-apidog-ignore-properties: []
                      value:
                        type: string
                      statusCode:
                        type: integer
                    required:
                      - errors
                      - value
                      - statusCode
                    x-apidog-orders:
                      - errors
                      - value
                      - statusCode
                    x-apidog-ignore-properties: []
                  hasError:
                    type: boolean
                  errorMessage:
                    type: string
                  statusCode:
                    type: integer
                  httpStatusCode:
                    type: integer
                required:
                  - status
                  - data
                  - hasError
                  - errorMessage
                  - statusCode
                  - httpStatusCode
                x-apidog-orders:
                  - status
                  - data
                  - hasError
                  - errorMessage
                  - statusCode
                  - httpStatusCode
                x-apidog-ignore-properties: []
              example:
                status:
                  code: '4001'
                  description: Business error with 1 or more errors
                data:
                  errors:
                    - subCode: E1101
                      description: Subject field is required.
          headers: {}
          x-apidog-name: Bad Request
      security:
        - bearerAuth: []
          x-apidog:
            schemeGroups:
              - id: uyL_cJmK7q60QJZRTi5ot
                schemeIds:
                  - bearerAuth
            required: true
            use:
              id: uyL_cJmK7q60QJZRTi5ot
            scopes:
              uyL_cJmK7q60QJZRTi5ot:
                bearerAuth: []
      x-apidog-folder: Venio/Contract
      x-apidog-status: developing
      x-run-in-apidog: https://app.apidog.com/web/project/351895/apis/api-18402429-run
components:
  schemas:
    ContractServiceDto:
      type: object
      properties:
        contractNo:
          type: string
          description: หมายเลขสัญญา
        contractServiceId: &ref_5
          type: integer
        subject: &ref_1
          type: string
          description: หัวข้อ Service Agreement
        frequency: &ref_2
          type: integer
          description: >-
            <p>ประเภทความถี่<br>Yearly = 260001<br>Quarterly = 260002<br>Monthly
            = 260003<br>Weekly = 26000</p>
        numberOfTimes: &ref_3
          type: integer
          description: จำนวนครั้ง
        agreementNote: &ref_4
          type: string
          description: บันทึก
          nullable: true
        activityServices:
          type: array
          items:
            properties:
              title:
                type: string
              dateStart:
                type: string
              dateEnd:
                type: string
            x-apidog-orders:
              - title
              - dateStart
              - dateEnd
            required:
              - title
              - dateStart
              - dateEnd
            $ref: '#/components/schemas/ActivityServiceDto'
          description: รายการกิจกรรมสัญญา
      required:
        - contractNo
        - contractServiceId
        - subject
        - frequency
        - numberOfTimes
        - activityServices
      x-apidog-orders:
        - contractNo
        - contractServiceId
        - subject
        - frequency
        - numberOfTimes
        - agreementNote
        - activityServices
      x-apidog-ignore-properties: []
      x-apidog-folder: ''
    ActivityServiceDto:
      type: object
      properties:
        title:
          type: string
          description: หัวข้อ
        dateStart:
          type: string
          description: วันที่เริ่ม
        dateEnd:
          type: string
          description: วันที่สิ้นสุด
      x-apidog-orders:
        - title
        - dateStart
        - dateEnd
      required:
        - title
        - dateStart
        - dateEnd
      x-apidog-ignore-properties: []
      x-apidog-folder: ''
    CreateUpdateContractDto:
      type: object
      properties:
        contractNo:
          type: string
          description: หมายเลขสัญญา (ใช้ในการแก้ไขสัญญา)
          nullable: true
        contractName:
          type: string
          description: ชื่อสัญญา
        contractType:
          type: string
          description: ประเภทสัญญา
        contractValue:
          type: integer
          description: มูลค่าสัญญา
          nullable: true
        customerCode:
          type: string
          description: รหัสลูกค้า
        dealNo:
          type: string
          description: รหัสดีล
          nullable: true
        dateStart:
          type: string
          description: วันที่เริ่ม
        dateEnd:
          type: string
          description: วันที่สิ้นสุด
        note:
          type: string
          description: รายละเอียด
        owner:
          type: string
          description: ผู้รับผิดชอบ
        contractService:
          type: object
          x-apidog-refs:
            01JYH12NJGE57CVGNG1FSHVBFD: *ref_0
          x-apidog-orders:
            - 01JYH12NJGE57CVGNG1FSHVBFD
          properties:
            subject: *ref_1
            frequency: *ref_2
            numberOfTimes: *ref_3
            agreementNote: *ref_4
          description: Service Agreement
          required:
            - subject
            - frequency
            - numberOfTimes
          x-apidog-ignore-properties:
            - subject
            - frequency
            - numberOfTimes
            - agreementNote
          nullable: true
        attachmentIds:
          type: array
          items:
            type: integer
            description: Id ของ attahment ประเภท Contract
          description: ลิส id ของ attahment ประเภท Contract
      required:
        - contractName
        - contractType
        - customerCode
        - dateStart
        - dateEnd
        - owner
        - attachmentIds
      x-apidog-orders:
        - contractNo
        - contractName
        - contractType
        - contractValue
        - customerCode
        - dealNo
        - dateStart
        - dateEnd
        - note
        - owner
        - contractService
        - attachmentIds
      x-apidog-ignore-properties: []
      x-apidog-folder: ''
    ContractDto:
      type: object
      properties:
        contractNo:
          type: string
          description: หมายเลขสัญญา
        contractType:
          type: string
          description: ประเภทสัญญา
        statusId:
          type: integer
          description: >-
            <p>สถานะสัญญา<br>Open = 1601<br>Active = 1602<br>Completed =
            1603<br>Cancel = 1604</p>
        contractName:
          type: string
          description: ชื่อสัญญา
        owner:
          type: string
          description: ผู้รับผิดชอบ
        dateStart:
          type: string
          description: วันที่เริ่ม
        dateEnd:
          type: string
          description: วันที่สิ้นสุด
        contractValue:
          type: integer
          description: มูลค่าสัญญา
        contractServices:
          type: array
          items:
            properties:
              contractServiceId: *ref_5
              subject: *ref_1
              frequency: *ref_2
              numberOfTimes: *ref_3
              agreementNote: *ref_4
            x-apidog-orders:
              - 01JYH1WVWE6SCP88NAZA4QRGC8
            type: object
            x-apidog-refs:
              01JYH1WVWE6SCP88NAZA4QRGC8: *ref_0
            required:
              - contractServiceId
              - subject
              - frequency
              - numberOfTimes
            x-apidog-ignore-properties:
              - contractServiceId
              - subject
              - frequency
              - numberOfTimes
              - agreementNote
          description: Service Agreement
        attachments:
          type: array
          items:
            $ref: '#/components/schemas/AttachmentDto'
          description: ไฟล์แนบ
        customerCode:
          type: string
          description: รหัสลูกค้า
        customerName:
          type: string
          description: ชื่อลูกค้า
        customerType:
          type: integer
          description: <p>ประเภทลูกค้า<br>Individual = 13001<br>Business = 13002</p>
        dealNo:
          type: string
          description: รหัสดีล
      required:
        - contractNo
        - contractType
        - statusId
        - contractName
        - owner
        - dateStart
        - dateEnd
        - contractValue
        - contractServices
        - attachments
        - customerCode
        - customerName
        - customerType
      x-apidog-orders:
        - contractNo
        - contractType
        - statusId
        - contractName
        - owner
        - dateStart
        - dateEnd
        - contractValue
        - contractServices
        - attachments
        - customerCode
        - customerName
        - customerType
        - dealNo
      x-apidog-ignore-properties: []
      x-apidog-folder: ''
    AttachmentDto:
      type: object
      properties:
        attachmentId:
          type: integer
          format: int64
        refId:
          type: integer
          format: int64
        type:
          type: integer
          format: int32
        filename:
          type: string
          nullable: true
        extension:
          type: string
          nullable: true
        fileSize:
          type: integer
          format: int32
        isActive:
          type: boolean
        createdByUserId:
          type: string
          nullable: true
        dateCreated:
          type: string
          format: date-time
        resourceUrl:
          type: string
          nullable: true
        companyId:
          type: integer
          format: int32
          nullable: true
        isProcessed:
          type: boolean
        data:
          type: string
          format: byte
          nullable: true
        timeStamp:
          type: integer
          format: int64
        'no':
          type: string
          nullable: true
        url:
          type: string
          nullable: true
        urlUpload:
          type: string
          nullable: true
        urlResponseUpload:
          type: string
          readOnly: true
          nullable: true
        localFileURL:
          type: string
          nullable: true
        thumbnail:
          type: string
          readOnly: true
          nullable: true
        uuid:
          type: string
          format: uuid
        publicUrl:
          type: string
          nullable: true
        seq:
          type: integer
          format: int32
        isCover:
          type: boolean
      additionalProperties: false
      x-apidog-orders:
        - attachmentId
        - refId
        - type
        - filename
        - extension
        - fileSize
        - isActive
        - createdByUserId
        - dateCreated
        - resourceUrl
        - companyId
        - isProcessed
        - data
        - timeStamp
        - 'no'
        - url
        - urlUpload
        - urlResponseUpload
        - localFileURL
        - thumbnail
        - uuid
        - publicUrl
        - seq
        - isCover
      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: []

```
