How do I use the reseller API?
Transcription
How do I use the reseller API?
Fasthosts Reseller API Developer Guide Fasthosts Reseller API Developer Guide Table of Contents Fasthosts Reseller API Developer Guide .................................................................................................................2 Table of Contents .....................................................................................................................................................2 Introduction .................................................................................................................................................................4 What is SOAP?.........................................................................................................................................................4 Managing customer orders ........................................................................................................................................5 Adding funds to your account ...................................................................................................................................6 Viewing pending customer orders ............................................................................................................................7 Approving a customer order .....................................................................................................................................9 Declining a customer order ......................................................................................................................................9 Your API connection details ....................................................................................................................................10 Finding your API connection details .......................................................................................................................11 Changing your API connection password ..............................................................................................................12 Connecting to the Reseller API ...............................................................................................................................14 Setting up your development environment .............................................................................................................14 Establishing a connection .......................................................................................................................................16 Function calls and Structures .................................................................................................................................18 Disconnecting your API connection ........................................................................................................................19 Understanding the API .............................................................................................................................................20 Accounts and packages .........................................................................................................................................20 Templates ...............................................................................................................................................................20 The cart ..................................................................................................................................................................21 Password complexity ..............................................................................................................................................22 Testing the API ..........................................................................................................................................................22 Walkthroughs and examples ...................................................................................................................................23 Creating a new customer account ..........................................................................................................................23 Registering a domain .............................................................................................................................................26 Installing a hosting package ...................................................................................................................................28 Adding, modifying, and upgrading a mailbox .........................................................................................................29 Installing MatrixStats ..............................................................................................................................................31 Installing SiteBuilder ...............................................................................................................................................32 Adding a database..................................................................................................................................................33 Processing an order ...............................................................................................................................................34 Page 2 of 126 Fasthosts Reseller API Developer Guide Security considerations ...........................................................................................................................................36 API function call reference ......................................................................................................................................36 API Connection.......................................................................................................................................................37 Order processing ....................................................................................................................................................39 Customer Accounts ................................................................................................................................................43 Templates ...............................................................................................................................................................46 Hosting packages ...................................................................................................................................................49 Databases ..............................................................................................................................................................51 Website ...................................................................................................................................................................55 MatrixStats ..............................................................................................................................................................56 TrafficDriver ............................................................................................................................................................58 SiteBuilder ..............................................................................................................................................................61 FTP accounts .........................................................................................................................................................64 Global FTP Accounts..............................................................................................................................................66 Mailbox management .............................................................................................................................................72 Domains and registration .......................................................................................................................................76 Subdomains ............................................................................................................................................................82 API Structures ...........................................................................................................................................................84 Lists and paging .....................................................................................................................................................116 Error handling .........................................................................................................................................................118 PHP ......................................................................................................................................................................118 ASP.NET ..............................................................................................................................................................118 Error codes ...........................................................................................................................................................119 Appendix: List of country codes ...........................................................................................................................121 Index .........................................................................................................................................................................124 Page 3 of 126 Fasthosts Reseller API Developer Guide Introduction The Fasthosts Reseller API provides an easy and powerful way to integrate the functionality of your Reseller control panel seamlessly into your own marketing website. Using your preferred development environment and the industry-standard SOAP XML interface, you can build unique services using our hosting infrastructure. With the Fasthosts Reseller API you can: Allow customers to set up their hosting directly from your website. Integrate a domain availability checker to your marketing website. Create your own control panels for your customers. Allow them manage their mailboxes, and add or remove services such as SiteBuilder, MatrixStats, TrafficDriver, and SQL databases. Integrate data from your Fasthosts account - such as customer information into your own applications. Automate repetitive tasks. Note: There are coding examples supplied throughout this document to help you understand the API. These examples are given in the PHP and ASP.NET (C#) languages. What is SOAP? The Simple Object Access Protocol (SOAP) is a widely used XML standard for exchanging structured data using HTTP. It enables you to call functionality from a remote service directly from your website or any other application. SOAP has been designed to be completely independent of any programming language, and all modern coding environments provide built-in or easily added support for this technology. Once you’ve established a connection with a remote service, using its functionality is as simple as calling a function in your own Page 4 of 126 Fasthosts Reseller API Developer Guide application. You can find an introduction to SOAP at O’Reilly’s XML.com: http://www.xml.com/pub/a/2000/02/09/feature/index.html Managing customer orders The Reseller API allows you to provision hosting and email services automatically for your customers. Any orders that a customer places through your API are subject to the same charges that would be incurred if they were added manually through your Fasthosts control panel. The API gives you two options for processing new customer orders: Process customer orders automatically. Services that are added using this option are automatically added to your account, and the payment is taken from the account balance. Process customer orders manually. If you add services with this option they will go into a pending orders queue. You will need to login to your Reseller control panel to accept or decline the order. Only when you accept the order will the service be added to your account. For example, you might want to process any customer orders under a certain amount automatically, such as domain registrations, but you might want orders of a higher value, such as Microsoft SQL databases, to appear in the pending orders list to await your approval before you are billed. If a service is ordered using the automatic processing option, the API will check to ensure you have adequate funds on the account to cover the cost of the transaction. If this is the case the service will be added and the charge will be taken from the account balance. If the balance on the account does not meet the transaction value the order will appear in the pending customer orders list, and you will need to approve it. Any orders that you approve from the pending customer orders list can be paid for by any of the credit or debit cards on your account, or by the funds on the account if Page 5 of 126 Fasthosts Reseller API Developer Guide available. It is not possible to pay for automatic transactions using any method other than the funds on the account. If you plan to use this method of ordering services through the API then you need to ensure you have sufficient funds on the account. You will be sent an email to notify you of any customer orders that go into the pending customer orders queue. This email will be sent to the account owner email address you have supplied. Adding funds to your account If you intend to process orders automatically through the API, you will need to ensure you have sufficient funds on the account to cover any costs. Step 1 Login to your Fasthosts Reseller account control panel. Step 2 Click on API at the top of the page. Step 3 Click on Manage Balance in the Pre-pay Balance box. Step 4 Your current balance will be shown on the next page. To add funds to the account, enter the amount you wish to add in the Amount text box, and click Continue. Page 6 of 126 Fasthosts Reseller API Developer Guide The funds will be added to your account and you will see a confirmation message. Viewing pending customer orders If you choose to process orders from the API manually, they will be placed in the pending customer orders queue in your control panel. You can then accept the order, to add the service to your account and bill you accordingly, or you can decline the order. Step 1 Login to your Fasthosts Reseller account control panel. Step 2 Click on API at the top of the page. Step 3 The Pending Orders box on the right will show if there are any outstanding orders awaiting activation or decline. In the example below there are three pending orders. Click the View Pending Orders button. Page 7 of 126 Fasthosts Reseller API Developer Guide Step 4 You will see a list of all pending customer orders. Each order will show the name of the product your customer has purchased, the date it was ordered, and the name of the customer. The Order Status column will show you whether the order is Pending Approval, has been approved, or has been declined. If either of the latter two options are the case, the date on which you processed the order is displayed. You can use the Date Range options above the list to view all pending, processed, and declined orders within the dates you specify. Quick tip: You can export the Pending Customer Orders list from the date range you have specified to a comma separated text file (CSV) or an Adobe Acrobat (PDF) file on your local machine. Just click the CSV or PDF buttons above the Customer Orders list. Page 8 of 126 Fasthosts Reseller API Developer Guide Approving a customer order If you are happy to add a customer order to your account, you need to approve it. Step 1 Login to your Fasthosts Reseller account control panel and browse to the Pending Customer Orders page. Step 2 To approve each customer order in turn: Locate the order you wish to approve in the list and click the Approve button. To approve multiple customer orders: Select the box by each order in the list you would like to approve. Click the Approve Selected Orders button at the bottom of the pending orders list. Step 3 Confirm any charges, and the new service will be added to your account. Declining a customer order If a customer applies for a service which you do not wish to add to your Reseller account, you should decline the order. Important: If you decline an order for an upgrade to TrafficDriver, SiteBuilder, or a mailbox the original product will be deleted. Step 1 Login to your Fasthosts Reseller account control panel and browse to the Pending Page 9 of 126 Fasthosts Reseller API Developer Guide Customer Orders page. Step 2 To decline each customer order in turn: Locate the order you wish to approve in the list and click the Decline button. To decline multiple customer orders: Select the box by each order in the list you would like to decline. Click the Decline Selected Orders button at the bottom of the pending orders list. The order status for the selected orders will be changed to declined, and the service will not be added to your account. If you change your mind you will need to add the declined product(s) manually through your Fasthosts control panel. Important: Fasthosts will not notify any of your customers that their orders have been declined. Your API connection details Before you can start provisioning hosting accounts, registering domains, or managing services on your account, you will need to connect to the API. In order to do this you will need your Reseller API connection username and password. Note: Your Reseller API connection username and password are randomly generated. These are not the same as your Fasthosts Reseller account login details. Page 10 of 126 Fasthosts Reseller API Developer Guide Finding your API connection details Your reseller API login username is available through your Fasthosts control panel. However, if you forget your API connection password you will need to generate new control panel details. Step 1 Log into your Fasthosts Reseller account control panel. Step 2 Click on API at the top of the page. Step 3 Click Create new login details in the API Login Details box. Step 4 Click Create New API Login Details. Note: You can keep your existing login details active for 24 hours to allow plenty of time to update your code. Your new API Login details are displayed on the page. Page 11 of 126 Fasthosts Reseller API Developer Guide Changing your API connection password You can generate a new password which you will use to logon to the Reseller API for your account. It is a good idea to do this regularly for added security. Page 12 of 126 Fasthosts Reseller API Developer Guide Note: When you change the Reseller API password your new password will become active immediately and your old password will remain active for 24 hours. This allows you more time to streamline your password changeover without affecting the services that use the API. Step 1 Log into your Fasthosts Reseller account control panel. Step 2 Click on API at the top of the page. Step 3 Click the Change Password link in the API Login Details box. Step 4 If you want to keep your existing password for 24 hours, ensure the Keep my old password active for 24 hours box is selected. Your new password will become active straight away, regardless of whether or not you keep the old password active during your password switchover. Click the Change Password button. Page 13 of 126 Fasthosts Reseller API Developer Guide Your new password will be generated and you will see a confirmation message on the screen. Connecting to the Reseller API The Reseller API uses SOAP, which means you can connect to it using the scripting language of your choice, or via a desktop application on your local machine. Setting up your development environment The Fasthosts shared web hosting servers are equipped with the components required to connect and use the SOAP protocol. If your site is hosted in your Reseller account, you can get started with the Reseller API straight away. However, if your corporate website is installed on your own dedicated server, or with a third party, you need to make sure it is equipped to support SOAP. PHP 5 PHP 5 supports all necessary SOAP functionality natively, and this is enabled on all Fasthosts shared servers. However, SOAP is not enabled in PHP by default, so if you are using your own server or development machine you will need to enable the php_soap.dll extension within the PHP.ini file. PHP 4 Fasthosts no longer supports PHP 4 on our shared hosting servers. If you are using PHP 4 on your own server or development machine you need to include the Pear SOAP library. You may need to install it on your development machine, if you have not already done so. It is available as a free download from: http://pear.php.net/package/SOAP Page 14 of 126 Fasthosts Reseller API Developer Guide This SOAP package also requires the following Pear libraries: http://pear.php.net/package/Net_URL http://pear.php.net/package/HTTP_Request Important: It is highly recommended that you consider upgrading to PHP 5, which is more stable and has several security improvements. ASP.NET ASP.NET supports SOAP natively, using its web references system. You can add the Reseller API as a web reference in Visual Studio.NET and Delphi 2005 in four steps: Step 1 Start a new ASP.NET project. Step 2 In the Solution Explorer (Visual Studio.NET) or the Project Manager (Delphi 2005) right-click the Web References node and select Add Web Reference. Step 3 Enter https://resellerapi.fasthosts.co.uk/?wsdl into the URL text field and click the Go button. The contents of the Web Services Description Language (WSDL) file should appear in the browser pane. Step 4 Enter a name for the web reference in the Web reference name text box and click Add Reference. The web reference will be added to your project. Once the web reference has been added, all of the API’s objects, properties and function calls will be available at design time. ASP The Microsoft SOAP Toolkit is pre-installed on Fasthosts’ shared Windows servers. However, you must install the toolkit on your development machine, if you have not already done so. Page 15 of 126 Fasthosts Reseller API Developer Guide It is available as a free download from: http://www.microsoft.com/downloads/details.aspx?FamilyId=C943C0DD-CEEC-40889753-86F052EC8450&displaylang=en Establishing a connection API sessions Before you can access the API’s functionality, you must log into the service using the username and password supplied in your Fasthosts control panel. You only need to log in once per session, as the login function returns a unique Session ID that can be used in subsequent calls. Each Session ID remains valid until you call the logout function or after five minutes of inactivity. You can make an unlimited number of calls in each session, provided it does not time-out. You only need to log out once you have finished using the API. Connecting to the API All SOAP connections have the following three stages. 1. Create a connector object and point to the WSDL file. 2. Perform the required API call. 3. Trap any resultant errors and handle them accordingly. The following examples show a simple SOAP call that follows each of the three stages to call the API’s Login function. The Login API call requests four string parameters: $ResellerUsername, $ResellerPassword, $CustomerUsername, and $CustomerPassword. Page 16 of 126 Fasthosts Reseller API Developer Guide $ResellerUsername and $ResellerPassword (required). These are the API login username and password given in your Fasthosts control panel. If these are incorrect an error will be generated which you will need to handle. $CustomerUsername and $CustomerPassword (optional). Supply these values to login as one of your customers, with their level of access. It is a good idea to supply these parameters if, for example, you are creating a customer control panel. PHP example 1 try 2 { 3 // log into API 4 $api = new SoapClient("https://resellerapi.fasthosts.co.uk/?wsdl"); 5 $session = $api->Login("myapiuser", "myapipassword", "", ""); 6 $header = new SoapHeader("FasthostsAPI", "Session", $session); 7 $api->__setSoapHeaders(array($header)); 8 } 9 10 catch (Exception $e) 11 { 12 13 // handle errors } The example above creates a new SOAP client on line 4, connecting to the Web Services Description Language (WSDL) file at https://resellerapi.fasthosts.co.uk/?wsdl. It then logs in on the next line, using the API username myapiuser and password myapipassword. This example does not pass the optional $CustomerUsername and $CustomerPassword parameters. On lines 6 and 7 the example gets the session returned from the Login command on the previous line, and stores it in the SOAP headers so any subsequent calls in the code will use this same session. The catch exception handler on line 13 determines the code to run if the connection fails. For detailed information on the API calls see the Reference chapter. Page 17 of 126 Fasthosts Reseller API Developer Guide ASP.NET (C#) example 1 using System; 2 using System.Web.Services.Protocols; 3 using Fasthosts.ExampleResellerSite.ResellerAPI; 4 5 namespace Fasthosts.ExampleResellerSite 6 { 7 public class APIExample 8 { 9 public void Examples() 10 { 11 // Log in to the API 12 // Create the User Session and assign it to the Soap header 13 ApiService api = new ApiService(); 14 api.SessionValue = api.Login( 15 "myapiuser", 16 "myapipassword", 17 "customeruser", 18 "customerpassword"); 19 } 20 21 } } A connection to the API is created on line 13, and the login occurs on lines 15-19. The returned session from the Login function call is assigned to the SOAP headers on line 15, so any subsequent calls in the code will use this same session. The ApiService() class on line 13 is named after the Web Reference you set up during the “Add Web Service” procedure outlined on page 15. For detailed information on the API calls see the Reference chapter. Function calls and Structures The API uses Function calls and Structures. You would call a Function to carry out a specific task, for example to Login to the API, to create a new account for a customer, or to add or manage services on that account, such as mailboxes or databases. Page 18 of 126 Fasthosts Reseller API Developer Guide Most of the functions require you to supply additional information, in order to process your requests. For example, the Login function, demonstrated in the previous chapter, requires you to pass your Reseller API username and password, and the optional customer account Username and Password parameters. These are just string parameters, so you only pass text to the function. However, some function calls require you to pass a structure, containing all the required data. One example is the Account structure. This structure is required when you are calling the CreateAccount function call. string CreateAccount(Account $Account) The text above shows that the CreateAccount function requires you to pass the $Account variable, and that this variable is of the type Account. The Account structure is defined as follows: struct Account { string $ParentAccountNumber; string $AccountNumber; string $FullName; datetime $OpenedDate; Contact $Contact; string $VATNumber; string $Username; string $Password; } Before you can call the CreateAccount function you need to create the Account structure and pass all the values to it. Disconnecting your API connection When you have finished your API session you should make sure you disconnect the Page 19 of 126 Fasthosts Reseller API Developer Guide session. You do this using the Logout API function call, which doesn’t require any parameters to be passed to it. PHP example 1 // log out of API 2 $api->Logout(); This example assumes the $api variable contains the API SOAP client object. This is the case if you followed the earlier example to establish the API connection. ASP.NET (C#) example 1 // log out of API 2 api.Logout(); This example assumes the api variable contains the API SOAP client object. This is the case if you followed the earlier example to establish the API connection. Understanding the API Accounts and packages You can manage your customers and their hosting services and products through the API using account and package functions. Each of your customers is known as an account by the API. One customer has one account. Each website that has hosting, email, or forwarding services associated with it is a package, and each package is linked to a customer account. Each package can only contain one website, but one customer can be associated with many packages. Templates Page 20 of 126 Fasthosts Reseller API Developer Guide A template is a definition of a hosting package and the services available with it. As a reseller, you can create templates in your control panel and assign the services you want to allow to accounts that are based on that template. For example, you can create a template for a Linux package, and give it 1 free mailbox and the SiteBuilder product. Any packages that are created based on this template would then have those services available. When you create hosting packages through the API you can choose the template you want to base the hosting package on. There are some standard Fasthosts’ created templates at your disposal as well as any templates you have custom built. The cart When you install a new product, or upgrade an existing one, the API will check to make sure your reseller account or your customer’s account has adequate stock available to install that service. The available stock will depend on the products that were added to the template on which the package is based. If the package includes the product currently being installed or upgraded, then this will be added to the account immediately. However, if the product is not included it will be added to the cart. You can choose to automatically process products that are sent to the cart, or you can manually approve or decline them from your Reseller control panel. Adding a product to your account through the API takes the following course. Step 1 Create the cart, which is associated with a customer account within your Reseller account. The CreateCart function (see page 39 for details) is used to create the cart. Step 2 Add services to the cart. For example, when registering or renewing a domain, adding SiteBuilder to a website, or upgrading a TrafficDriver plan, these would all be added to the cart first. If your customer has the available stock the product will not be added to the cart, instead it will be provisioned immediately from their account. Page 21 of 126 Fasthosts Reseller API Developer Guide Step 3 When all the products for this customer are added, the contents must be converted to an order by checking the cart out. The CheckoutCart function (see page 40 for details) is used to do this. Step 4 The order can then be processed automatically, or sent to the pending orders queue for manual processing. The ProcessOrder or PendOrder functions (page 41 for details) are used for order processing. Quick tip: For testing purposes the API also provides the CreateTestCart function, which can be used to replace CreateCart. See the chapter Testing the API for details. The examples in the Walkthroughs and examples chapter demonstrate the use of the cart object, and detail the automatic and manual processing methods. Password complexity For added security, all passwords for Fasthosts services must conform to the following complexity requirements: Each password must be at least 5 characters long. Each password must include a combination of upper and lower case characters. Each password must contain a number. Each password must contain a symbol. If you attempt to add or update a product or service which requires a password, and the password does not meet the criteria above, an error will be returned. Testing the API Page 22 of 126 Fasthosts Reseller API Developer Guide For your convenience the API has a test mode, so you can add and process products through the API without actually adding those products to your account. This also avoids any costs that may be incurred if the services/products were added for real. To use the test mode, simply substitute your CreateCart function call with CreateTestCart when setting up your Cart object. The Cart object that is created by the CreateTestCart function is identical in every way to the Cart object created with CreateCart, except that any payments that are processed from the test cart will not be billed, and any products and services will appear in your Pending Orders queue in your Reseller control panel. These items are clearly marked as test products. For details on the CreateTestCart function see page 40. Walkthroughs and examples This chapter contains a few examples of how to put the API into practice on your own website or customer control panels. Note: The examples in this chapter assume you logged in by following the example in the chapter Connecting to the API on page 16. Creating a new customer account To create a new account for a customer within your own Reseller account, you use the CreateAccount API function call. string CreateAccount(Account $Account) This requires you to pass an Account structure containing all the details of the account you want to create. If the function is successful it will return the newly Page 23 of 126 Fasthosts Reseller API Developer Guide created account number. The word string before the function name states that this function will return a string value, which will contain the account number of the newly created account. Before we call the CreateAccount function, we need to assign all the details of the new account we are creating to an Account structure. The example below gets all the values from a form. Important: This example shows no validation of the information entered, which means this form is open to various security vulnerabilities. Always make sure you validate any information from third party sources before you use it. PHP example 1 // Populate customer object from the form 2 $customer = new StdClass(); // creates an object using PHP's base class 3 $customer->ParentAccountNumber = $session->AccountNumber; 4 $customer->Contact->FirstName = $_POST["FirstName"]; 5 $customer->Contact->LastName = $_POST["LastName"]; 6 $customer->Contact->Company = $_POST["Company"]; 7 $customer->Contact->Address1 = $_POST["Address1"]; 8 $customer->Contact->Address2 = $_POST["Address2"]; 9 $customer->Contact->City = $_POST["City"]; 10 $customer->Contact->Region = $_POST["Region"]; 11 $customer->Contact->Country = new StdClass(); 12 $customer->Contact->Country->Code = $_POST["CountryCode"]; 13 $customer->Contact->AreaCode = $_POST["AreaCode"]; 14 $customer->Contact->PhoneNumber = $_POST["PhoneNumber"]; 15 $customer->Contact->MobileNumber = $_POST["MobileNumber"]; 16 $customer->Contact->Email = $_POST["Email"]; 17 $customer->Contact->UKRegistrantType = $_POST["UKRegistrantType"]; 18 $customer->Username = $_POST["Email"]; 19 $customer->Password = $_POST["Password"]; ASP.NET (C#) example 1 // Create a new User Account object 2 Account newUserAccount = new Account(); 3 4 // Populate customer object from the form Page 24 of 126 Fasthosts Reseller API Developer Guide 5 newUserAccount.Contact = new Contact(); 6 newUserAccount.Contact.FirstName = txtFirstName.Text; 7 newUserAccount.Contact.LastName = txtLastName.Text; 8 newUserAccount.Contact.Company = txtCompany.Text; 9 10 newUserAccount.Contact.Address1 = txtAddress1.Text; 11 newUserAccount.Contact.Address2 = txtAddress2.Text; 12 newUserAccount.Contact.City = txtCity.Text; 13 newUserAccount.Contact.Region = txtRegion.Text; 14 newUserAccount.Contact.AreaCode = txtAreaCode.Text; 15 16 newUserAccount.Contact.Country = new Country(); 17 newUserAccount.Contact.Country.Code = ddlCountryCode.SelectedValue; 18 19 newUserAccount.Contact.PhoneNumber = ddlTelephonePrefix.Text + "-" + txtPhoneNumberArea.Text + "-" + txtPhoneNumber.Text; 20 newUserAccount.Contact.UKRegistrantType = ddlUKRegistrantType.SelectedValue; 21 22 newUserAccount.Contact.Email = txtEmail.Text; 23 24 newUserAccount.Username = txtEmail.Text; 25 newUserAccount.Password = txtPassword.Text; Now that we have created our Customer object, which contains the customer’s contact details, we just need to create the account and handle any errors that are encountered. PHP example 1 try 2 { 3 // Create the account for this customer. 4 $AccountNumber = $api->CreateAccount($customer); 5 } 6 catch (SoapFault $e) 7 { 8 // Display error if encountered 9 $error = $e->detail->APIError; 10 11 echo $error->Code . " : " . $error->Message; } ASP.NET (C#) example 1 try Page 25 of 126 Fasthosts Reseller API Developer Guide 2 { 3 // Create the account for this customer 4 string accountNumber = api.CreateAccount(newUserAccount); 5 } 6 catch (SoapException soapEx) 7 { 8 // Display error if encountered 9 throw new Exception(soapEx.Detail.InnerXml); 10 } This example creates the new account and sets the $AccountNumber variable with the new account’s number. Registering a domain It is easy to check whether or not a domain is available for registration, using the GetDomainStatus function call, and then register it using RegisterDomain. In the examples below we will check the status of, and attempt to register, mydomain.com. PHP example 1 $status = $api->GetDomainStatus("mydomain.com"); 2 if (!$status->CanRegister) 3 { 4 echo "Domain is not available"; 5 } 6 else 7 { 8 // create cart for purchasing domain registration 9 // ($session->AccountNumber is the account number of 10 // the customer because we logged in as the customer) 11 $cart = $api->CreateCart($session->AccountNumber); 12 13 // register mydomain.com for 2 years 14 $api->RegisterDomain($session->AccountNumber, "mydomain.com", 2, $cart); 15 16 // At this point, a domain registration for mydomain.com has 17 // been created (but not committed). A domain registration may 18 // or may not be added to the cart. It will only be added to 19 // the cart if no available domain registration "stock" was 20 // available in your customer's or reseller account. 21 // Whether or not a domain registration was added to the cart, 22 // or if the customer or reseller already had an available Page 26 of 126 Fasthosts Reseller API Developer Guide 23 // domain registration "stock item", the cart still needs to 24 // be checked out for the domain to be registered. 25 26 // checkout cart and create order 27 $order = $api->CheckoutCart($cart); 28 29 // Leave order pending in the queue for manual approval through 30 // your control panel. You will receive an email notifying you 31 // of the pending order. You will not be charged until you 32 // approve the order. 33 34 $api->PendOrder($order); } ASP.NET (C#) example 1 // Check if mydomain.com is available 2 DomainStatus status = api.GetDomainStatus("mydomain.com"); 3 if (!status.CanRegister) 4 { 5 // Report error to user 6 throw new Exception("Domain is not available"); 7 } 8 else 9 { 10 // create cart for purchasing domain registration 11 // (api.SessionValue.AccountNumber is the account number of 12 // 13 Cart cart = api.CreateCart(api.SessionValue.AccountNumber); the customer because we logged in as the customer) 14 15 // register mydomain.com for 2 years 16 api.RegisterDomain(api.SessionValue.AccountNumber, "mydomain.com", 2, cart); 17 18 // At this point, a domain registration for mydomain.com has 19 // been created (but not committed). A domain registration may 20 // or may not be added to the cart. It will only be added to 21 // the cart if no available domain registration "stock" was 22 // available in your customer's or reseller account. 23 // Whether or not a domain registration was added to the cart, 24 // or if the customer or reseller already had an available 25 // domain registration "stock item", the cart still needs to 26 // be checked out for the domain to be registered. 27 28 // checkout cart and create order 29 Order order = api.CheckoutCart(cart); 30 31 // Leave order pending in the queue for manual approval through 32 // your control panel. You will receive an email notifying you Page 27 of 126 Fasthosts Reseller API Developer Guide 33 // of the pending order. You will not be charged until you 34 // approve the order. 35 36 api.PendOrder(order); } Installing a hosting package You can use the InstallPackage function to create a new package based on a template you’ve already created in your reseller control panel. You’ll need to create a cart object first, which you can then add the package to. When ready, you then need to convert the cart to an order, using the CheckOutCart function. The example below installs a package based on a template. A template is a definition of a hosting package and the services available with it. As a reseller, you can create templates in your control panel, and give each one a unique code. For example, you can create a template for a Linux package, and give it 1 free mailbox and the SiteBuilder product. You could name it “Linux Star Hosting” and give it a unique code of “LINUX_STAR”. You can now resell this and install this package on new customers’ accounts. The examples below use the templates “WINDOWS_PRO” and “MAIL_PLUS_DIRECT”; these are example templates and may not be available in your account. To discover templates available to you see the GetTemplateList() API call. PHP examples 1 // Installing a hosting package 2 $package = new StdClass(); 3 $package->AccountNumber = "UK000000001"; 4 $package->TemplateCode = "WINDOWS_PRO"; 5 $package->DomainName = "mydomain.com"; 6 $cart = $api->CreateCart($package->AccountNumber); // Create the cart 7 $api->InstallPackage($package, $cart); // Create the package 8 $order = $api->CheckoutCart($cart); // Convert to order 9 $api->PendOrder($order); // Put in pending orders queue 1 // Installing an email package // or a custom template Page 28 of 126 Fasthosts Reseller API Developer Guide 2 $package = new StdClass(); 3 $package->AccountNumber = "UK000000001"; 4 $package->TemplateCode = "MAIL_PLUS_DIRECT"; 5 $package->DomainName = "mydomain.com"; 6 $cart = $api->CreateCart($package->AccountNumber); // Create the cart 7 $api->InstallPackage($package, $cart); // Create the package 8 $order = $api->CheckoutCart($cart); // Convert to order 9 $api->PendOrder($order); // Put in pending orders queue // or a custom template ASP.NET (C#) examples 1 // Installing a hosting package 2 Package package = new Package(); 3 package.AccountNumber = "UK000000001"; 4 package.TemplateCode = "WINDOWS_PRO"; 5 package.DomainName = "mydomain.com"; 6 Cart cart = api.CreateCart(package.AccountNumber); // Create the cart 7 api.InstallPackage(package, cart); // Create the package 8 Order order = api.CheckoutCart(cart); // Converts to order 9 api.PendOrder(order); // Put in pending orders queue 1 // Installing an email package 2 Package package = new Package(); 3 package.AccountNumber = "UK000000001"; 4 package.TemplateCode = "MAIL_PLUS_DIRECT"; 5 package.DomainName = "mydomain.com"; 6 Cart cart = api.CreateCart(package.AccountNumber); // Create the cart 7 api.InstallPackage(package, cart); // Create the package 8 Order order = api.CheckoutCart(cart); // Converts to order 9 api.PendOrder(order); // Put in pending orders queue Adding, modifying, and upgrading a mailbox The examples below show you how to create a mailbox, change the password of an existing mailbox, and upgrade a mailbox type. As with all other products, you first need to create a cart, using CreateCart, to add the new product to. PHP examples 1 // Adding a mailbox to a hosting package 2 $package = $api->GetPackageByDomain("mydomain.com"); Page 29 of 126 Fasthosts Reseller API Developer Guide 3 $mailbox = new StdClass(); 4 $mailbox->Package = $package; 5 $mailbox->Username = "robertblatchford"; $mailbox->Password = "mysecretpassword"; // Create as a “Starter” mailbox 6 $mailbox->Type = "Starter"; 7 $cart = $api->CreateCart($package->AccountNumber); 8 $api->CreateMailBox($mailbox, $cart); 9 $order = $api->CheckoutCart($cart); 10 $api->PendOrder($order); // Put in pending orders queue 1 // Changing a mailbox password 2 $package = $api->GetPackageByDomain("mydomain.com"); 3 $mailbox = $api->GetMailBox($package, "robertblatchford"); 4 $mailbox->Password = "chooseanotherpassword"; 5 $api->ConfigureMailBox($mailbox); 1 // Upgrading a mailbox to "Advanced" 2 $package = $api->GetPackageByDomain("mydomain.com"); 3 $mailbox = $api->GetMailBox($package, "robertblatchford"); 4 $cart = $api->CreateCart($package->AccountNumber); 5 $api->UpgradeMailBoxType($mailbox, "Mailextra", $cart); 6 $order = $api->CheckoutCart($cart); 7 $api->PendOrder($order); // Put in pending orders queue ASP.NET (C#) examples 1 // Adding a mailbox to a hosting package 2 Package package = api.GetPackageByDomain("mydomain.com"); 3 MailBox mailbox = new MailBox(); 4 mailbox.Package = package; 5 mailbox.Username = "newusername"; 6 mailbox.Password = "mypassword"; 7 mailbox.Type = "Starter"; 8 Cart cart = api.CreateCart(package.AccountNumber); 9 api.CreateMailBox(mailbox, cart); 10 Order order = api.CheckoutCart(cart); 11 api.PendOrder(order); // Create as “Starer” mailbox // Put in pending orders queue 1 // Changing a mailbox password 2 Package package = api.GetPackageByDomain("mydomain.com"); 3 MailBox mailbox = api.GetMailBox(package, "newusername"); 4 mailbox.Password = "anewpassword"; 5 api.ConfigureMailBox(mailbox); Page 30 of 126 Fasthosts Reseller API Developer Guide 1 // Upgrading a mailbox to "Advanced" 2 Package package = api.GetPackageByDomain("mydomain.com"); 3 MailBox mailbox = api.GetMailBox(package, "newusername"); 4 Cart cart = api.CreateCart(package.AccountNumber); 5 api.UpgradeMailBoxType(mailbox, "Mailextra", cart); 6 Order order = api.CheckoutCart(cart); 7 api.PendOrder(order); // Put in pending orders queue Installing MatrixStats MatrixStats is a very useful tool for your customers, and can be installed using the InstallMatrixStats function. As with all other products, you first need to create a cart, using CreateCart, to add the new product to. PHP example 1 // Install MatrixStats to mydomain.com 2 $package = $api->GetPackageByDomain("mydomain.com"); 3 $matrixstats = $api->GetMatrixStats($package); 4 if (!$matrixstats->Installed) 5 { 6 $matrixstats->Username = "robertblatchford"; 7 $matrixstats->Password = "chooseapassword"; 8 $cart = $api->CreateCart($package->AccountNumber); // Create the cart 9 $api->InstallMatrixStats($matrixstats, $cart); // Add product to cart $order = $api->CheckoutCart($cart); // Convert to order $api->PendOrder($order); // Put in pending queue 10 11 12 } ASP.NET (C#) example 1 // Install MatrixStats to mydomain.com 2 Package package = api.GetPackageByDomain("mydomain.com"); 3 MatrixStats matrixStats = api.GetMatrixStats(package); 4 if (!matrixStats.Installed) 5 { 6 matrixStats.Username = "newusername"; 7 matrixStats.Password = "anewpassword"; 8 Cart cart = api.CreateCart(package.AccountNumber); // Create the cart 9 api.InstallMatrixStats(matrixStats, cart); // Add product to cart Order order = api.CheckoutCart(cart); // Convert to order 10 Page 31 of 126 Fasthosts Reseller API Developer Guide 11 12 api.PendOrder(order); // Put in pending queue } Installing SiteBuilder SiteBuilder can be installed using the InstallSiteBuilder function call. As with all other products, you first need to create a cart, using CreateCart, to add the new product to. PHP example 1 // Install SiteBuilder 10 pages to mydomain.com 2 $package = $api->GetPackageByDomain("mydomain.com"); 3 $sitebuilder = $api->GetSiteBuilder($package); 4 if (!$sitebuilder->Installed) 5 { 6 $sitebuilder->Username = "robertblatchford"; 7 $sitebuilder->Password = "chooseapassword"; 8 $sitebuilder->Plan = "10Page"; 9 $cart = $api->CreateCart($package->AccountNumber); 10 $api->InstallSiteBuilder($sitebuilder, $cart); 11 $order = $api->CheckoutCart($cart); 12 $api->PendOrder($order); 13 // Put in pending orders queue } ASP.NET (C#) example 1 // Install SiteBuilder 10 pages to mydomain.com 2 Package package = api.GetPackageByDomain("mydomain.com"); 3 SiteBuilder siteBuilder = api.GetSiteBuilder(package); 4 if (!siteBuilder.Installed) 5 { 6 siteBuilder.Username = "newusername"; 7 siteBuilder.Password = "anewpassword"; 8 siteBuilder.Plan = "10Page"; 9 Cart cart = api.CreateCart(package.AccountNumber); 10 api.InstallSiteBuilder(siteBuilder, cart); 11 Order order = api.CheckoutCart(cart); 12 api.PendOrder(order); 13 // Put in pending orders queue } Page 32 of 126 Fasthosts Reseller API Developer Guide Adding a database You can add a MySQL or MSSQL database to a hosting package using the CreateDatabase API function call. As with all other products, you first need to create a cart, using CreateCart, to add the new product to. PHP example 1 // Add a MySQL database to mydomain.com 2 $package = $api->GetPackageByDomain("mydomain.com"); 3 4 // Create 2 users for the database 5 $user1 = new StdClass(); 6 $user1->Username = "robertblatchford"; 7 $user1->Password = "chooseapassword"; 8 $user1->IsDBO = true; 9 $user2 = new StdClass(); 10 $user2->Username = "anotheruser"; 11 $user2->Password = "chooseanotherpassword"; 12 $user2->IsDBO = false; 13 14 // Create database 15 $database = new StdClass(); 16 $database->Package = $package; 17 $database->Name = "chooseanameforthisdatabase"; 18 $database->Type = "MySQL"; 19 $database->Users = array($user1, $user2); 20 21 // Install database and convert cart to order ready for processing 22 $cart = $api->CreateCart($package->AccountNumber); 23 $api->CreateDatabase($database, $cart); 24 $order = $api->CheckoutCart($cart); 25 $api->PendOrder($order); // Put in pending orders queue ASP.NET (C#) example 1 // Add a MySQL database to mydomain.com 2 Package package = api.GetPackageByDomain("mydomain.com"); 3 4 // Create 2 users 5 DatabaseUser user = new DatabaseUser(); 6 user.Username = "User1"; 7 user.Password = "password"; Page 33 of 126 Fasthosts Reseller API Developer Guide 8 user.IsDBO = true; 9 DatabaseUser user2 = new DatabaseUser(); 10 user.Username = "User2"; 11 user.Password = "password"; 12 user.IsDBO = false; 13 14 // Create Database 15 Database database = new Database(); 16 database.Package = package; 17 database.Name = "adatabasename"; 18 database.Type = "MySQL"; 19 database.Users = new DatabaseUser[] { user, user2 }; 20 21 // Install Database 22 Cart cart = api.CreateCart(package.AccountNumber); 23 api.CreateDatabase(database, cart); 24 Order order = api.CheckoutCart(cart); 25 api.PendOrder(order); Processing an order Once you’ve created your cart, added products to it, and checked it out, you need to process the order. You have two options available: manual processing, or automatic processing. If you process your order manually it will appear in the pending orders queue in your control panel. You can then approve or decline any orders processed in this way before the product is added to your customers account. If you process the order automatically, the products will be added straight away and any billing will be taken from the funds on your Reseller account balance. For more information on manual and automatic billing, see Managing customer orders on page 5. You can process the orders using the ProcessOrder or PendOrder functions. The examples below create a cart, add a Standard mailbox for mydomain.com, and process the order. PHP examples Page 34 of 126 Fasthosts Reseller API Developer Guide 1 // Processing an order automatically 2 $package = $api->GetPackageByDomain("mydomain.com"); 3 $mailbox = new StdClass(); 4 $mailbox->Package = $package; 5 $mailbox->Username = "robertblatchford"; 6 $mailbox->Password = "mysecretpassword"; 7 $mailbox->Type = "Starter"; 8 $cart = $api->CreateCart($package->AccountNumber); 9 $api->CreateMailBox($mailbox, $cart); 10 $order = $api->CheckoutCart($cart); 11 // Submit order for processing and wait for it to complete 12 $api->ProcessOrder($order, true); 1 // Leaving an order in the pending queue for manual processing 2 $package = $api->GetPackageByDomain("mydomain.com"); 3 $mailbox = new StdClass(); 4 $mailbox->Package = $package; 5 $mailbox->Username = "robertblatchford"; 6 $mailbox->Password = "mysecretpassword"; 7 $mailbox->Type = "Starter"; 8 $cart = $api->CreateCart($package->AccountNumber); 9 $api->CreateMailBox($mailbox, $cart); 10 $order = $api->CheckoutCart($cart); 11 // Leave order in pending queue 12 $api->PendOrder($api); ASP.NET (C#) examples 1 // Processing an order automatically 2 Package package = api.GetPackageByDomain("mydomain.com"); 3 MailBox mailbox = new MailBox(); 4 mailbox.Package = package; 5 mailbox.Username = "newusername"; 6 mailbox.Password = "mypassword"; 7 mailbox.Type = "Starter"; 8 Cart cart = api.CreateCart(package.AccountNumber); 9 api.CreateMailBox(mailbox, cart); 10 Order order = api.CheckoutCart(cart); 11 // Submit order for processing and wait for it to complete 12 api.ProcessOrder(order, true); 1 // Leaving an order in the pending queue for manual processing 2 Package package = api.GetPackageByDomain("mydomain.com"); 3 MailBox mailbox = new MailBox(); Page 35 of 126 Fasthosts Reseller API Developer Guide 4 mailbox.Package = package; 5 mailbox.Username = "newusername"; 6 mailbox.Password = "mypassword"; 7 mailbox.Type = "Starter"; 8 Cart cart = api.CreateCart(package.AccountNumber); 9 api.CreateMailBox(mailbox, cart); 10 Order order = api.CheckoutCart(cart); 11 // Leave order in pending queue 12 api.PendOrder(order); Security considerations Website security is a very important consideration when designing your corporate marketing website, signup screens, or control panels, yet it is one that often gets overlooked or rushed. When designing your interfaces you should consider the following suggestions. It is a good idea not to hard code your Reseller API username and password into your scripts. Instead store them as variables in an include file in the private folder. This will make it much easier to update them if these values ever change. Always validate all data from third party sources, such as forms and databases, to ensure that it is in an acceptable format before you process it. For example, telephone numbers should only contain numbers, email addresses should include an @ and . symbol in the right places, addresses should only contain alpha0numeric characters etc. All scripting languages have functions available to help you validate your data. Any data from third parties should be converted to HTML before it is printed on a page or in a control on a form. Special symbols (such as < and >) should be converted to their HTML values (< and >) to prevent malicious users entering code that your browser could run. When logging in to the Reseller API use the customer username and passwords whenever possible. This will limit the available functionality to just modifying that customers data, removing any chance of altering another customer’s data accidentally. API function call reference Page 36 of 126 Fasthosts Reseller API Developer Guide This section details the various function calls at your disposal to manage your customer accounts. The function calls are sorted by product. API Connection Establishing a connection to the Reseller API, and ending the session when you are finished. Login Establish a connection to the API. Session Login( string $ResellerUsername, string $ResellerPassword, [ string $CustomerUsername ], [ string $CustomerPassword ] ) Parameters Parameter Type Description $ResellerUsername String Your API username, from your control panel. $ResellerPassword String Your API password, from your control panel. $CustomerUsername String (Optional) Username of customer account. $CustomerPassword String (Optional) Password of customer account. Return values Returns a Session structure containing details of the newly established session. For more information on this structure see page 109. Notes The $CustomerUsername and $CustomerPassword parameters are entirely optional. If you do supply these login credentials you will login to the API with the security Page 37 of 126 Fasthosts Reseller API Developer Guide privileges granted to your customer, therefore you won’t be able to modify other customer’s services. It’s a good idea to supply the customer login parameters if you are building a customer control panel. If Login fails it will return error 109 – Login Failed. For a detailed list of all API error codes see Error handling on page 118. PHP example 1 // log into API 2 $api = new SoapClient("https://resellerapi.fasthosts.co.uk/?wsdl"); 3 $session = $api->Login("myapiuser", "myapipassword", "", ""); 4 $header = new SoapHeader("FasthostsAPI", "Session", $session); 5 $api->__setSoapHeaders(array($header)); ASP.NET (C#) example 1 // Create the User Session and assign it to the Soap header 2 ApiService api = new ApiService(); 3 api.SessionValue = api.Login( 4 "myapiuser", 5 "myapipassword", "customeruser", "customerpassword”); For a detailed example, see Connecting to the API on page 16. Logout Disconnect from the API. Void Logout() Parameters None. Return values Page 38 of 126 Fasthosts Reseller API Developer Guide None. Notes If you don’t call Logout, the session will expire and you will be logged out automatically after five minutes of inactivity. PHP example 1 // log out of the API 2 $api->Logout(); ASP.NET (C#) example 1 // log out of the API 2 api.Logout(api.SessionValue); Order processing CreateCart A cart is needed to install any services or packages. If any stock is required for the installation of a service or package, it will be added to the cart. This function creates a new cart. Cart CreateCart( string $AccountNumber ) Parameters Parameter Type Description $AccountNumber String Number of the account to add products within the cart to. Page 39 of 126 Fasthosts Reseller API Developer Guide Return values Returns a Cart structure object (see page 89) containing details of the newly created cart. CreateTestCart Creates a test cart. The test cart is identical to the cart created by CreateCart, with the exception that when the test cart is checked out no products or services will be installed, and a test order will be created in the pending orders queue in your control panel. Cart CreateTestCart( string $AccountNumber ) Parameters Parameter Type Description $AccountNumber String Number of the account to add products within the cart to. Return values Returns a Cart structure object (see page 89) containing details of the newly created cart. Notes If using the test cart, the Cart.IsTest property in the Cart and Order structures will be True. CheckoutCart Creates an order from the items in the cart. Order CheckoutCart( Cart $Cart ) Page 40 of 126 Fasthosts Reseller API Developer Guide Parameters Parameter Type Description $Cart Cart Cart structure containing details of the cart created with the CreateCart or CreateTestCart functions. Return values Returns an Order structure object (see page 106) containing details of the order. Notes The cart will no longer exist after calling CheckoutCart. ProcessOrder Automatically process and add any products in the order to your Reseller account. Payment for any products is taken from your account balance. Void ProcessOrder( Order $Order, boolean $Wait ) Parameters Parameter Type Description $Order Order Order structure returned from CheckoutCart. $Wait Boolean See notes Return values None. Notes If $Wait is true, ProcessOrder will only return once the order has been processed or has failed. An email will be sent to notify you of the success or failure of the order. If $Wait is false, ProcessOrder will submit the order to the processing queue and Page 41 of 126 Fasthosts Reseller API Developer Guide return straight away. No email will be sent to you because the order usually takes 10 - 30 seconds to complete. Please be aware that setting $Wait to True will halt execution of your script until the order has been processed, which could take several seconds. ProcessOrder will wait for a maximum of 30 seconds before returning. There is no guarantee that the order will have processed or failed in that time. For instance, an order may go into a manual fraud-checking queue in which case it could take hours before being processed. CancelOrder Cancels an order. The order will be removed from the queue, and everything installed will be rolled back. Nothing will be charged to your Reseller account. Void CancelOrder( Order $Order ) Parameters Parameter Type Description $Order Order Order structure returned from CheckoutCart. Return values None. PendOrder Leave an order in the processing queue, and send a notification email to the reseller. Any orders placed with this function will require you to log in to your Reseller control panel and approve or decline the order form the pending orders queue. void PendOrder( Order $Order ) Page 42 of 126 Fasthosts Reseller API Developer Guide Parameters Parameter Type Description $Order Order Order structure returned from CheckoutCart. Return values None. GetAccountBalance Returns the balance of funds on your Reseller account. int GetAccountBalance() Parameters None. Return values Returns an integer value containing your current balance. Note: The balance is returned in pence. For example, if your Reseller account has a balance of £100, GetAccountBalance will return 10000. Customer Accounts UpdateAccount Update the details of a customer account within your Reseller account. void UpdateAccount( Account $Account ) Page 43 of 126 Fasthosts Reseller API Developer Guide Parameters Parameter Type Description $Account Account The account structure containing the new details. Return values None. GetAccount Returns details for a given customer account. Account GetAccount( string $AccountNumber ) Parameters Parameter Type Description $AccountNumber String The number of the customer account to query. Return values Returns an Account structure object (see page 84) containing the customer account details. GetAccountList Returns a list of all customer accounts available in your Reseller account. AccountList GetAccountList( string $ParentAccountNumber, Paging $Paging ) Page 44 of 126 Fasthosts Reseller API Developer Guide Parameters Parameter Type Description $ParentAccountNumber String Parent account number. $Paging Paging Paging structure object, specifying paging options. Return values Returns an AccountList structure containing the list of all Accounts associated with the parent account. Notes $ParentAccountNumber would usually be set to your own Reseller account number. However, if you have customers who resell your services you could supply their account number instead, and retrieve a list of accounts associated with that customer. CloseAccount Closes a customer’s account, removing the customer from the customers list in your Reseller control panel. void CloseAccount( string $AccountNumber ) Parameters Parameter Type Description $AccountNumber String Number of the account to close. Return values None. CreateAccount Create a new customer account within your Reseller account. Page 45 of 126 Fasthosts Reseller API Developer Guide string CreateAccount( Account $Account ) Parameters Parameter Type Description $Account Account Account structure containing the details of the new account you want to create. Return values Returns a string containing the new account number. GetCountryCodes Return a list of Countries, and their two character country codes. A full list of the country codes returned can be found on page 121. array GetCountryCodes() Parameters None. Return values Returns an array of Country structures (see page 92) containing details of each country. Templates GetTemplateList Return a list of the templates on your account. Page 46 of 126 Fasthosts Reseller API Developer Guide TemplateList GetTemplateList( Paging $Paging ) Parameters Parameter Type Description $Paging Paging Paging structure object, specifying paging options. Return values Returns a TemplateList (see page 113) structure containing the list of templates. Notes This function could be used to allow the selection of different account types from your own signup pages, based on the templates you have added through your Reseller control panel. GetHostingTemplateList Return a TemplateList (see page 113) structure containing a list of the templates that include website and email hosting services. TemplateList GetHostingTemplateList( Paging $Paging ) Parameters Parameter Type Description $Paging Paging Paging structure object, specifying paging options. Return values Returns a TemplateList (see page 113) structure containing the list of templates. Notes This function is similar to GetTemplateList(), the only difference is that Page 47 of 126 Fasthosts Reseller API Developer Guide GetTemplateList() returns all available templates on the account, whereas GetHostingTemplateList() returns only templates that include hosting services on the shared server platform. GetTemplate Returns a Template structure containing details of the template. Template GetTemplate( string $TemplateCode ) Parameters Parameter Type Description $TemplateCode String The unique code assigned to the template. Return values Returns a Template structure (see page 113) containing the template details. Notes If using a custom template, you were asked to specify a template code when you created it through your Reseller control panel. GetPackageList Return a list of all hosting packages associated with a customer account. PackageList GetPackageList( string $AccountNumber, Paging $Paging ) Parameters Parameter Type Description Page 48 of 126 Fasthosts Reseller API Developer Guide $AccountNumber String Account number of the customer who’s packages you are querying. $Paging Paging Paging structure object, specifying paging options. Return values Returns a PackageList structure (see page 107) containing the list of packages and their details. Hosting packages GetPackageByTemplate Searches for a package installed from a specific template in an account. Package GetPackageByTemplate( string $AccountNumber, string $TemplateCode ) Parameters Parameter Type Description $AccountNumber String The account number of the customer you are querying. $TemplateCode String Code of the template from which the package was installed (e.g. “LINUX_STARTER”) Return values Returns a Package structure (see page 106) containing package details. Notes Searches for a package installed from a specific template (eg. “WINDOWS_PRO”) in an account. If more than one such package exists in an account – the first one will be returned. Page 49 of 126 Fasthosts Reseller API Developer Guide GetPackageByDomain Returns package information for a specified domain. Package GetPackageByDomain( string $DomainName ) Parameters Parameter Type Description $DomainName String The domain name to query. Return values Returns a Package structure (see page 106) containing package details. InstallPackage Install a new hosting package in a customer account. void InstallPackage( Package $Package, Cart $Cart ) Parameters Parameter Type Description $Package Package Package structure containing information on the new package being installed. $Cart Cart Cart structure containing details of any services to be installed on the new package. Return values None. Page 50 of 126 Fasthosts Reseller API Developer Guide ClosePackage Remove a hosting package from your reseller account. void ClosePackage( Package $Package ) Parameters Parameter Type Description $Package Package Package structure containing details of the package to close. Return values None. Notes Closing the hosting package will delete the web hosting and email services from your Reseller account. All website files and mailboxes will be deleted and will not be recoverable. Databases GetDatabaseList Returns a paged list of databases installed in a customer’s package. DatabaseList GetDatabaseList( Package $Package, Paging $Paging ) Parameters Page 51 of 126 Fasthosts Reseller API Developer Guide Parameter Type Description $Package Package Package structure containing details of the package structure to query. $Paging Paging Paging structure object, specifying paging options. Return values Returns a DatabaseList structure (see page 93) containing a list of all the databases on the specified package.. GetDatabase Returns a paged list of databases installed in a customer’s package. Database GetDatabase( Package $Package, string $Type, string $DatabaseName ) Parameters Parameter Type Description $Package Package Package structure containing details of the package on which the database is installed. $Type String The type of database, see notes. $DatabaseName String The name of the database. Return values Database structure (see page 93) containing the database details. Notes Allowed values for $Type are: “MySQL” or “MSSQL”. CreateDatabase Add a new MySQL or Microsoft SQL database to the cart. Page 52 of 126 Fasthosts Reseller API Developer Guide void CreateDatabase( Database $Database, Cart $Cart ) Parameters Parameter Type Description $Database Database Database structure containing details of the new database to be created. $Cart Cart Cart structure containing details of the cart to add the new database to. Return values None. ConfigureDatabase Configure a database. void ConfigureDatabase( Database $Database ) Parameters Parameter Type Description $Database Database Database structure containing the new database details. Return values None. Notes The database to modify is identified by the $DatabaseName, $Package, and $Type properties of the Database structure above. Page 53 of 126 Fasthosts Reseller API Developer Guide DropDatabase Deletes the specified database from your reseller account. void DropDatabase( Database $Database ) Parameters Parameter Type Description $Database Database Database structure containing the database to delete. Return values None. UpgradeDatabaseSpace Upgrade the size of a given database. void UpgradeDatabaseSpace( Database $Database, Cart $Cart ) Parameters Parameter Type Description $Database Database Database structure containing the database to upgrade. $Cart Cart Cart structure containing the cart to add the new space product to. Return values None. Page 54 of 126 Fasthosts Reseller API Developer Guide Notes The space upgrade is fixed to 150 MB. Website GetWebsite Returns details of a website associated with a specified hosting package, such as the root folder, load balancing options, storage and bandwidth quotas, and error pages. Website GetWebsite( Package $Package ) Parameters Parameter Type Description $Package Package The package containing the website you want to query. Return values Returns a Website structure (see page 115) containing the requested details. ConfigureWebsite Change configuration of a website. void ConfigureWebsite( Website $Website ) Parameters Parameter Type Description Page 55 of 126 Fasthosts Reseller API Developer Guide $Website Website Website structure containing details of the website to configure. Return values None. GetScriptCodes Returns a list of valid scripting languages supported by Fasthosts and their codes. array GetScriptCodes() Parameters None. Return values Returns an array of ScriptMap structures (see page 108) containing the requested details. MatrixStats GetMatrixStats Get details of a MatrixStats installation on a particular domain hosting package. MatrixStats GetMatrixStats( Package $Package ) Parameters Parameter Type Description $Package Package Package structure object containing details of the package to query. Page 56 of 126 Fasthosts Reseller API Developer Guide Return values Returns a MatrixStats structure object (see page 105) containing details of the MatrixStats product on the supplied package.. InstallMatrixStats Installs the MatrixStats product on a domain in a customer account. void InstallMatrixStats( MatrixStats $MatrixStats, Cart $Cart ) Parameters Parameter Type Description $MatrixStats MatrixStats MatrixStats structure object to install. $Cart Cart The Cart structure to add MatrixStats to. Return values None. ConfigureMatrixStats Configure the MatrixStats product on a package in your account. void ConfigureMatrixStats( MatrixStats $MatrixStats ) Parameters Parameter Type Description $MatrixStats MatrixStats The MatrixStats structure to configure. Page 57 of 126 Fasthosts Reseller API Developer Guide Return values None. RemoveMatrixStats Removes a MatrixStats product from a domain. void RemoveMatrixStats( MatrixStats $Matrixstats ) Parameters Parameter Type Description $MatrixStats MatrixStats The MatrixStats structure object containing the product to remove. Return values None. TrafficDriver GetTrafficDriver Return details of a TrafficDriver product on a given package within your Reseller account. TrafficDriver TrafficDriver( Package $Package ) Parameters Parameter Type Description Page 58 of 126 Fasthosts Reseller API Developer Guide $Package Package The Package structure containing details of the package you are querying. Return values Returns a TrafficDriver structure object (see page 114) containing details of the TrafficDriver installation on the specified package. InstallTrafficDriver Install TrafficDriver product on a package. void InstallTrafficDriver( TrafficDriver $TrafficDriver, Cart $Cart ) Parameters Parameter Type Description $TrafficDriver TrafficDriver TrafficDriver structure containing details of the new TrafficDriver product you are installing. $Cart Cart The Cart structure for the cart you are adding this new product to. Return values None. ConfigureTrafficDriver Configure an existing TrafficDriver product. void ConfigureTrafficDriver( TrafficDriver $TrafficDriver ) Parameters Page 59 of 126 Fasthosts Reseller API Developer Guide Parameter Type Description $TrafficDriver TrafficDriver The TrafficDriver structure object to configure. Return values None. RemoveTrafficDriver Remove a TrafficDriver product from a hosting package. void RemoveTrafficDriver( TrafficDriver $TrafficDriver ) Parameters Parameter Type Description $TrafficDriver TrafficDriver The TrafficDriver structure object to remove. Return values None. UpgradeTrafficDriverLevel Upgrade TrafficDriver to a higher plan. Session UpdateTrafficDriverLevel( TrafficDriver $TrafficDriver, string $Level, Cart $Cart ) Parameters Parameter Type Description Page 60 of 126 Fasthosts Reseller API Developer Guide $TrafficDriver TrafficDriver The TrafficDriver structure object to upgrade. $Level String String value representing the new level/plan. $Cart Cart The Cart structure object to add the product to. Return values None. Notes The allowed values for $Level are: “High”, “Super”, or “Extreme”. SiteBuilder GetSiteBuilder Return details of a SiteBuilder product on a given hosting package. SiteBuilder GetSiteBuilder( Package $Package ) Parameters Parameter Type Description $Package Package The package structure object containing details of the package to query. Return values Returns a SiteBuilder structure object (see page 110) containing the details of the SiteBuilder product on the specified package. InstallSiteBuilder Installs the SiteBuilder product on a package within your account. Page 61 of 126 Fasthosts Reseller API Developer Guide void InstallSiteBuilder( SiteBuilder $SiteBuilder, Cart $Cart ) Parameters Parameter Type Description $SiteBuilder SiteBuilder The SiteBuilder structure to install. $Cart Cart The Cart structure to add the new product to. Return values None. ConfigureSiteBuilder Configure a SiteBuilder product. void ConfigureSiteBuilder( SiteBuilder $SiteBuilder ) Parameters Parameter Type Description $SiteBuilder SiteBuilder The SiteBuilder structure to configure. Return values None. RemoveSiteBuilder Removes a SiteBuilder product. void RemoveSiteBuilder( Page 62 of 126 Fasthosts Reseller API Developer Guide SiteBuilder $SiteBuilder ) Parameters Parameter Type Description $SiteBuilder SiteBuilder The SiteBuilder structure containing the product to remove. Return values None. UpgradeSiteBuilderPlan Upgrades a SiteBuilder product to a higher plan, therefore providing the customer with more pages. void UpgradeSiteBuilderPlan( SiteBuilder $SiteBuilder, string $Plan, Cart $Cart ) Parameters Parameter Type Description $SiteBuilder SiteBuilder SiteBuilder structure containing product to upgrade. $Plan String String value representing new plan. $Cart Cart Cart structure to add the product to. Return values None. Notes Allowed values for $Plan are: “25Page” or “Unlimited”. Page 63 of 126 Fasthosts Reseller API Developer Guide FTP accounts GetFTPAccountList Returns a list of custom FTP accounts on a given hosting package.. FTPAccountList GetFTPAccountList( Package $Package, Paging $Paging ) Parameters Parameter Type Description $Package Package Package structure containing details of the hosting package to query. $Paging Paging Paging structure containing paging and sorting options for the returned list. Return values Returns an FTPAccountList structure (see page 100) containing a list of all FTP accounts on the specified package. GetFTPAccount Returns a specific FTP account. FTPAccount GetFTPAccount( Package $Package, string $Username ) Parameters Parameter Type Description Page 64 of 126 Fasthosts Reseller API Developer Guide $Package $Package Package structure detailing the hosting package the FTP account is associated with. $Username String String value containing the FTP username for the custom FTP account. Return values Returns an FTPAccount structure (see page 100) containing details of the custom FTP account on the given package. CreateFTPAccount Create a new FTP account. void CreateFTPAccount( FTPAccount $FTPAccount, Cart $Cart ) Parameters Parameter Type Description $FTPAccount FTPAccount FTPAccount structure containing the custom FTP account to create. $Cart Cart Cart structure containing the cart to add this new product to. Return values None. DeleteFTPAccount Delete an FTP account. void DeleteFTPAccount( FTPAccount $FTPAccount ) Page 65 of 126 Fasthosts Reseller API Developer Guide Parameters Parameter Type Description $FTPAccount FTPAccount FTPAccount structure containing the account to delete. Return values None. ConfigureFTPAccount Configure a custom FTP account. void ConfigureFTPAccount( FTPAccount $FTPAccount ) Parameters Parameter Type Description $FTPAccount FTPAccount FTPAccount structure containing the account to configure. Return values None. Global FTP Accounts Global FTP accounts allow you, as a Reseller, to access multiple domains from one FTP login username and password. There are two types of Global FTP account available. Master – The master Global FTP account allows full access to all domains within your account. Because of the potential security risks involved with this account type, the master FTP user is disabled by default and must be Page 66 of 126 Fasthosts Reseller API Developer Guide enabled in your control panel. Custom – You can create your own FTP account to allow access to one or more domain names. You can also create your own Paths within the Global FTP account, which allow you to restrict access to certain folders and prevent the adding, editing, or deleting of files. GetGlobalFTPAccountList Retrieves a list of all Global FTP Accounts within your Reseller account. AdvancedFTPAccountList GetGlobalFTPAccountList( Paging $Paging ) Parameters Parameter Type Description $Paging Paging A Paging structure (see page 108) containing paging and sorting options for the returned list. Return Values Returns an AdvancedFTPAccountList structure (see page 87) containing all the global FTP Accounts in your Reseller Account. GetGlobalFTPAccount Retrieve details of a specific Global FTP Account by its username. AdvancedFTPAccount GetGlobalFTPAccount( string $Username ) Parameters Parameter Type Description Page 67 of 126 Fasthosts Reseller API Developer Guide $Username String The username of the FTP account to retrieve. Return values Returns an AdvancedFTPAccount structure (see page 86). CreateGlobalFTPAccount Creates a Global FTP Account using the supplied credentials. void CreateGlobalFTPAccount( AdvancedFTPAccount $AdvancedFTPAccount Cart $Cart ) Parameters Parameter Type Description $AdvancedFTPAccount AdvancedFTPAccount An AdvancedFTPAccount structure (see page 86) containing the credentials for the FTP account to be created. $Cart Cart A Cart structure (see page 89) containing the cart to add the new Global FTP product to. Return values None. DeleteGlobalFTPAccount Delete the specified Global FTP account, including any FTP account paths. void DeleteGlobalFTPAccount( AdvancedFTPAccount $AdvancedFTPAccount ) Parameters Parameter Type Description Page 68 of 126 Fasthosts Reseller API Developer Guide $AdvancedFTPAccount AdvancedFTPAccount An AdvancedFTPAccount structure (see page 86) containing the credentials for the FTP account to be deleted. Return values None. ConfigureGlobalFTPAccount This function updates the password for a Global FTP account using the supplied account details. void ConfigureGlobalFTPAccount( AdvancedFTPAccount $AdvancedFTPAccount ) Parameters Parameter Type Description $AdvancedFTPAccount AdvancedFTPAccount An AdvancedFTPAccount structure (see page 86) containing the credentials for the FTP account to be configured. Return values None. GetGlobalFTPAccountPathsForFTPAccount Gets a list of all FTP account paths associated with the Global FTP Account. FTPAccountPathList GetGlobalFTPAccountPathsForFTPAccount( AdvancedFTPAccount $AdvancedFTPAccount Paging $Paging ) Parameters Parameter Type Description Page 69 of 126 Fasthosts Reseller API Developer Guide $AdvancedFTPAccount AdvancedFTPAccount An AdvancedFTPAccount structure (see page 86) containing the credentials for the FTP account to be queried. $Paging Paging A Paging structure (see page 108) containing paging and sorting options for the returned list. Return values Returns an FTPAccountPathList structure (see page 102) containing all the paths associated with the AdvancedFTPAccount. CreateGlobalFTPAccountPath Creates a new FTP account path for the Global FTP account, using the supplied credentials. void CreateGlobalFTPAccountPath( AdvancedFTPAccount $AdvancedFTPAccount FTPAccountPath $FTPAccountPath ) Parameters Parameter Type Description $AdvancedFTPAccount AdvancedFTPAccount An AdvancedFTPAccount structure (see page 86) containing the credentials for the FTP account in which the new path is to be created. $FTPAccountPath FTPAccountPath An FTPAccountPath structure (see page 101) containing the access permissions and root folder of the new path. Return values None. DeleteGlobalFTPAccountPath Delete the specified FTP account path from the Global FTP account. void DeleteGlobalFTPAccountPath( Page 70 of 126 Fasthosts Reseller API Developer Guide AdvancedFTPAccount $AdvancedFTPAccount FTPAccountPath $FTPAccountPath ) Parameters Parameter Type Description $AdvancedFTPAccount AdvancedFTPAccount An AdvancedFTPAccount structure (see page 86) containing the credentials for the FTP account from which the path is to be deleted. $FTPAccountPath FTPAccountPath An FTPAccountPath structure (see page 101) containing the details of the path to be removed. Return values None. ConfigureGlobalFTPAccountPath Update the access permissions and root folder for the FTP account path associated with the supplied Global FTP Account. void ConfigureGlobalFTPAccountPath( AdvancedFTPAccount $AdvancedFTPAccount FTPAccountPath $FTPAccountPath ) Parameters Parameter Type Description $AdvancedFTPAccount AdvancedFTPAccount An AdvancedFTPAccount structure (see page 86) containing the credentials for the FTP account containing the path to be configured. $FTPAccountPath FTPAccountPath An FTPAccountPath structure (see page 101) containing the details of the path to be removed. Return values None. Page 71 of 126 Fasthosts Reseller API Developer Guide Mailbox management GetMailboxList Return a list of mailboxes on a given hosting package. MailBoxList GetMailboxList( Package $Package, Paging $Paging ) Parameters Parameter Type Description $Package Package Package structure containing the package to query. $Paging Paging Paging structure containing paging and sorting options for the returned list. Return values Returns a MailBoxList structure (see page 104) containing the list of mailboxes on the specified package. GetMailBox Returns a MailBox structure containing details on a given mailbox. MailBox GetMailBox( Package $Package, string $Username ) Parameters Parameter Type Description $Package Package Package structure containing the package to query. Page 72 of 126 Fasthosts Reseller API Developer Guide $Username String Username of the mailbox, this will be the full email address. Return values Returns a MailBox structure (see page 103) containing the mailbox details. Notes Allowed values for $Type are: “Starter”, “Starterplus”, “Advanced”, “Maillite”, “Mailextra” “Forwarding”, “Professional”, “Hex2013_25gb” or “Hex2013_50gb”. No longer supported values for $Type are: “Exchange” CreateMailBox Creates a new mailbox. void CreateMailBox( MailBox $MailBox, Cart $Cart ) Parameters Parameter Type Description $MailBox MailBox MailBox structure containing the mailbox to create. $Cart Cart Cart structure containing the cart to add this new product to. Return values None. DeleteMailBox Deletes the given mailbox. void DeleteMailBox( MailBox $MailBox ) Page 73 of 126 Fasthosts Reseller API Developer Guide Parameters Parameter Type Description $MailBox MailBox MailBox structure containing the mailbox to delete. Return values None. ConfigureMailBox Change the configuration of a mailbox. void ConfigureMailBox( Mailbox $MailBox ) Parameters Parameter Type Description $MailBox MailBox MailBox structure containing the mailbox to delete. Return values None. UpgradeMailBoxSpace Upgrade the size of a mailbox. void UpgradeMailBoxSpace( MailBox $MailBox, Cart $Cart ) Parameters Page 74 of 126 Fasthosts Reseller API Developer Guide Parameter Type Description $MailBox MailBox MailBox structure containing the mailbox to upgrade. $Cart Cart Cart structure containing the cart to add this new product to. Return values None. Notes Mailbox size upgrades are fixed to 150MB, and only “Advanced” mailboxes can have more space added. UpgradeMailBoxType Upgrade the mailbox to another type, for example from an Advanced mailbox to an Hosted Exchange 25GB mailbox. void UpgradeMailBoxType( MailBox $MailBox, string $Type, Cart $Cart ) Parameters Parameter Type Description $MailBox MailBox MailBox structure containing the mailbox to upgrade. $Type String The new mailbox type. $Cart Cart Cart structure containing the cart to add this upgrade to. Return values None. Notes Allowed values for $Type are: “Starter”, ”StarterPlus”, “Advanced”, “Maillite”, Page 75 of 126 Fasthosts Reseller API Developer Guide “Mailextra”, “Forwarding”, “Professional”, “Hex2013_25gb” or “Hex2013_50gb”. This function also supports downgrading mailboxes. No longer supported values for $Type are: “Exchange” Domains and registration GetDomainStatus Returns a DomainStatus structure containing various information on the status of the given domain. DomainStatus GetDomainStatus( string $DomainName ) Parameters Parameter Type Description $DomainName String The domain to query. Return values Returns all the domain summary information in a DomainStatus structure (see page 97). RegisterDomain Register a new domain in your Reseller account. void RegisterDomain( string $AccountNumber, string $DomainName, int $Term, Cart $Cart ) Parameters Parameter Type Description Page 76 of 126 Fasthosts Reseller API Developer Guide $AccountNumber String Specify the customer account you want to associate this domain with. $DomainName String The domain name to register. $Term Integer The number of years to register the domain for. $Cart Cart Cart structure containing the cart to add this domain registration to. Return values None. Notes You can use the GetDomainStatus function to determine if the domain is available for registration, and to find the minimum and maximum allowed values for $Term for the domain, before calling this function. TransferDomain Transfer a domain to your Fasthosts Reseller account from another registration service provider. Void TransferDomain( string $AccountNumber, string $DomainName, int $Term, string $AuthCode, Cart $Cart ) Parameters Parameter Type Description $AccountNumber String Specify the customer account you want to associate this domain with. $DomainName String The domain name to register. $Term Integer The number of years to register the domain for. $AuthCode String The authorisation code required to successfully transfer the domain. $Cart Cart Cart structure containing the cart to add this domain transfer to. Page 77 of 126 Fasthosts Reseller API Developer Guide Return values None. Notes The authorisation code will be supplied by the losing registrar. RenewDomain Renew a domain in your Reseller account on behalf of a customer. void RenewDomain( string $DomainName, int $Term, Cart $Cart ) Parameters Parameter Type Description $DomainName String The domain name to renew. $Term Integer The number of years to renew the domain name for. $Cart Cart Cart structure containing the cart to add this domain renewal to. Return values None. Notes You can use the GetDomainStatus function to determine the maximum allowed value for $Term and the current expiry date of the domain, before calling this function. InstallDomainPrivacy Install the Domain Privacy product on to the given domain name. Page 78 of 126 Fasthosts Reseller API Developer Guide void InstallDomainPrivacy( DomainRegistration $Domain, Cart $Cart ) Parameters Parameter Type Description $Domain DomainRegistration DomainRegistration structure containing the domain to add privacy product to. $Cart Cart Cart structure containing the cart to add this product to. Return values None. Notes Use the GetDomain function call (see page 80) to return the DomainRegistration structure required by this function. Domain Privacy can be disabled by calling UpdateDomain with Privacy.Enabled set to False. GetDomainList Return the list of domain registrations associated with one of your customer’s accounts.. DomainSummaryList GetDomainList( string $AccountNumber, Paging $Paging ) Parameters Parameter Type Description $AccountNumber String The number of the customer account you are Page 79 of 126 Fasthosts Reseller API Developer Guide querying. $Paging Paging structure containing paging and sorting options for the list. Paging Return values Returns a DomainSummaryList structure (see page 99) containing the domain list. GetDomain Returns details of a domain registration. DomainRegistration GetDomain( string $DomainName ) Parameters Parameter Type Description $DomainName String The domain to return. Return values Returns a DomainRegistration structure (see page 96) containing the domain name object. UpdateDomain Update a domain’s details. void UpdateDomain( DomainRegistration $Domain ) Parameters Parameter Type Description Page 80 of 126 Fasthosts Reseller API Developer Guide $Domain DomainRegistration DomainRegistration structure containing the domain to change. Return values None. GetDomainSuggestions Generates a list of domain name suggestions, useful if allowing a customer to register a domain name on your website. array GetDomainSuggestions( string $DomainName, array $TLDs, int $Quantity ) Parameters Parameter Type Description $DomainName String Original domain name used to generate the suggestions $TLDs Array of String Array of top level domains to generate suggestions for. $Quantity Integer The number of suggestions to return. Return values Returns an array of string values containing each suggested domain name. GetTLDsForRegistration Returns an array of top level domains that Fasthosts support for registration. array GetTLDsForRegistration() Page 81 of 126 Fasthosts Reseller API Developer Guide Parameters None. Return values Returns an array of string values. GetTLDsForTransfer Returns an array of top level domains that Fasthosts support for transfer. array GetTLDsFortransfer() Parameters None. Return values Returns an array of string values. Subdomains GetSubDomainList Returns a list of sub domains associated with the given package. SubDomainList GetSubDomainList( Package $Package, Paging $Paging ) Parameters Parameter Type Description $Package Package Package structure containing the package to query. Page 82 of 126 Fasthosts Reseller API Developer Guide $Paging Paging Paging structure containing paging and sorting options for the returned list. Return values Returns a SubDomainList structure (see page 112) containing the list of sub domains. GetSubDomain Returns a SubDomain structure, containing details of the given sub domain. SubDomain GetSubDomain( Package $Package, string $Name ) Parameters Parameter Type Description $Package Package Package structure containing the package to query. $Name String The name of the sub domain to return, excluding the domain name. Return values Returns a SubDomain structure (see page 112) containing the sub domain details. Notes Name should just be the subdomain part of the full domain. For example if the full sub domain name is: users.mydomain.com, then $Name would be “users”. AddSubDomain Add a new sub domain to an existing domain hosting package. void AddSubDomain( SubDomain $SubDomain, Page 83 of 126 Fasthosts Reseller API Developer Guide Cart $Cart ) Parameters Parameter Type Description $SubDomain SubDomain The SubDomain structure to add. $Cart Cart Cart structure containing the cart to add this product to. Return values None. RemoveSubDomain Delete an existing sub domain. void RemoveSubDomain( SubDomain $SubDomain ) Parameters Parameter Type Description $SubDomain SubDomain The SubDomain structure object to remove. Return values None. API Structures Data structures are used by the API functions to send or return multiple parameters. Account Page 84 of 126 Fasthosts Reseller API Developer Guide Contains information on a customer account. struct Account { string $ParentAccountNumber; string $AccountNumber; string $FullName; datetime $OpenedDate; Contact $Contact; string $VATNumber; string $Username; string $Password; } Property Type Description $ParentAccountNumber String Your reseller account number. (Read only). $AccountNumber String The customer account number. (Read only). $FullName String Customers full name. (Read only). $OpenedDate DateTime The date and time the account was opened. (Read only). $Contact Contact Contact structure containing this customers contact details. $VATNumber String Customers company VAT number, if applicable. $Username String The username for the customers account (typically their email address). $Password String The password for the customers account. Notes The $Contact property uses the Contact structure, details of which can be found on page 90. AccountList Contains array of accounts returned by GetAccountList function call. struct AccountList { array $Objects; Page 85 of 126 Fasthosts Reseller API Developer Guide int $TotalCount; } Property Type Description $Objects Array of AccountSummary Array of AccountSummary objects containing details of each account. $TotalCount Integer Number of accounts. Notes See the chapter Lists and paging on page 116. AccountSummary Contains account summary information. struct AccountSummary { string $AccountNumber; string $ParentAccountNumber; string $FullName; datetime $OpenedDate; } Property Type Description $AccountNumber String Account number $ParentAccountNumber String Your reseller account number. $FullName String Full name of customer associated with account. $OpenedDate DateTime Date and time the account was opened. AdvancedFTPAccount Contains details for a Global Custom FTP Account which can have multiple FTP Account Paths associated with it. Page 86 of 126 Fasthosts Reseller API Developer Guide struct AdvancedFTPAccount { string $Username string $Password } Property Type Description $Username String The username for the FTP account. $Password String The password for the FTP account, which must comply with the password complexity rules (see page 22). AdvancedFTPAccountList Contains a list of Advanced FTP Accounts struct AdvancedFTPAccountList { array $Objects int $TotalCount } Property Type Description $Objects Array of AdvancedFTPAccount An array of AdvancedFTPAccount structures containing details of each individual FTP account. $TotalCount Integer The total number of Advanced FTP accounts. APIError Contains details of error message from API. struct APIError { int $Code; string $Object; string $Property; string $Message; Page 87 of 126 Fasthosts Reseller API Developer Guide } Property Type Description $Code Integer The error code. $Object String The object the error relates to. $Property String The property in the object the error belongs to. $Message String The error message encountered. Notes See Error handling on page 118. AutoReply The AutoReply object is contained within the MailBox object, and specifies whether the auto-reply functionality is enabled on this mailbox, and what the auto-reply message is. struct AutoReply { boolean $Enabled; string $Message; } Property Type Description $Enabled Boolean If true, AutoReply is enabled. $Message String Message to automatically reply with. BandwidthPeriod The BandwidthPeriod object is contained within the BandwidthQuota object, which in turn is contained within the Website object. It specifies which period the bandwidth quota is valid for. Page 88 of 126 Fasthosts Reseller API Developer Guide struct BandwidthPeriod { string $Base; datetime $LastReset; } Property Type Description $Base String “Day” / “Month” / “Year” $LastReset DateTime Last time the bandwidth usage was reset to 0. Notes If a customer has a limited bandwidth quota per day, month, or year, the $Base property will have a value of “Day”, “Month”, or “Year” respectively. BandwidthQuota Stores bandwidth quota details. struct BandwidthQuota { BandwidthPeriod $Period; int $Size; int $Used; } Property Type Description $Period BandwidthPeriod The period this usage applies to. $Size Integer The total allowed bandwidth usage per period. $Used Integer The used bandwidth so far during this period. Cart Before installing any services in a customer’s account, a shopping cart needs to be created. Any items that require purchase of stock by the reseller will be added to the cart and charged to the reseller’s account when the order is processed. Page 89 of 126 Fasthosts Reseller API Developer Guide struct Cart { string $AccountNumber; string $CartNumber; boolean $IsTest; } Property Type Description $AccountNumber String Customer account number cart is associated with. $CartNumber String Unique reference number for this cart. $IsTest Boolean Determines if this is a test cart or not. Notes This structure is created by the API and returned when CreateCart or CreateTestCart is called. It passed as a parameter to service-installation API calls, and if the reseller does not have the stock to provision the service in the customer’s account, the stock will be added to the cart, and charged for when the order is processed. Contact Contains customer contact details. struct Contact { string $FirstName; string $LastName; string $Initials; string $Address1; string $Address2; string $City; string $Region; string $AreaCode; string $Country; string $Email; string $PhoneNumber; string $MobileNumber; string $FaxNumber; Page 90 of 126 Fasthosts Reseller API Developer Guide string $Company; string $CompanyNumber; string $UKRegistrantType; } Property Type Description $Title String Customer’s title. $FirstName String Customer’s given name. $LastName String Customer’s surname. $Initials String Customer’s Initials. $Address1 String House name or number. $Address2 String Street name. $City String City/town/village. $Region String The county or province. $AreaCode String Postal or zip code. $Country Country Country structure containing the Country details. $Email String Customers contact email address. $PhoneNumber String Phone number. $MobileNumber String Mobile phone number. $FaxNumber String Fax number. $Company String Name of the customer’s company. $CompanyNumber String Company registration number. $UKRegistrantType String Specify the Registrant type when registering UK domains (see notes below). Notes The $Country property is a Country structure, which contains all of the country details. See the Country structure reference for more details. The phone number must take the format: +Country-Area-Number. For example +441452-123123. If the phone number is in any other format the API will return error 109 (Invalid Data). When registering a .uk domain name Nominet, the governing body for UK domains, require you to specify the Registrant type, which is supplied through the Page 91 of 126 Fasthosts Reseller API Developer Guide $UKRegistrantType parameter. This must take one of the following formats: LTD, PLC, IND, FIND, STRA, PRTNR, OTHER, LLP, IP, RCHAR, FCORP, or FOTHER. Value Description LTD UK Limited Company PLC UK Public Company IND UK Individual FIND Non-UK Individual STRA UK Sole Trader PRTNR UK Partnership OTHER UK Other LLP UK Limited Liability Partnership IP UK Industrial/Provident Registered Company RCHAR UK Registered Charity FCORP Non-UK Corporation FOTHER Non-UK Other Country Contains country details. struct Country { string $Code; string $Name; } Property Type Description $Code String Two character country code. $Name String Name of the country. (Read only). Notes The $Code property is the two character code for the country. For example, GB, US, IE. You can use the GetCountryCodes API function call to retrieve the full list of countries. The list of country codes is available on page 121. Page 92 of 126 Fasthosts Reseller API Developer Guide Database Contains information on a database. struct Database { string $Name; string $Type; StorageQuota $Storage; array $Users; Package $Package; } Property Type Description $Name String Name of the database. $Type String Type of database (“MySQL” or ”MSSQL”). $Storage StorageQuota StorageQuota structure containing quota details. (Read only). $Users Array of DatabaseUser Array of DatabaseUser structure objects containing information on all users. $Package Package Package structure containing the hosting package details this database belongs to. (Read only). Notes See the DatabaseUser section (page 94) to see how users are edited. DatabaseList Contains a list of Database objects, which are returned by the GetDatabaseList function call. struct DatabaseList { array $Objects; int $TotalCount; } Page 93 of 126 Fasthosts Reseller API Developer Guide Property Type Description $Objects Array of Database Array of Database objects. $TotalCount Integer Total number of databases. Notes See the chapter Lists and paging on page 116. DatabaseUser Stores details on a database user. struct DatabaseUser { string $Username; string $Password; boolean $IsDBO; } Property Type Description $Username String Username of the database user. $Password String Password this user needs to login to the database. $IsDBO Boolean Determines if this user is a database owner. Notes The DatabaseUser object is contained in the Database object. Users can be added, removed or edited by adding, removing or editing the $Users property in the Database object. DomainContacts Contains four domain contacts, the Owner, Administrative, Technical, and Billing. Page 94 of 126 Fasthosts Reseller API Developer Guide struct DomainContacts { Contact $Owner; Contact $Admin; Contact $Technical; Contact $Billing; } Property Type Description $Owner Contact Contact structure object containing Owner contact details. $Admin Contact Contact structure object containing Administrative contact details. $Technical Contact Contact structure object containing Technical contact details. $Billing Contact Contact structure object containing Billing contact details. Notes The DomainContacts object is contained in the DomainRegistration object. DomainPrivacy Stores information on the installation of domain privacy. struct DomainPrivacy { boolean $Enabled; } Property Type Description $Enabled Boolean True if domain privacy installed. Notes The DomainPrivacy object is contained in the DomainRegistration object. Page 95 of 126 Fasthosts Reseller API Developer Guide DomainRegistration Contains domain registration information. struct DomainRegistration { DomainContacts $Contacts; boolean $AllowTransferAway; boolean $AutoRenew; string $AuthCode; string $IPSTag; array $NameServers; string $DomainName; boolean $IsTransfer; datetime $ExpiryDate; datetime $RegistrationDate; int $RegistrationTerm; DomainPrivacy $Privacy; Package $Package; } Property Type Description $Contacts DomainContacts DomainContacts structure containing Admin, Billing, Owner, and Technical contact details. $AllowTransferAway Boolean True if the domain is not locked to Fasthosts. $AutoRenew Boolean If True this domain will automatically renew when due. $AuthCode String String containing the transfer Authorisation code. (GTLD domains). $IPSTag String String containing the IPS Tag (UK domains). $NameServers Array of NameServer Array of NameServer structure objects containing details on each nameserver. $DomainName String Domain name. (Read only). $IsTransfer Boolean True if this domain was transferred to Fasthosts instead of being registered directly. (Read only). $ExpiryDate DateTime Date of expiry. (Read only). $RegistrationDate DateTime Date of registration. (Read only). $RegistrationTerm Integer Number of years this domain is registered for. (Read only). $Privacy DomainPrivacy DomainPrivacy structure object containing privacy Page 96 of 126 Fasthosts Reseller API Developer Guide state. $Package Package Package structure object containing details of the package with which this domain is associated. (Read only). DomainStatus Contains details of any domain. struct DomainStatus { string $DomainName; boolean $TLDSupportsTransfer; boolean $TLDSupportsRegistration; boolean $CanTransfer; boolean $CanRegister; boolean $CanHost; int $MinRegPeriod; int $MaxRegPeriod; boolean $RequiresAuthCode; string $AdminEmail; boolean $Locked; string $IPSTag; } Property Type Description $DomainName String Full domain name. $TLDSupportsTransfer Boolean True if Fasthosts supports the transfer in of domains with this TLD. $TLDSupportsRegistration Boolean True if this domain name is supported for registration through Fasthosts. $CanTransfer Boolean True if a transfer can be initiated now. $CanRegister Boolean True if this domain can be registered now. $CanHost Boolean True if this domain can be hosted in a customer’s account. $MinRegPeriod Integer Minimum number of years this domain can be registered for. $MaxRegPeriod Integer Maximum number of years this domain can be registered for. $RequiresAuthCode Boolean True if this domain requires an authorisation code for transfer. Page 97 of 126 Fasthosts Reseller API Developer Guide $AdminEmail String The admin email address listed against this domain. $Locked Boolean True if domain is locked. $IPSTag String IPS Tag (UK domains only). Notes Use this object by calling GetDomainStatus to determine the registration status of a domain. If the domain can be registered with Fasthosts, $CanRegister will be true. If the domain can be hosted with Fasthosts, $CanHost will be true. DomainSummary Contains summary information of a domain name. struct DomainSummary { string $DomainName; boolean $IsTransfer; datetime $ExpiryDate; datetime $RegistrationDate; int $RegistrationTerm; DomainPrivacy $Privacy; Package $Package; } Property Type Description $DomainName String Name of the domain. $IsTransfer Boolean True if this domain was transferred into Fasthosts instead of registered. $ExpiryDate DateTime Expiry date. $RegistrationDate DateTime Date the domain was registered. $RegistrationTerm Integer Number of years this domain is registered for. $Privacy DomainPrivacy DomainPrivacy structure object containing privacy details. $Package Package Package structure object containing details of the package this domain is associated with. Page 98 of 126 Fasthosts Reseller API Developer Guide DomainSummaryList Contains a list of domain summaries. struct DomainSummaryList { array $Objects; int $TotalCount; } Property Type Description $Objects Array of DomainSummary DomainSummary structure object containing summary details for each domain in the list. $TotalCount Integer Total number of items. Notes See the chapter Lists and paging on page 116. ErrorPage Stores details of an error page. struct ErrorPage { int $Code; string $Page; } Property Type Description $Code Integer Error page code, see notes. $Page String URL of the error page displayed. Notes The ErrorPage object is contained in the Website object, and associates custom error Page 99 of 126 Fasthosts Reseller API Developer Guide pages with HTTP error codes. The supported error codes are: 400 - Bad request: occurs when server doesn't recognise a request. 401 - Unauthorised: appears when an incorrect username and password are supplied. 403 - Forbidden: either the index page is missing or the visitor is trying to view folders directly. It can also occur if web server permissions prevent a script from running. 404 - Not found: given when a web address is typed incorrectly or a particular web page no longer exists. 500 - Internal server error: non-specific error caused by an error in a web script or a problem with the server itself. FTPAccount Contains details of a custom FTP account. struct FTPAccount { string $Username; string $Password; string $RootFolder; FTPPermissions $Permissions; Package $Package; } Property Type Description $Username String FTP account username $Password String FTP account password $RootFolder String Root folder of the FTP account. $Permissions FTPPermissions FTPPermissions structure containing the permissions this FTP account should possess. $Package Package Package structure containing the package to associate this FTP account with. (Read only). FTPAccountList Contains a list of FTP accounts. Page 100 of 126 Fasthosts Reseller API Developer Guide struct FTPAccountList { array $Objects; int $TotalCount; } Property Type Description $Objects Array of FTPAccount Array of FTPAccount structures containting details of each individual FTP account. $TotalCount Integer Total number of FTP accounts. Notes See the chapter Lists and paging on page 116. FTPAccountPath This data structure contains details of an FTP Account Path for a folder within a website. Different access permissions can be specified. struct FTPAccountPath { string $DomainName string $RootFolder FTPPermissions $Permissions } Property Type Description $DomainName String The domain name of the website with which the path is associated. $RootFolder String The root folder of the website where permission is granted for access. For example “/htdocs/”. $Permissions FTPPermissions An FTPPermissions structure containing access permissions for the path. Page 101 of 126 Fasthosts Reseller API Developer Guide FTPAccountPathList Contains a list of FTP Account Paths. struct FTPAccountPathList { array $Objects int $TotalCount } Property Type Description $Objects Array of FTPAccountPath An array of FTPAccountPath structures which contain details of each individual FTP account. $TotalCount Integer The total number of FTP paths. FTPPermissions Stores permissions for an FTP account. struct FTPPermissions { boolean $CanViewFiles; boolean $CanEditFiles; boolean $CanDeleteFiles; boolean $CanViewFolders; boolean $CanAddFolders; boolean $CanDeleteFolders; } Property Type Description $CanViewFiles Boolean User able to view files. $CanEditFiles Boolean User able to edit files. $CanDeleteFiles Boolean User able to delete files. $CanViewFolders Boolean User able to view folders. $CanAddFolders Boolean User able to add new folders. Page 102 of 126 Fasthosts Reseller API Developer Guide $CanDeleteFolders Boolean User able to delete folders. Notes The FTPPermissions object is contained in the FTPAccount object and refers to permissions for that FTP account. MailBox Stores information on a customer’s mailbox. struct MailBox { string $Username; string $Password; string $DisplayName; string $Type; StorageQuota $Storage; AutoReply $AutoReply; MailForwarding $Forwarding; SpamFiltering $SpamFiltering; Package $Package; } Property Type Description $Username String Username of the mailbox. $Password String Password used to protect the mailbox. Not used if Type is “Forwarding”. $DisplayName String Display name (Professional and Hosted exchange mailboxes only). $Type String The type of mailbox: “Starter”, “StarterPlus”, “Advanced”, “Maillite”, “Mailextra”, “Forwarding”, “Professional”, “Hex2013_25gb” and “Hex2013_50gb” $Storage StorageQuota Storage structure containing quota details. Not used if Type is “Forwarding”. (Read only). $AutoReply AutoReply AutoReply structure containing AutoReply details. Only used if Type is “Advanced”. $Forwarding MailForwarding MailForwarding structure containing details of any forwarding set up on this mailbox. Not used if Type is “Professional”, “Hex2013_25gb” or “Hex2013_50gb”. Page 103 of 126 Fasthosts Reseller API Developer Guide $SpamFiltering SpamFiltering SpamFiltering structure containing spam filtering details. Only used if Type is “Advanced” or “Professional”, “Hex2013_25gb” or “Hex2013_50gb”. $Package Package Package structure containing details of the package this mailbox is associated with. (Read only). MailBoxList Contains a list of mailboxes. struct MailBoxList { array $Objects; int; $TotalCount } Property Type Description $Objects Array of MailBox Array of MailBox structure objects containing the properties of all mailboxes in this list. $TotalCount Integer Total number of all items. Notes See the chapter Lists and paging on page 116. MailForwarding Contains details of mail forwarding. struct MailForwarding { Array $Addresses; } Property Type Description Page 104 of 126 Fasthosts Reseller API Developer Guide $Addresses Array of String Array of string values containing forwarding email addresses. Notes The MailForwarding object is contained in the MailBox object, and specifies forwarding email addresses for that mailbox. MatrixStats Contains information on a customer’s MatrixStats product. struct MatrixStats { string $Username; string $Password; boolean $Installed; Package $Package; } Property Type Description $Username String MatrixStats username. $Password String MatrixStats password. $Installed Boolean True if this service is currently installed on the package. (Read only). $Package Package Package structure containing the details of the package. (Read only). NameServer Contains details of a nameserver. struct NameServer { string $Name; string $IP; } Page 105 of 126 Fasthosts Reseller API Developer Guide Property Type Description $Name String Name of the nameserver, eg ns1.yourdomain.com. $IP String IP address the nameserver points to. Notes The NameServer object is contained in the DomainRegistration object, and specifies a nameserver used for that domain. Order Stores details of a purchase order by the reseller for provisioning stock in a customer’s account when a Cart is checked out. struct Order { string $OrderNumber; boolean $IsTest; } Property Type Description $OrderNumber String The unique order number. $IsTest Boolean Determines if this is a test order. Notes After a Cart has been created, and stock has been added to the cart by installing services on a customer’s account, the Cart is checked out by calling CheckoutCart, and an Order object is returned. This Order can be processed or left in the pending queue or cancelled by the reseller. Once it has been processed, the reseller will be charged. Package Contains details of a hosting package. Page 106 of 126 Fasthosts Reseller API Developer Guide struct Package { string $AccountNumber; string $TemplateCode; string $DomainName; string $Status; } Property Type Description $AccountNumber String Customer account number. $TemplateCode String Template code of package. $DomainName String The domain this package is associated with. $Status String Current status of package: “PreConfigure”, “Ordered”, “Allocated”, or “Active”. Notes A hosting package goes through a number of steps once it has been ordered. Only when the $Status is “Active” is it ready for use. PackageList Contains a list of packages. struct PackageList { array $Objects; int $TotalCount; } Property Type Description $Objects Array of Package Array of Package structure objects. TotalCount Integer Total number of packages found. Page 107 of 126 Fasthosts Reseller API Developer Guide Notes See the chapter Lists and paging on page 116. Paging Used to control the display of items over several pages. Used by many functions that list accounts or services, such as GetAccountList, GetTemplateList, GetPackageList, GetDatabaseList, and GetFTPAccountList. struct Paging { int $First; int $Count; string $Filter; string $Sort; } Property Type Description $First Integer Index of first item to show. $Count Integer Total number of items displayed per page. $Filter String Apply a search filter. $Sort String Specify sorting options. Notes See the chapter Lists and paging on page 116. ScriptMap Contains a web-scripting language and code currently active in a website. struct ScriptMap { string $Code; string $Script; } Page 108 of 126 Fasthosts Reseller API Developer Guide Property Type Description $Code String Script language code. $Script String Name of script language. (Read only). Notes The ScriptMap object is contained in the Website object, and specifies a scripting language currently active in the website. To get a complete list of scripting languages that can be activated in a website, see GetScriptCodes on page 56. Session Contains session details of the current API connection. struct Session { string $SessionID; datetime $DateCreated; string $AccountNumber; } Property Type Description $SessionID String ID number of the current session. $DateCreated DateTime Date and time this session was created. $AccountNumber String Contains the account number. See notes. Notes The values assigned to the Session structure are retrieved by the Login API function call, and should be placed in the SOAP header to maintain the session for all subsequent API calls to access. If you supply the $CustomerUsername and $CustomerPassword parameters when using the Login function call (see page 37), the $AccountNumber property will contain the customer account number, otherwise it will contain your Reseller account number. Page 109 of 126 Fasthosts Reseller API Developer Guide SiteBuilder Contains details of a customer’s SiteBuilder product. struct SiteBuilder { string $Username; string $Password; string $Plan; boolean $Installed; Package $Package; } Property Type Description $Username String SiteBuilder username (Read only). $Password String SiteBuilder password. $Plan String The SiteBuilder plan. $Installed Boolean True if this service is installed on the package. (Read only). $Package Package Package structure containing details of the associated package. (Read only). Notes $Plan can contain one of the following values: “10Page”, “25Page”, “Unlimited”. SpamFiltering Contains details of spam filtering options on a mailbox. struct SpamFiltering { int $Strength; string $Action; array $WhiteList; array $BlackList; } Page 110 of 126 Fasthosts Reseller API Developer Guide Property Type Description $Strength Integer Number of filtering strength level. $Action String $WhiteList Array of String Array of string values containing email addresses on the spam White list. $BlackList Array of String Array of string values containing email addresses on the spam Black list. Notes $Strength specifies the strictness of the spam filtering on a mailbox, with 1 being the strongest and 15 being the weakest. 5 is recommended for most users. $Action specifies whether to “Tag” the subject of a message as spam, or to “Delete” the spam message completely. StorageQuota Contains the current usage of an allowed storage quota on a mailbox, website or database. struct StorageQuota { int $Size; int $Used; } Property Type Description $Size Integer Total size in MBs allowed for use. $Used Integer MBs used up. Notes The StorageQuota object is contained in MailBox, Website and Database objects, and specifies the allowed space and used-up space in those objects. Page 111 of 126 Fasthosts Reseller API Developer Guide SubDomain Stores information on a sub domain. struct Session { string $Name; string $Folder; Package $Package; } Property Type Description $name String Name of the sub domain. $Folder String The name of the folder that the sub domain uses as its root. $Package Package Package structure object containing details of the package this sub domain is associated with. (Read only). Notes A sub domain takes web requests and forwards them to a folder in your main domain. For example users.mydomain.com could forward to www.mydomain.com/users. SubDomainList Contains a list of subdomains. struct SubDomainList { array $Objects; int $TotalCount; } Property Type Description $Objects Array of SubDomain Array containing SubDomain objects for each item in this list. Page 112 of 126 Fasthosts Reseller API Developer Guide $TotalCount Integer Number of sub domains. Notes See the chapter Lists and paging on page 116. Template Stores information on a template. struct Template { string $Code; string $Name; string $Description; } Property Type Description $Code String Code of the template. $Name String Name of the template $Description String Description of the template, as set up in your control panel. Notes A template is a definition of a hosting package and the services available with it. As a reseller, you can create templates in your control panel, and give each one a unique code. For example, you can create a template for a Linux package, and give it 1 free mailbox and SiteBuilder. You could name it “Linux Star Hosting” and give it a unique code of “LINUX_STAR”. You can now resell this and install this package on new customers’ accounts. TemplateList Contains a list of templates. Page 113 of 126 Fasthosts Reseller API Developer Guide struct TemplateList { array $Objects; int $TotalCount; } Property Type Description $Objects Array of Template Array of Template structure objects. $TotalCount Integer Total number of templates. Notes See the chapter Lists and paging on page 116. TrafficDriver Stores information on a TrafficDriver product. struct TrafficDriver { string $Username; string $Password; string $Level; boolean $Installed; Package $Package; } Property Type Description $Username String Username to connect to this product. $Password String Password to connect to this product. $Level String The TrafficDriver plan: “Basic”, “High”, “Super”, or “Extreme”. $Installed Boolean True if this product is installed on the package. (Read only). $Package Package Package structure containing details of the Page 114 of 126 Fasthosts Reseller API Developer Guide package. (Read only). WebLogging Details of web logging on a website. struct WebLogging { boolean $Enabled; string $Format; string $Folder; } Property Type Description $Enabled Boolean True if logging is enabled for this website. $Format String Format of logfile: “WC3” or “CLF”. $Folder String Folder logfiles are created in. Notes The WebLogging object is contained in the Website object, and contains the details of web logging for that website. Website Stores details of a customer’s website. struct Website { string $Type; string $RootFolder; boolean $LoadBalanced; StorageQuota $Storage; BandwidthQuota $Bandwidth; Logging $Logging; array $ErrorPages; array $ScriptMap; boolean $Installed; Page 115 of 126 Fasthosts Reseller API Developer Guide Package $Package; } Property Type Description $Type String “IIS” or “Apache”. (Read only). $RootFolder String Root folder of the website, e.g. “htdocs”. $loadBalanced Boolean True if website is load balanced. (Read only). $Storage StorageQuota Storage space usage. (Read only). $Bandwidth BandwidthQuota Bandwidth usage for current period. (Read only). $Logging Logging Web-logging configuration. $ErrorPages Array of ErrorPages Custom error pages. $ScriptMap Array of ScriptMap Active scripting for website. $Installed Boolean True if website is installed in package. (Read only). $Package Package Hosting package of website. (Read only). Lists and paging The API provides several functions for returning useful lists, such as customer accounts, packages, domains, and templates. One of the parameters for all of these functions is a Paging structure containing the paging and filtering properties. The paging structure is defined as follows: struct Paging { int $First; int $Count; string $Filter; string $Sort; } Property Type Description $First Integer Index of first item to show. Page 116 of 126 Fasthosts Reseller API Developer Guide $Count Integer Total number of items displayed per page. $Filter String Apply a search filter. $Sort String Specify sorting options. $First is the index of the first item to be returned - not the page number. For example, if you want 10 items to be displayed per page and this is the third page, set this to 30. $Count is the number of items you want returned, so if you want 10 items to be displayed per page, set this value to 10. Setting the $Count to 0 is equivalent to not setting it at all – the number of items returned will not be limited, so all remaining items will appear in the list. $Filter is a filter using the API properties, which will determine the outcome of the list. For example, for the GetAccountList function you could specify: "Contact.FirstName like 'P%' and Contact.Country.Code='GB'" (this will get all customers with first names starting with P and whose country is Britain. Another example, for the GetDatabaseList funftion you could specify: "Type='MySQL'" (this will get all MySQL databases). The following operators and characters allowed in the filter string: and, or, =, <>, <, >, <=, >=, like, *, /, +, -, (, ) If specifying string values within a filter, enclose them in single quotes. When using the "like" operator, you can use a percentage sign % to represent any sequence of characters. For example "Contact.FirstName like 'Pa%' and Contact.Country.Code='GB'" would return Paul and Patrick (if they live in Great Britain) but not Peter. $Sort is a comma separated list of Object.Properties for sorting. For example for the GetAccountList function you could specify: "Contact.Surname, AccountNumber" (this will sort first by surname, then by account number). Page 117 of 126 Fasthosts Reseller API Developer Guide Another example, for the GetDatabaseList function you could specify: "Name,Type" (this will sort by database name, then by type). Error handling SOAP has its own inbuilt error handling framework to process the API’s error codes and associated message. Errors are returned in the APIError structure, details of which can be found on page 87. PHP Errors are handled by PHP’s SoapFault exception object. 1 try 2 { 3 // Perform some task which generates a Soap Exception 4 $api->CreateAccount($customer); 5 } 6 catch (SoapFault $e) 7 { 8 // Access the APIError structure containing the exception details. 9 $error = $e->detail->APIError; 10 // Display the error code and message 11 echo $error->Code . " : " . $error->Message; 12 } ASP.NET Exceptions are handled by the SoapException exception object. 1 try 2 { 3 // Perform some task which generates a Soap Exception 4 api.CreateAccount(newUserAccount); 5 } 6 catch (SoapException soapEx) Page 118 of 126 Fasthosts Reseller API Developer Guide 7 { 8 // Parse the soap exception into useful error parts... 9 string errorCode = string.Empty; 10 string errorObject = string.Empty; 11 string errorProperty = string.Empty; 12 string errorMessage = string.Empty; 13 14 XmlDocument xDoc = new XmlDocument(); 15 xDoc.LoadXml(soapEx.Detail.InnerXml); 16 17 XmlNode errorCodeNode = xDoc.SelectSingleNode("/APIError/Code"); 18 19 if (errorCodeNode != null) 20 errorCode = errorCodeNode.InnerText; 21 22 XmlNode objectNode = xDoc.SelectSingleNode("/APIError/Object"); 23 if (objectNode != null) 24 errorObject = objectNode.InnerText; 25 26 XmlNode propertyNode = xDoc.SelectSingleNode("/APIError/Property"); 27 if (propertyNode != null) 28 errorProperty = propertyNode.InnerText; 29 30 XmlNode messageNode = xDoc.SelectSingleNode("/APIError/Message"); 31 if (messageNode != null) 32 errorMessage = messageNode.InnerText; 33 34 // Use parsed information to report more useful error message to user 35 36 throw new Exception(errorCode . " : " . errorMessage); } Error codes The error codes that the reseller API will return if encountered are shown in the table below. Error Code Message Invalid Data 101 Invalid data supplied. Invalid Paging 102 Invalid paging values supplied. Invalid Property 103 Unknown property. Object Not Found 104 [Object] not found. Invalid Filter 105 Invalid filter. Invalid API Call 106 Invalid API Call: [APICall]. Page 119 of 126 Fasthosts Reseller API Developer Guide Invalid Session 107 Invalid session ID. Not Logged In 108 Not logged in. Login Failed 109 Login failed for [Username]. Action Restricted 110 Action restricted. Object Exists 111 [Object] already exists. Domain Not Available 113 [Domain] is unavailable. AccountNotEmpty 114 [ID] is not empty and cannot be deleted. NotSupported 115 The [Property] is not supported for [Object]. TypeNotSupported 116 [Type] is not current supported on [Domain]. Notes APIError has the following structure: struct APIError { int $Code; string $Object; string $Property; string $Message; } $Code is a unique code representing an error. $Message is a human-readable English error message. $Object and $Property reference an object/property that relates to the error. For example if an invalid password is supplied for a database user, the error code returned would be 101 (Invalid Data), the Object would be “DatabaseUser”, and the Property would be “Password”. Page 120 of 126 Fasthosts Reseller API Developer Guide Appendix: List of country codes Below is a list of the countries (along with their country codes) which are returned by the GetCountryCodes API function call. AD Andorra BW Botswana ET Ethiopia AE United Arab Emirates BY Belarus FI Finland AF Afghanistan BZ Belize FJ Fiji AG Antigua And Barbuda CA Canada FK Falkland Islands AI Anguilla CC Cocos (keeling) Islands AL Albania CD Congo, the Democratic AM Armenia AN Netherlands Antilles CF Central African Republic FO Faroe Islands AO Angola CG Congo FR France AQ Antarctica CH Switzerland GA Gabon AR Argentina CI Côte D'ivoire GB United Kingdom AS American Samoa CK Cook Islands GD Grenada AT Austria CL Chile GE Georgia AU Australia CM Cameroon GF French Guiana AW Aruba CN China GG Guernsey AX Aland Islands CO Colombia GH Ghana AZ Azerbaijan CR Costa Rica GI Gibraltar BA Bosnia And Herzegovina CU Cuba GL Greenland BB Barbados CV Cape Verde GM Gambia BD Bangladesh CX Christmas Island GN Guinea BE Belgium CY Cyprus GP Guadeloupe BF Burkina Faso CZ Czech Republic GQ Equatorial Guinea BG Bulgaria DE Germany GR Greece BH Bahrain DJ Djibouti GS South Georgia And The BI Burundi DK Denmark BJ Benin DM Dominica GT Guatemala BL Saint Barthélemy DO Dominican Republic GU Guam BM Bermuda DZ Algeria GW Guinea-Bissau BN Brunei Darussalam EC Ecuador GY Guyana BO Bolivia EE Estonia HK Hong Kong BR Brazil EG Egypt HM Heard Island And BS Bahamas EH Western Sahara BT Bhutan ER Eritrea HN Honduras BV Bouvet Island ES Spain HR Croatia (Malvinas) FM Republic of Micronesia, Federated States Of South Sandwich Islands McDonald Islands Page 121 of 126 Fasthosts Reseller API Developer Guide HT Haiti LV Latvia NZ New Zealand HU Hungary LY Libyan Arab Jamahiriya OM Oman ID Indonesia MA Morocco PA Panama IE Ireland MC Monaco PE Peru IL Israel MD Moldova, Republic Of PF French Polynesia IM Isle Of Man ME Montenegro PG Papua New Guinea IN India MF Saint Martin PH Philippines IO British Indian Ocean MG Madagascar PK Pakistan Territory MH Marshall Islands PL Poland IQ Iraq MK Macedonia, The Former PM Saint Pierre And IR Iran, Islamic Republic Of IS Iceland ML Mali PN Pitcairn IT Italy MM Myanmar PR Puerto Rico JE Jersey MN Mongolia PS Palestinian Territory, JM Jamaica MO Macao JO Jordan MP Northern Mariana PT Portugal JP Japan Islands PW Palau KE Kenya MQ Martinique PY Paraguay KG Kyrgyzstan MR Mauritania QA Qatar KH Cambodia MS Montserrat RE Reunion KI Kiribati MT Malta RO Romania KM Comoros MU Mauritius RS Serbia KN Saint Kitts And Nevis MV Maldives RU Russian Federation KP Korea, Democratic MW Malawi RW Rwanda People's Republic Of MX Mexico SA Saudi Arabia KR Korea, Republic Of MY Malaysia SB Solomon Islands KW Kuwait MZ Mozambique SC Seychelles KY Cayman Islands NA Namibia SD Sudan KZ Kazakhstan NC New Caledonia SE Sweden LA Lao People's NE Niger SG Singapore Democratic Republic NF Norfolk Island SH Saint Helena LB Lebanon NG Nigeria SI Slovenia LC Saint Lucia NI Nicaragua SJ Svalbard and Jan LI Liechtenstein LK Sri Lanka NL Netherlands SK Slovakia LR Liberia NO Norway SL Sierra Leone LS Lesotho NP Nepal SM San Marino LT Lithuania NR Nauru SN Senegal LU Luxembourg NU Niue SO Somalia Yugoslav Republic Of Miquelon Occupied Mayen Page 122 of 126 Fasthosts Reseller API Developer Guide SR Suriname TN Tunisia ST Sao Tome And Principe TO Tonga SV El Salvador TR Turkey SY Syrian Arab Republic TT Trinidad and Tobago SZ Swaziland TV Tuvalu VE Venezuela TC Turks and Caicos TW Taiwan, Province Of VG Virgin Islands, British China VI Virgin Islands, U.S. Tanzania, United VN Viet Nam Republic Of VU Vanuatu Islands TD Chad TF French Southern TZ VA Holy See (Vatican City State) VC Saint Vincent and the Grenadines Territories UA Ukraine WF Wallis And Futuna TG Togo UG Uganda WS Samoa TH Thailand UM United States Minor YE Yemen TJ Tajikistan Outlying Islands YT Mayotte TK Tokelau US United States ZA South Africa TL Timor-leste UY Uruguay ZM Zambia TM Turkmenistan UZ Uzbekistan ZW Zimbabwe Page 123 of 126 Fasthosts Reseller API Developer Guide Index Account, 43 CreateCart function call, 39 Account structure, 84 CreateDatabase function call, 52 AccountList structure, 85 CreateFTPAccount function call, 65 AccountSummary structure, 86 CreateGlobalFTPAccount function call, 68 AddSubDomain function call, 83 CreateGlobalFTPAccountPath function call, 70 AdvancedFTPAccount structure, 86 CreateMailBox function call, 73 AdvancedFTPAccountList structure, 87 CreateTestCart function call, 40 APIError structure, 87 Customer orders, 5 ASP, 15 declining, 9 ASP.NET, 15 viewing, 7 AutoReply structure, 88 Database, 51 Balance Database structure, 93 adding, 6 DatabaseList structure, 93 BandwidthPeriod structure, 88 DatabaseUser structure, 94 BandwidthQuota structure, 89 DeleteFTPAccount function call, 65 CancelOrder function call, 42 DeleteGlobalFTPAccount function call, 68 Cart structure, 89 DeleteGlobalFTPAccountPath function call, 70 CheckoutCart function call, 40 DeleteMailBox function call, 73 CloseAccount function call, 45 Development environment, 14 ClosePackage function call, 51 DomainContacts structure, 94 ConfigureDatabase function call, 53 DomainPrivacy structure, 95 ConfigureFTPAccount function call, 66 DomainRegistration structure, 95 ConfigureGlobalFTPAccount function call, 69 Domains, 76 ConfigureGlobalFTPAccountPath function call, 71 DomainStatus structure, 97 ConfigureMailBox function call, 74 DomainSummary structure, 98 ConfigureMatrixStats function call, 57 DomainSummaryList structure, 98 ConfigureSiteBuilder function call, 62 DropDatabase function call, 54 ConfigureTrafficDriver function call, 59 Error codes, 119 ConfigureWebsite function call, 55 Error handling, 117 Connection Error pages, 99 details, 10 ErrorPage structure, 99 reference, 37 Examples Contact structure, 90 Adding a database, 33 Country codes, 121 Adding, modifying, and upgrading a mailbox, 29 Country structure, 92 Creating a customer account, 23 CreateAccount function call, 45 Installing a hosting package, 28 example, 23 Installing MatrixStats, 31 Page 124 of 126 Fasthosts Reseller API Developer Guide Installing SiteBuilder, 32 GetSubDomainList function call, 82 Processing an order, 34 GetTemplate function call, 48 Registering a domain, 26 GetTemplateList function call, 46, 47 Exceptions. See error handling GetTLDsForRegistration function call, 81 FTP accounts, 64 GetTLDsForTransfer function call, 82 FTPAccount structure, 100 GetTrafficDriver function call, 58 FTPAccountList structure, 100 GetWebsite function call, 55 FTPAccountPath structure, 101 Global FTP Accounts, 66 FTPAccountPathList structure, 101 Paths, 66 FTPPermissions structure, 102 InstallDomainPrivacy function call, 78 Function call reference, 36 InstallMatrixStats function call, 57 Funds. See balance InstallPackage function call, 50 GetAccount function call, 44 InstallSiteBuilder function call, 61 GetAccountBalance function call, 43 InstallTrafficDriver function call, 59 GetAccountList function call, 44 Listing, 116 GetCountryCodes Logging structure. See WebLogging structure list of country codes, 121 Login function call, 37 GetCountryCodes function call, 46 Logout function call, 38 GetDatabase function call, 52 Mailbox, 72 GetDatabaseList function call, 51 MailBox structure, 103 GetDomain function call, 80 MailBoxList structure, 103 GetDomainList function call, 79 MailForwarding structure, 104 GetDomainStatus function call, 76 MatrixStats, 56 GetDomainSuggestions function call, 81 MatrixStats structure, 104 GetFTPAccount function call, 64 Microsoft SOAP Toolkit, 15 GetFTPAccountList function call, 64 NameServer structure, 105 GetGlobalFTPAccount function call, 67 Order, 39 GetGlobalFTPAccountList function call, 67 Order structure, 106 GetGlobalFTPAccountPathsForFTPAccount function Orders. See Customer orders call, 69 Package, 49 GetMailBox function call, 72 Package structure, 106 GetMailboxList function call, 72 PackageList structure, 107 GetMatrixStats function call, 56 Paging, 116 GetPackageByDomain function call, 50 Paging structure, 107 GetPackageByTemplate function call, 49 Password GetPackageList function call, 48 changing, 12 GetScriptCodes function call, 56 finding, 11 GetSiteBuilder function call, 61 Password complexity, 22 GetSubDomain function call, 83 Paths, 66 Page 125 of 126 Fasthosts Reseller API Developer Guide Pear libraries, 15 SoapFault, 118 Pending orders. See Customer orders SpamFiltering structure, 110 PendOrder function call, 42 StorageQuota structure, 111 PHP, 14 SubDomain structure, 111 ProcessOrder function call, 41 SubDomainList structure, 112 Reference Subdomains, 82 function calls, 36 Template structure, 112 structures, 84 TemplateList structure, 113 RegisterDomain function call, 76 Templates, 46 Registration, 76 TrafficDriver, 58 RemoveMatrixStats function call, 58 TrafficDriver structure, 114 RemoveSiteBuilder function call, 62 TransferDomain function call, 77 RemoveSubDomain function call, 84 UpdateAccount function call, 43 RemoveTrafficDriver function call, 60 UpdateDomain function call, 80 RenewDomain function call, 78 UpgradeDatabaseSpace function call, 54 ScriptMap structure, 108 UpgradeMailBoxSpace function call, 74 Security considerations, 36 UpgradeMailBoxType function call, 75 Session structure, 109 UpgradeSiteBuilderPlan function call, 63 Simple Object Access Protocol, 4 UpgradeTrafficDriverLevel function call, 60 SiteBuilder, 61 Web reference, 15 SiteBuilder structure, 109 WebLogging structure, 114 SOAP, 4 Website, 55 SOAP Pear libraries. See Pear Libraries Website structure, 115 SoapException, 118 Page 126 of 126