REST API Specification – ContactState

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

Get ContactState

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

  • Description: Retrieve ContactState by id.
  • URL structure: http://zurmo_url/index.php/contacts/contactState/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 ContactState 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/contacts/contactState/api/read/' . $id, 'GET', $headers);
    // Decode json data
    $response = json_decode($response, true);
    if ($response['status'] == 'SUCCESS')
    {
        $contactState = $response['data'];
        //Do something with ContactState
    }
    else
    {
        // Error, for example if we provided invalid ContactState id
        $errors = $response['errors'];
        // Do something with errors
    }
    
  • Return:
    Data contains ContactState info.

    {
      "status":"SUCCESS",
      "data":{
        "id":4,
        "name":"Dead",
        "order":"3",
        "serializedLabels":null
      },
      "message":null,
      "errors":null
    }
    

Get All Contact’s ContactStates

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

  • Description: Retrieve all Contact’s ContactStates.
  • URL structure: http://zurmo_url/index.php/contacts/contactState/api/listContactStates/
  • 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/contacts/contactState/api/listContactStates/', 'GET', $headers);
    // Decode json data
    $response = json_decode($response, true);
    if ($response['status'] == 'SUCCESS')
    {
        $contactStates = $response['data'];
        //Do something with $contactStates
    }
    else
    {
        // Error
        $errors = $response['errors'];
        // Do something with errors
    }
    
  • Return:
    Data contains ContactStates.

    {
      "status":"SUCCESS",
      "data":{
        "totalCount":2,
        "currentPage":1,
        "items":[
        {
          "id":5,
          "name":"Qualified",
          "order":"4",
          "serializedLabels":null
        },
        {
          "id":6,
          "name":"Customer",
          "order":"5",
          "serializedLabels":null
        }]
      },
      "message":null,
      "errors":null
    }
    

Get All Lead’s ContactStates

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

  • Description: Retrieve all Lead’s ContactStates.
  • URL structure: http://zurmo_url/index.php/contacts/contactState/api/listLeadStates/
  • 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/contacts/contactState/api/listLeadStates/', 'GET', $headers);
    // Decode json data
    $response = json_decode($response, true);
    if ($response['status'] == 'SUCCESS')
    {
        $contactStates = $response['data'];
        //Do something with $contactStates
    }
    else
    {
        // Error
        $errors = $response['errors'];
        // Do something with errors
    }
    
  • Return:
    Data contains ContactStates.

    {
      "status":"SUCCESS",
      "data":{
        "totalCount":4,
        "currentPage":1,
        "items":[
        {
          "id":1,
          "name":"New",
          "order":"0",
          "serializedLabels":null
        },
        {
          "id":2,
          "name":"In Progress",
          "order":"1",
          "serializedLabels":null
        },
        {
          "id":3,
          "name":"Recycled",
          "order":"2",
          "serializedLabels":null
        },
        {
          "id":4,
          "name":"Dead",
          "order":"3",
          "serializedLabels":null
        }]
      },
      "message":null,
      "errors":null
    }
    

Get All ContactStates

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

  • Description: Retrieve all ContactStates.
  • URL structure: http://zurmo_url/index.php/contacts/contactState/api/list/
  • 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/contacts/contactState/api/list/', 'GET', $headers);
    // Decode json data
    $response = json_decode($response, true);
    if ($response['status'] == 'SUCCESS')
    {
        $contactStates = $response['data'];
        //Do something with $contactStates
    }
    else
    {
        // Error
        $errors = $response['errors'];
        // Do something with errors
    }
    
  • Return:
    Data contains ContactStates.

    {
      "status":"SUCCESS",
      "data":{
        "totalCount":"6",
        "currentPage":1,
        "items":[
        {
          "id":1,
          "name":"New",
          "order":"0",
          "serializedLabels":null
        },
        {
          "id":2,
          "name":"In Progress",
          "order":"1",
          "serializedLabels":null
        },
        {
          "id":3,
          "name":"Recycled",
          "order":"2",
          "serializedLabels":null
        },
        {
          "id":4,
          "name":"Dead",
          "order":"3",
          "serializedLabels":null
        },
        {
          "id":5,
          "name":"Qualified",
          "order":"4",
          "serializedLabels":null
        },
        {
          "id":6,
          "name":"Customer",
          "order":"5",
          "serializedLabels":null
        }]
      },
      "message":null,
      "errors":null
    }
    

List ContactState Attributes

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

  • Description: List ContactState attributes.
  • URL structure: http://zurmo_url/index.php/contacts/contactState/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/contacts/contactState/api/listAttributes', 'GET', $headers);
    // Decode json data
    $response = json_decode($response, true);
    if ($response['status'] == 'SUCCESS')
    {
        $contactStateAttributes = $response['data'];
        //Do something with ContactState attributes
    }
    else
    {
        // Error
        $errors = $response['errors'];
        // Do something with errors
    }
    
  • Return:
    Data contains ContactState attributes info.

Leave a Comment

  • Sorin Ilie

    I am trying to use the API to set the state of new contacts to “NEW” from my website contact form. $data['state']['id'] =1; appears to not work but $data['state']['id'] = 5 ; does.

    So what is the ID -> state correspondence ?