Skip to content

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>
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",
  },
});
{
  "failure": null,
  "kind": "change_plan",
  "operationId": "string",
  "paymentAction": null,
  "resolvedAt": null,
  "result": {
    "effectiveAt": null,
    "type": "version",
    "version": "string"
  },
  "status": "succeeded",
  "submittedAt": null
}

Parameters

Photon-VersionPhotonVersion

Selects the API contract date. Without it, the request is served as 2026-07-01.

Idempotency-Keystringrequired

Identifies one logical mutation across retries.

organizationIdstringrequired
projectIdstringrequired

The project being billed.

Body

categorystringrequired

Category slug, e.g. analytics or messaging.

planCodestringrequired

Plan to subscribe to, e.g. analytics_pro.

promotionCodestring

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

failurenullrequired
kindBillingOperationKindrequired
operationIdstringrequired

Stable handle for this provisioning action.

paymentActionnullrequired
resolvedAtstring | nullrequired
resultBillingOperationResultrequired
statusunknownrequired

Terminal. The result is authoritative.

submittedAtstring | nullrequired

One of: FailedBillingOperation

failureBillingOperationFailurerequired
kindBillingOperationKindrequired
operationIdstringrequired

Stable handle for this provisioning action.

paymentActionnullrequired
resolvedAtstring | nullrequired
resultnullrequired
statusunknownrequired

Terminal. Failure contains a stable code and retryability.

submittedAtstring | nullrequired

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.

failurenullrequired
kindBillingOperationKindrequired
operationIdstringrequired

Stable handle for this provisioning action.

paymentActionBillingPaymentAction | nullrequired

Set while a payment the operation waits for needs the customer's authentication. Completing it within the payment window completes the operation.

resolvedAtnullrequired
resultnullrequired
statusunknownrequired

Accepted and still executing. Poll the operation route.

submittedAtstring | nullrequired