Update subscription
Route
PUT
/api/v1/subscriptions/:id
Usage
- Curl
- Python
- Ruby
- Javascript
- C#
- PHP
LAGO_URL="https://api.getlago.com"
API_KEY="__YOUR_API_KEY__"
curl --location --request PUT "$LAGO_URL/api/v1/subscriptions/:id" \
--header "Authorization: Bearer $API_KEY" \
--header 'Content-Type: application/json' \
--data-raw '{
"subscription": {
"name": "subscription_name",
"subscription_at": "2022-08-08T00:00:00Z"
}
}'
from lago_python_client.client import Client
from lago_python_client.exceptions import LagoApiError
from lago_python_client.models import Subscription
client = Client(api_key='__YOUR_API_KEY__')
update_params = Subscription(name='new name', subscription_at='2022-08-08T00:00:00Z')
try:
client.subscriptions.update(update_params, 'id')
except LagoApiError as e:
repair_broken_state(e) # do something on error or raise your own exception
require 'lago-ruby-client'
client = Lago::Api::Client.new({api_key: '__YOUR_API_KEY__'})
update_params = { name: 'new name', subscription_at: '2022-08-08T00:00:00Z' }
client.subscriptions.update(update_params, 'id')
await client.subscriptions.updateSubscription("external_id", {
subscription: { name: "new name", subscriptionAt: "2022-08-08T00:00:00Z" },
});
using System.Collections.Generic;
using System.Diagnostics;
using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client;
using Org.OpenAPITools.Model;
namespace Example
{
public class UpdateSubscriptionExample
{
public static void Main()
{
Configuration.Default.BasePath = "https://api.getlago.com/api/v1";
// Configure HTTP bearer authorization: bearerAuth
Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN";
var apiInstance = new SubscriptionsApi(Configuration.Default);
var externalId = "example_id"; // string | External ID of the existing subscription
var subscriptionUpdateInput = new SubscriptionUpdateInput(); // SubscriptionUpdateInput | Update an existing subscription
try
{
// Update an existing subscription
Subscription result = apiInstance.UpdateSubscription(externalId, subscriptionUpdateInput);
Debug.WriteLine(result);
}
catch (ApiException e)
{
Debug.Print("Exception when calling SubscriptionsApi.UpdateSubscription: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
}
}
}
}
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure Bearer authorization: bearerAuth
$config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
$apiInstance = new OpenAPI\Client\Api\SubscriptionsApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
$external_id = "example_id"; // string | External ID of the existing subscription
$subscription_update_input = new \OpenAPI\Client\Model\SubscriptionUpdateInput(); // \OpenAPI\Client\Model\SubscriptionUpdateInput | Update an existing subscription
try {
$result = $apiInstance->updateSubscription($external_id, $subscription_update_input);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling SubscriptionsApi->updateSubscription: ', $e->getMessage(), PHP_EOL;
}
Arguments
{
"subscription": {
"name": "subscription_name",
"subscription_at": "2022-08-08T00:00:00Z"
}
}
Attributes | Type | Description |
---|---|---|
name | String Optional | Display name of the subscription. |
subscription_at | String Optional ISO 8601 datetime in UTC | Start date and time of the subscription. Can only be modified for pending subscriptions that have not yet started. |
Deprecated arguments
Attributes | Type | Description |
---|---|---|
subscription_date | String Optional | Start date of the subscription. Can only be modified for pending subscriptions that have not yet started. |
Responses
- HTTP 200
- HTTP 400
- HTTP 401
- HTTP 404
The subscription was successfully updated
Returns a subscription object.
{
"status": 400,
"error": "Bad Request"
}
The subscription
json root is not present in the request body.
{
"status": 401,
"error": "Unauthorized"
}
Access to the API endpoint is unhautorized.
Possible reasons are:
- The
Authorization
header is missing - The
Authorization
header does not contain the API key - The Api key is invalid or expired
{
"status": 404,
"error": "Not Found",
"code": "subscription_not_found"
}
The subscription
was not found.