Subscriptions
Subscriptions
Use the Subscriptions API to manage video monetization with plans and members for pay-per-view or subscription-based access.
Base URL
example
https://api.dyntube.com/v1Available Endpoints
Plans
| Method | Endpoint | Description |
|---|---|---|
| POST | /plans | Create a new plan |
| GET | /plans | Get list of plans |
| DELETE | /plans?id={planId} | Delete an unused plan |
Members
| Method | Endpoint | Description |
|---|---|---|
| POST | /members | Create a new member |
| GET | /members | Get list of members |
| GET | /members/{id} | Get one member |
| GET | /members/{id}/activity | Get member activity |
| GET | /member-plans | List member-plan assignments |
| POST | /member-plans | Attach a plan to a member |
Member plan lifecycle
Use /member-plans/{id} to inspect an assignment, then use its pause, resume, cancel-now, or cancel-at-period-end action when access needs to change.
Plan Types
| Type | Value | Description |
|---|---|---|
| Purchase | 1 | One-time purchase access |
| Rental | 3 | Time-limited rental access |
Quick Example
javascript
// Create a subscription plan
const response = await fetch('https://api.dyntube.com/v1/plans', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'Premium Access',
description: 'Access to all premium videos',
type: 3, // Rental
frequency: {
interval: 1,
count: 30 // 30 days
},
videoKeys: ['vid_abc123'],
status: 1
})
});
const plan = await response.json();
console.log('Plan created:', plan.id);Recommended workflow
- Create a plan that identifies the videos or channels included in the offer.
- Create a member for the viewer who should receive protected access.
- Attach the plan to the member and retain the returned member-plan ID.
- Read the member plan when checking its current access and lifecycle state.
Something missing or wrong here? Tell us and we will correct it. New to DynTube? Start with uploading and embedding.