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

# Finalize schedules of an account

> Finalize schedules of an account



## OpenAPI

````yaml post /v2/accounts/{account_id}/finalize_schedules
openapi: 3.0.3
info:
  version: '1.0'
  title: Togai Apis
  contact:
    email: engg@togai.com
  license:
    name: Apache 2.0
    url: http://www.apache.org/licenses/LICENSE-2.0.html
  description: APIs for Togai App
servers:
  - description: Api endpoint
    url: https://api.togai.com/
  - description: Sandbox api endpoint
    url: https://sandbox-api.togai.com/
security:
  - bearerAuth: []
tags:
  - name: Customers
    description: Customer level calls
  - name: Accounts
    description: Account level calls
  - name: Event Schemas
    description: Event Schema level calls
  - name: Usage Meters
    description: Usage Meter level calls
  - name: Price Plans
    description: (DEPRECATED) Price Plan level calls
  - name: PricePlanV2
    description: Price Plan V2 level calls
  - name: Schedules
    description: Account Schedule level calls
  - name: Pricing Rules
    description: Pricing Rules level calls
  - name: Settings
    description: Settings
  - name: Price Experimentation
    description: Price Experimentation apis
  - name: InvoiceGroups
    description: Invoice Group level calls
  - name: Organization
    description: Organization level calls
  - name: FileStorage
    description: File Storage level calls
  - name: Aliases
    description: Alias level calls
  - name: Reports
    description: Report level calls
  - name: ReportTemplates
    description: Report Template level calls
  - name: Customer Portal
    description: Portal level calls
  - name: Alerts
    description: Alert level calls
  - name: Event Management
    description: APIs for getting events ingested in Togai
    externalDocs:
      description: docs
      url: https://togai.com/docs/billing/events
  - name: Metrics
    description: APIs for getting Togai metrics
    externalDocs:
      description: docs
      url: https://togai.com/docs/metrics
  - name: Licenses
    description: APIs for getting or updating license records in Togai
  - name: Entitlements
    description: APIs related to entitlements
  - name: Invoices
    description: Invoices API
  - name: Credits
    description: Credits API
  - name: Wallet
    description: Wallet API
  - name: InvoiceTemplates
    description: InvoiceTemplates API
  - name: InvoiceSequence
    description: InvoiceSequence API
  - name: Payments
    description: Payments API
  - name: Authentication
    description: Authentication API
externalDocs:
  description: Find out more about Togai
  url: https://docs.togai.com/docs
paths:
  /v2/accounts/{account_id}/finalize_schedules:
    post:
      tags:
        - Schedules
      summary: Finalize schedules of an account
      description: Finalize schedules of an account
      operationId: finalizeAccountSchedules
      parameters:
        - $ref: '#/components/parameters/account_id'
      requestBody:
        $ref: '#/components/requestBodies/FinalizeAccountSchedules'
      responses:
        '200':
          $ref: '#/components/responses/SchedulesPaginatedResponse'
components:
  parameters:
    account_id:
      in: path
      description: account_id corresponding to an account
      name: account_id
      required: true
      schema:
        type: string
        maxLength: 50
        example: ACC00001
  requestBodies:
    FinalizeAccountSchedules:
      description: Payload to finalize account schedules
      required: true
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/FinalizeAccountSchedules'
  responses:
    SchedulesPaginatedResponse:
      description: Paginated response for pricing schedules
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/SchedulesPaginatedResponse'
  schemas:
    FinalizeAccountSchedules:
      description: Request to finalize account schedules
      type: object
      additionalProperties: false
      properties:
        mergeSchedules:
          type: boolean
          description: >
            If this flag is true, the schedules will be merged with the existing
            schedules of the account if possible.

            If this flag is false, the existing schedules will be replaced with
            the new schedules.

            Default value is false
        preActions:
          description: Pre actions to be performed before association or disassociation
          type: array
          items:
            $ref: '#/components/schemas/PreAction'
    SchedulesPaginatedResponse:
      type: object
      additionalProperties: false
      required:
        - data
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/AccountSchedule'
        nextToken:
          type: string
        previousToken:
          type: string
    PreAction:
      type: object
      title: PreAction
      description: Pre action to be performed before association or disassociation
      required:
        - type
      properties:
        type:
          type: string
          enum:
            - GRANT_LICENSE
          description: Type of pre action to be performed
        config:
          type: object
          description: >
            Configuration required for performing pre action

            - `GRANT_LICENSE`: grant one time licenses to an account before
            association
              - `licenseId` [Required]: Id of the license to be granted
              - `updateType` [Required]: Type of update to be performed on the license (RELATIVE or ABSOLUTE)
              - `quantity` [Required]: Quantity of license to be granted
              - `effectiveFrom` [Optional]: Effective date from which the license will be granted
          additionalProperties:
            type: string
    AccountSchedule:
      type: object
      additionalProperties: false
      required:
        - id
        - accountId
        - pricePlanId
        - pricePlanInfo
        - version
        - deferredRevenue
        - startDate
        - endDate
        - allowOngoingCycleUpdates
        - accountScheduleInfo
      properties:
        id:
          type: string
        accountId:
          type: string
        pricePlanId:
          type: string
        version:
          type: integer
        deferredRevenue:
          type: boolean
        pricePlanInfo:
          $ref: '#/components/schemas/PricePlanInfo'
        accountScheduleInfo:
          $ref: '#/components/schemas/ScheduleInfo'
        isOverridden:
          description: >
            Indicates whether the schedule is overridden. Note: A null value for
            this field does not imply that the schedule is not overridden.
          type: boolean
        startDate:
          type: string
          format: date-time
        endDate:
          type: string
          format: date-time
        allowOngoingCycleUpdates:
          type: boolean
    PricePlanInfo:
      type: object
      additionalProperties: false
      required:
        - name
      properties:
        name:
          type: string
        description:
          type: string
    ScheduleInfo:
      type: object
      additionalProperties: false
      required:
        - supportedCurrencies
        - pricingCycleConfig
      properties:
        supportedCurrencies:
          type: array
          items:
            type: string
        pricingCycleConfig:
          $ref: '#/components/schemas/PricingCycleConfig'
        pricingRules:
          type: array
          items:
            $ref: '#/components/schemas/PricingRule'
    PricingCycleConfig:
      type: object
      description: Represents configurations related to pricing cycle
      required:
        - interval
        - gracePeriod
      properties:
        interval:
          $ref: '#/components/schemas/PricingCycleInterval'
        startOffset:
          type: object
          description: >
            Represents the start of pricing cycle in terms of
             - dayOffset - number of days from beginning of week / month and
             - monthOffset - number of months from beginning of interval (quarter, half-year or year)
            Note: If a day with offset doesn't exist for a month, closest
            previous day is considered

            Examples:

            WEEKLY -
              - {dayOffset: 1, monthOffset: NIL} - First day of every week (Monday)
              - {dayOffset: 3, monthOffset: NIL} - 3rd day of every week (Wednesday)
              - {dayOffset: LAST, monthOffset: NIL} - Last day of every week (Sunday)
            MONTHLY -
              - {dayOffset: 1, monthOffset: NIL} - First day of every month
              - {dayOffset: 12, monthOffset: NIL} - 12th of every month
              - {dayOffset: 28, monthOffset: NIL} - 28th of every month. i.e, 28th of Jan, 28th of Feb, ...
              - {dayOffset: 30, monthOffset: NIL} - 30th of every month. i.e, 28th of Jan, 28th of Feb, ...
              - {dayOffset: LAST, monthOffset: NIL} - Last day of every month. i.e, 31st of Jan, 28th of Feb, ...
            QUARTERLY
              - {dayOffset: 15, monthOffset: FIRST} - 15th Jan, 15th Apr, 15th Jul and 15th Oct
              - {dayOffset: 15, monthOffset: 2} - 15th Feb, 15th May, 15th Aug and 15th Nov
              - {dayOffset: 15, monthOffset: LAST} - 15th Mar, 15th Jun, 15th Sep and 15th Dec
              - {dayOffset: LAST, monthOffset: FIRST} - 31st Jan, 30th Apr, 30th Jul and 31th Oct
            HALF_YEARLY
              - {dayOffset: 15, monthOffset: FIRST} - 15th Jan and 15th Jul
              - {dayOffset: 15, monthOffset: 4} - 15th Apr and 15th Oct
              - {dayOffset: 15, monthOffset: LAST} - 15th Jun and 15th Dec
            ANNUALLY
              - {dayOffset: 15, monthOffset: FIRST} - 15th Jan
              - {dayOffset: 15, monthOffset: 1} - 15th Jan
              - {dayOffset: LAST, monthOffset: 2} - 29th Feb on Leap year, 28th otherwise 
              - {dayOffset: 15, monthOffset: 8} - 15th Aug
              - {dayOffset: 15, monthOffset: LAST} - 15th Dec
          required:
            - dayOffset
            - monthOffset
          properties:
            dayOffset:
              type: string
              description: >
                If interval is WEEKLY, min: "1" and max: "7" as strings. Spl.
                string allowed: LAST

                Otherwise, min: "1" and max: "31" as strings. Spl. string
                allowed: LAST
            monthOffset:
              type: string
              description: >
                min: "1" and max: "12". Spl. string allowed: FIRST / LAST.

                For QUARTERLY only 1 - 3 is allowed and for HALF_YEARLY 1 - 6.
                This being an optional field, shouldn't be passed for MONTHLY.
        gracePeriod:
          type: integer
          description: >
            Togai allows you to ingest past dated events that will be processed
            by a pricing cycle till the end grace period. 

            For example: Pricing cycle is Monthly from 1st to 30th and
            gracePeriod is 5 days which next month 1 to 5th date, you can ingest
            past dated events during this grace period.
          format: int32
          example: 3
        anniversaryCycle:
          type: boolean
          description: >
            Togai calculates the startOffsets based on the date of association
            instead of requiring from the user and 

            these offsets will be applied as an override if this flag is
            enabled.

            Examples:

            WEEKLY -
              - 23/10/2023 (Monday) - {dayOffset: 1, monthOffset: NIL} 
              - 25/10/2023 (Wednesday) - {dayOffset: 3, monthOffset: NIL} 
              - 29/10/2023 (Sunday) - {dayOffset: 7, monthOffset: NIL}
            MONTHLY -
              - 1st Oct - {dayOffset: 1, monthOffset: NIL}
              - 12th Oct - {dayOffset: 12, monthOffset: NIL}
              - 28th Oct - {dayOffset: 28, monthOffset: NIL}
              - 30th Oct - {dayOffset: 30, monthOffset: NIL}
              - 31th Oct - {dayOffset: LAST, monthOffset: NIL}
            QUARTERLY
              - 15th Jan, 15th Apr, 15th Jul and 15th Oct - {dayOffset: 15, monthOffset: 1}
              - 15th Feb, 15th May, 15th Aug and 15th Nov - {dayOffset: 15, monthOffset: 2} 
              - 15th Mar, 15th Jun, 15th Sep and 15th Dec - {dayOffset: 15, monthOffset: 3}
            HALF_YEARLY
              - 15th Jan and 15th Jul - {dayOffset: 15, monthOffset: 1} 
              - 15th Apr and 15th Oct - {dayOffset: 15, monthOffset: 4} 
              - 15th Jun and 15th Dec - {dayOffset: 15, monthOffset: 6}
            ANNUALLY
              - 15th Jan - {dayOffset: 15, monthOffset: 1}
              - 29th Feb on Leap year  - {dayOffset: LAST, monthOffset: 2}
              - 28th Feb  - {dayOffset: LAST, monthOffset: 2}
              - 15th Aug - {dayOffset: 15, monthOffset: 8}
              - 15th Dec - {dayOffset: 15, monthOffset: 12}
    PricingRule:
      type: object
      description: Represents pricing rules of a price plan. i.e, price plan bound by time.
      additionalProperties: false
      required:
        - id
        - name
        - version
        - order
        - computation
        - action
      properties:
        id:
          type: string
        name:
          type: string
        version:
          type: integer
          format: int32
          minimum: 1
        invoiceTiming:
          $ref: '#/components/schemas/PricingRuleTiming'
        order:
          type: integer
          format: int32
          minimum: 1
        condition:
          description: >-
            JSON logic condition deciding whether to compute this pricing rule
            or not
          type: string
        computation:
          description: JSON logic to be computed
          type: string
        action:
          $ref: '#/components/schemas/PricingRuleAction'
          description: JSON logic to be computed
          title: action
    PricingCycleInterval:
      type: string
      description: >-
        Interval field allow you to define the billing interval you would like
        to set
      enum:
        - WEEKLY
        - MONTHLY
        - QUARTERLY
        - HALF_YEARLY
        - ANNUALLY
    PricingRuleTiming:
      type: string
      enum:
        - IN_ADVANCE
        - IN_ARREARS
      x-enum-varnames:
        - IN_ADVANCE
        - IN_ARREARS
      description: >
        If IN_ADVANCE, the rule will be applied on rate cards with invoice
        timing IN_ADVANCE .

        If IN_ARREARS, the rule will be applied on rate cards with invoice
        timing IN_ARREARS .
    PricingRuleAction:
      type: object
      additionalProperties: false
      required:
        - type
      properties:
        type:
          type: string
          enum:
            - ADD
            - UPDATE
        target:
          type: string
        id:
          type: string
        description:
          type: string
        metadata:
          type: object
          additionalProperties:
            type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: Bearer <credential>

````