Subscription Management API Documentation
APIs to upgrade, downgrade, cancel & Subscribe to various APIs on API.market.
The Subscription Management API allows users to manage their API subscriptions programmatically using API keys. This API supports creating new subscriptions, upgrading/downgrading existing plans, and canceling subscriptions.
Authentication
All API endpoints require authentication using one of the following headers:
x-api-market-key: YOUR_API_KEY_HERE
Base URL
Base URL:
https://api.market/api/v1Clean, RESTful design
Consistent response format
API Endpoints
1. Get Product Details with Pricing Plans
Retrieves product information along with all available pricing plans.
Endpoint: GET /api/v1/product/{workspaceSlug}/{productSlug}
Request:
curl -X GET \
'https://api.market/api/v1/product/magicapi/upscaler' \
-H 'accept: application/json' \
-H 'x-api-market-key: YOUR_API_KEY_HERE'Response:
2. Get Current Subscription Details
Retrieves the current subscription status for a specific product.
Endpoint: GET /api/v1/subscription/{workspaceSlug}/{productSlug}
Request:
Response (Active Subscription):
Response (No Subscription):
3. Create/Upgrade/Downgrade Subscription
Creates a new subscription or changes an existing subscription to a different pricing plan.
Endpoint: POST /api/v1/subscription/{workspaceSlug}/{productSlug}/{pricingPlanId}
Request:
Request Body Parameters:
additionalData(optional): Additional information for the subscriptionisDryRun(optional): Set totrueto simulate the operation without making changes
Response (New Subscription):
Response (Upgrade/Downgrade):
Action Types:
subscribed: First-time subscriptionresubscribed: Re-subscribing to the same planupgraded: Moving to a higher-priced plandowngraded: Moving to a lower-priced planunchanged: Same price, different planchanged: Plan changed but price comparison failed
4. Cancel Subscription
Cancels the current subscription for a product.
Endpoint: DELETE /api/v1/subscription/{workspaceSlug}/{productSlug}
Request:
Request Body Parameters:
cancelImmediately(optional): Set totrueto cancel immediately,falseto cancel at period endreason(optional): Reason for cancellation
Response:
Error Handling
HTTP Status Codes
200: Success
400: Bad Request (missing parameters, invalid data)
401: Unauthorized (invalid or missing API key)
403: Forbidden (insufficient permissions)
404: Not Found (product, pricing plan, or subscription not found)
405: Method Not Allowed
409: Conflict (subscription already exists, invalid state transition)
500: Internal Server Error
Error Response Format
Rate Limiting
API calls are subject to rate limiting based on your subscription plan
Rate limits are enforced per API key
Exceeding limits will result in 429 (Too Many Requests) responses
Best Practices
1. Always Check Current Subscription
Before making changes, retrieve the current subscription to understand the current state.
2. Use Dry Run for Testing
Set isDryRun: true in the request body to simulate operations without making actual changes.
3. Handle Errors Gracefully
Implement proper error handling for all API responses, especially for network failures.
4. Monitor Subscription Changes
Track subscription changes in your application to provide users with real-time updates.
Example Integration
Support
For technical support or questions about the Subscription Management API:
Documentation: docs.api.market
API Status: status.api.market
Support Email: [email protected]
Last updated