# Update plugin subscription

`PUT /api/plugins/{pluginId}/subscriptions/{id}`

Authentication: no security requirement declared for this operation.

Parameters:

- `id` (path, string, required) - Plugin subscription ID
  Type: string

Request body: application/json (required)

Type: object

Schema: [UpdatePluginSubscriptionDTO](https://sourcey-gauzy.pages.dev/api-reference/models/updatepluginsubscriptiondto/index.md)

- `status` (optional)
  Type: string
  
  Subscription status
  
  enum: ["active","cancelled","expired","trial","past_due","suspended","pending"]

- `startDate` (optional)
  Type: string
  
  Subscription start date

- `endDate` (optional)
  Type: string
  
  Subscription end date

- `trialEndDate` (optional)
  Type: string
  
  Trial end date

- `autoRenew` (optional)
  Type: boolean
  
  Auto-renewal enabled

- `metadata` (optional)
  Type: object
  
  Subscription metadata

Responses:

- 200: Plugin subscription updated successfully

Content type: application/json

Type: object

Schema: [PluginSubscription_1](https://sourcey-gauzy.pages.dev/api-reference/models/pluginsubscription-1/index.md)

- `deletedAt` (optional)
  Type: string, date-time
  
  Example:
  
  ```json
  "2018-11-21T06:20:32.232Z"
  ```

- `createdAt` (optional)
  Type: string, date-time
  
  The creation timestamp of the entity.
  
  Example:
  
  ```json
  "2018-11-21T06:20:32.232Z"
  ```

- `updatedAt` (optional)
  Type: string, date-time
  
  The last update timestamp of the entity.
  
  Example:
  
  ```json
  "2018-11-21T06:20:32.232Z"
  ```

- `id` (optional)
  Type: string

- `isActive` (optional)
  Type: boolean
  
  default: true

- `isArchived` (optional)
  Type: boolean
  
  default: false

- `archivedAt` (optional)
  Type: string, date-time
  
  Example:
  
  ```json
  "2018-11-21T06:20:32.232Z"
  ```

- `tenantId` (optional)
  Type: string

- `organizationId` (optional)
  Type: string

- `status` (required)
  Type: string
  
  Subscription status
  
  enum: ["active","cancelled","expired","trial","past_due","suspended","pending"]

- `scope` (required)
  Type: string
  
  Subscription scope
  
  enum: ["tenant","organization","user"]

- `startDate` (required)
  Type: string, date-time
  
  Start date of subscription

- `endDate` (optional)
  Type: string, date-time
  
  End date of subscription

- `trialEndDate` (optional)
  Type: string, date-time
  
  Trial end date

- `autoRenew` (required)
  Type: boolean
  
  Whether auto-renewal is enabled

- `cancelledAt` (optional)
  Type: string, date-time
  
  Cancellation date

- `cancellationReason` (optional)
  Type: string
  
  Cancellation reason

- `metadata` (optional)
  Type: object
  
  Subscription metadata for additional data

- `externalSubscriptionId` (optional)
  Type: string
  
  External subscription ID from payment provider

- `pluginId` (required)
  Type: string
  
  Plugin ID

- `pluginTenantId` (required)
  Type: string
  
  Plugin Tenant ID

- `planId` (optional)
  Type: string
  
  Subscription plan ID

- `subscriberId` (optional)
  Type: string
  
  Subscriber user ID for user-specific subscriptions

- `parentId` (optional)
  Type: string
  
  Parent subscription ID for hierarchical subscriptions

- `parent` (optional)
  Type: unknown
  
  Parent subscription (for subscriptions created through assignment)
  
  allOf:
    Reference: [PluginSubscription_1](https://sourcey-gauzy.pages.dev/api-reference/models/pluginsubscription-1/index.md); Type: PluginSubscription_1

- `children` (optional)
  Type: array
  
  Child subscriptions (user subscriptions created through assignment)
  
  Items:
    Reference: [PluginSubscription_1](https://sourcey-gauzy.pages.dev/api-reference/models/pluginsubscription-1/index.md); Type: PluginSubscription_1

- `billings` (optional)
  Type: array
  
  Plugin billings for this subscription
  
  Items:
    Type: string

## Examples

### cURL

```bash
curl -X PUT 'http://localhost:3000/api/plugins/%7BpluginId%7D/subscriptions/string' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "status": "active",
  "startDate": "string",
  "endDate": "string",
  "trialEndDate": "string",
  "autoRenew": true,
  "metadata": {}
}'
```

### JavaScript

```javascript
const body = `{
  "status": "active",
  "startDate": "string",
  "endDate": "string",
  "trialEndDate": "string",
  "autoRenew": true,
  "metadata": {}
}`;

const response = await fetch('http://localhost:3000/api/plugins/%7BpluginId%7D/subscriptions/string', {
  method: 'PUT',
  headers: {
    'Content-Type': 'application/json',
  },
  body,
});

const data = await response.text();
```

### Python

```python
import requests

body = '''{
  "status": "active",
  "startDate": "string",
  "endDate": "string",
  "trialEndDate": "string",
  "autoRenew": true,
  "metadata": {}
}'''

response = requests.put(
    'http://localhost:3000/api/plugins/%7BpluginId%7D/subscriptions/string',
    data=body.encode('utf-8'),
    headers={
        'Content-Type': 'application/json',
    },
)
print(response.text)
```
