# Update subscription PUT https://api-sandbox.payabli.com/api/Subscription/{subId} Content-Type: application/json Updates a subscription's details. Reference: https://docs.payabli.com/developers/api-reference/subscription/update-subscription ## OpenAPI Specification ```yaml openapi: 3.1.1 info: title: Update a subscription version: endpoint_subscription.UpdateSubscription paths: /Subscription/{subId}: put: operationId: update-subscription summary: Update a subscription description: Updates a subscription's details. tags: - - subpackage_subscription parameters: - name: subId in: path description: 'The subscription ID. ' required: true schema: type: integer - name: requestToken in: header required: true schema: type: string responses: '200': description: Success content: application/json: schema: $ref: >- #/components/schemas/type_subscription:UpdateSubscriptionResponse requestBody: content: application/json: schema: type: object properties: paymentDetails: $ref: '#/components/schemas/type_:PaymentDetail' description: >- Object describing details of the payment. To skip the payment, set the `totalAmount` to 0. Payments will be paused until the amount is updated to a non-zero value. When `totalAmount` is set to 0, the `serviceFee` must also be set to 0. scheduleDetails: $ref: '#/components/schemas/type_:ScheduleDetail' description: Object describing the schedule for subscription setPause: $ref: '#/components/schemas/type_subscription:SetPause' components: schemas: type_:PaymentCategories: type: object properties: amount: type: number format: double description: Price/cost per unit of item or category. description: type: string description: Description of item or category label: type: string description: Name of item or category. qty: type: integer default: 1 description: Quantity of item or category required: - amount - label type_:SplitFundingContent: type: object properties: accountId: type: string description: The accountId for the account the split should be sent to. amount: type: number format: double description: Amount from the transaction to sent to this recipient. description: type: string description: A description for the split. recipientEntryPoint: type: string description: The entrypoint the split should be sent to. type_:SplitFunding: type: array items: $ref: '#/components/schemas/type_:SplitFundingContent' type_:PaymentDetail: type: object properties: categories: type: array items: $ref: '#/components/schemas/type_:PaymentCategories' description: >- Array of payment categories/line items describing the amount to be paid. **Note**: These categories are for information only and aren't validated against the total amount provided. checkImage: type: object additionalProperties: description: Any type description: Object containing image of paper check. checkNumber: type: string description: >- A check number to be used in the ach transaction. **Required** for payment method = 'check'. currency: type: string description: >- The currency for the transaction, `USD` or `CAD`. If your paypoint is configured for CAD, you must send the `CAD` value in this field, otherwise it defaults to USD, which will cause the transaction to fail. serviceFee: type: number format: double description: >- Service fee to be deducted from the total amount. This amount must be a number, percentages aren't accepted. If you are using a percentage-based fee schedule, you must calculate the value manually. splitFunding: $ref: '#/components/schemas/type_:SplitFunding' description: >- Split funding instructions for the transaction. See [Split a Transaction](/developers/developer-guides/money-in-split-funding) for more. totalAmount: type: number format: double description: >- Total amount to be charged. If a service fee is sent, then this amount should include the service fee." required: - totalAmount type_:Frequency: type: string enum: - value: onetime - value: weekly - value: every2weeks - value: every6months - value: monthly - value: every3months - value: annually type_:ScheduleDetail: type: object properties: endDate: type: string description: >- Subscription end date in any of the accepted formats: YYYY-MM-DD, MM/DD/YYYY or the value `untilcancelled` to indicate a scheduled payment with infinite cycle. frequency: $ref: '#/components/schemas/type_:Frequency' description: Frequency of the subscription. planId: type: integer description: >- This field is for future development, leave null. Identifier of subscription plan applied in the scheduled payment/subscription. startDate: type: string description: >- Subscription start date in any of the accepted formats: YYYY-MM-DD, MM/DD/YYYY. This must be a future date. type_subscription:SetPause: type: boolean type_:IsSuccess: type: boolean type_:ResponseText: type: string type_:CustomerId: type: integer format: int64 type_subscription:UpdateSubscriptionResponse: type: object properties: isSuccess: $ref: '#/components/schemas/type_:IsSuccess' responseData: type: string description: >- If `isSuccess` = true, this contains the identifier of the subscription, and sometimes extra information, depending on what was updated. If `isSuccess` = false, this contains the reason for the failure. responseText: $ref: '#/components/schemas/type_:ResponseText' customerId: $ref: '#/components/schemas/type_:CustomerId' required: - responseText ``` ## SDK Code Examples ```python PauseSubscription from payabli import payabli client = payabli( api_key="YOUR_API_KEY", ) client.subscription.update_subscription( sub_id=231, set_pause=True, ) ``` ```typescript PauseSubscription import { PayabliClient } from "@payabli/sdk-node"; const client = new PayabliClient({ apiKey: "YOUR_API_KEY" }); await client.subscription.updateSubscription(231, { setPause: true }); ``` ```go PauseSubscription import ( context "context" option "github.com/payabli/sdk-go/option" sdkgo "github.com/payabli/sdk-go" sdkgoclient "github.com/payabli/sdk-go/client" ) client := sdkgoclient.NewClient( option.WithApiKey( "", ), ) response, err := client.Subscription.UpdateSubscription( context.TODO(), 231, &sdkgo.RequestUpdateSchedule{ SetPause: sdkgo.Bool( true, ), }, ) ``` ```csharp PauseSubscription using PayabliApi; var client = new PayabliApiClient("API_KEY"); await client.Subscription.UpdateSubscriptionAsync( 231, new RequestUpdateSchedule { SetPause = true } ); ``` ```ruby PauseSubscription require 'uri' require 'net/http' url = URI("https://api-sandbox.payabli.com/api/Subscription/231") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Put.new(url) request["requestToken"] = '' request["Content-Type"] = 'application/json' request.body = "{\n \"setPause\": true\n}" response = http.request(request) puts response.read_body ``` ```java PauseSubscription HttpResponse response = Unirest.put("https://api-sandbox.payabli.com/api/Subscription/231") .header("requestToken", "") .header("Content-Type", "application/json") .body("{\n \"setPause\": true\n}") .asString(); ``` ```php PauseSubscription request('PUT', 'https://api-sandbox.payabli.com/api/Subscription/231', [ 'body' => '{ "setPause": true }', 'headers' => [ 'Content-Type' => 'application/json', 'requestToken' => '', ], ]); echo $response->getBody(); ``` ```swift PauseSubscription import Foundation let headers = [ "requestToken": "", "Content-Type": "application/json" ] let parameters = ["setPause": true] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api-sandbox.payabli.com/api/Subscription/231")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "PUT" 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() ``` ```python UnpauseSubscription from payabli import payabli client = payabli( api_key="YOUR_API_KEY", ) client.subscription.update_subscription( sub_id=231, set_pause=False, ) ``` ```typescript UnpauseSubscription import { PayabliClient } from "@payabli/sdk-node"; const client = new PayabliClient({ apiKey: "YOUR_API_KEY" }); await client.subscription.updateSubscription(231, { setPause: false }); ``` ```go UnpauseSubscription import ( context "context" option "github.com/payabli/sdk-go/option" sdkgo "github.com/payabli/sdk-go" sdkgoclient "github.com/payabli/sdk-go/client" ) client := sdkgoclient.NewClient( option.WithApiKey( "", ), ) response, err := client.Subscription.UpdateSubscription( context.TODO(), 231, &sdkgo.RequestUpdateSchedule{ SetPause: sdkgo.Bool( true, ), }, ) ``` ```csharp UnpauseSubscription using PayabliApi; var client = new PayabliApiClient("API_KEY"); await client.Subscription.UpdateSubscriptionAsync( 231, new RequestUpdateSchedule { SetPause = false } ); ``` ```ruby UnpauseSubscription require 'uri' require 'net/http' url = URI("https://api-sandbox.payabli.com/api/Subscription/231") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Put.new(url) request["requestToken"] = '' request["Content-Type"] = 'application/json' request.body = "{\n \"setPause\": false\n}" response = http.request(request) puts response.read_body ``` ```java UnpauseSubscription HttpResponse response = Unirest.put("https://api-sandbox.payabli.com/api/Subscription/231") .header("requestToken", "") .header("Content-Type", "application/json") .body("{\n \"setPause\": false\n}") .asString(); ``` ```php UnpauseSubscription request('PUT', 'https://api-sandbox.payabli.com/api/Subscription/231', [ 'body' => '{ "setPause": false }', 'headers' => [ 'Content-Type' => 'application/json', 'requestToken' => '', ], ]); echo $response->getBody(); ``` ```swift UnpauseSubscription import Foundation let headers = [ "requestToken": "", "Content-Type": "application/json" ] let parameters = ["setPause": false] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api-sandbox.payabli.com/api/Subscription/231")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "PUT" 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() ``` ```python UpdateSubscription from payabli import PaymentDetail, ScheduleDetail, payabli client = payabli( api_key="YOUR_API_KEY", ) client.subscription.update_subscription( sub_id=231, payment_details=PaymentDetail( service_fee=0.0, total_amount=100.0, ), schedule_details=ScheduleDetail( end_date="03-20-2025", frequency="weekly", plan_id=1, start_date="09-20-2024", ), ) ``` ```typescript UpdateSubscription import { PayabliClient } from "@payabli/sdk-node"; const client = new PayabliClient({ apiKey: "YOUR_API_KEY" }); await client.subscription.updateSubscription(231, { paymentDetails: { serviceFee: 0, totalAmount: 100 }, scheduleDetails: { endDate: "03-20-2025", frequency: "weekly", planId: 1, startDate: "09-20-2024" } }); ``` ```go UpdateSubscription import ( context "context" option "github.com/payabli/sdk-go/option" sdkgo "github.com/payabli/sdk-go" sdkgoclient "github.com/payabli/sdk-go/client" ) client := sdkgoclient.NewClient( option.WithApiKey( "", ), ) response, err := client.Subscription.UpdateSubscription( context.TODO(), 231, &sdkgo.RequestUpdateSchedule{ SetPause: sdkgo.Bool( true, ), }, ) ``` ```csharp UpdateSubscription using PayabliApi; var client = new PayabliApiClient("API_KEY"); await client.Subscription.UpdateSubscriptionAsync( 231, new RequestUpdateSchedule { PaymentDetails = new PaymentDetail { ServiceFee = 0, TotalAmount = 100 }, ScheduleDetails = new ScheduleDetail { EndDate = "03-20-2025", Frequency = Frequency.Weekly, PlanId = 1, StartDate = "09-20-2024", }, } ); ``` ```ruby UpdateSubscription require 'uri' require 'net/http' url = URI("https://api-sandbox.payabli.com/api/Subscription/231") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Put.new(url) request["requestToken"] = '' request["Content-Type"] = 'application/json' request.body = "{\n \"paymentDetails\": {\n \"totalAmount\": 100,\n \"serviceFee\": 0\n },\n \"scheduleDetails\": {\n \"endDate\": \"03-20-2025\",\n \"frequency\": \"weekly\",\n \"planId\": 1,\n \"startDate\": \"09-20-2024\"\n }\n}" response = http.request(request) puts response.read_body ``` ```java UpdateSubscription HttpResponse response = Unirest.put("https://api-sandbox.payabli.com/api/Subscription/231") .header("requestToken", "") .header("Content-Type", "application/json") .body("{\n \"paymentDetails\": {\n \"totalAmount\": 100,\n \"serviceFee\": 0\n },\n \"scheduleDetails\": {\n \"endDate\": \"03-20-2025\",\n \"frequency\": \"weekly\",\n \"planId\": 1,\n \"startDate\": \"09-20-2024\"\n }\n}") .asString(); ``` ```php UpdateSubscription request('PUT', 'https://api-sandbox.payabli.com/api/Subscription/231', [ 'body' => '{ "paymentDetails": { "totalAmount": 100, "serviceFee": 0 }, "scheduleDetails": { "endDate": "03-20-2025", "frequency": "weekly", "planId": 1, "startDate": "09-20-2024" } }', 'headers' => [ 'Content-Type' => 'application/json', 'requestToken' => '', ], ]); echo $response->getBody(); ``` ```swift UpdateSubscription import Foundation let headers = [ "requestToken": "", "Content-Type": "application/json" ] let parameters = [ "paymentDetails": [ "totalAmount": 100, "serviceFee": 0 ], "scheduleDetails": [ "endDate": "03-20-2025", "frequency": "weekly", "planId": 1, "startDate": "09-20-2024" ] ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api-sandbox.payabli.com/api/Subscription/231")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "PUT" 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() ```