id
stringlengths
14
16
text
stringlengths
33
5.27k
source
stringlengths
105
270
206a7be6ad6a-22
}, "_module":"Contacts" } ] } Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Fetch_Related_Records/index.html
d1646ac9056d-0
How to Manipulate Tags (CRUD) Overview The following page will provide examples of bash script demonstrating how to use the CRUD (Create, Read, Update, Delete) endpoints for tags in the REST v11 API. Authentication First, you will need to authenticate to the Sugar API. An example is shown below: curl -X POST -H Cache-Control:no-cache -d '{ "grant_type":"password", "client_id":"sugar", "client_secret":"", "username":"admin", "password":"password", "platform":"custom_api" }' http://<site_url>/rest/v11/oauth2/token More information on authenticating can be found in the How to Authenticate and Log Out example and /oauth2/logout POST endpoint documentation. Creating Tags
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Manipulate_Tags_CRUD/index.html
d1646ac9056d-1
Creating Tags Once you get oauth_token you would need to use it in the following API Calls to create tags.  curl -X POST -H OAuth-Token:<access_token> -H Cache-Control:no-cache -d '{ "name":"Test Name", }' http://<site_url>/rest/v11/Tags More information on this API endpoint can be found in the /<module> POST documentation.  Response { "id": "12c6ee48-1000-11e8-8838-6a0001bcacb0", "name": "Tag Name", "date_entered": "2018-02-12T15:21:52+01:00", "date_modified": "2018-02-12T15:21:52+01:00",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Manipulate_Tags_CRUD/index.html
d1646ac9056d-2
"modified_user_id": "1", "modified_by_name": "Administrator", "modified_user_link": { "full_name": "Administrator", "id": "1", "_acl": { "fields": { "pwd_last_changed": { "write": "no", "create": "no" }, "last_login": { "write": "no", "create": "no" } }, "delete": "no", "_hash": "08b99a97c2e8d792f7a44d8882b5af6d" } }, "created_by": "1", "created_by_name": "Administrator", "created_by_link": {
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Manipulate_Tags_CRUD/index.html
d1646ac9056d-3
"created_by_link": { "full_name": "Administrator", "id": "1", "_acl": { "fields": { "pwd_last_changed": { "write": "no", "create": "no" }, "last_login": { "write": "no", "create": "no" } }, "delete": "no", "_hash": "08b99a97c2e8d792f7a44d8882b5af6d" } }, "description": "", "deleted": false, "name_lower": "tag name", "following": "", "my_favorite": false, "locked_fields": [], "source_id": "",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Manipulate_Tags_CRUD/index.html
d1646ac9056d-4
"locked_fields": [], "source_id": "", "source_type": "", "source_meta": "", "assigned_user_id": "1", "assigned_user_name": "Administrator", "assigned_user_link": { "full_name": "Administrator", "id": "1", "_acl": { "fields": { "pwd_last_changed": { "write": "no", "create": "no" }, "last_login": { "write": "no", "create": "no" } }, "delete": "no", "_hash": "08b99a97c2e8d792f7a44d8882b5af6d" } },
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Manipulate_Tags_CRUD/index.html
d1646ac9056d-5
} }, "_acl": { "fields": {} }, "_module": "Tags" } Creating Records with Tags You can also create tags on initial record creation. All you need to do populate the tag field as an array when creating a record. Here is an example that demonstrates using the /<module> POST endpoint. curl -X POST -H OAuth-Token:<access_token> -H Cache-Control:no-cache -d '{ name: "Test Record", tag:["First Tag", "Second Tag"] }' http://<site_url>/rest/v11/Accounts More information on this API endpoint can be found in the /<module> POST documentation. Response The data sent to the server is shown below: {
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Manipulate_Tags_CRUD/index.html
d1646ac9056d-6
Response The data sent to the server is shown below: { "id": "ea507760-0ffd-11e8-bcf5-6a0001bcacb0", "name": "Test Record", "date_entered": "2018-02-12T15:06:25+01:00", "date_modified": "2018-02-12T15:06:25+01:00", "modified_user_id": "1", "modified_by_name": "Administrator", "modified_user_link": { "full_name": "Administrator", "id": "1", "_acl": { "fields": { "pwd_last_changed": { "write": "no", "create": "no" },
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Manipulate_Tags_CRUD/index.html
d1646ac9056d-7
"last_login": { "write": "no", "create": "no" } }, "delete": "no", "_hash": "08b99a97c2e8d792f7a44d8882b5af6d" } }, "created_by": "1", "created_by_name": "Administrator", "created_by_link": { "full_name": "Administrator", "id": "1", "_acl": { "fields": { "pwd_last_changed": { "write": "no", "create": "no" }, "last_login": { "write": "no", "create": "no" } }, "delete": "no",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Manipulate_Tags_CRUD/index.html
d1646ac9056d-8
}, "delete": "no", "_hash": "08b99a97c2e8d792f7a44d8882b5af6d" } }, "description": "", "deleted": false, "facebook": "", "twitter": "", "googleplus": "", "account_type": "", "industry": "", "annual_revenue": "", "phone_fax": "", "billing_address_street": "", "billing_address_street_2": "", "billing_address_street_3": "", "billing_address_street_4": "", "billing_address_city": "", "billing_address_state": "",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Manipulate_Tags_CRUD/index.html
d1646ac9056d-9
"billing_address_state": "", "billing_address_postalcode": "", "billing_address_country": "", "rating": "", "phone_office": "", "phone_alternate": "", "website": "", "ownership": "", "employees": "", "ticker_symbol": "", "shipping_address_street": "", "shipping_address_street_2": "", "shipping_address_street_3": "", "shipping_address_street_4": "", "shipping_address_city": "", "shipping_address_state": "", "shipping_address_postalcode": "",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Manipulate_Tags_CRUD/index.html
d1646ac9056d-10
"shipping_address_postalcode": "", "shipping_address_country": "", "parent_id": "", "sic_code": "", "duns_num": "", "parent_name": "", "member_of": { "name": "", "id": "", "_acl": { "fields": [], "_hash": "654d337e0e912edaa00dbb0fb3dc3c17" } }, "campaign_id": "", "campaign_name": "", "campaign_accounts": { "name": "", "id": "",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Manipulate_Tags_CRUD/index.html
d1646ac9056d-11
"name": "", "id": "", "_acl": { "fields": [], "_hash": "654d337e0e912edaa00dbb0fb3dc3c17" } }, "following": true, "my_favorite": false, "tag": [ { "id": "ea69c120-0ffd-11e8-b5f6-6a0001bcacb0", "name": "First Tag", "tags__name_lower": "first tag" }, { "id": "eafb28e0-0ffd-11e8-8d80-6a0001bcacb0", "name": "Second Tag", "tags__name_lower": "second tag" }
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Manipulate_Tags_CRUD/index.html
d1646ac9056d-12
"tags__name_lower": "second tag" } ], "locked_fields": [], "assigned_user_id": "", "assigned_user_name": "", "assigned_user_link": { "full_name": "", "id": "", "_acl": { "fields": [], "_hash": "654d337e0e912edaa00dbb0fb3dc3c17" } }, "team_count": "", "team_count_link": { "team_count": "", "id": "1", "_acl": { "fields": [], "_hash": "654d337e0e912edaa00dbb0fb3dc3c17" } },
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Manipulate_Tags_CRUD/index.html
d1646ac9056d-13
}, "team_name": [ { "id": "1", "name": "Global", "name_2": "", "primary": true, "selected": false } ], "email": [], "email1": "", "email2": "", "invalid_email": "", "email_opt_out": "", "email_addresses_non_primary": "", "calculated_c": "", "_acl": { "fields": {} }, "_module": "Accounts" } Reading/Retrieving Tags Next, we can retrieve the records using /Tags/:record GET endpoint. Here is the example of retrieving the tag record that we created.Â
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Manipulate_Tags_CRUD/index.html
d1646ac9056d-14
curl -H OAuth-Token: -H Cache-Control:no-cache http://<site_url>/rest/v11/Tags/12c6ee48-1000-11e8-8838-6a0001bcacb0 More information on this API endpoint can be found in the /<module>/:record GET documentation.  Response { "id": "12c6ee48-1000-11e8-8838-6a0001bcacb0", "name": "Tag Name", "date_entered": "2018-02-12T15:21:52+01:00", "date_modified": "2018-02-12T15:21:52+01:00", "modified_user_id": "1", "modified_by_name": "Administrator",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Manipulate_Tags_CRUD/index.html
d1646ac9056d-15
"modified_by_name": "Administrator", "modified_user_link": { "full_name": "Administrator", "id": "1", "_acl": { "fields": { "pwd_last_changed": { "write": "no", "create": "no" }, "last_login": { "write": "no", "create": "no" } }, "delete": "no", "_hash": "08b99a97c2e8d792f7a44d8882b5af6d" } }, "created_by": "1", "created_by_name": "Administrator", "created_by_link": { "full_name": "Administrator", "id": "1",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Manipulate_Tags_CRUD/index.html
d1646ac9056d-16
"full_name": "Administrator", "id": "1", "_acl": { "fields": { "pwd_last_changed": { "write": "no", "create": "no" }, "last_login": { "write": "no", "create": "no" } }, "delete": "no", "_hash": "08b99a97c2e8d792f7a44d8882b5af6d" } }, "description": "", "deleted": false, "name_lower": "tag name", "following": "", "my_favorite": false, "locked_fields": [], "source_id": "", "source_type": "",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Manipulate_Tags_CRUD/index.html
d1646ac9056d-17
"source_id": "", "source_type": "", "source_meta": "", "assigned_user_id": "1", "assigned_user_name": "Administrator", "assigned_user_link": { "full_name": "Administrator", "id": "1", "_acl": { "fields": { "pwd_last_changed": { "write": "no", "create": "no" }, "last_login": { "write": "no", "create": "no" } }, "delete": "no", "_hash": "08b99a97c2e8d792f7a44d8882b5af6d" } }, "_acl": { "fields": {} },
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Manipulate_Tags_CRUD/index.html
d1646ac9056d-18
} }, "_acl": { "fields": {} }, "_module": "Tags" } Updating Tags You can update a tag using the /Tags/:record PUT endpoint. In this example, we are going to update the Tag record that we created in the Creating Tags section and change its name to "Renamed Tag Name". curl -X PUT -H OAuth-Token:<access_token> -H Cache-Control:no-cache -d '{ "name":"Renamed Tag Name" }' http://<site_url>/rest/v11/Tags/12c6ee48-1000-11e8-8838-6a0001bcacb0 More information on this API endpoint can be found in the /<module>/:record PUT documentation.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Manipulate_Tags_CRUD/index.html
d1646ac9056d-19
Response { "id": "12c6ee48-1000-11e8-8838-6a0001bcacb0", "name": "Renamed Tag Name", "date_entered": "2018-02-12T15:21:52+01:00", "date_modified": "2018-02-12T16:07:18+01:00", "modified_user_id": "1", "modified_by_name": "Administrator", "modified_user_link": { "full_name": "Administrator", "id": "1", "_acl": { "fields": { "pwd_last_changed": { "write": "no", "create": "no" },
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Manipulate_Tags_CRUD/index.html
d1646ac9056d-20
"last_login": { "write": "no", "create": "no" } }, "delete": "no", "_hash": "08b99a97c2e8d792f7a44d8882b5af6d" } }, "created_by": "1", "created_by_name": "Administrator", "created_by_link": { "full_name": "Administrator", "id": "1", "_acl": { "fields": { "pwd_last_changed": { "write": "no", "create": "no" }, "last_login": { "write": "no", "create": "no" } }, "delete": "no",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Manipulate_Tags_CRUD/index.html
d1646ac9056d-21
}, "delete": "no", "_hash": "08b99a97c2e8d792f7a44d8882b5af6d" } }, "description": "", "deleted": false, "name_lower": "renamed tag name", "following": "", "my_favorite": false, "locked_fields": [], "source_id": "", "source_type": "", "source_meta": "", "assigned_user_id": "1", "assigned_user_name": "Administrator", "assigned_user_link": { "full_name": "Administrator", "id": "1", "_acl": { "fields": {
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Manipulate_Tags_CRUD/index.html
d1646ac9056d-22
"id": "1", "_acl": { "fields": { "pwd_last_changed": { "write": "no", "create": "no" }, "last_login": { "write": "no", "create": "no" } }, "delete": "no", "_hash": "08b99a97c2e8d792f7a44d8882b5af6d" } }, "_acl": { "fields": {} }, "_module": "Tags" } Deleting Tags Finally, we will delete the record we created using /Tags/:record DELETE API request.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Manipulate_Tags_CRUD/index.html
d1646ac9056d-23
curl -X DELETE -H OAuth-Token:<access_token> -H Cache-Control:no-cache http://<site_url>/rest/v11/Tags/12c6ee48-1000-11e8-8838-6a0001bcacb0 More information on this API endpoint can be found in the /<module>/:record DELETE documentation.  Response {"id":"12c6ee48-1000-11e8-8838-6a0001bcacb0"} Last modified: 2023-02-03 21:09:36
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Manipulate_Tags_CRUD/index.html
cedacda7fdcb-0
How to Export a List of Records Overview An example in bash script demonstrating how to export a list of records using the v11 /<module>/export/:record_list_id REST GET endpoint. Exporting Records Authenticating First, you will need to authenticate to the Sugar API. An example is shown below: curl -X POST -H Cache-Control:no-cache -H "Content-Type: application/json" -d '{ "grant_type":"password", "client_id":"sugar", "client_secret":"", "username":"admin", "password":"password", "platform":"custom_api" }' https://{site_url}/rest/v11/oauth2/token
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Export_a_List_of_Records/index.html
cedacda7fdcb-1
More information on authenticating can be found in the How to Authenticate and Log Out example and /oauth2/logout endpoint documentation. Filtering Records Next, we will need to identify the records we want to export using the /<module>/filter endpoint. curl -s -X POST -H OAuth-Token:{access_token} -H "Content-Type: application/json" -H Cache-Control:no-cache -d '{ "filter":[ { "$or":[ { "name":{ "$starts":"A" } }, { "name":{ "$starts":"b" } } ] } ], "max_num":2, "offset":0,
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Export_a_List_of_Records/index.html
cedacda7fdcb-2
], "max_num":2, "offset":0, "fields":"id", "order_by":"date_entered", "favorites":false, "my_items":false }' https://{site_url}/rest/v11/Accounts/filter More information on the filter API can be found in the /<module>/filter documentation. Response The data received from the server is shown below: { "next_offset":2, "records":[ { "id":"f16760a4-3a52-f77d-1522-5703ca28925f", "date_modified":"2016-04-05T10:23:28-04:00", "_acl":{ "fields":{
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Export_a_List_of_Records/index.html
cedacda7fdcb-3
"_acl":{ "fields":{ } }, "_module":"Accounts" }, { "id":"ec409fbb-2b22-4f32-7fa1-5703caf78dc3", "date_modified":"2016-04-05T10:23:28-04:00", "_acl":{ "fields":{ } }, "_module":"Accounts" } ] } Creating a Record List Once we have the list of ids, we then need to create a record list in Sugar that consists of those ids. curl -s -X POST -H OAuth-Token:{access_token} -H "Content-Type: application/json" -H Cache-Control:no-cache -d '{
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Export_a_List_of_Records/index.html
cedacda7fdcb-4
"records":[ "f16760a4-3a52-f77d-1522-5703ca28925f", "ec409fbb-2b22-4f32-7fa1-5703caf78dc3" ] }' https://{site_url}/rest/v11/Accounts/record_list Response The data received from the server is shown below: { "id":"ef963176-4845-bc55-b03e-570430b4173c", "assigned_user_id":"1", "module_name":"Accounts", "records":[ "f16760a4-3a52-f77d-1522-5703ca28925f",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Export_a_List_of_Records/index.html
cedacda7fdcb-5
"ec409fbb-2b22-4f32-7fa1-5703caf78dc3" ], "date_modified":"2016-04-05 21:39:19" } Exporting Records Once we have the record list created, we can then export the CSV file. curl -i -s -X GET -H OAuth-Token:{access_token} -H Cache-Control:no-cache https://{site_url}/rest/v11/Accounts/export/ef963176-4845-bc55-b03e-570430b4173c More information on exporting records can be found in the /<module>/export/:record_list_id documentation. Response The data received from the server is shown below: HTTP/1.1 200 OK
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Export_a_List_of_Records/index.html
cedacda7fdcb-6
The data received from the server is shown below: HTTP/1.1 200 OK Date: Tue, 05 Apr 2016 21:50:32 GMT Server: Apache/2.2.29 (Unix) DAV/2 PHP/5.3.29 mod_ssl/2.2.29 OpenSSL/0.9.8zg X-Powered-By: PHP/5.3.29 Expires: Cache-Control: max-age=10, private Pragma: Content-Disposition: attachment; filename=Accounts.csv Content-transfer-encoding: binary Last-Modified: Tue, 05 Apr 2016 21:50:32 GMT ETag: 9b34f5d74e0298aaf7fd1f27d02e14f2
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Export_a_List_of_Records/index.html
cedacda7fdcb-7
Content-Length: 1703 Connection: close Content-Type: application/octet-stream; charset=ISO-8859-1 "Name","ID","Website","Office Phone","Alternate Phone","Fax","Billing Street","Billing City","Billing State","Billing Postal Code","Billing Country","Shipping Street","Shipping City","Shipping State","Shipping Postal Code","Shipping Country","Description","Type","Industry","Annual Revenue","Employees","SIC Code","Ticker Symbol","Parent Account ID","Ownership","Campaign ID","Rating","Assigned User Name","Assigned User ID","Team ID","Teams","Team Set ID","Date Created","Date Modified","Modified By Name","Modified By ID","Created By","Created By ID","Deleted","test","Facebook Account","Twitter Account","Google Plus ID","DUNS","Email","Invalid Email","Email Opt Out","Non-primary emails"
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Export_a_List_of_Records/index.html
cedacda7fdcb-8
"Arts & Crafts Inc","ec409fbb-2b22-4f32-7fa1-5703caf78dc3","www.hrinfo.tw","(252) 456-8602","","","777 West Filmore Ln","Los Angeles","CA","77076","USA","777 West Filmore Ln","Los Angeles","CA","77076","USA","","Customer","Hospitality","","","","","","","","","Max Jensen","seed_max_id","West","West, East, Global","dec43cb2-5273-8be2-968a-5703cadee75f","2016-04-05 10:23","2016-04-05
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Export_a_List_of_Records/index.html
cedacda7fdcb-9
10:23","2016-04-05 10:23","Administrator","1","Administrator","1","0","","","","","","[email protected]","0","0","[email protected],0,0"
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Export_a_List_of_Records/index.html
cedacda7fdcb-10
"B.H. Edwards Inc","f16760a4-3a52-f77d-1522-5703ca28925f","www.sectiondev.edu","(361) 765-0216","","","111 Silicon Valley Road","Persistance","CA","29709","USA","111 Silicon Valley Road","Persistance","CA","29709","USA","","Customer","Apparel","","","","","","","","","Sally Bronsen","seed_sally_id","West","West","West","2016-04-05 10:23","2016-04-05 10:23","Administrator","1","Administrator","1","0","","","","","","[email protected]","0","1","[email protected],0,0"
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Export_a_List_of_Records/index.html
cedacda7fdcb-11
You can also output the results directly to a CSV file by omitting the header data and output the results directly to a new CSV file. curl -s -X GET -H OAuth-Token:{access_token} -H -H Cache-Control:no-cache https://{site_url}/rest/v11/Accounts/export/ef963176-4845-bc55-b03e-570430b4173c > Output.csv Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Export_a_List_of_Records/index.html
ff39b51b98c7-0
How to Unfollow a Record Overview An example in bash script demonstrating how to unfollow a record using the v11 /<module>/:record/unsubscribe REST DELETE endpoint. Unfollowing a Record Authenticating First, you will need to authenticate to the Sugar API. An example is shown below: curl -X POST -H Cache-Control:no-cache -H "Content-Type: application/json" -d '{ "grant_type":"password", "client_id":"sugar", "client_secret":"", "username":"admin", "password":"password", "platform":"custom_api" }' https://{site_url}/rest/v11/oauth2/token
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Unfollow_a_Record/index.html
ff39b51b98c7-1
More information on authenticating can be found in the How to Authenticate and Log Out example and /oauth2/logout endpoint documentation. Unfollowing a Record Next, we can unfollow a specific record using the /<module>/:record/unsubscribe endpoint. curl -s -X DELETE -H OAuth-Token:{access_token} -H Cache-Control:no-cache https://{site_url}/rest/v11/Accounts/e7b0d745-0a3e-c896-5358-5708113786d7/unsubscribe More information on the unsubscribe API can be found in the /:record/unsubscribe DELETE documentation. Response The data received from the server is shown below: true
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Unfollow_a_Record/index.html
ff39b51b98c7-2
Response The data received from the server is shown below: true Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Unfollow_a_Record/index.html
1941fd4dfd2b-0
How to Use the Global Search Overview An example in bash script demonstrating how to globally search for records using the REST v11 /search GET endpoint. Authenticating First, you will need to authenticate to the Sugar API. An example is shown below: curl -X POST -H Cache-Control:no-cache -H "Content-Type: application/json" -d '{ "grant_type":"password", "client_id":"sugar", "client_secret":"", "username":"admin", "password":"password", "platform":"custom_api" }' https://{site_url}/rest/v11/oauth2/token More information on authenticating can be found in the How to Authenticate and Log Out example and /oauth2/logout endpoint documentation. Searching Records
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Use_the_Global_Search/index.html
1941fd4dfd2b-1
Searching Records Next, we will need to identify the records we want to see using the /search endpoint. In this case, we are going to search for all records that have the email address of '[email protected]'.  In this example, there are 3 records, an Account, a Contact and a Lead. curl -s -X GET -H OAuth-Token:{access_token} -H Cache-Control:no-cache https://{site_url}/rest/v11/search? [email protected]& max_num=3& offset=0& fields=& order_by=& favorites=false& my_items=false More information on the search API can be found in the /search documentation. Response The data received from the server is shown below: {
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Use_the_Global_Search/index.html
1941fd4dfd2b-2
Response The data received from the server is shown below: { "next_offset":-1, "records":[ { "my_favorite":false, "following":false, "id":"f31b2f00-468c-3d35-1e88-56fedbd3921d", "name":"Kaycee Gibney", "date_entered":"2016-04-01T20:34:00+00:00", "date_modified":"2016-04-06T15:16:24+00:00", "modified_user_id":"1", "modified_by_name":"Administrator", "created_by":"1", "created_by_name":"Administrator", "doc_owner":"", "user_favorites":"",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Use_the_Global_Search/index.html
1941fd4dfd2b-3
"doc_owner":"", "user_favorites":"", "description":"", "deleted":false, "assigned_user_id":"seed_jim_id", "assigned_user_name":"Jim Brennan", "team_count":"", "team_name":[ { "id":"East", "name":"East", "name_2":"", "primary":true } ], "email":[ { "email_address":"[email protected]", "invalid_email":false, "opt_out":false, "primary_address":true, "reply_to_address":false }, { "email_address":"[email protected]",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Use_the_Global_Search/index.html
1941fd4dfd2b-4
"email_address":"[email protected]", "invalid_email":false, "opt_out":true, "primary_address":false, "reply_to_address":false } ], "email1":"[email protected]", "email2":"[email protected]", "invalid_email":false, "email_opt_out":false, "email_addresses_non_primary":"", "salutation":"", "first_name":"Kaycee", "last_name":"Gibney", "full_name":"Kaycee Gibney", "title":"Mgr Operations", "facebook":"", "twitter":"", "googleplus":"",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Use_the_Global_Search/index.html
1941fd4dfd2b-5
"facebook":"", "twitter":"", "googleplus":"", "department":"", "do_not_call":false, "phone_home":"(599) 165-2396", "phone_mobile":"(215) 591-9574", "phone_work":"(771) 945-3648", "phone_other":"", "phone_fax":"", "primary_address_street":"321 University Ave.", "primary_address_street_2":"", "primary_address_street_3":"", "primary_address_city":"Santa Monica", "primary_address_state":"NY", "primary_address_postalcode":"96154", "primary_address_country":"USA", "alt_address_street":"",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Use_the_Global_Search/index.html
1941fd4dfd2b-6
"alt_address_street":"", "alt_address_street_2":"", "alt_address_street_3":"", "alt_address_city":"", "alt_address_state":"", "alt_address_postalcode":"", "alt_address_country":"", "assistant":"", "assistant_phone":"", "picture":"", "email_and_name1":"", "lead_source":"Existing Customer", "account_name":"Tracker Com LP", "account_id":"72ad6f00-e345-1cab-b370-56fedbd23deb", "dnb_principal_id":"", "opportunity_role_fields":"", "opportunity_role_id":"",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Use_the_Global_Search/index.html
1941fd4dfd2b-7
"opportunity_role_id":"", "opportunity_role":"", "reports_to_id":"", "report_to_name":"", "birthdate":"", "portal_name":"KayceeGibney33", "portal_active":true, "portal_password":true, "portal_password1":null, "portal_app":"", "preferred_language":"en_us", "campaign_id":"", "campaign_name":"", "c_accept_status_fields":"", "m_accept_status_fields":"", "accept_status_id":"", "accept_status_name":"", "accept_status_calls":"", "accept_status_meetings":"",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Use_the_Global_Search/index.html
1941fd4dfd2b-8
"accept_status_meetings":"", "sync_contact":false, "mkto_sync":false, "mkto_id":null, "mkto_lead_score":null, "_acl":{ "fields":{ } }, "_module":"Contacts", "_search":{ "score":0.70710677, "highlighted":{ "email1":{ "text":"\u003Cstrong\[email protected]\u003C\/strong\u003E", "module":"Contacts", "label":"LBL_EMAIL_ADDRESS" } } } }, { "my_favorite":false, "following":false,
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Use_the_Global_Search/index.html
1941fd4dfd2b-9
{ "my_favorite":false, "following":false, "id":"e8c641ca-1b8c-74c1-d08d-56fedbdd3187", "name":"MTM Investment Bank F S B", "date_entered":"2016-04-01T20:34:00+00:00", "date_modified":"2016-04-06T15:16:52+00:00", "modified_user_id":"1", "modified_by_name":"Administrator", "created_by":"1", "created_by_name":"Administrator", "doc_owner":"", "user_favorites":"", "description":"", "deleted":false,
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Use_the_Global_Search/index.html
1941fd4dfd2b-10
"description":"", "deleted":false, "assigned_user_id":"seed_will_id", "assigned_user_name":"Will Westin", "team_count":"", "team_name":[ { "id":"East", "name":"East", "name_2":"", "primary":true }, { "id":"West", "name":"West", "name_2":"", "primary":false } ], "email":[ { "email_address":"[email protected]", "invalid_email":false, "opt_out":false, "primary_address":true, "reply_to_address":false }, {
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Use_the_Global_Search/index.html
1941fd4dfd2b-11
"reply_to_address":false }, { "email_address":"[email protected]", "invalid_email":false, "opt_out":false, "primary_address":false, "reply_to_address":false } ], "email1":"[email protected]", "email2":"[email protected]", "invalid_email":false, "email_opt_out":false, "email_addresses_non_primary":"", "facebook":"", "twitter":"", "googleplus":"", "account_type":"Customer", "industry":"a", "annual_revenue":"", "phone_fax":"",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Use_the_Global_Search/index.html
1941fd4dfd2b-12
"annual_revenue":"", "phone_fax":"", "billing_address_street":"67321 West Siam St.", "billing_address_street_2":"", "billing_address_street_3":"", "billing_address_street_4":"", "billing_address_city":"Alabama", "billing_address_state":"NY", "billing_address_postalcode":"52272", "billing_address_country":"USA", "rating":"", "phone_office":"(012) 704-8075", "phone_alternate":"", "website":"www.salesqa.it", "ownership":"", "employees":"", "ticker_symbol":"",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Use_the_Global_Search/index.html
1941fd4dfd2b-13
"employees":"", "ticker_symbol":"", "shipping_address_street":"67321 West Siam St.", "shipping_address_street_2":"", "shipping_address_street_3":"", "shipping_address_street_4":"", "shipping_address_city":"Alabama", "shipping_address_state":"NY", "shipping_address_postalcode":"52272", "shipping_address_country":"USA", "parent_id":"", "sic_code":"", "duns_num":"", "parent_name":"", "campaign_id":"", "campaign_name":"", "_acl":{ "fields":{ } }, "_module":"Accounts",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Use_the_Global_Search/index.html
1941fd4dfd2b-14
"fields":{ } }, "_module":"Accounts", "_search":{ "score":0.70710677, "highlighted":{ "email1":{ "text":"\u003Cstrong\[email protected]\u003C\/strong\u003E", "module":"Accounts", "label":"LBL_EMAIL_ADDRESS" } } } }, { "my_favorite":false, "following":false, "id":"f3951f4d-2d17-7939-c5ec-56fedbb9e92f", "name":"Talia Knupp",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Use_the_Global_Search/index.html
1941fd4dfd2b-15
"name":"Talia Knupp", "date_entered":"2016-04-01T20:34:00+00:00", "date_modified":"2016-04-06T15:33:24+00:00", "modified_user_id":"1", "modified_by_name":"Administrator", "created_by":"1", "created_by_name":"Administrator", "doc_owner":"", "user_favorites":"", "description":"", "deleted":false, "assigned_user_id":"seed_will_id", "assigned_user_name":"Will Westin", "team_count":"", "team_name":[ { "id":"East", "name":"East",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Use_the_Global_Search/index.html
1941fd4dfd2b-16
{ "id":"East", "name":"East", "name_2":"", "primary":true }, { "id":"West", "name":"West", "name_2":"", "primary":false } ], "email":[ { "email_address":"[email protected]", "invalid_email":false, "opt_out":false, "primary_address":true, "reply_to_address":false }, { "email_address":"[email protected]", "invalid_email":false, "opt_out":false, "primary_address":false, "reply_to_address":false } ],
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Use_the_Global_Search/index.html
1941fd4dfd2b-17
"reply_to_address":false } ], "email1":"[email protected]", "email2":"[email protected]", "invalid_email":false, "email_opt_out":false, "email_addresses_non_primary":"", "salutation":"", "first_name":"Talia", "last_name":"Knupp", "full_name":"Talia Knupp", "title":"Senior Product Manager", "facebook":"", "twitter":"", "googleplus":"", "department":"", "do_not_call":false, "phone_home":"(963) 741-3689", "phone_mobile":"(600) 831-9872",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Use_the_Global_Search/index.html
1941fd4dfd2b-18
"phone_mobile":"(600) 831-9872", "phone_work":"(680) 991-2837", "phone_other":"", "phone_fax":"", "primary_address_street":"111 Silicon Valley Road", "primary_address_street_2":"", "primary_address_street_3":"", "primary_address_city":"Sunnyvale", "primary_address_state":"NY", "primary_address_postalcode":"99452", "primary_address_country":"USA", "alt_address_street":"", "alt_address_street_2":"", "alt_address_street_3":"", "alt_address_city":"", "alt_address_state":"",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Use_the_Global_Search/index.html
1941fd4dfd2b-19
"alt_address_city":"", "alt_address_state":"", "alt_address_postalcode":"", "alt_address_country":"", "assistant":"", "assistant_phone":"", "picture":"", "converted":false, "refered_by":"", "lead_source":"Word of mouth", "lead_source_description":"", "status":"In Process", "status_description":"", "reports_to_id":"", "report_to_name":"", "dnb_principal_id":"", "account_name":"First National S\/B", "account_description":"", "contact_id":"", "contact_name":"", "account_id":"",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Use_the_Global_Search/index.html
1941fd4dfd2b-20
"contact_name":"", "account_id":"", "opportunity_id":"", "opportunity_name":"", "opportunity_amount":"", "campaign_id":"", "campaign_name":"", "c_accept_status_fields":"", "m_accept_status_fields":"", "accept_status_id":"", "accept_status_name":"", "accept_status_calls":"", "accept_status_meetings":"", "webtolead_email1":[ { "email_address":"[email protected]", "invalid_email":false, "opt_out":false, "primary_address":true, "reply_to_address":false }, {
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Use_the_Global_Search/index.html
1941fd4dfd2b-21
"reply_to_address":false }, { "email_address":"[email protected]", "invalid_email":false, "opt_out":false, "primary_address":false, "reply_to_address":false } ], "webtolead_email2":[ { "email_address":"[email protected]", "invalid_email":false, "opt_out":false, "primary_address":true, "reply_to_address":false }, { "email_address":"[email protected]", "invalid_email":false, "opt_out":false, "primary_address":false,
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Use_the_Global_Search/index.html
1941fd4dfd2b-22
"opt_out":false, "primary_address":false, "reply_to_address":false } ], "webtolead_email_opt_out":"", "webtolead_invalid_email":"", "birthdate":"", "portal_name":"", "portal_app":"", "website":"", "preferred_language":"", "mkto_sync":false, "mkto_id":null, "mkto_lead_score":null, "fruits_c":"Apples", "_acl":{ "fields":{ } }, "_module":"Leads", "_search":{ "score":0.70710677, "highlighted":{
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Use_the_Global_Search/index.html
1941fd4dfd2b-23
"score":0.70710677, "highlighted":{ "email1":{ "text":"\u003Cstrong\[email protected]\u003C\/strong\u003E", "module":"Leads", "label":"LBL_EMAIL_ADDRESS" } } } } ] } There are 3 records shown above, the _module field tells you if the record is from Accounts, Contacts or Leads.  The _search field is an array that tells you where in the record it found the search string.  It gives you back a highlighted string that you can use for display. Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Use_the_Global_Search/index.html
914807c368c1-0
How to Authenticate and Log Out Overview An example in bash script on how to authenticate and logout of the v11 REST API using the /oauth2/token and /oauth2/logout POST endpoints. Authenticating
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Authenticate_and_Log_Out/index.html
914807c368c1-1
Authenticating The example below demonstrates how to authenticate to the REST v11 API. It is important to note that the oauth2 token arguments takes in several parameters that you should be aware of. The platform argument tends to cause confusion in that it is used to authenticate a user to a specific platform. Since Sugar only allows 1 user in the system at a time per platform, authenticating an integration script with a platform type of "base" will logout any current users in the system using those credentials. To work around this, your custom scripts should have a new platform type specified such as "custom_api" or any other static text you prefer. The client_id and client_secret parameters can be used for additional security based on client types. You can create your own client type in Admin > OAuth Keys. More information can be found in the /oauth2/token documentation. An example script is shown below:
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Authenticate_and_Log_Out/index.html
914807c368c1-2
curl -X POST -H Cache-Control:no-cache -H "Content-Type: application/json" -d '{ "grant_type":"password", "client_id":"sugar", "client_secret":"", "username":"admin", "password":"password", "platform":"custom_api" }' https://{site_url}/rest/v11/oauth2/token Response The data received from the server is shown below: { "access_token":"c6d495c9-bb25-81d2-5f81-533ef6479f9b", "expires_in":3600, "token_type":"bearer", "scope":null,
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Authenticate_and_Log_Out/index.html
914807c368c1-3
"token_type":"bearer", "scope":null, "refresh_token":"cbc40e67-12bc-4b56-a1d9-533ef62f2601", "refresh_expires_in":1209600, "download_token":"cc5d1a9f-6627-3349-96e5-533ef6b1a493" } Logout To log out of a session, a request can be made to the  /oauth2/logout POST endpoint. More information can be found in the /oauth2/logout documentation. An example extending off of the above authentication example is shown below:
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Authenticate_and_Log_Out/index.html
914807c368c1-4
curl -s -X POST -H OAuth-Token:<access_token> -H Cache-Control:no-cache https://{site_url}/rest/v11/oauth2/logout Response The data received from the server is shown below: { "success":true } Last modified: 2023-02-03 21:04:03
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/Bash/How_to_Authenticate_and_Log_Out/index.html
0f771b143661-0
PHP PHP Examples interacting with the v11 REST API.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/index.html
0f771b143661-1
TopicsHow to Export a List of RecordsAn PHP example demonstrating how to export a list of records using the v11 /<module>/export/:record_list_id REST GET endpoint.How to Filter a List of RecordsA PHP example demonstrating how to filter records using the v11 /<module>/filter REST POST endpoints.How to Favorite a RecordA PHP example demonstrating how to favorite a record using the v11 <module>/:record/favorite REST PUT API endpoint.How to Manipulate File AttachmentsA PHP example demonstrating how to attach a file to a record using the v11 <module>/:record/file/:field REST POST API endpoint, then retrieve it with the GET endpoint.How to Fetch Related RecordsA PHP example demonstrating how to fetch related records using the v11 /<module>/:record/link/:link REST GET endpoints.How to Manipulate Records (CRUD)A PHP example demonstrating
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/index.html
0f771b143661-2
REST GET endpoints.How to Manipulate Records (CRUD)A PHP example demonstrating how to use the CRUD (Create, Read, Update, Delete) endpoints in the REST v11 API.How to Follow a RecordA PHP example demonstrating how to follow a record using the v11 /<module>/:record/subscribe REST POST endpoint.How to Unfavorite a RecordA PHP example demonstrating how to unfavorite a record using the v11 /<module>/:record/unfavorite REST PUT endpoint.How to Unfollow a RecordA PHP example demonstrating how to unfollow a record using the v11 /<module>/:record/unsubscribe REST DELETE endpoint.How to Get the Most Active UsersA PHP example demonstrating how to fetch the most active users for meetings, calls, inbound emails, and outbound emails using the v11 /mostactiveusers REST GET endpoint.How to Authenticate and Log OutA PHP example on
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/index.html
0f771b143661-3
/mostactiveusers REST GET endpoint.How to Authenticate and Log OutA PHP example on how to authenticate and logout of the v11 REST API using the /oauth2/token and /oauth2/logout POST endpoints.How to PingA PHP example demonstrating how to ping using the REST v11 /ping GET endpoint.How to Fetch the Current Users TimeA PHP example demonstrating how to fetch the current users time with the v11 /ping/whattimeisit REST GET endpoint.How to Fetch Recently Viewed RecordsA PHP example demonstrating how to retrieve recently viewed records using the v11 /recent REST GET endpoint.How to Use the Global SearchA PHP example demonstrating how to globally search for records using the REST v11 /search GET endpoint.How to Check for Duplicate RecordsAn PHP example demonstrating how to check for duplicate records using the v11 /<module>/duplicateCheck REST POST endpoint.How to Manipulate
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/index.html
0f771b143661-4
the v11 /<module>/duplicateCheck REST POST endpoint.How to Manipulate QuotesA PHP example demonstrating how to manipulate Quotes and related record data such as ProductBundles, Products, and ProductBundleNotes.How to Manipulate Tags (CRUD)A PHP example demonstrating how to work with tags using the v11 REST endpoints.
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/index.html
0f771b143661-5
Last modified: 2023-02-03 21:09:36
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/index.html
30601491f6ef-0
How to Fetch Recently Viewed Records Overview A PHP example demonstrating how to retrieve recently viewed records using the v11 /recent REST GET endpoint. Authenticating First, you will need to authenticate to the Sugar API. An example is shown below: <?php $instance_url = "http://{site_url}/rest/v11"; $username = "admin"; $password = "password"; //Login - POST /oauth2/token $auth_url = $instance_url . "/oauth2/token"; $oauth2_token_arguments = array( "grant_type" => "password", //client id - default is sugar. //It is recommended to create your own in Admin > OAuth Keys "client_id" => "sugar",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Fetch_Recently_Viewed_Records/index.html
30601491f6ef-1
"client_id" => "sugar", "client_secret" => "", "username" => $username, "password" => $password, //platform type - default is base. //It is recommend to change the platform to a custom name such as "custom_api" to avoid authentication conflicts. "platform" => "custom_api" ); $auth_request = curl_init($auth_url); curl_setopt($auth_request, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_setopt($auth_request, CURLOPT_HEADER, false); curl_setopt($auth_request, CURLOPT_SSL_VERIFYPEER, 0);
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Fetch_Recently_Viewed_Records/index.html
30601491f6ef-2
curl_setopt($auth_request, CURLOPT_RETURNTRANSFER, 1); curl_setopt($auth_request, CURLOPT_FOLLOWLOCATION, 0); curl_setopt($auth_request, CURLOPT_HTTPHEADER, array( "Content-Type: application/json" )); //convert arguments to json $json_arguments = json_encode($oauth2_token_arguments); curl_setopt($auth_request, CURLOPT_POSTFIELDS, $json_arguments); //execute request $oauth2_token_response = curl_exec($auth_request); //decode oauth2 response to get token $oauth2_token_response_obj = json_decode($oauth2_token_response);
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Fetch_Recently_Viewed_Records/index.html
30601491f6ef-3
$oauth_token = $oauth2_token_response_obj->access_token; More information on authenticating can be found in the How to Authenticate and Log Out example and /oauth2/logout endpoint documentation.  Recently Viewed Records Next, we will need to identify the records we want to see using the /recent endpoint. In this case, we are going to request Accounts, Contacts and Leads. //Set up the search parameters - GET /recent $recent_url = $instance_url . "/recent"; $recent_arguments = array( "module_list" => 'Accounts,Contacts,Leads', ); //As this request is a GET we will add the arguments to the URL $recent_url .= "?" . http_build_query($recent_arguments);
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Fetch_Recently_Viewed_Records/index.html
30601491f6ef-4
$recent_request = curl_init($recent_url); curl_setopt($recent_request, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_setopt($recent_request, CURLOPT_HEADER, false); curl_setopt($recent_request, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($recent_request, CURLOPT_RETURNTRANSFER, 1); curl_setopt($recent_request, CURLOPT_FOLLOWLOCATION, 0); curl_setopt($recent_request, CURLOPT_HTTPHEADER, array( "Content-Type: application/json", "oauth-token: {$oauth_token}" )); //execute request
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Fetch_Recently_Viewed_Records/index.html
30601491f6ef-5
)); //execute request $recent_response = curl_exec($recent_request); //decode json $recent_response_obj = json_decode($recent_response); More information on the search API can be found in the /recent documentation. Request http://{site_url}/rest/v11/recent?module_list=Accounts%2CContacts%2CLeads Response The data received from the server is shown below: { "next_offset":-1, "records":[ { "my_favorite":false, "following":false, "id":"f3951f4d-2d17-7939-c5ec-56fedbb9e92f", "name":"Talia Knupp",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Fetch_Recently_Viewed_Records/index.html
30601491f6ef-6
"name":"Talia Knupp", "date_entered":"2016-04-01T15:34:00-05:00", "date_modified":"2016-04-06T10:33:24-05:00", "modified_user_id":"1", "modified_by_name":"Administrator", "created_by":"1", "created_by_name":"Administrator", "doc_owner":"", "user_favorites":"", "description":"", "deleted":false, "assigned_user_id":"seed_will_id", "assigned_user_name":"Will Westin", "team_count":"", "team_name":[ { "id":"East", "name":"East",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Fetch_Recently_Viewed_Records/index.html
30601491f6ef-7
{ "id":"East", "name":"East", "name_2":"", "primary":true }, { "id":"West", "name":"West", "name_2":"", "primary":false } ], "email":[ { "email_address":"[email protected]", "invalid_email":false, "opt_out":false, "primary_address":true, "reply_to_address":false }, { "email_address":"[email protected]", "invalid_email":false, "opt_out":false, "primary_address":false, "reply_to_address":false } ],
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Fetch_Recently_Viewed_Records/index.html
30601491f6ef-8
"reply_to_address":false } ], "email1":"[email protected]", "email2":"[email protected]", "invalid_email":false, "email_opt_out":false, "email_addresses_non_primary":"", "salutation":"", "first_name":"Talia", "last_name":"Knupp", "full_name":"Talia Knupp", "title":"Senior Product Manager", "facebook":"", "twitter":"", "googleplus":"", "department":"", "do_not_call":false, "phone_home":"(963) 741-3689", "phone_mobile":"(600) 831-9872",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Fetch_Recently_Viewed_Records/index.html
30601491f6ef-9
"phone_mobile":"(600) 831-9872", "phone_work":"(680) 991-2837", "phone_other":"", "phone_fax":"", "primary_address_street":"111 Silicon Valley Road", "primary_address_street_2":"", "primary_address_street_3":"", "primary_address_city":"Sunnyvale", "primary_address_state":"NY", "primary_address_postalcode":"99452", "primary_address_country":"USA", "alt_address_street":"", "alt_address_street_2":"", "alt_address_street_3":"", "alt_address_city":"", "alt_address_state":"",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Fetch_Recently_Viewed_Records/index.html
30601491f6ef-10
"alt_address_city":"", "alt_address_state":"", "alt_address_postalcode":"", "alt_address_country":"", "assistant":"", "assistant_phone":"", "picture":"", "converted":false, "refered_by":"", "lead_source":"Word of mouth", "lead_source_description":"", "status":"In Process", "status_description":"", "reports_to_id":"", "report_to_name":"", "dnb_principal_id":"", "account_name":"First National S\/B", "account_description":"", "contact_id":"", "contact_name":"", "account_id":"",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Fetch_Recently_Viewed_Records/index.html
30601491f6ef-11
"contact_name":"", "account_id":"", "opportunity_id":"", "opportunity_name":"", "opportunity_amount":"", "campaign_id":"", "campaign_name":"", "c_accept_status_fields":"", "m_accept_status_fields":"", "accept_status_id":"", "accept_status_name":"", "accept_status_calls":"", "accept_status_meetings":"", "webtolead_email1":[ { "email_address":"[email protected]", "invalid_email":false, "opt_out":false, "primary_address":true, "reply_to_address":false }, {
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Fetch_Recently_Viewed_Records/index.html
30601491f6ef-12
"reply_to_address":false }, { "email_address":"[email protected]", "invalid_email":false, "opt_out":false, "primary_address":false, "reply_to_address":false } ], "webtolead_email2":[ { "email_address":"[email protected]", "invalid_email":false, "opt_out":false, "primary_address":true, "reply_to_address":false }, { "email_address":"[email protected]", "invalid_email":false, "opt_out":false, "primary_address":false,
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Fetch_Recently_Viewed_Records/index.html
30601491f6ef-13
"opt_out":false, "primary_address":false, "reply_to_address":false } ], "webtolead_email_opt_out":"", "webtolead_invalid_email":"", "birthdate":"", "portal_name":"", "portal_app":"", "website":"", "preferred_language":"", "mkto_sync":false, "mkto_id":null, "mkto_lead_score":null, "fruits_c":"Apples", "_acl":{ "fields":{ } }, "_module":"Leads", "_last_viewed_date":"2016-04-06T10:33:24-05:00" },
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Fetch_Recently_Viewed_Records/index.html
30601491f6ef-14
}, { "my_favorite":false, "following":false, "id":"e8c641ca-1b8c-74c1-d08d-56fedbdd3187", "name":"MTM Investment Bank F S B", "date_entered":"2016-04-01T15:34:00-05:00", "date_modified":"2016-04-06T10:16:52-05:00", "modified_user_id":"1", "modified_by_name":"Administrator", "created_by":"1", "created_by_name":"Administrator", "doc_owner":"", "user_favorites":"", "description":"", "deleted":false,
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Fetch_Recently_Viewed_Records/index.html
30601491f6ef-15
"description":"", "deleted":false, "assigned_user_id":"seed_will_id", "assigned_user_name":"Will Westin", "team_count":"", "team_name":[ { "id":"East", "name":"East", "name_2":"", "primary":true }, { "id":"West", "name":"West", "name_2":"", "primary":false } ], "email":[ { "email_address":"[email protected]", "invalid_email":false, "opt_out":false, "primary_address":true, "reply_to_address":false }, {
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Fetch_Recently_Viewed_Records/index.html
30601491f6ef-16
"reply_to_address":false }, { "email_address":"[email protected]", "invalid_email":false, "opt_out":false, "primary_address":false, "reply_to_address":false } ], "email1":"[email protected]", "email2":"[email protected]", "invalid_email":false, "email_opt_out":false, "email_addresses_non_primary":"", "facebook":"", "twitter":"", "googleplus":"", "account_type":"Customer", "industry":"a", "annual_revenue":"", "phone_fax":"",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Fetch_Recently_Viewed_Records/index.html
30601491f6ef-17
"annual_revenue":"", "phone_fax":"", "billing_address_street":"67321 West Siam St.", "billing_address_street_2":"", "billing_address_street_3":"", "billing_address_street_4":"", "billing_address_city":"Alabama", "billing_address_state":"NY", "billing_address_postalcode":"52272", "billing_address_country":"USA", "rating":"", "phone_office":"(012) 704-8075", "phone_alternate":"", "website":"www.salesqa.it", "ownership":"", "employees":"", "ticker_symbol":"",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Fetch_Recently_Viewed_Records/index.html
30601491f6ef-18
"employees":"", "ticker_symbol":"", "shipping_address_street":"67321 West Siam St.", "shipping_address_street_2":"", "shipping_address_street_3":"", "shipping_address_street_4":"", "shipping_address_city":"Alabama", "shipping_address_state":"NY", "shipping_address_postalcode":"52272", "shipping_address_country":"USA", "parent_id":"", "sic_code":"", "duns_num":"", "parent_name":"", "campaign_id":"", "campaign_name":"", "_acl":{ "fields":{ } }, "_module":"Accounts",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Fetch_Recently_Viewed_Records/index.html
30601491f6ef-19
"fields":{ } }, "_module":"Accounts", "_last_viewed_date":"2016-04-06T10:16:52-05:00" }, { "my_favorite":false, "following":false, "id":"f31b2f00-468c-3d35-1e88-56fedbd3921d", "name":"Kaycee Gibney", "date_entered":"2016-04-01T15:34:00-05:00", "date_modified":"2016-04-06T10:16:24-05:00", "modified_user_id":"1", "modified_by_name":"Administrator", "created_by":"1",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Fetch_Recently_Viewed_Records/index.html
30601491f6ef-20
"created_by":"1", "created_by_name":"Administrator", "doc_owner":"", "user_favorites":"", "description":"", "deleted":false, "assigned_user_id":"seed_jim_id", "assigned_user_name":"Jim Brennan", "team_count":"", "team_name":[ { "id":"East", "name":"East", "name_2":"", "primary":true } ], "email":[ { "email_address":"[email protected]", "invalid_email":false, "opt_out":false, "primary_address":true, "reply_to_address":false },
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Fetch_Recently_Viewed_Records/index.html
30601491f6ef-21
"reply_to_address":false }, { "email_address":"[email protected]", "invalid_email":false, "opt_out":true, "primary_address":false, "reply_to_address":false } ], "email1":"[email protected]", "email2":"[email protected]", "invalid_email":false, "email_opt_out":false, "email_addresses_non_primary":"", "salutation":"", "first_name":"Kaycee", "last_name":"Gibney", "full_name":"Kaycee Gibney", "title":"Mgr Operations", "facebook":"",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Fetch_Recently_Viewed_Records/index.html
30601491f6ef-22
"title":"Mgr Operations", "facebook":"", "twitter":"", "googleplus":"", "department":"", "do_not_call":false, "phone_home":"(599) 165-2396", "phone_mobile":"(215) 591-9574", "phone_work":"(771) 945-3648", "phone_other":"", "phone_fax":"", "primary_address_street":"321 University Ave.", "primary_address_street_2":"", "primary_address_street_3":"", "primary_address_city":"Santa Monica", "primary_address_state":"NY", "primary_address_postalcode":"96154", "primary_address_country":"USA",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Fetch_Recently_Viewed_Records/index.html
30601491f6ef-23
"primary_address_country":"USA", "alt_address_street":"", "alt_address_street_2":"", "alt_address_street_3":"", "alt_address_city":"", "alt_address_state":"", "alt_address_postalcode":"", "alt_address_country":"", "assistant":"", "assistant_phone":"", "picture":"", "email_and_name1":"", "lead_source":"Existing Customer", "account_name":"Tracker Com LP", "account_id":"72ad6f00-e345-1cab-b370-56fedbd23deb", "dnb_principal_id":"", "opportunity_role_fields":"",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Fetch_Recently_Viewed_Records/index.html
30601491f6ef-24
"opportunity_role_fields":"", "opportunity_role_id":"", "opportunity_role":"", "reports_to_id":"", "report_to_name":"", "birthdate":"", "portal_name":"KayceeGibney33", "portal_active":true, "portal_password":true, "portal_password1":null, "portal_app":"", "preferred_language":"en_us", "campaign_id":"", "campaign_name":"", "c_accept_status_fields":"", "m_accept_status_fields":"", "accept_status_id":"", "accept_status_name":"", "accept_status_calls":"",
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_13.0/Cookbook/Web_Services/REST_API/PHP/How_to_Fetch_Recently_Viewed_Records/index.html