Skip to main content

Documentation

Update Plan

Change or modify a pricing plan for services.

You can update a plan’s nickname or metadata.

This method triggers the Plan Updated webhook. This webhook contains the same information as the response.

    • plan

    • ID of the plan.

    • active

    • Indicates whether the plan is available for a subscription. Can be true when the product associated with this plan is active.

    • nickname

    • Brief description of the plan.

Code Samples
    • .NET

      • using System;
        using System.Text.Json;
        
        namespace RapydApiRequestSample
        {
            class Program
            {
                static void Main(string[] args)
                {
                    try
                    {
                        string plan = "plan_51788cf4ed1b672cb0a2a97773887f5b";
        
                        var metadata = new
                        {
                            merchant_defined = "updated"
                        };
        
                        var requestObj = new
                        {
                            metadata,
                            nickname = "Basic parking"
                        };
        
                        string request = JsonSerializer.Serialize(requestObj);
        
                        string result = RapydApiRequestSample.Utilities.MakeRequest("POST", $"/v1/plans/{plan}", request);
        
                        Console.WriteLine(result);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Error completing request: " + e.Message);
                    }
                }
            }
        }
    • JavaScript

      • const makeRequest = require('<path-to-your-utility-file>/utilities').makeRequest;
        
        async function main() {
          try {
            const body = {
              nickname: 'main plan'
            };
            const result = await makeRequest(
              'POST',
              '/v1/plans/plan_51788cf4ed1b672cb0a2a97773887f5b',
              body
            );
        
            console.log(result);
          } catch (error) {
            console.error('Error completing request', error);
          }
        }
    • PHP

      • <?php
        $path = $_SERVER['DOCUMENT_ROOT'];
        $path .= "/<path-to-your-utility-file>/utilities.php";
        include($path);
        
        $body = [
            "nickname" => "Basic parking"
        ];
        
        try {
            $object = make_request('post', '/v1/plans/plan_51788cf4ed1b672cb0a2a97773887f5b', $body);
            var_dump($object);
        } catch(Exception $e) {
            echo "Error: $e";
        }
        ?>
    • Python

      • from pprint import pprint
        
        from utilities import make_request
        
        plan_data = {
            "metadata": {
                "merchant_defined": "updated"
            },
            "nickname": "Basic parking"
        }
        result = make_request(method='post', path='/v1/plans/plan_51788cf4ed1b672cb0a2a97773887f5b', body=plan_data)
        pprint(result)
        
  • /v1/plans/:plan

  • Update Plan

  • curl -X post 'https://sandboxapi.rapyd.net/v1/plans/plan_51788cf4ed1b672cb0a2a97773887f5b' \
    -H 'access_key: your-access-key-here' \
    -H 'Content-Type: application/json' \
    -H 'idempotency: your-idempotency-parameter-here' \
    -H 'salt: your-random-string-here' \
    -H 'signature: your-calculated-signature-here' \
    -H 'timestamp: your-unix-timestamp-here' \
    --data-raw '{
        "nickname": "Basic parking"
    }'
  • {
        "status": {
            "error_code": "",
            "status": "SUCCESS",
            "message": "",
            "response_code": "",
            "operation_id": "2ff82671-6a3c-46c5-b6d2-67dd03fb4b23"
        },
        "data": {
            "id": "plan_19d3a529a2ffcd6ea077cd3ddd58356b",
            "aggregate_usage": "sum",
            "amount": 12,
            "billing_scheme": "per_unit",
            "created_at": 1761210476,
            "currency": "USD",
            "interval": "day",
            "interval_count": 1,
            "metadata": {},
            "product": {
                "id": "product_5a3e46804b01c4999cd061f032a02aea",
                "active": true,
                "attributes": [
                    "location",
                    "size"
                ],
                "created_at": 1673881298,
                "description": "Covered parking - compact car",
                "images": [
                    "64bit-encoded-image-1"
                ],
                "metadata": {},
                "name": "Hourly parking",
                "package_dimensions": {
                    "height": 0,
                    "length": 0,
                    "weight": 0,
                    "width": 0
                },
                "shippable": false,
                "skus": [],
                "statement_descriptor": "Hourly parking",
                "type": "services",
                "unit_label": "day",
                "updated_at": 1673881298
            },
            "nickname": "Basic parking",
            "tiers": [],
            "tiers_mode": "",
            "transform_usage": {
                "divide_by": 60,
                "round": "up"
            },
            "trial_period_days": 0,
            "usage_type": "metered",
            "active": true
        }
    }
  • Activate Plan

  • curl -X post 'https://sandboxapi.rapyd.net/v1/plans/plan_889a7dc707b2ca13a815b008bec61a7d' \
    -H 'access_key: your-access-key-here' \
    -H 'Content-Type: application/json' \
    -H 'idempotency: your-idempotency-parameter-here' \
    -H 'salt: your-random-string-here' \
    -H 'signature: your-calculated-signature-here' \
    -H 'timestamp: your-unix-timestamp-here' \
    --data-raw '{
        "active": true
    }'
  • {
        "status": {
            "error_code": "",
            "status": "SUCCESS",
            "message": "",
            "response_code": "",
            "operation_id": "ab1b2d51-ad16-44cf-88db-edc7d75bc926"
        },
        "data": {
            "id": "plan_19d3a529a2ffcd6ea077cd3ddd58356b",
            "aggregate_usage": "sum",
            "amount": 12,
            "billing_scheme": "per_unit",
            "created_at": 1761210476,
            "currency": "USD",
            "interval": "day",
            "interval_count": 1,
            "metadata": {},
            "product": {
                "id": "product_5a3e46804b01c4999cd061f032a02aea",
                "active": true,
                "attributes": [
                    "location",
                    "size"
                ],
                "created_at": 1673881298,
                "description": "Covered parking - compact car",
                "images": [
                    "64bit-encoded-image-1"
                ],
                "metadata": {},
                "name": "Hourly parking",
                "package_dimensions": {
                    "height": 0,
                    "length": 0,
                    "weight": 0,
                    "width": 0
                },
                "shippable": false,
                "skus": [],
                "statement_descriptor": "Hourly parking",
                "type": "services",
                "unit_label": "day",
                "updated_at": 1673881298
            },
            "nickname": "Basic parking",
            "tiers": [],
            "tiers_mode": "",
            "transform_usage": {
                "divide_by": 60,
                "round": "up"
            },
            "trial_period_days": 0,
            "usage_type": "metered",
            "active": true
        }
    }