Change plan
Change plan: changePlan in the TypeScript, Python, Rust and Go clients.
POST /v1/organizations/{organizationId}/billing/projects/{projectId}/purchase
Purchases or changes the selected project's plan for the supplied category and planCode, redeeming promotionCode when given. A 202 response means the change is pending: poll the returned operation URL and honor Retry-After until it succeeds or fails. A 200 response means the idempotency key resolved to an operation that is already terminal; inspect that result rather than assuming success from the status code alone. Supply the required Idempotency-Key header. Supply both organizationId and projectId to select the project within its organization.
photon.organizations.billing.changePlan(input: ChangePlanInput, options?: RequestOptions): Promise<ChangePlanOutput>photon.organizations.billing.change_plan(input: ChangePlanInput, *, options: RequestOptions | None = None) -> models.TerminalBillingOperation | models.PendingBillingOperationclient.change_plan(idempotency_key: String, organization_id: String, project_id: String, body: &types::ChangePlanRequest).await -> Result<ResponseValue<ChangePlanResponse>, Error<ChangePlanError>>client.Organizations.Billing.ChangePlan(ctx context.Context, params *ChangePlanParams, opts ...RequestOption) (*ChangePlanResponse, error)import { Photon } from "@photon-ai/api";
const photon = new Photon({
headers: { Authorization: `Bearer ${process.env.PHOTON_API_TOKEN}` },
});
const result = await photon.organizations.billing.changePlan({
path: {
organizationId: "organizationId",
projectId: "projectId",
},
headers: {
idempotencyKey: "idempotencyKey",
},
body: {
category: "category",
planCode: "planCode",
},
});import os
from photon_api import Photon
from photon_api.rpc_generated import ChangePlanInput
photon = Photon(headers={"Authorization": f"Bearer {os.environ['PHOTON_API_TOKEN']}"})
result = photon.organizations.billing.change_plan(
ChangePlanInput.model_validate({
"path": {
"organizationId": "organizationId",
"projectId": "projectId",
},
"headers": {
"Idempotency-Key": "idempotencyKey",
},
"body": {
"category": "category",
"planCode": "planCode",
},
})
)use photon_ai_api::{Credential, PhotonClientBuilder, SecretString};
let token = std::env::var("PHOTON_API_TOKEN")?;
let client = PhotonClientBuilder::new()
.credential("accountServiceKey", Credential::Bearer(SecretString::from(token)))
.build()?;
let result = client
.change_plan(
"idempotencyKey".to_owned(),
"organizationId".to_owned(),
"projectId".to_owned(),
&serde_json::from_value(serde_json::json!({
"category": "category",
"planCode": "planCode",
}))?,
)
.await
.map_err(|error| format!("{error:?}"))?
.into_inner();import (
"context"
"encoding/json"
"os"
photonapi "github.com/photon-hq/api/packages/go"
)
ctx := context.Background()
client := photonapi.NewClient(photonapi.WithAPIKey(os.Getenv("PHOTON_API_TOKEN")))
var body photonapi.ChangePlanRequest
if err := json.Unmarshal([]byte(`{
"category": "category",
"planCode": "planCode"
}`), &body); err != nil {
return err
}
result, err := client.Organizations.Billing.ChangePlan(ctx, &photonapi.ChangePlanParams{
IdempotencyKey: "idempotencyKey",
OrganizationID: "organizationId",
ProjectID: "projectId",
Body: body,
})
if err != nil {
return err
}
_ = result{
"failure": null,
"kind": "change_plan",
"operationId": "string",
"paymentAction": null,
"resolvedAt": null,
"result": {
"effectiveAt": null,
"type": "version",
"version": "string"
},
"status": "succeeded",
"submittedAt": null
}{
"failure": null,
"kind": "change_plan",
"operationId": "string",
"paymentAction": null,
"resolvedAt": null,
"result": null,
"status": "pending",
"submittedAt": null
}Parameters
Selects the API contract date. Without it, the request is served as 2026-07-01.
Identifies one logical mutation across retries.
The project being billed.
Body
Category slug, e.g. analytics or messaging.
Plan to subscribe to, e.g. analytics_pro.
A promotion code the customer entered, matched ignoring case. It is redeemed with the change, which only an upgrade or a first plan can carry; a refused code fails the operation with code promotion_code_rejected and changes nothing. Coupons the project already has stay and stack.
Returns
200 The idempotency key resolved to an operation that is already terminal. TerminalBillingOperation
Headers: Photon-Version. The raw response carries these headers; see Raw responses.
One of: SucceededBillingOperation
Stable handle for this provisioning action.
Terminal. The result is authoritative.
One of: FailedBillingOperation
Stable handle for this provisioning action.
Terminal. Failure contains a stable code and retryability.
202 Plan change accepted. Poll the returned operation until it succeeds or fails. PendingBillingOperation
Headers: Location, Photon-Version. The raw response carries these headers; see Raw responses.
Stable handle for this provisioning action.
Set while a payment the operation waits for needs the customer's authentication. Completing it within the payment window completes the operation.
Accepted and still executing. Poll the operation route.