Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

This document describes how to configure, connect to, and interact with the Reseller API. The Reseller API is available to all resellers, and offers the ability to provision and manage Blesta licenses.

Info
titleInterested in becoming a reseller?

For more information on becoming a reseller visit http://www.blesta.com/resellers/.

Table of Contents
Table of Contents
outlinetrue
classtoc

Overview

The Reseller API is a RESTful service. All data is returned in JSON format. The API is located at:

No Format
https://account.blesta.com/plugin/blesta_reseller/v2/index/

Authentication

The API supports Basic Access Authentication. All requests must be made over HTTPS.

Code Block
languagebash
titleExample Request
curl https://account.blesta.com/plugin/blesta_reseller/v2/index/getCredit.json -u USERNAME:PASSWORD

Errors

There are several types of errors that may be encountered when working with the API:

  1. Sending invalid parameters will result in a 400 Bad Request response.

    No Format
    HTTP/1.1 400 Bad Request
    Content-Length: 137
    
    {
     "message":"The request cannot be fulfilled due to bad syntax.",
     "errors":
     {
      "field":
      {
       "code":"Error message."
      }
     }
    }
  2. Providing invalid credentials will result in a 401 Unauthorized response.

    No Format
    HTTP/1.1 401 Unauthorized
    Content-Length: 67
    
    {"message":"The authorization details given appear to be invalid."}
  3. Attempting to access a resource that is not callable will result in a 403 Forbidden response.

    No Format
    HTTP/1.1 403 Forbidden
    Content-Length: 55
    
    {"message":"The requested resource is not accessible."}
  4. Attempting to access a resource that does not exist will result in a 404 Not Found response.

    No Format
    HTTP/1.1 404 Not Found
    Content-Length: 52
    
    {"message":"The requested resource does not exist."}
  5. Requesting a format that is not supported will result in a 415 Unsupported Media Type response.

    No Format
    HTTP/1.1 415 Unsupported Media Type
    Content-Length: 66
    
    {"message":"The format requested is not supported by the server."}
  6. If an unexpected error occurs a 500 Internal Server Error will result. If this error is encountered consult the documentation for the method you are requesting.

    No Format
    HTTP/1.1 500 Internal Server Error
    Content-Length: 42
    
    {"message":"An unexpected error occured."}
  7. When Blesta is under maintenance mode, the API will return a 503 Service Unavailable response.

    No Format
    HTTP/1.1 503 Service Unavailable 
    Content-Length: 81 
    
    {"message":"The requested resource is currently unavailable due to maintenance."}

All error response objects contain an array of input parameters that produced errors. From the example above "field" is the parameter name. Each field may contain one or more error codes along with a related message. Common codes are empty, exists, format, length, and valid, but many more are available. The error code is always the index of the error message, and is used primarily in identifying the type of error encountered.

Timestamps

The Reseller API returns all timestamps in UTC time using the following ISO 8601 format:

No Format
YYYY-MM-DD hh:mm:ss / 2021-12-31 12:00:00

Methods

Get Credit

Fetch the amount of credit available under your account.

No Format
GET https://account.blesta.com/plugin/blesta_reseller/v2/index/getcredit.json
Code Block
languagebash
titleExample Request
curl https://account.blesta.com/plugin/blesta_reseller/v2/index/getcredit.json -u USERNAME:PASSWORD
No Format
{
 "response": 50.25
}

 

Get Packages

Fetches all available reseller packages.

No Format
GET https://account.blesta.com/plugin/blesta_reseller/v2/index/getpackages.json
Code Block
languagebash
titleExample Request
curl https://account.blesta.com/plugin/blesta_reseller/v2/index/getpackages.json -u USERNAME:PASSWORD
No Format
{
 "response":[
   {
    "id":"25",
    "name":"Blesta Monthly License",
    "description":"",
    "description_html":"",
    "qty":null,
    "id_code":"25",
    "pricing":[
     {
      "id":"49",
      "term":"1",
      "period":"month",
      "price":"13.0000",
      "setup_fee":"0.0000",
      "cancel_fee":"0.0000",
      "currency":"USD"
     }
    ]
   },
   {
    "id":"26",
    "name":"Blesta Owned License",
    "description":"",
    "description_html":"",
    "qty":null,
    "id_code":"26",
    "pricing":[
     {
      "id":"32",
      "term":"0",
      "period":"onetime",
      "price":"95.0000",
      "setup_fee":"0.0000",
      "cancel_fee":"0.0000",
      "currency":"USD"
     }
    ]
   }
 ]
}

 

Get Package Pricing

Fetches pricing for a specific package.

No Format
GET https://account.blesta.com/plugin/blesta_reseller/v2/index/getpackagepricing.json
Code Block
languagebash
titleExample Request
curl https://account.blesta.com/plugin/blesta_reseller/v2/index/getpackagepricing.json?package_id=PACKAGE_ID -u USERNAME:PASSWORD
No Format
{
 "response":[
  {
   "id":"49",
   "term":"1",
   "period":"month",
   "price":"13.0000",
   "setup_fee":"0.0000",
   "cancel_fee":"0.0000",
   "currency":"USD"
  }
 ]
}

 

Add License

Adds a new license.

No Format
POST https://account.blesta.com/plugin/blesta_reseller/v2/index/addlicense.json
Code Block
languagebash
titleExample Request
curl https://account.blesta.com/plugin/blesta_reseller/v2/index/addlicense.json -u USERNAME:PASSWORD -d "vars[pricing_id]=PRICING_ID&vars[test_mode]=true"
No Format
{
 "response":"abcdef0123456789"
}

Cancel License

Cancels a license.

No Format
POST https://account.blesta.com/plugin/blesta_reseller/v2/index/cancellicense.json
Code Block
languagebash
titleExample Request
curl https://account.blesta.com/plugin/blesta_reseller/v2/index/cancellicense.json -u USERNAME:PASSWORD -d "vars[license]=LICENSE_KEY&vars[test_mode]=true"

 

Suspend License

Suspends a license.

No Format
POST https://account.blesta.com/plugin/blesta_reseller/v2/index/suspendlicense.json
Code Block
languagebash
titleExample Request
curl https://account.blesta.com/plugin/blesta_reseller/v2/index/suspendlicense.json -u USERNAME:PASSWORD -d "vars[license]=LICENSE_KEY&vars[test_mode]=true"

 

Unsuspend License

Unsuspends a license.

No Format
POST https://account.blesta.com/plugin/blesta_reseller/v2/index/unsuspendlicense.json
Code Block
languagebash
titleExample Request
curl https://account.blesta.com/plugin/blesta_reseller/v2/index/unsuspendlicense.json -u USERNAME:PASSWORD -d "vars[license]=LICENSE_KEY&vars[test_mode]=true"

 

Update License

Updates a license to set it into a reissue state.

No Format
POST https://account.blesta.com/plugin/blesta_reseller/v2/index/update.json
Code Block
languagebash
titleExample Request
curl https://account.blesta.com/plugin/blesta_reseller/v2/index/update.json -u USERNAME:PASSWORD -d "vars[license]=LICENSE_KEY&vars[reissue_status]=reissue&vars[test_mode]=true"

 

Returns all licenses that match the search criteria, which includes license key, domain, IP, and install path. Only non-canceled licenses are returned. Up to 25 results are returned for each response. To fetch additional results, increment the vars[page] parameter.

No Format
GET https://account.blesta.com/plugin/blesta_reseller/v2/index/search.json
Code Block
languagebash
titleExample Request
curl --globoff "https://account.blesta.com/plugin/blesta_reseller/v2/index/search.json?vars[search]=SEARCH_STRING&vars[page]=1" -u USERNAME:PASSWORD
No Format
{
 "response":[{
  "status":"suspended",
  "date_added":"2012-11-03 17:57:03",
  "date_renews":null,
  "date_suspended":"2013-08-17 17:00:03",
  "date_canceled":null,
  "pricing_id":"32",
  "term":"0",
  "period":"onetime",
  "fields":{
   "license_module_callhome":"",
   "license_module_domains":[
    "domain1.com",
    "domain2.com"
   ],
   "license_module_ips":[
    "192.168.0.1",
    "192.168.0.2"
   ],
   "license_module_key":"abcdef0123456789",
   "license_module_paths":[
    "\/var\/www\/public_html\/"
   ],
   "license_module_status":"",
   "license_module_version":""
  }
 }]
}