Skip to main content
POST
https://api-dev.weir.ai/
/
org
/
subscribe
curl -X POST 'https://api.weir.ai/org/subscribe' \
  -H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
  -H 'Content-Type: application/json' \
  -H 'x-source: console' \
  -d '{
    "cardId": "card_123456789",
    "amount": 99.99,
    "subscriptionId": "sub_plan_123"
  }'
{
  "data": {
    "subscriptionId": "sub_123456789",
    "planId": "sub_plan_123",
    "status": "active",
    "startDate": "2024-01-22T00:00:00Z",
    "nextBillingDate": "2024-02-22T00:00:00Z",
    "amount": 99.99,
    "currency": "USD"
  },
  "message": "Subscription created successfully",
  "status": "success"
}

Subscribe to Plan

Subscribe your organization to a subscription plan using a payment method.
curl -X POST 'https://api.weir.ai/org/subscribe' \
  -H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
  -H 'Content-Type: application/json' \
  -H 'x-source: console' \
  -d '{
    "cardId": "card_123456789",
    "amount": 99.99,
    "subscriptionId": "sub_plan_123"
  }'
{
  "data": {
    "subscriptionId": "sub_123456789",
    "planId": "sub_plan_123",
    "status": "active",
    "startDate": "2024-01-22T00:00:00Z",
    "nextBillingDate": "2024-02-22T00:00:00Z",
    "amount": 99.99,
    "currency": "USD"
  },
  "message": "Subscription created successfully",
  "status": "success"
}

Request Body

cardId
string
required
Payment card ID to use for the subscription.
amount
number
required
Subscription amount.
subscriptionId
string
required
Subscription plan ID to subscribe to.

Usage Examples

const subscribe = async (subscriptionData, accessToken) => {
  const response = await fetch('https://api.weir.ai/org/subscribe', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${accessToken}`,
      'Content-Type': 'application/json',
      'x-source': 'console'
    },
    body: JSON.stringify(subscriptionData)
  });
  if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
  return await response.json();
};