> ## Documentation Index
> Fetch the complete documentation index at: https://docs.easybilling.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Contract Action



## OpenAPI

````yaml /billing.openapi.json post /api/contract-actions
openapi: 3.1.0
info:
  title: Billing
  description: |+

  version: 1.0.0
  summary: ''
servers:
  - url: https://sbx.api.easybilling.cloud/billing
    description: SBX
  - url: https://api.easybilling.cloud/billing
    description: Production-AWS
security:
  - token: []
tags:
  - name: account
  - name: payment method
  - name: contract action
  - name: usage event
  - name: billing document
  - name: invoice pdf
  - name: prepaid credits
  - name: customer portal
paths:
  /api/contract-actions:
    post:
      tags:
        - contract action
      summary: Create Contract Action
      parameters:
        - name: Idempotency-Key
          in: header
          description: ''
          required: true
          example: '{{$string.uuid}}'
          schema:
            type: string
        - name: trace-id
          in: header
          description: ''
          required: true
          example: '{{$string.uuid}}'
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                accountNumber:
                  type: string
                  description: Account Number
                actions:
                  type: array
                  items:
                    $ref: '#/components/schemas/ContractActionItemRequest'
                  description: Contract actions
              required:
                - accountNumber
                - actions
            examples:
              Create Contract with Plan:
                value:
                  accountNumber: ACC-0000000001
                  actions:
                    - type: create-contract-with-plan
                      createContractWithPlan:
                        - planId: 16ad814a-dd1b-41c8-9b4b-4e8551170fee
                          effectiveDate: '2026-02-01'
                          expirationDate: '2027-02-01'
                          currency:
                            - USD
                      immediatelyPay: true
                      paymentInfo:
                        paymentGatewayType: stripe-connect
                        paymentSuccessUrl: >-
                          https://sbx.app.easybilling.cloud/customer/info?type=paymentSuccess
                        paymentCancelUrl: >-
                          https://sbx.app.easybilling.cloud/customer/info?type=paymentFailed
                summary: Create Contract with Plan
              Create Contract with Contract Price:
                value:
                  accountNumber: ACC-0000000001
                  actions:
                    - type: create-contract-with-plan
                      createContractWithPlan:
                        - planId: 16ad814a-dd1b-41c8-9b4b-4e8551170fee
                          effectiveDate: '2026-02-01'
                          expirationDate: '2027-02-01'
                          currency:
                            - USD
                          contractPrice:
                            - planItemId: 074d0187-0a8b-4f81-a3cf-56762b1dad54
                              effectiveDate: '2025-02-01'
                              pricingTables:
                                - pricingTableItems:
                                    - tier: 1
                                      start: 0
                                      price: 99
                                      priceFormat: per-unit
                                      currency: USD
                      immediatelyPay: true
                      paymentInfo:
                        paymentGatewayType: stripe-connect
                        paymentSuccessUrl: >-
                          https://sbx.app.easybilling.cloud/customer/info?type=paymentSuccess
                        paymentCancelUrl: >-
                          https://sbx.app.easybilling.cloud/customer/info?type=paymentFailed
                summary: Create Contract with Contract Price
              Switch Plan:
                value:
                  accountNumber: ACC-0000000001
                  actions:
                    - type: switch-plan
                      switchPlan:
                        contractId: 06380c37-9fbe-439f-bb38-926745116471
                        planId: 4e9ed307-819c-4195-afb7-39269eea37b4
                        effectiveOption: next-billing-date
                        currency:
                          - USD
                      immediatelyPay: true
                      paymentInfo:
                        paymentGatewayType: stripe-connect
                        paymentSuccessUrl: >-
                          https://sbx.app.easybilling.cloud/customer/info?type=paymentSuccess
                        paymentCancelUrl: >-
                          https://sbx.app.easybilling.cloud/customer/info?type=paymentFailed
                summary: Switch Plan
              Cancel Contract:
                value:
                  accountNumber: ACC-0000000001
                  actions:
                    - type: cancel
                      cancel:
                        contractId: 06380c37-9fbe-439f-bb38-926745116471
                        effectiveOption: immediately
                summary: Cancel Contract
              Renew Contract:
                value:
                  accountNumber: ACC-0000000001
                  actions:
                    - type: renew
                      renew:
                        contractId: 06380c37-9fbe-439f-bb38-926745116471
                        expirationDate: '2029-02-01'
                summary: Renew Contract
              Create Prepaid Credits:
                value:
                  accountNumber: ACC-0000000001
                  actions:
                    - type: create-contract-with-plan-item
                      createContractWithPlanItem:
                        - planItemId: e5abfaa0-4bf5-41f1-89d0-bddcd975afbd
                          effectiveDate: '2026-02-20'
                          currency:
                            - USD
                          contractPrice:
                            - planItemId: e5abfaa0-4bf5-41f1-89d0-bddcd975afbd
                              effectiveDate: '2026-02-20'
                              quantity: 99
                      immediatelyPay: true
                      paymentInfo:
                        paymentGatewayType: stripe-connect
                        paymentSuccessUrl: >-
                          https://sbx.app.easybilling.cloud/customer/info?type=paymentSuccess
                        paymentCancelUrl: >-
                          https://sbx.app.easybilling.cloud/customer/info?type=paymentFailed
                summary: Create Prepaid Credits
              Early Renew:
                value:
                  accountNumber: ACC-0000000001
                  actions:
                    - type: early-renew
                      earlyRenew:
                        contractId: 06380c37-9fbe-439f-bb38-926745116471
                        planId: 4e9ed307-819c-4195-afb7-39269eea37b4
                        effectiveOption: immediately
                        currency:
                          - USD
                      immediatelyPay: true
                      paymentInfo:
                        paymentGatewayType: stripe-connect
                        paymentSuccessUrl: >-
                          https://sbx.app.easybilling.cloud/customer/info?type=paymentSuccess
                        paymentCancelUrl: >-
                          https://sbx.app.easybilling.cloud/customer/info?type=paymentFailed
                summary: Early Renew
                description: >-
                  Early renew a contract. You can change a plan and the contract
                  and billing cycle will re-start from the new effective date,
                  with all entitlements refreshed from this date.
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContractActionResponse'
              examples:
                Response for Create Contract:
                  summary: Response for Create Contract
                  value:
                    contractActionNumber: CA-0000000176
                    contractInfo:
                      accountNumber: A000-525
                      contractNumber: CT-0000000085
                      effectiveDate: '2025-07-01'
                      expirationDate: '2026-07-01'
                      status: active
                      contractSegments:
                        - accountNumber: A000-525
                          contractNumber: CT-0000000085
                          previousContractSegmentId: null
                          effectiveDate: '2025-07-01'
                          expirationDate: '2026-07-01'
                          currency:
                            - CNY
                          planId: 16ad814a-dd1b-41c8-9b4b-4e8551170fee
                          billingCycleDay: 1
                          billingCycleType: monthly
                          status: active
                          id: 979b1d96-1d82-4270-9d95-9db7c77fc237
                          createdAt: '2025-07-13T03:41:23.723864Z'
                          updatedAt: '2025-07-13T03:41:23.723868Z'
                          createdBy: d3e40eb2-c5d4-4141-b9d2-c8ebdad3c542
                          updatedBy: d3e40eb2-c5d4-4141-b9d2-c8ebdad3c542
                      id: 06380c37-9fbe-439f-bb38-926745116471
                      createdAt: '2025-07-13T03:41:23.726906Z'
                      updatedAt: '2025-07-13T03:41:23.726910Z'
                      createdBy: d3e40eb2-c5d4-4141-b9d2-c8ebdad3c542
                      updatedBy: d3e40eb2-c5d4-4141-b9d2-c8ebdad3c542
                    paymentResults:
                      - documentId: b3b2a701-c51e-45a9-9bdc-89d6786cf0eb
                        legalDocumentType: invoice
                        paymentGatewayType: stripe-connect
                        sessionId: b3b2a701xxxx45a99bdc89d6786cxxxx
                        sessionUrl: >-
                          https://checkout.stripe.com/c/pay/cs_test_sampleDataReplaceABCDEFGhijklmnopQRSTUVWXYZ1234567890abcdefghijklm#fidnandhSAMPLEWIDTHxKEEPlengthPATTERNreplaceALLcharactersWITHrandomLETTERSnumbersANDsymbolsFORtestingOnlyNOTvalidStripeKEYpurposeKEEPunderscoresANDpercentsANDhashfragmentsLENGTHexactMATCHoriginalURLbutMEANINGlessCONTENT
          headers: {}
      deprecated: false
      security:
        - token: []
components:
  schemas:
    ContractActionItemRequest:
      type: object
      properties:
        type:
          type: string
          description: Contract action type
          enum:
            - create-contract-with-plan
            - create-contract-with-plan-item
            - switch-plan
            - early-renew
            - update-price
            - cancel
            - renew
        createContractWithPlan:
          type: array
          items:
            $ref: '#/components/schemas/CreateContractWithPlanAction'
          description: Create a recurring subscripton contract with a plan
        createContractWithPlanItem:
          type: array
          items:
            $ref: '#/components/schemas/CreateContractWithPlanItemAction'
          description: Create prepaid credits
        switchPlan:
          $ref: '#/components/schemas/SwitchPlanAction'
          description: >-
            Switch to another plan: upgrade or downgrade. It keeps the same
            billing cycle and billing cycle day.
        earlyRenew:
          $ref: '#/components/schemas/EarlyRenewAction'
          description: >-
            Early renew a contract. You can change a plan and the contract and
            billing cycle will re-start from the new effective date, with all
            entitlements refreshed from this date.
        renew:
          $ref: '#/components/schemas/RenewAction'
          description: Renew a contract
        updatePrice:
          type: array
          items:
            $ref: '#/components/schemas/UpdatePriceAction'
          description: Update prices for a contract
        cancel:
          $ref: '#/components/schemas/CancelAction'
          description: cancel a contract
        externalReferenceId:
          type: string
          description: External reference identifier, e.g., an external Order ID.
        immediatelyPay:
          type: boolean
          description: >-
            Indicates whether payment should be made immediately (true for
            immediate payment).
        paymentInfo:
          $ref: '#/components/schemas/paymentInfo'
          description: Payment information for the contract.
    ContractActionResponse:
      type: object
      properties:
        id:
          type: string
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
        createdBy:
          type: string
        updatedBy:
          type: string
        number:
          type: string
        accountId:
          type: string
        contractId:
          type: string
        actionType:
          type: string
        contractActionItemRequest:
          $ref: '#/components/schemas/ContractActionItemRequest'
        contractSegmentIds:
          type: array
          items:
            type: string
        status:
          type: string
          enum:
            - active
            - expired
            - canceled
    CreateContractWithPlanAction:
      type: object
      properties:
        planId:
          type: string
        effectiveDate:
          type: string
        expirationDate:
          type: string
          description: empty value means no expiration
        currency:
          type: array
          items:
            type: string
        contractPrice:
          type: array
          items:
            $ref: '#/components/schemas/ContractPriceRequest'
      required:
        - planId
        - effectiveDate
        - currency
        - contractPrice
    CreateContractWithPlanItemAction:
      type: object
      properties:
        planItemId:
          type: string
        effectiveDate:
          type: string
        currency:
          type: array
          items:
            type: string
        contractPrice:
          type: array
          items:
            type: object
            properties:
              planItemId:
                type: string
              effectiveDate:
                type: string
              quantity:
                type: number
            required:
              - planItemId
              - effectiveDate
      required:
        - planItemId
        - effectiveDate
        - currency
        - contractPrice
    SwitchPlanAction:
      type: object
      properties:
        contractId:
          type: string
        planId:
          type: string
        effectiveDate:
          type: string
          description: >-
            Use either effectiveDate or effectiveOption. effectiveDate for plan
            switch must be a billing cycle date in the future.
        effectiveOption:
          type: string
          description: >-
            Use either effectiveDate or effectiveOption. It can only be next
            billing date for effectiveOption
          enum:
            - next-billing-date
        currency:
          type: array
          items:
            type: string
      required:
        - contractId
        - planId
        - currency
    EarlyRenewAction:
      type: object
      properties:
        contractId:
          type: string
        planId:
          type: string
        effectiveOption:
          type: string
          description: Use either effectiveDate or effectiveOption
          enum:
            - immediately
            - next-billing-date
        effectiveDate:
          type: string
          description: Use either effectiveDate or effectiveOption
        expirationDate:
          type: string
          description: empty value means no expiration
        currency:
          type: array
          items:
            type: string
      required:
        - contractId
        - planId
        - currency
    RenewAction:
      type: object
      properties:
        contractId:
          type: string
        expirationDate:
          type: string
          description: empty value means no expiration
      required:
        - contractId
    UpdatePriceAction:
      type: object
      properties:
        contractId:
          type: string
        contractSegmentId:
          type: string
        planId:
          type: string
        effectiveOption:
          type: string
          description: >-
            Use either effectiveDate or effectiveOption. It can only be next
            billing date for effectiveOption
          enum:
            - next-billing-date
        effectiveDate:
          type: string
          description: >-
            Use either effectiveDate or effectiveOption. effectiveDate for price
            update must be a billing cycle date in the future.
        contractPrice:
          type: array
          items:
            $ref: '#/components/schemas/ContractPriceRequest'
      required:
        - contractId
        - contractSegmentId
        - planId
        - contractPrice
    CancelAction:
      type: object
      properties:
        contractId:
          type: string
        effectiveOption:
          type: string
          description: Use either effectiveDate or effectiveOption
          enum:
            - immediately
            - next-billing-date
        effectiveDate:
          type: string
          description: Use either effectiveDate or effectiveOption
      required:
        - contractId
    paymentInfo:
      type: object
      properties:
        paymentGatewayType:
          type: string
          enum:
            - stripe-connect
            - payer-max-isv
            - alipay-page
            - wechat-pay-native
        paymentSuccessUrl:
          type: string
          description: requied for Stripe
        paymentCancelUrl:
          type: string
          description: requied for Stripe
      required:
        - paymentGatewayType
    ContractPriceRequest:
      type: object
      properties:
        planItemId:
          type: string
        effectiveDate:
          type: string
        quantity:
          type: number
        contractResourceCredits:
          type: array
          items:
            $ref: '#/components/schemas/ContractResourceCreditRequest'
        attributePricingTable:
          $ref: '#/components/schemas/AttributePricingTableRequest'
        pricingTables:
          type: array
          items:
            $ref: '#/components/schemas/PricingTableRequest1'
        discounts:
          type: array
          items:
            type: object
            properties:
              code:
                type: string
                maxLength: 32
              description:
                type:
                  - string
                  - 'null'
                maxLength: 128
              model:
                type: string
                enum:
                  - percentage
              value:
                type: number
                minimum: 0
                maximum: 100
            required:
              - code
              - model
              - value
      required:
        - planItemId
        - effectiveDate
        - contractResourceCredits
    ContractResourceCreditRequest:
      type: object
      properties:
        id:
          type: string
          description: ID
        totalCredits:
          type: number
          minimum: 0
        uom:
          type: string
        priceAllocationRatio:
          type: number
          minimum: 0
      required:
        - id
        - totalCredits
        - uom
        - priceAllocationRatio
    AttributePricingTableRequest:
      required:
        - attributePricingTableItems
        - effectiveDate
        - name
      type: object
      properties:
        name:
          type: string
        effectiveDate:
          type: string
          format: date
        expirationDate:
          type: string
          format: date
        attributePricingTableItems:
          maxItems: 100
          minItems: 1
          type: array
          items:
            $ref: '#/components/schemas/AttributePricingTableItemRequest'
    PricingTableRequest1:
      required:
        - startDate
      type: object
      properties:
        name:
          type: string
        startDate:
          type: string
          format: date
        endDate:
          type: string
          format: date
        pricingTableItems:
          type: array
          items:
            $ref: '#/components/schemas/PricingTableItemRequest2'
    AttributePricingTableItemRequest:
      required:
        - attributes
        - pricingTable
      type: object
      properties:
        attributes:
          type: object
          additionalProperties:
            type: string
          properties: {}
        pricingTable:
          $ref: '#/components/schemas/PricingTableRequest1'
    PricingTableItemRequest2:
      required:
        - price
        - priceFormat
        - tier
      type: object
      properties:
        tier:
          type: integer
          format: int32
        start:
          type: integer
          format: int64
        end:
          type: integer
          format: int64
        price:
          type: number
        ceilingPrice:
          type: number
        floorPrice:
          type: number
        blockSize:
          type: integer
          format: int64
        priceFormat:
          type: string
          enum:
            - per-unit
            - flat-fee
            - per-block
        currency:
          type: string
  securitySchemes:
    token:
      type: http
      scheme: bearer

````