.. _hostserverapi: Hosting Service API =================== API Basics ---------- The TeamDrive Enterprise Server architecture provides an extensive application programming interface (API) that can be used to: * Script/automate processes that would otherwise require use of the web-based administration console * Obtain information about various entities and parameters (e.g. user names, licenses, storage). The API is based on XML Remote Procedure Calls (see http://en.wikipedia.org/wiki/XML-RPC for a detailed description). Only HTTP POST-Requests will be accepted. Each request must include a checksum in the URL appended as a parameter. This checksum is created by calculating a MD5 checksum over the request body appended with a server-specific salt value. The MD5 checksum value must be provided in lower case characters (e.g. by passing it through the ``tolower()`` function of the respective programming language). On the TeamDrive Registration Server Administration Console, this salt value can be obtained from the ``APIChecksumSalt`` system setting (*"Edit Settings -> RegServer"*). On a TeamDrive Hosting Service, this value is stored in the configuration setting ``APISalt`` and must match the value of the Registration Server this Hosting Service has been associated with. Each request also needs to include a ```` which is the current timestamp converted to integer. The URL to access the TeamDrive Hosting Service API looks as follows: ``https:///pbas/p1_as/api/api.htm?checksum=`` Please replace ```` with the host name of the Host or Registration Server you want to connect to. ```` needs to be replaced with the checksum of the current API request. If you are accessing the API over a local network or a VPN, you can use plain HTTP. However, when sending the data over an insecure network, you must use HTTPS for security reasons. .. note:: API access is verified by the IP address the request originated from. On the Registration Server, check the setting ``API_IP_ACCESS`` (*"Edit Distributor Settings" -> "API" -> "API_IP_ACCESS"* via the Administration Console) and make sure that the external IP address of the system performing the API call is included in the list. On the Hosting Service, the IP address must be added to the configuration setting ``APIAccessList``. Example API Call ---------------- The following shell script example outlines how an API call is generated and how the required MD5 checksum is calculated. In this example ``curl`` is used to perform the actual API call. The result is printed to the console:: #!/bin/sh URL="http://hostserver.local/pbas/p1_as/api/api.htm" CHECKSUM="d3b07384d113edec49eaa6238ad5ff00" TIMESTAMP=`date "+%s"` REQUEST="\ 3.0.003\ getdepotdata\ $TIMESTAMP\ YourUserName\ " MD5=`echo -n "$REQUEST$CHECKSUM" | md5sum | cut -f1 -d" "` curl -d "$REQUEST" "$URL?checksum=$MD5" API Usage Recommendations ------------------------- On your side of the (web-) application, you must ensure that only successfully logged in users can view or change their own data. Users should never be allowed to view data from other TeamDrive Users. Only users associated with your distributor code can be managed with API calls coming from your IP. For users with a foreign distributor code you will receive a URL which must be displayed to the user so that they can login to the website of their distributor. Error Handling -------------- The following errors can occur due to misconfiguration or service failures, they may not return valid XML. Your application should handle these failures appropriately. Wrong Apache configuration ~~~~~~~~~~~~~~~~~~~~~~~~~~ Request: ``http:///pbas/p1_as/api/service.html`` Answer:: 404 Not Found

Not Found

The requested URL /pbas/p1_as/api/service.html was not found on this server.


Apache/2.2.9 (Fedora) Server Port 80
Apache handler could not be addressed ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Request: ``http:///pbas/p1_as/api/service.html`` Answer:: 503 Service Unavailable

503 Service Unavailable

Error Processing Request

The following error occurred in \'SendCGIRequest("td2api")\' while processing your request: -12996 (-12946). Application errors ~~~~~~~~~~~~~~~~~~ Application errors will return error messages in an XML format like this:: 3.0.003 ```` and ```` (optional) are integer values. ```` is a text. Error codes regarding the API will start at -30100 (see :ref:`errorcodes`). General errors with the PrimeBase Virtual Machine or database connection are in the range between 0 and -23000. Programming errors ~~~~~~~~~~~~~~~~~~ If a program error occurs, the server will return an error similar to the following one:: Execution Error

Execution Error

An error occurred while processing your request:
Primary error code: -10005, Secondary error code: 0

"api_init.sys"@client line 7: ';' token expected in place of 'execute'.

Invalid Requests ~~~~~~~~~~~~~~~~ Invalid requests will return one of the following errors: Unknown IP Address ^^^^^^^^^^^^^^^^^^ Reply:: 3.0.004 -30000 Access denied Invalid Command ^^^^^^^^^^^^^^^ Reply:: 3.0.004 -30001 Invalid Command Invalid Request ^^^^^^^^^^^^^^^ Reply:: 3.0.004 -30002 Invalid Request Invalid XML ^^^^^^^^^^^ Reply:: 3.0.004 -30003 Invalid XML Requirements ------------ A TeamDrive user can have different Depots on different Hosting Services. A record of which user has which depot can be stored on the Registration Server using "setdepotforuser" or in your own system by storing the username, the Hosting Service URL and the depot id. .. _getdepotdataRef: Retrieve Depot Information -------------------------- .. note:: This request must be sent to each Hosting Service where the user has a Depot. Request:: 3.0.004 getdepotdata Reply: .. note:: Storage and transfer quantities are in Bytes: ``1 KB = 1024 Bytes``\ . ```` is a list of Usernames which can access the depot to create spaces. This list is empty for a default depot. :: 3.0.004 ... ... Error Cases ~~~~~~~~~~~ .. _getspacedataRef: No Depot on the Server for the User ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Reply:: 3.0.004 -30301 No Depot for User Retrieve Space Information ---------------------------- .. note:: This request must be sent to each Hosting Service where the user has a Depot. Request:: 3.0.004 getspacedata Reply: .. note:: Storage and transfer quantities are in Bytes: ``1 KB = 1024 Bytes``\ . :: 3.0.004 ... ... .. note:: The space name field is empty by default for security reasons. You can enable the returning of space names by setting the configuration options ``StoreSpaceNames`` and ``APIReturnSpaceNames`` to ``True`` via the TeamDrive Hosting Service Administration Console. Error Cases ~~~~~~~~~~~ No Depot on the Server for the User ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ See above. Depot-ID or the Combination of Username and Depot-ID is Unknown ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Reply:: 3.0.004 -30302 Depot-ID does not match .. _deletedepotRef: Delete Depot ------------ .. important:: This call will also delete all of the user's spaces **Added in 3.0.004:** ````: can be used as a free text field for the change history Request:: 3.0.004 deletedepot Reply:: 3.0.004 0 Error Cases ~~~~~~~~~~~ No Depot on the Server for the User ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ See above. Depot-ID or the Combination of Username and Depot-ID is Unknown ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ See above. .. _activatedepotRef: Activate Depot (added in 3.0.004) ----------------------------------- Request:: 3.0.004 activatedepot Reply:: 3.0.004 0 Error Cases ~~~~~~~~~~~ No Depot on the Server for the User ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ See above. Depot-ID or the Combination of Username and Depot-ID is Unknown ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ See above. .. _deactivatedepotRef: Deactivate Depot (added in 3.0.002) ----------------------------------- **Added in 3.0.004:** ````: can be used as a free text field for the change history Request:: 3.0.004 deactivatedepot Reply:: 3.0.004 0 Error Cases ~~~~~~~~~~~ No Depot on the Server for the User ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ See above. Depot-ID or the Combination of Username and Depot-ID is Unknown ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ See above. .. _deletespaceRef: Delete a Space -------------- .. note:: ```` is a comma separated list of space-id's. Request:: 3.0.004 deletespace Reply:: 3.0.004 0 Error Cases ~~~~~~~~~~~ No Depot on the Server for the User ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ See above. Depot-ID or the Combination of Username and Depot-ID is Unknown ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ See above. Space-ID or Combination of Space-ID and Depot-ID is Unknown ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Reply:: 3.0.004 -30303 Space-ID does not match .. _setdepotRef: Set Depot Limits (added in 3.0.003) ----------------------------------- .. note:: The values of ```` and ```` is in Bytes: ``1 KB = 1024 Bytes``\ . Request:: 3.0.004 setdepot Reply:: 3.0.004 0 Error Cases ~~~~~~~~~~~ No Depot on the Server for the User ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ See above. Depot-ID or the Combination of Username and Depot-ID is Unknown ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ See above. Increasing Depot Failed due to Invalid or Wrong Disclimit or Trafficlimit ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Reply:: 3.0.004 -30304 Increasing Depot failed .. _increasedepotRef: Increase Depot Limits --------------------- .. note:: The value of ```` is in Bytes: ``1 KB = 1024 Bytes``\ . **Added in 3.0.003:** ````: value is optional; if empty, the storage limit * 10 will be used for the traffic limit ````: can be used as a free text field for the change history Request:: 3.0.004 increasedepot Reply:: 3.0.004 0 Error Cases ~~~~~~~~~~~ No Depot on the Server for the User ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ See above. Depot-ID or the Combination of Username and Depot-ID is Unknown ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ See above. Increasing Depot Failed due to Invalid or Wrong increaselimit ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Reply:: 3.0.004 -30304 Increasing Depot failed .. _decreasedepotRef: Decrease Depot Limits --------------------- .. note:: The value of ```` is in Bytes: ``1 KB = 1024 Bytes``\ . **Added in 3.0.003:** ````: value is optional; if empty, the storage limit * 10 will be used for the traffic limit ````: can be used as a free text field for the change history Request:: 3.0.004 decreasedepot Reply:: 3.0.004 0 Error Cases ~~~~~~~~~~~ No Depot on the Server for the User ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ See above. Depot-ID or the Combination of Username and Depot-ID is Unknown ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ See above. Decreasing Depot Failed due to Invalid or Wrong Decreaselimit ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Reply:: 3.0.004 -30305 Decreasing Depot failed .. _addusertodepotRef: Authorize Users to Create Spaces in other Depots ------------------------------------------------ .. note:: ```` is a comma seperated list of usernames Request:: 3.0.004 addusertodepot Reply: .. note:: The reply will return a base64 encoded text in the ````-Tag. :: 3.0.004 0 Error Cases ~~~~~~~~~~~ No Depot on the Server for the User ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ See above. Depot-ID or the Combination of Username and Depot-ID is Unknown ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ See above. .. _deleteuserfromdepotRef: Remove Authorization from Users to Create Spaces in Other depots ---------------------------------------------------------------- .. note:: ```` is a comma separated list of usernames Request:: 3.0.004 deleteuserfromdepot Reply:: 3.0.004 0 Error Cases ~~~~~~~~~~~ No Depot on the Server for the User ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ See above. Depot-ID or the Combination of Username and Depot-ID is Unknown ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ See above. .. _updatecontractRef: Update Contract (added in 3.0.002) ---------------------------------- .. note:: ```` is optional Request:: 3.0.004 updatecontract Reply:: 3.0.004 0 Error Cases ~~~~~~~~~~~ Depot-ID or the Combination of Username and Depot-ID is Unknown ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ See Above Create and Deploy a Depot ------------------------- .. note:: Creating a new depot and deploying the depot file to a list of users must be done by executing a few requests to different servers. It depends on whether you want to use your own Host Server or the TeamDrive Cloud Host Server. If you are using the TeamDrive Cloud Host Servers, you have to send a :ref:`gethostfordepot ` request to the TeamDrive Registration Server. The reply will return a Hosting Service-URL dependant on your distributor code. Send the :ref:`createdepot `\ -request to the returned URL or directly to your own Host Server, if you are using one. The reply will return a depot-document. Send this document, together with a list of usernames, to the TeamDrive Registration Server using the "sendinvitation" request as described above. .. _gethostfordepotRef: Requesting a Hosting Service-URL ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. note:: In ```` send "EU", "US", or the IP-Address of the user. The ```` will only supported if the distributor has servers in different locations running. Otherwise the default Hosting Service will be used. Request:: 3.0.004 gethostfordepot Reply:: 3.0.004 Error Cases ~~~~~~~~~~~ User Unknown ^^^^^^^^^^^^ See above Account not Activated ^^^^^^^^^^^^^^^^^^^^^ See above Invalid Location ^^^^^^^^^^^^^^^^ Reply:: 3.0.004 -30112 Invalid location .. _createdepotRef: Create Depot ~~~~~~~~~~~~ .. note:: ```` is a comma separated list of usernames (this parameter is optional). **Added in 3.0.004:** ````: can be used as a free text field for the change history Request:: 3.0.004 createdepot Reply: .. note:: The reply will return a base64 encoded text in the ````\ -Tag, which must be send as an ``sendinvitation`` request, with the list of users, to the Registration Server (see Registration Server API "send invitation" using the command "sendinvitation"). :: 3.0.004 ... Error Cases ~~~~~~~~~~~ Creating depot failed due to invalid Depot-ID ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Reply:: 3.0.004 -30302 Depot-ID does not match Creating Depot Failed due to Invalid Storage Limit ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Reply:: 3.0.004 -30306 Invalid storage limit .. _createdepotwithoutuserRef: Create Depot Without User (added in 3.0.002) -------------------------------------------- .. note:: The request is similar to :ref:`createdepot `\ . Might be useful if a shop application wanted to retrieve a depot before the user has an account in the shop. **Added in 3.0.004:** ````: can be used as a free text field for the change history Request:: 3.0.004 createdepotwithoutuser Reply: .. note:: The reply will include the depot id. :: 3.0.004 .. _assignusertodepotRef: Assign User to Depot (added in 3.0.002) --------------------------------------- .. note:: This request should be used if the depot was created using the :ref:`createdepotwithoutuser ` call. If the user does not exist yet, they will be created. **Added in 3.0.004:** ````: can be used as a free text field for the change history Request:: 3.0.004 assignusertodepot Reply:: 3.0.004 0 Error Cases ~~~~~~~~~~~ No Depot on the Server for the User ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ See above Depot-ID or the Combination of Username and Depot-ID is Unknown ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ See above .. _getdepotdocumentRef: Get Depot Document ------------------ Request:: 3.0.004 getdepotdocument Reply:: 3.0.004 ... Error Cases ~~~~~~~~~~~ No Depot on the Server for the User ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ See above Depot-ID or the Combination of Username and Depot-ID is Unknown ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ See above