REST API Specification – Notes

Note: In all API calls, replace the % and example values between the % signs with your own variable values.

Get Note

Replace %id% with the id of the note that you want to retrieve, %sessionId% and %token% with ‘sessionId’ and ‘token’ variables returned by the authentication process.

  • Description: Retrieve note by id.
  • URL structure: http://zurmo_url/index.php/notes/note/api/read/%id%
  • Method: GET
  • HTTP header parameters:
    Accept: application/json
    ZURMO_API_REQUEST_TYPE: REST
    ZURMO_SESSION_ID: %sessionId%
    ZURMO_TOKEN: %token%
  • Parameters: None
  • PHP sample:
    $authenticationData = login('super','super');
    //Add code to check if user is logged successfully
    
    $id = 1; // Change this with value of note id
    
    $headers = array(
        'Accept: application/json',
        'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'],
        'ZURMO_TOKEN: ' . $authenticationData['token'],
        'ZURMO_API_REQUEST_TYPE: REST',
    );
    $response = ApiRestHelper::createApiCall('http://zurmo_url/index.php/notes/note/api/read/' . $id, 'GET', $headers);
    // Decode json data
    $response = json_decode($response, true);
    if ($response['status'] == 'SUCCESS')
    {
        $note = $response['data'];
        //Do something with note
    }
    else
    {
        // Error, for example if we provided invalid note id
        $errors = $response['errors'];
        // Do something with errors
    }
    
  • Return:
    Data contains note info.

    {
      "status":"SUCCESS",
      "data":{
        "id":1,
        "createdDateTime":"2012-05-08 08:56:00",
        "modifiedDateTime":"2012-05-08 08:56:00",
        "createdByUser":{
          "id":1,
          "username":"super"
        },
        "modifiedByUser":{
          "id":1,
          "username":"super"
        },
        "owner":{
          "id":1,
          "username":"super"
        },
        "latestDateTime":"2012-05-08 08:56:00",
        "description":"First Note",
        "occurredOnDateTime":"2012-05-08 08:56:00"
      },
      "message":null,
      "errors":null
    }
    

Delete Note

Replace %id% with the id of note that you want to delete, %sessionId% and %token% with ‘sessionId’ and ‘token’ variables returned by the authentication process.

  • Description: Delete note by id.
  • URL structure: http://zurmo_url/index.php/notes/note/api/delete/%id%
  • Method: DELETE
  • HTTP header parameters:
    Accept: application/json
    ZURMO_API_REQUEST_TYPE: REST
    ZURMO_SESSION_ID: %sessionId%
    ZURMO_TOKEN: %token%
  • Parameters: None
  • PHP sample:
    $id = 1; // Change this value to note id that you want to delete
    $authenticationData = login('super','super');
    //Add code to check if user is logged successfully
    
    $headers = array(
        'Accept: application/json',
        'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'],
        'ZURMO_TOKEN: ' . $authenticationData['token'],
        'ZURMO_API_REQUEST_TYPE: REST',
    );
    $response = ApiRestHelper::createApiCall('http://zurmo_url/index.php/notes/note/api/delete/' . $id, 'DELETE', $headers);
    $response = json_decode($response, true);
    if ($response['status'] == 'SUCCESS')
    {
        // Inform user that note is deleted
    }
    else
    {
        // Error, for example if we provided invalid note id
        $errors = $response['errors'];
        // Do something with errors
    }
    
  • Return:
    {
      "status":"SUCCESS",
      "data":null,
      "message":null,
      "errors":null
    }
    

Create New Note

Replace %sessionId% and %token% with ‘sessionId’ and ‘token’ variables returned by the authentication process.

  • Description: Create new note
  • URL structure: http://zurmo_url/index.php/notes/note/api/create/
  • Method: POST
  • HTTP header parameters:
    Accept: application/json
    ZURMO_API_REQUEST_TYPE: REST
    ZURMO_SESSION_ID: %sessionId%
    ZURMO_TOKEN: %token%
  • Parameters:
    $data = Array
    (
        [description] => Note description
        [occurredOnDateTime] => 2012-05-08 08:58:56
        [modelRelations] => Array
            (
                [activityItems] => Array
                    (
                        [0] => Array
                            (
                                [action] => add
                                [modelId] => 4
                                [modelClassName] => Contact
                            )
                    )
            )
    )
    
  • PHP sample:
    $authenticationData = login('super','super');
    //Add code to check if user is logged successfully
    
    $headers = array(
        'Accept: application/json',
        'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'],
        'ZURMO_TOKEN: ' . $authenticationData['token'],
        'ZURMO_API_REQUEST_TYPE: REST',
    );
    $data = Array
    (
        'description' => 'Note description',
        'occurredOnDateTime' => '2012-05-08 08:58:56',
        // Attach note to contact
        'modelRelations' => array (
            'activityItems' => array(
                array(
                    'action' => 'add', 
                    'modelId' => $contact->id, // Replace this with contact Id (or account/opportunity id to which you want to attach note)
                    'modelClassName' => 'Contact' // Instead 'Contact' you can attach note to 'Account', 'Opportunity'
                ),
             ),
         ),
    );
    
    
    $response = ApiRestHelper::createApiCall('http://zurmo_url/index.php/notes/note/api/create/', 'POST', $headers, array('data' => $data));
    $response = json_decode($response, true);
    
    if ($response['status'] == 'SUCCESS')
    {
        $note = $response['data'];
        //Do something with note data
    }
    else
    {
        // Error
        $errors = $response['errors'];
        // Do something with errors, show them to user
    }
    
  • Return:
    {
      "status":"SUCCESS",
      "data":{
        "id":2,
        "description":"Note description",
        "occurredOnDateTime":"2012-05-08 09:03:07",
        "latestDateTime":"2012-05-08 09:03:07",
        "owner":{
          "id":1,
          "username":"super"
        },
        "createdDateTime":"2012-05-08 09:03:08",
        "modifiedDateTime":"2012-05-08 09:03:08",
        "createdByUser":{
          "id":1,
          "username":"super"
        },
        "modifiedByUser":{
          "id":1,
          "username":"super"
        }
      },
      "message":null,
      "errors":null
    }
    

Update existing note

Replace %id% with the id of the note that you want to update, %sessionId% and %token% with ‘sessionId’ and ‘token’ variables returned by the authentication process.

  • Description: Update existing note by id
  • URL structure: http://zurmo_url/index.php/notes/note/api/update/%id%
  • Method: PUT
  • HTTP header parameters:
    Accept: application/json
    ZURMO_API_REQUEST_TYPE: REST
    ZURMO_SESSION_ID: %sessionId%
    ZURMO_TOKEN: %token%
  • Parameters:
    All parameters are optional, so you can only provide properties that you want to update.
    For example:

    $data = Array
    (
        [description]    => Updated note description
        [modelRelations] => Array
            (
                [activityItems] => Array
                    (
                        [0] => Array
                            (
                                [action] => add
                                [modelId] => 5
                                [modelClassName] => Contact
                            )
                    )
            )
    )
    
  • PHP sample:
    $id = 1; // Change this value to note id that you want to change
    $authenticationData = login('super','super');
    //Add code to check if user is logged successfully
    
    $headers = array(
        'Accept: application/json',
        'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'],
        'ZURMO_TOKEN: ' . $authenticationData['token'],
        'ZURMO_API_REQUEST_TYPE: REST',
    );
    // Change note description
    $data['description']    = "Updated note description";
    $data['modelRelations'] = array(
        'activityItems' => array(
            array(
                'action' => 'add', // Another option is to delete relationship, and it that case replace 'add' with 'remove'
                'modelId' => $contact->id,
                'modelClassName' => 'Contact'
            ),
        ),
    );
    $response = ApiRestHelper::createApiCall('http://zurmo_url/index.php/notes/note/api/update/' . $id, 'PUT', $headers, array('data' => $data));
    $response = json_decode($response, true);
    if ($response['status'] == 'SUCCESS')
    {
        $note = $response['data'];
        //Do something with note data
    }
    else
    {
        // Error, for example if we provided invalid note id
        $errors = $response['errors'];
        // Do something with errors
    }
    
  • Return:
    Code will return complete updated note info.

    {
      "status":"SUCCESS",
      "data":{
        "id":2,
        "description":"Updated note description",
        "occurredOnDateTime":"2012-05-08 09:03:07",
        "latestDateTime":"2012-05-08 09:03:07",
        "owner":{
          "id":1,
          "username":"super"
        },
        "createdDateTime":"2012-05-08 09:03:08",
        "modifiedDateTime":"2012-05-08 09:03:08",
        "createdByUser":{
          "id":1,
          "username":"super"
        },
        "modifiedByUser":{
          "id":1,
          "username":"super"
        }
      },
      "message":null,
      "errors":null
    }
    

Search notes

Replace %sessionId% and %token% with ‘sessionId’ and ‘token’ variables returned by the authentication process.

  • Description: Search notes
  • URL structure: http://zurmo_url/index.php/notes/note/api/list/filter/%searchFilter%
  • Method: GET
  • HTTP header parameters:
    Accept: application/json
    ZURMO_API_REQUEST_TYPE: REST
    ZURMO_SESSION_ID: %sessionId%
    ZURMO_TOKEN: %token%
  • Query parameters:
    $searchFilter = Array
    (
        [pagination] => Array
            (
                [page] => 1
                [pageSize] => 3
            )
        [search] => Array
            (
                [description] => Some text
            )
        [sort] => description.desc
    )
    
  • PHP sample:
    $authenticationData = login('super','super');
    //Add code to check if user is logged successfully
    
    $headers = array(
        'Accept: application/json',
        'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'],
        'ZURMO_TOKEN: ' . $authenticationData['token'],
        'ZURMO_API_REQUEST_TYPE: REST',
    );
    $searchParams = array(
        'pagination' => array(
            'page'     => 1,
            'pageSize' => 3,
        ),
        'search' => array(
            'description' => '',
        ),
        'sort' => 'description.desc',
    );
    // Get first page of results
    $searchParamsQuery = http_build_query($searchParams);
    $response = ApiRestTestHelper::createApiCall('http://zurmo_url/index.php/notes/note/api/list/filter/' . $searchParamsQuery, 'GET', $headers);
    $response = json_decode($response, true);
    if ($response['status'] == 'SUCCESS')
    {
        // Do something with results
        if ($response['data']['totalCount'] > 0)
        {
            foreach ($response['data']['items'] as $item)
            {
            // Print notes
            }
        }
        else
        {
         // There are no notes
        }
    }
    else
    {
        $errors = $response['errors'];
        // Do something with errors
    }
    // Now get second page (you might wanted to check if there are results on second page first)
    $searchParams = array(
        'pagination' => array(
            'page'     => 2,
            'pageSize' => 3,
        ),
        'search' => array(
            'description' => '',
        ),
        'sort' => 'description.desc',
    );
    // Get second page of results
    $searchParamsQuery = http_build_query($searchParams);
    $response = ApiRestTestHelper::createApiCall('http://zurmo_url/index.php/notes/note/api/list/filter/' . $searchParamsQuery, 'GET', $headers);
    $response = json_decode($response, true);
    if ($response['status'] == 'SUCCESS')
    {
        // Do something with results
        if ($response['data']['totalCount'] > 0)
        {
            foreach ($response['data']['items'] as $item)
            {
            // Print notes
            }
        }
        else
        {
         // There are no notes
        }
    }
    else
    {
        $errors = $response['errors'];
        // Do something with errors
    }
    
  • Return:
    {
      "status":"SUCCESS",
      "data":{
        "totalCount":"5",
        "currentPage":2,
        "items":[
          {
            "id":3,
            "createdDateTime":"2012-05-08 09:10:53",
            "modifiedDateTime":"2012-05-08 09:10:53",
            "createdByUser":{
              "id":1,
              "username":"super"
            },
            "modifiedByUser":{
              "id":1,
              "username":"super"
            },
            "owner":{
              "id":1,
              "username":"super"
            },
            "latestDateTime":"2012-05-08 09:10:53",
            "description":"First Note",
            "occurredOnDateTime":"2012-05-08 09:10:53"
          },
          {
            "id":7,
            "createdDateTime":"2012-05-08 09:10:54",
            "modifiedDateTime":"2012-05-08 09:10:54",
            "createdByUser":{
              "id":1,
              "username":"super"
            },
            "modifiedByUser":{
              "id":1,
              "username":"super"
            },
            "owner":{
              "id":1,
              "username":"super"
            },
            "latestDateTime":"2012-05-08 09:10:54",
            "description":"Fifth Note",
            "occurredOnDateTime":"2012-05-08 09:10:54"
          }
        ]
      },
      "message":null,
      "errors":null
    }
    

Notes Dynamic Search

Replace %sessionId% and %token% with ‘sessionId’ and ‘token’ variables returned by the authentication process.

  • Description: Dynamic search notes
  • URL structure: http://zurmo_url/index.php/notes/note/api/list/filter/
  • Method: GET, POST
  • HTTP header parameters:
    Accept: application/json
    ZURMO_API_REQUEST_TYPE: REST
    ZURMO_SESSION_ID: %sessionId%
    ZURMO_TOKEN: %token%
  • Query parameters:
    $data = Array
    (
        [dynamicSearch] => Array
            (
                [dynamicClauses] => Array
                    (
                        [0] => Array
                            (
                                [attributeIndexOrDerivedType] => owner
                                [structurePosition] => 1
                                [owner] => Array
                                    (
                                        [id] => 3
                                    )
    
                            )
    
                        [1] => Array
                            (
                                [attributeIndexOrDerivedType] => name
                                [structurePosition] => 2
                                [description] => Fi
                            )
    
                        [2] => Array
                            (
                                [attributeIndexOrDerivedType] => name
                                [structurePosition] => 3
                                [description] => Se
                            )
    
                    )
    
                [dynamicStructure] => 1 AND (2 OR 3)
            )
    
        [pagination] => Array
            (
                [page] => 1
                [pageSize] => 2
            )
    
        [sort] => description.asc
    )
    
  • PHP sample:
    $authenticationData = login('super','super');
    //Add code to check if user is logged successfully
    
    $headers = array(
        'Accept: application/json',
        'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'],
        'ZURMO_TOKEN: ' . $authenticationData['token'],
        'ZURMO_API_REQUEST_TYPE: REST',
    );
    $data = array(
        'dynamicSearch' => array(
            'dynamicClauses' => array(
            array(
                'attributeIndexOrDerivedType' => 'owner',
                'structurePosition' => 1,
                'owner' => array(
                    'id' => Yii::app()->user->userModel->id,
                ),
            ),
            array(
                'attributeIndexOrDerivedType' => 'name',
                'structurePosition' => 2,
                'description' => 'Fi',
            ),
            array(
                'attributeIndexOrDerivedType' => 'name',
                'structurePosition' => 3,
                'description' => 'Se',
            ),
            ),
            'dynamicStructure' => '1 AND (2 OR 3)',
        ),
        'pagination' => array(
            'page'     => 1,
            'pageSize' => 2,
        ),
        'sort' => 'description.asc',
    );
    // Get first page of results
    $response = ApiRestTestHelper::createApiCall('http://zurmo_url/index.php/notes/note/api/list/filter/', 'POST', $headers, array('data' => $data));
    $response = json_decode($response, true);
    if ($response['status'] == 'SUCCESS')
    {
        // Do something with results
        if ($response['data']['totalCount'] > 0)
        {
            foreach ($response['data']['items'] as $item)
            {
            // Print notes
            }
        }
        else
        {
         // There are no notes
        }
    }
    else
    {
        $errors = $response['errors'];
        // Do something with errors
    }
    
  • Return:
    {
      "status":"SUCCESS",
      "data":{
        "totalCount":"5",
        "currentPage":2,
        "items":[
          {
            "id":3,
            "createdDateTime":"2012-05-08 09:10:53",
            "modifiedDateTime":"2012-05-08 09:10:53",
            "createdByUser":{
              "id":1,
              "username":"super"
            },
            "modifiedByUser":{
              "id":1,
              "username":"super"
            },
            "owner":{
              "id":1,
              "username":"super"
            },
            "latestDateTime":"2012-05-08 09:10:53",
            "description":"First Note",
            "occurredOnDateTime":"2012-05-08 09:10:53"
          },
          {
            "id":7,
            "createdDateTime":"2012-05-08 09:10:54",
            "modifiedDateTime":"2012-05-08 09:10:54",
            "createdByUser":{
              "id":1,
              "username":"super"
            },
            "modifiedByUser":{
              "id":1,
              "username":"super"
            },
            "owner":{
              "id":1,
              "username":"super"
            },
            "latestDateTime":"2012-05-08 09:10:54",
            "description":"Fifth Note",
            "occurredOnDateTime":"2012-05-08 09:10:54"
          }
        ]
      },
      "message":null,
      "errors":null
    }
    

Notes Improved Search

Replace %sessionId% and %token% with ‘sessionId’ and ‘token’ variables returned by the authentication process.

  • Description: Search notes – improved
  • URL structure: http://zurmo_url/index.php/notes/note/api/search/filter/
  • Method: GET, POST
  • HTTP header parameters:
    Accept: application/json
    ZURMO_API_REQUEST_TYPE: REST
    ZURMO_SESSION_ID: %sessionId%
    ZURMO_TOKEN: %token%
  • Query parameters:
    $data = Array
    (
        [search] => Array
            (
                [modelClassName] => Note
                [searchAttributeData] => Array
                    (
                        [clauses] => Array
                            (
                                [1] => Array
                                    (
                                        [attributeName] => owner
                                        [relatedAttributeName] => id
                                        [operatorType] => equals
                                        [value] => 1
                                    )
                                [2] => Array
                                    (
                                        [attributeName] => description
                                        [operatorType] => startsWith
                                        [value] => Fi
                                    )
                                [3] => Array
                                    (
                                        [attributeName] => description
                                        [operatorType] => startsWith
                                        [value] => Se
                                    )
                            )
                        [structure] => 1 AND (2 OR 3)
                    )
            )
        [pagination] => Array
            (
                [page] => 1
                [pageSize] => 2
            )
        [sort] => description asc
    )
    
  • PHP sample:
    $authenticationData = login('super','super');
    //Add code to check if user is logged successfully
    
    $headers = array(
        'Accept: application/json',
        'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'],
        'ZURMO_TOKEN: ' . $authenticationData['token'],
        'ZURMO_API_REQUEST_TYPE: REST',
    );
    $data = array(
      'search' => array(
        'modelClassName' => 'Note',
        'searchAttributeData' => array(
          'clauses' => array(
             1 => array(
               'attributeName'        => 'owner',
               'relatedAttributeName' => 'id',
               'operatorType'         => 'equals',
               'value'                => $userId,
             ),
             2 => array(
               'attributeName'        => 'description',
               'operatorType'         => 'startsWith',
               'value'                => 'Fi'
             ),
             3 => array(
               'attributeName'        => 'description',
               'operatorType'         => 'startsWith',
               'value'                => 'Se'
             ),
          ),
          'structure' => '1 AND (2 OR 3)',
        ),
      ),
      'pagination' => array(
        'page'     => 1,
        'pageSize' => 2,
      ),
      'sort' => 'description asc',
    );
    // Get first page of results
    $response = ApiRestTestHelper::createApiCall('http://zurmo_url/index.php/notes/note/api/search/filter/', 'POST', $headers, array('data' => $data));
    $response = json_decode($response, true);
    if ($response['status'] == 'SUCCESS')
    {
        // Do something with results
        if ($response['data']['totalCount'] > 0)
        {
            foreach ($response['data']['items'] as $item)
            {
            // Print notes
            }
        }
        else
        {
         // There are no notes
        }
    }
    else
    {
        $errors = $response['errors'];
        // Do something with errors
    }
    
  • Return:
    {
      "status":"SUCCESS",
      "data":{
        "totalCount":"5",
        "currentPage":2,
        "items":[
          {
            "id":3,
            "createdDateTime":"2012-05-08 09:10:53",
            "modifiedDateTime":"2012-05-08 09:10:53",
            "createdByUser":{
              "id":1,
              "username":"super"
            },
            "modifiedByUser":{
              "id":1,
              "username":"super"
            },
            "owner":{
              "id":1,
              "username":"super"
            },
            "latestDateTime":"2012-05-08 09:10:53",
            "description":"First Note",
            "occurredOnDateTime":"2012-05-08 09:10:53"
          },
          {
            "id":7,
            "createdDateTime":"2012-05-08 09:10:54",
            "modifiedDateTime":"2012-05-08 09:10:54",
            "createdByUser":{
              "id":1,
              "username":"super"
            },
            "modifiedByUser":{
              "id":1,
              "username":"super"
            },
            "owner":{
              "id":1,
              "username":"super"
            },
            "latestDateTime":"2012-05-08 09:10:54",
            "description":"Fifth Note",
            "occurredOnDateTime":"2012-05-08 09:10:54"
          }
        ]
      },
      "message":null,
      "errors":null
    }
    

List Note Attributes

Replace %sessionId% and %token% with ‘sessionId’ and ‘token’ variables returned by authentication process.

  • Description: List contact attributes.
  • URL structure: http://zurmo_url/index.php/notes/note/api/listAttributes
  • Method: GET
  • HTTP header parameters:
    Accept: application/json
    ZURMO_API_REQUEST_TYPE: REST
    ZURMO_SESSION_ID: %sessionId%
    ZURMO_TOKEN: %token%
  • Parameters: None
  • PHP sample
    $authenticationData = login('super','super');
    //Add code to check if user is logged successfully
    
    $headers = array(
        'Accept: application/json',
        'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'],
        'ZURMO_TOKEN: ' . $authenticationData['token'],
        'ZURMO_API_REQUEST_TYPE: REST',
    );
    $response = ApiRestHelper::createApiCall('http://zurmo_url/index.php/notes/note/api/listAttributes', 'GET', $headers);
    // Decode json data
    $response = json_decode($response, true);
    if ($response['status'] == 'SUCCESS')
    {
        $noteAttributes = $response['data'];
        //Do something with note attributes
    }
    else
    {
        // Error
        $errors = $response['errors'];
        // Do something with errors
    }
    
  • Return:
    Data contains note attributes info.

Leave a Comment

  • Mr. Singh

    Hi, I’ve two queries

    1. How to fetch the total number of notes from API in our php script. I want to use it in pagination.
    2. How to fetch the notes only from particular Vendor/Account.

    Thanks