Skip to content

Products

briansemify edited this page Oct 24, 2025 · 7 revisions

Products / Service Plan Attachment

Attach service plans (products) to accounts or campaigns.

All endpoints require Authorization with Bearer JWT token.

Available Product Plans

Product Name Product ID
SEO Grow 3012
SEO Leap 3022
SEO Soar 3032

Available Endpoints

Get Service Plans for Campaign and Account

  • Endpoint: GET /api/v1/products/plans/campaigns/{campaign_id}/accounts/{account_id}
  • Description: Returns service plans that are currently attached to a specific account-campaign combination
  • Purpose: Use this to see which service plans are already active on a campaign
  • Parameters:
    • campaign_id (integer): The top-level campaign ID (camp_stage_id = 5) for the account
    • account_id (integer): The account ID owned by the reseller

Create and Attach Service Plan

  • Endpoint: POST /api/v1/products/plans/campaigns
  • Description: Attaches a product plan to an account
  • Required Fields:
    • account_id (integer): Account ID to attach the service plan to
    • campaign_id (integer): Campaign ID to attach the service plan to
    • service_plan_id (integer): Service plan ID (e.g., 3012, 3022, 3032)

Example Requests

Get Attached Service Plans

curl -H "Authorization: Bearer $TOKEN" \
     -H "Content-Type: application/json" \
     "https://uat.services.semify.com/api/v1/products/plans/campaigns/26939/accounts/1"

Attach Service Plan to Campaign

curl -X POST \
     -H "Authorization: Bearer $TOKEN" \
     -H "Content-Type: application/json" \
     -d '{
       "account_id": 12345,
       "campaign_id": 54321,
       "service_plan_id": 3012
     }' \
     "https://uat.services.semify.com/api/v1/products/plans/campaigns"

Sample Responses

Get Attached Service Plans Response

{
  "data": [
    {
      "service_plan_id": 3012,
      "plan_name": "SEO Grow",
      "description": "Basic SEO service plan",
      "price": 299.00,
      "billing_interval": "monthly",
      "attached_date": "2024-01-15T10:30:00Z",
      "status": "active"
    },
    {
      "service_plan_id": 3022,
      "plan_name": "SEO Leap", 
      "description": "Advanced SEO service plan",
      "price": 499.00,
      "billing_interval": "monthly",
      "attached_date": "2024-01-20T14:20:00Z",
      "status": "active"
    }
  ],
  "messages": ["Service plan retrieval success"],
  "error": false,
  "pagination": {
    "totalPages": 1,
    "maxRows": 0,
    "offset": 0,
    "page": 1,
    "totalRecords": 2
  }
}

Attach Service Plan Response

{
  "data": {
    "account_id": 12345,
    "campaign_id": 54321,
    "service_plan_id": 3012
  },
  "error": false,
  "pagination": {
    "totalPages": 1,
    "maxRows": 0,
    "offset": 0,
    "page": 1,
    "totalRecords": 1
  },
  "messages": [
    "Successful plan attachment"
  ]
}

Typical Workflow

  1. Check currently attached service plans: GET /api/v1/products/plans/campaigns/{campaign_id}/accounts/{account_id}
  2. Attach new service plan to campaign: POST /api/v1/products/plans/campaigns
  3. Verify service plan is active: Use GET endpoint again to confirm attachment

Important Notes

  • Attached Service Plans: The GET endpoint returns service plans that are currently attached to the account-campaign combination
  • Top-Level Campaign: Use the campaign ID with camp_stage_id = 5 (the top-level campaign for the account)
  • Reseller Ownership: The reseller owns the account_id and the top-level campaign_id
  • Service Plan Validation: Validate product availability for your reseller account before attachment
  • Campaign Association: Service plans are attached to specific campaigns within accounts
  • Error Handling: Check response messages for attachment success or failure

Recommendations

  • Check Existing Plans: Use the GET endpoint to see what service plans are already attached before adding new ones
  • Use Top-Level Campaign: Always use the campaign ID with camp_stage_id = 5 for service plan operations
  • Validate Before Attaching: Ensure the service plan is available for your reseller account before attachment
  • Record Billing Identifiers: Store billing identifiers in attributes or external_* fields for reconciliation
  • Implement Error Handling: Handle API errors gracefully and retry failed requests
  • Monitor Attachments: Use the GET endpoint to verify service plan attachments are successful
  • Store Service Plan IDs: Keep track of attached service plan IDs for future reference and management

Clone this wiki locally