# Create Subscription Plan POST /api/v1/payments/subscription/create-price-plan/ Content-Type: application/json Creates a new subscription plan (admin only). Reference: https://docs.aisquare.studio/api-reference/ai-square-studio-api/payments/subscription-create-price-plan-create ## OpenAPI Specification ```yaml openapi: 3.1.0 info: title: AISquare Studio API version: 1.0.0 paths: /api/v1/payments/subscription/create-price-plan/: post: operationId: subscription-create-price-plan-create summary: Create Subscription Plan description: Creates a new subscription plan (admin only). tags: - subpackage_payments responses: '201': description: Plan created successfully content: application/json: schema: $ref: '#/components/schemas/PricePlan' '400': description: Invalid input content: application/json: schema: description: Any type '401': description: Unauthorized content: application/json: schema: description: Any type '403': description: Forbidden content: application/json: schema: description: Any type requestBody: content: application/json: schema: type: object properties: plan_type: $ref: >- #/components/schemas/ApiV1PaymentsSubscriptionCreatePricePlanPostRequestBodyContentApplicationJsonSchemaPlanType description: The type of pricing plan to create product_name: type: string description: The name of the product/plan amount: type: number format: double description: The base amount for fixed/per-unit plans currency: type: string default: usd description: The currency for the plan interval: type: string default: month description: The billing interval (month, year, etc.) tiers: type: array items: $ref: >- #/components/schemas/ApiV1PaymentsSubscriptionCreatePricePlanPostRequestBodyContentApplicationJsonSchemaTiersItems description: Required for tiered plans, list of tier configurations required: - plan_type - product_name - amount components: schemas: ApiV1PaymentsSubscriptionCreatePricePlanPostRequestBodyContentApplicationJsonSchemaPlanType: type: string enum: - fixed - tiered - per_unit description: The type of pricing plan to create title: >- ApiV1PaymentsSubscriptionCreatePricePlanPostRequestBodyContentApplicationJsonSchemaPlanType ApiV1PaymentsSubscriptionCreatePricePlanPostRequestBodyContentApplicationJsonSchemaTiersItems: type: object properties: up_to: type: integer unit_amount: type: integer title: >- ApiV1PaymentsSubscriptionCreatePricePlanPostRequestBodyContentApplicationJsonSchemaTiersItems PricePlan: type: object properties: id: type: integer product_id: type: string price_id: type: string amount: type: string format: decimal currency: type: string interval: type: string description: type: string required: - id - product_id - price_id - amount - currency - interval - description title: PricePlan ``` ## SDK Code Examples ```python Created Plan Example import requests url = "https://api.example.com/api/v1/payments/subscription/create-price-plan/" payload = { "plan_type": "fixed", "product_name": "string", "amount": 1.1 } headers = {"Content-Type": "application/json"} response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript Created Plan Example const url = 'https://api.example.com/api/v1/payments/subscription/create-price-plan/'; const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"plan_type":"fixed","product_name":"string","amount":1.1}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go Created Plan Example package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.example.com/api/v1/payments/subscription/create-price-plan/" payload := strings.NewReader("{\n \"plan_type\": \"fixed\",\n \"product_name\": \"string\",\n \"amount\": 1.1\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby Created Plan Example require 'uri' require 'net/http' url = URI("https://api.example.com/api/v1/payments/subscription/create-price-plan/") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Content-Type"] = 'application/json' request.body = "{\n \"plan_type\": \"fixed\",\n \"product_name\": \"string\",\n \"amount\": 1.1\n}" response = http.request(request) puts response.read_body ``` ```java Created Plan Example import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.example.com/api/v1/payments/subscription/create-price-plan/") .header("Content-Type", "application/json") .body("{\n \"plan_type\": \"fixed\",\n \"product_name\": \"string\",\n \"amount\": 1.1\n}") .asString(); ``` ```php Created Plan Example request('POST', 'https://api.example.com/api/v1/payments/subscription/create-price-plan/', [ 'body' => '{ "plan_type": "fixed", "product_name": "string", "amount": 1.1 }', 'headers' => [ 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp Created Plan Example using RestSharp; var client = new RestClient("https://api.example.com/api/v1/payments/subscription/create-price-plan/"); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"plan_type\": \"fixed\",\n \"product_name\": \"string\",\n \"amount\": 1.1\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift Created Plan Example import Foundation let headers = ["Content-Type": "application/json"] let parameters = [ "plan_type": "fixed", "product_name": "string", "amount": 1.1 ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.example.com/api/v1/payments/subscription/create-price-plan/")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```