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.

Interested in becoming a reseller?

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

Table of Contents

Overview

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

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

Authentication

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

Example 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.

    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.

    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.

    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.

    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.

    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.

    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.

    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:

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

Methods

Get Credit

Fetch the amount of credit available under your account.

GET https://account.blesta.com/plugin/blesta_reseller/v2/index/getcredit.json
Example Request
curl https://account.blesta.com/plugin/blesta_reseller/v2/index/getcredit.json -u USERNAME:PASSWORD
{
 "response": 50.25
}


Get Packages

Fetches all available reseller packages.

GET https://account.blesta.com/plugin/blesta_reseller/v2/index/getpackages.json
Example Request
curl https://account.blesta.com/plugin/blesta_reseller/v2/index/getpackages.json -u USERNAME:PASSWORD
{
 "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.

The following parameters must be provided:

  • package_id


GET https://account.blesta.com/plugin/blesta_reseller/v2/index/getpackagepricing.json
Example Request
curl https://account.blesta.com/plugin/blesta_reseller/v2/index/getpackagepricing.json?package_id=PACKAGE_ID -u USERNAME:PASSWORD
{
 "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.

The following parameters must be provided:

  • vars[pricing_id]

VAR?

If you are a VAR or Tiered VAR reseller, your pricing ID is 364 unless otherwise noted.

The following parameters are optional:

  • vars[test_mode] - "true" or "false"


POST https://account.blesta.com/plugin/blesta_reseller/v2/index/addlicense.json
Example 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"
{
 "response":"abcdef0123456789"
}

Cancel License

Cancels a license.

The following parameters must be provided:

  • vars[license]

The following parameters are optional:

  • vars[test_mode] - "true" or "false"


POST https://account.blesta.com/plugin/blesta_reseller/v2/index/cancellicense.json
Example 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.

The following parameters must be provided:

  • vars[license]

The following parameters are optional:

  • vars[test_mode] - "true" or "false"


POST https://account.blesta.com/plugin/blesta_reseller/v2/index/suspendlicense.json
Example 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.

The following parameters must be provided:

  • vars[license]

The following parameters are optional:

  • vars[test_mode] - "true" or "false"


POST https://account.blesta.com/plugin/blesta_reseller/v2/index/unsuspendlicense.json
Example 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.

The following parameters must be provided:

  • vars[license]
  • vars[reissue_status]

The following parameters are optional:

  • vars[test_mode] - "true" or "false"


POST https://account.blesta.com/plugin/blesta_reseller/v2/index/update.json
Example 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.

The following parameters must be provided:

  • vars[search]

The following parameters are optional:

  • vars[page]


GET https://account.blesta.com/plugin/blesta_reseller/v2/index/search.json
Example Request
curl --globoff "https://account.blesta.com/plugin/blesta_reseller/v2/index/search.json?vars[search]=SEARCH_STRING&vars[page]=1" -u USERNAME:PASSWORD
{
 "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":""
  }
 }]
}

Search Count

Returns the total number of licenses that match the search criteria. Only a count of non-canceled licenses are returned.

It is useful to fetch the search count before performing a search when multiple pages of results are expected. Since up to 25 results may be returned per page of search results, you may divide the total search count by 25 to determine the number of pages you can set vars[page] to when searching.

The following parameters must be provided:

  • vars[search]


GET https://account.blesta.com/plugin/blesta_reseller/v2/index/searchcount.json
Example Request
curl --globoff "https://account.blesta.com/plugin/blesta_reseller/v2/index/searchcount.json?vars[search]=SEARCH_STRING" -u USERNAME:PASSWORD
{
 "response":56
}
  • No labels