# Change plan

Source: https://docs.orbytelabs.com/api-reference/subscriptions/changeSubscription

## POST /v1/subscriptions/{identity}/change

```json
{
  "operationId": "changeSubscription",
  "summary": "Change plan",
  "tags": [
    "Subscriptions"
  ],
  "description": "Upgrades start and charge for a full new billing period immediately, granting credits after confirmed payment. If payment requires action, the old plan remains until payment completes. Downgrades retain the current plan until renewal and return scheduledChange with the target plan and effectiveAt timestamp.",
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "parameters": [
    {
      "schema": {
        "type": "string",
        "minLength": 1,
        "maxLength": 200
      },
      "required": true,
      "name": "identity",
      "in": "path"
    }
  ],
  "requestBody": {
    "required": true,
    "content": {
      "application/json": {
        "schema": {
          "type": "object",
          "properties": {
            "planKey": {
              "type": "string",
              "minLength": 1,
              "maxLength": 80,
              "pattern": "^[a-z0-9][a-z0-9_-]*$"
            },
            "idempotencyKey": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            }
          },
          "required": [
            "planKey",
            "idempotencyKey"
          ],
          "additionalProperties": false
        }
      }
    }
  },
  "responses": {
    "200": {
      "description": "Current subscription",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "identity": {
                "type": "string",
                "minLength": 1,
                "maxLength": 200
              },
              "planKey": {
                "type": "string"
              },
              "status": {
                "type": "string"
              },
              "periodStart": {
                "type": "number"
              },
              "periodEnd": {
                "type": "number"
              },
              "cancelAtPeriodEnd": {
                "type": "boolean"
              },
              "scheduledChange": {
                "type": "object",
                "properties": {
                  "planKey": {
                    "type": "string"
                  },
                  "effectiveAt": {
                    "type": "number"
                  }
                },
                "required": [
                  "planKey",
                  "effectiveAt"
                ],
                "additionalProperties": false
              },
              "paymentHold": {
                "type": "boolean"
              },
              "creditGrants": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "creditKey": {
                      "type": "string"
                    },
                    "amountNanocredits": {
                      "type": "string",
                      "maxLength": 19,
                      "pattern": "^(0|[1-9][0-9]*)$"
                    }
                  },
                  "required": [
                    "creditKey",
                    "amountNanocredits"
                  ],
                  "additionalProperties": false
                },
                "default": []
              },
              "topupsEnabled": {
                "type": "boolean",
                "default": true
              },
              "featureMultipliers": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "featureKey": {
                      "type": "string"
                    },
                    "basisPoints": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "featureKey",
                    "basisPoints"
                  ],
                  "additionalProperties": false
                },
                "default": []
              },
              "pendingChange": {
                "type": "object",
                "properties": {
                  "planKey": {
                    "type": "string"
                  },
                  "expiresAt": {
                    "type": "number"
                  },
                  "paymentUrl": {
                    "type": "string"
                  }
                },
                "required": [
                  "planKey",
                  "expiresAt"
                ],
                "additionalProperties": false
              },
              "featureLimits": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "featureKey": {
                      "type": "string"
                    },
                    "limit": {
                      "type": "number"
                    },
                    "period": {
                      "type": "string",
                      "enum": [
                        "month",
                        "billing"
                      ]
                    },
                    "overage": {
                      "type": "string",
                      "enum": [
                        "block",
                        "credits"
                      ]
                    }
                  },
                  "required": [
                    "featureKey",
                    "limit",
                    "period",
                    "overage"
                  ],
                  "additionalProperties": false
                }
              }
            },
            "required": [
              "id",
              "identity",
              "planKey",
              "status",
              "periodStart",
              "periodEnd",
              "cancelAtPeriodEnd",
              "featureLimits"
            ],
            "additionalProperties": false
          }
        }
      }
    },
    "400": {
      "description": "Invalid request",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "error": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "error",
              "message"
            ],
            "additionalProperties": false
          }
        }
      }
    },
    "401": {
      "description": "Missing, expired, or revoked API key",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "error": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "error",
              "message"
            ],
            "additionalProperties": false
          }
        }
      }
    },
    "403": {
      "description": "Insufficient permission or unsupported key kind",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "error": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "error",
              "message"
            ],
            "additionalProperties": false
          }
        }
      }
    },
    "404": {
      "description": "Resource not found",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "error": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "error",
              "message"
            ],
            "additionalProperties": false
          }
        }
      }
    },
    "409": {
      "description": "Conflict or insufficient balance",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "error": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "error",
              "message"
            ],
            "additionalProperties": false
          }
        }
      }
    },
    "413": {
      "description": "Body exceeds 16 KiB",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "error": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "error",
              "message"
            ],
            "additionalProperties": false
          }
        }
      }
    },
    "415": {
      "description": "Content-Type must be application/json",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "error": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "error",
              "message"
            ],
            "additionalProperties": false
          }
        }
      }
    },
    "422": {
      "description": "Unsupported pricing or billing configuration",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "error": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "error",
              "message"
            ],
            "additionalProperties": false
          }
        }
      }
    },
    "429": {
      "description": "Rate limit exceeded; see Retry-After",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "error": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "error",
              "message"
            ],
            "additionalProperties": false
          }
        }
      }
    },
    "500": {
      "description": "Unexpected server error",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "error": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "error",
              "message"
            ],
            "additionalProperties": false
          }
        }
      }
    }
  }
}
```

Complete schema: [OpenAPI 3.1 document](https://docs.orbytelabs.com/openapi.json)