> ## 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.

# Create a price plan v2 migration

> Migrates accounts across price plans. This is an asynchronous process functioning on top of Togai's Jobs 
framework. Status of the created migrations can be obtained using the [Jobs APIs](https://docs.togai.com/api-reference/jobs/get-the-status-of-a-job)




## OpenAPI

````yaml post /v2/price_plans/migration
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/price_plans/migration:
    post:
      tags:
        - PricePlanV2
      summary: Create a price plan v2 migration
      description: >
        Migrates accounts across price plans. This is an asynchronous process
        functioning on top of Togai's Jobs 

        framework. Status of the created migrations can be obtained using the
        [Jobs
        APIs](https://docs.togai.com/api-reference/jobs/get-the-status-of-a-job)
      operationId: pricePlanMigrationV2
      requestBody:
        $ref: '#/components/requestBodies/CreatePricePlanMigrationRequest'
      responses:
        '201':
          $ref: '#/components/responses/BaseSuccessResponse'
        '400':
          $ref: '#/components/responses/ErrorResponse'
        '401':
          $ref: '#/components/responses/ErrorResponse'
        '403':
          $ref: '#/components/responses/ErrorResponse'
        '404':
          $ref: '#/components/responses/ErrorResponse'
        '429':
          $ref: '#/components/responses/ErrorResponse'
        default:
          $ref: '#/components/responses/ErrorResponse'
components:
  requestBodies:
    CreatePricePlanMigrationRequest:
      description: Payload to create price plan migration request
      required: true
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/CreatePricePlanMigrationRequest'
          examples:
            CreatePricePlanMigrationRequest:
              $ref: '#/components/examples/CreatePricePlanMigrationRequest'
  responses:
    BaseSuccessResponse:
      description: OK
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/BaseSuccessResponse'
    ErrorResponse:
      description: Error response
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            ErrorResponse:
              summary: Error message
              value:
                message: <Reason message>
  schemas:
    CreatePricePlanMigrationRequest:
      description: Request to create price plan migration request
      allOf:
        - $ref: '#/components/schemas/pricePlanMigrationConfig'
        - type: object
          properties:
            requireConfirmation:
              description: >
                This field specifies whether to process job or to wait till the
                job is confirmed. Default value: false
              type: boolean
    BaseSuccessResponse:
      type: object
      additionalProperties: false
      required:
        - success
      properties:
        success:
          type: boolean
          example: true
    ErrorResponse:
      type: object
      additionalProperties: false
      required:
        - message
      properties:
        message:
          type: string
          description: error description
          maxLength: 500
    pricePlanMigrationConfig:
      description: Migrate all account associations of a price plan to another price plan
      type: object
      additionalProperties: false
      required:
        - sourceId
        - sourceVersion
        - migrationMode
      properties:
        sourceId:
          description: Id of source price plan
          type: string
          maxLength: 255
        sourceVersion:
          description: Version of the source price plan
          type: integer
          format: int32
        targetId:
          description: Id of target price plan
          type: string
          maxLength: 255
        targetVersion:
          description: Version of the target price plan
          type: integer
          format: int32
        migrationMode:
          type: string
          enum:
            - IMMEDIATE
            - IMMEDIATE_IGNORE_OVERRIDE
            - NEXT_CYCLE
            - NEXT_CYCLE_IGNORE_OVERRIDE
            - START_OF_CURRENT_CYCLE
        retainStartOffsets:
          type: boolean
          description: >
            If this flag is true, current pricing cycle of the account on the
            date of association will continue rather 

            than the configurations of the newly associated price plan. Pricing
            cycle overrides specified  using 

            `pricePlanDetailsOverride` will take precedence over the pricing
            cycle configurations of 

            the new price plan that the account needs to migrate to.
            PricingCycleInterval of the existing plan and 

            the new plan must be same for this to work. We'll return a `400
            BadRequest` otherwise.

            Examples:
              - Ongoing plan (1st Oct to 30th Oct) - {dayOffset: 1, monthOffset: NIL}
                New association (15th Oct to 15th Nov) of different price plan with retainStartOffsets option true 
                will use the same pricing cycle configuration {dayOffset: 1, monthOffset: NIL} rather than using the
                pricing cycle configuration of the new price plan that the account needs to migrate to.
              - Ongoing plan (1st Oct to 30th Oct) - {dayOffset: 1, monthOffset: NIL}
                New association (1st Nov to 30th Nov) of different price plan with retainStartOffsets option true will
                throw a `400 BadRequest` as no existing price plan configuration found on date of association
        isPricePlanV2Migration:
          type: boolean
          description: >
            If this flag is true, the migration will be done for price plan v2.
            Default value is false
  examples:
    CreatePricePlanMigrationRequest:
      value:
        requireConfirmation: true
        sourceId: pp.1zYnCiM9Bpg.lv25y
        sourceVersion: 1
        targetId: pp.2zYnCiM9Bpg.bfeu2
        targetVersion: 2
        migrationMode: IMMEDIATE
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: Bearer <credential>

````