The Samanage REST API allows customers and developers to expand and build on the Samanage platform.
Samanage provides an API that can be used to retrieve and update asset inventory information from your Samanage account. The Samanage API also allows to create, retrieve, update and delete asset information such as computers, software, printers, risks and other assets, contracts and software licenses, and help desk tickets. The API makes it easy to create applications and interface between your business systems and your Samanage account.
Some potential application ideas:
- Integrate internal help desk / call center system to view asset information
- Automatic contract / license creation from your procurement system
- Trigger business processes based on tickets, for example new asset purchase request
- Automate asset maintenance and disposal processes
- Notify internal stakeholders of new risks and license compliance gaps
The Samanage API is built upon REST principles, making access to these actions consistent and intuitive. Collections are accessed via a URL ending in a plural noun such as '/hardwares', and to target an individual record, append it's numerical id (/hardwares/205778). To tell the API whether you are retrieving, updating, or deleting the record, make use of the "HTTP verbs", GET, PUT, and DELETE (respectively). For example, to create a new record, send a POST request to the collection's URL (/hardwares). The API will respond with a document reflecting your changes.
Tip: When building your API requests, as a best practice we recommend logging into your online Samanage account and reviewing your inventory and asset information. You can than compare the response your API calls receive with the information as shown in the online account.
The API supports the XML format. To specify the required format, add the format extension to the API call. For example, to retrieve a list of tickets in XML format, send a request to the /hardwares.xml path.
The API authentication is based on HTTP digest authentication. Clients should supply both the username and password created for integration with the API. This username and password should be supplied only upon the first request to the API. All subsequent requests will automatically use the same credentials.
curl --digest -u "username:password" "https://app.samanage.com/api.xml"
If the authentication fails, a "401 Unauthorized" message will be returned.
Usernames and passwords should never be transferred in plain text over the wire. Instead, use SSL (which can be accessed using https://) to ensure that all communication with the server is encrypted and secured.
We expect clients to provide the version number they are ready to work with in the "Accept" HTTP header. Valid "Accept" headers should specify which content type and version number the client is ready to work with. For example, "application/vnd.samanage.v1+xml".
If no "Accept" header is specified, the API will use the latest available version. We strongly recommend indicating the supported version number in the HTTP header, so when we upgrade the API version, your client won't be impacted. We will provide advanced notice when we roll out new versions of the API, so you can benefit from new capabilities.
If you request an API version that is no longer supported, the API will respond with an HTTP status code of "406 - Not Acceptable".
curl --digest -u "username:password" -H "Accept: application/vnd.samanage.v1+xml" https://app.samanage.com/hardwares.xml
Every response with a large result set will be paginated. For example, the response to /tickets.xml might look like this:
You can request a specific page by providing a "page" parameter. For example, to request the third page of the hardware list, you can use the following command:
curl --digest -u "username:password" https://app.samanage.com/hardwares.xml?page=3
To control the number of rows returned provide the per_page parameter. (You can request a maximum of 100 rows. When you make a request, the per page parameter you set will be saved until you make a new request.) For example, to request 100 rows with each result page, use the following command:
curl --digest -u "username:password" https://app.samanage.com/hardwares.xml?per_page=100
Here are a few examples of supported API calls, and the corresponding responses. These examples are shown in the form of 'curl' commands. Curl (http://en.wikipedia.org/wiki/CURL) is a command line utility used to perform HTTP requests, and is available on most Unix systems. However, you can use any tool or language that can submit a corresponding HTTP request. Curl, in the form of libcurl, has bindings in more than 30 languages, which should provide a tool that can be used in whatever language you are working with.
Every list will accept a page=<page number> parameter. The response will return those assets on the specified page.
API Entry Point
All communication with the API begins with a list of available services. Although it is possible to get to a specific service URL directly, we advise you to start with the api.xml entry point. That way, your program will still work properly if we change the underlying URLs for services in future versions of the API.
curl --digest -u "username:password" -H "Accept: application/vnd.samanage.v1+xml" -X GET https://app.samanage.com/api.xml
<?xml version="1.0" encoding="UTF-8"?>
<name>Helpdesk Tickets List</name>
<name>Other Assets List</name>
<name>Audit Log List</name>