SugarCRM SupportDocumentationSugar DeveloperSugar Developer Guide 6.5Application FrameworkWeb ServicesREST



REST service documentation.

What is REST?

REST stands for 'Representational State Transfer'. This protocol is used by Sugar to exchange information both internally and externally.

How do I access the REST service?

The REST service in SugarCRM and be found by navigating to:

Where 'sugar_url' is the url of your Sugar instance and 'version' is the latest version of the API specific to your release of Sugar. You can find out more about versioning in the section titled 'API: Versioning'.

Input / Output Datatypes

The default input / output datatype for REST is JSON / PHP serialize.

These datatype files, SugarRestJSON.php and SugarRestSerialize.php, are in:


Defining your own datatypes

You can also define you own datatype. To do this, you need to create a new file such as:


Next, you will need to override generateResponse() and serve() functions. The Serve function decodes or unserializes the appropriate datatype based on the input type; the generateResponse function encodes or serializes it based on the output type.

See service/test.html for more examples on usage. In this file, the getRequestData function, which generates URL with json, is both the input_type and the response_type. That is, the request data from the javascript to the server is json and response data from server is also json. You can mix and match any datatype as input and output. For example, you can have json as the input_type and serialize as the response_type based on your application's requirements.

REST Requests

If you are making a REST request via cURL from within the Sugar application, you can make use of the SugarHttpClient Class. This class will help automate your cURL requests for you.

REST Failure Response

If a call failure should occur, the result will be as shown below:

Name Type Description
name String Error message.
number Integer Error number.
description String Description of error.

Last modified: 01/15/2016 10:13pm