Nostradamus Prophecy Machine
Wondering what’s next for npm?Check out our public roadmap! »

pipedrive

10.4.3 • Public • Published

Pipedrive client for NodeJS based apps

Pipedrive is a sales pipeline software that gets you organized. It's a powerful sales CRM with effortless sales pipeline management. See www.pipedrive.com for details.

This is the official Pipedrive API wrapper-client for NodeJS based apps, distributed by Pipedrive Inc freely under the MIT licence. It provides convenient access to the Pipedrive API, allowing you to operate with objects such as Deals, Persons, Organizations, Products and much more.

Installation

npm install pipedrive

⚠️ Version 10 is a complete rewrite of the library and introduces breaking changes in the client API. This release includes improved OAuth 2 support, async & await / promises and access to all Pipedrive API endpoints.

If you have been using a previous version of the client and cannot upgrade immediately, older versions are still available.

Please use the issues page for reporting bugs or leaving feedback. Note that most of the code is automatically generated.

API Reference

The Pipedrive RESTful API Reference can be found at https://developers.pipedrive.com/docs/api/v1

License

This Pipedrive API client is distributed under the MIT license.

How to use

With a pre-set API token

const express = require('express');
const app = express();
const lib = require('pipedrive');
 
const PORT = 1800;
 
lib.Configuration.apiToken = 'YOUR_API_TOKEN_HERE';
 
app.listen(PORT, () => {
    console.log(`Listening on port ${PORT}`);
});
 
app.get('/', async (req, res) => {
    const user = await lib.UsersController.getCurrentUserData();
 
    res.send(user);
});
 

With OAuth 2

In order to setup authentication in the API client, you need the following information.

Parameter Description
oAuthClientId OAuth 2 Client ID
oAuthClientSecret OAuth 2 Client Secret
oAuthRedirectUri OAuth 2 Redirection endpoint or Callback Uri

API client can be initialized as following:

const lib = require('pipedrive');
 
// Configuration parameters and credentials
lib.Configuration.oAuthClientId = "oAuthClientId"; // OAuth 2 Client ID
lib.Configuration.oAuthClientSecret = "oAuthClientSecret"; // OAuth 2 Client Secret
lib.Configuration.oAuthRedirectUri = "oAuthRedirectUri"; // OAuth 2 Redirection endpoint or Callback Uri
 

You must now authorize the client.

Authorizing your client

Your application must obtain user authorization before it can execute an endpoint call. The SDK uses OAuth 2.0 authorization to obtain a user's consent to perform an API request on user's behalf.

1. Obtaining user consent

To obtain user's consent, you must redirect the user to the authorization page. The buildAuthorizationUrl() method creates the URL to the authorization page.

const oAuthManager = lib.OAuthManager;
const authUrl = oAuthManager.buildAuthorizationUrl();
// open up the authUrl in the browser

2. Handle the OAuth server response

Once the user responds to the consent request, the OAuth 2.0 server responds to your application's access request by using the URL specified in the request.

If the user approves the request, the authorization code will be sent as the code query string:

https://example.com/oauth/callback?code=XXXXXXXXXXXXXXXXXXXXXXXXX

If the user does not approve the request, the response contains an error query string:

https://example.com/oauth/callback?error=access_denied

3. Authorize the client using the code

After the server receives the code, it can exchange this for an access token. The access token is an object containing information for authorizing the client and refreshing the token itself.

const tokenPromise = oAuthManager.authorize(code);

The Node.js SDK supports both callbacks and promises. So, the authorize call returns a promise and also returns response back in the callback (if one is provided)

Refreshing token

Access tokens may expire after sometime. To extend its lifetime, you must refresh the token.

const refreshPromise = oAuthManager.refreshToken();
refreshPromise.then(() => {
    // token has been refreshed
} , (exception) => {
    // error occurred, exception will be of type lib/Exceptions/OAuthProviderException
});

If a token expires, the SDK will attempt to automatically refresh the token before the next endpoint call which requires authentication.

Storing an access token for reuse

It is recommended that you store the access token for reuse.

This code snippet stores the access token in a session for an express application. It uses the cookie-parser and cookie-session npm packages for storing the access token.

const express = require('express');
const cookieParser = require('cookie-parser');
const cookieSession = require('cookie-session');
 
const app = express();
app.use(cookieParser());
app.use(cookieSession({
  name: 'session',
  keys: ['key1']
}));
 
const lib = require('pipedrive');
...
// store token in the session
req.session.token = lib.Configuration.oAuthToken;

However, since the the SDK will attempt to automatically refresh the token when it expires, it is recommended that you register a token update callback to detect any change to the access token.

lib.Configuration.oAuthTokenUpdateCallback = function(token) {
    // getting the updated token
    req.session.token = token;
}

The token update callback will be fired upon authorization as well as token refresh.

Creating a client from a stored token

To authorize a client from a stored access token, just set the access token in Configuration along with the other configuration parameters before making endpoint calls:

NB! This code only supports one client and should not be used as production code. Please store a separate access token for each client.

const express = require('express');
const cookieParser = require('cookie-parser');
const cookieSession = require('cookie-session');
 
const app = express();
app.use(cookieParser());
app.use(cookieSession({
  name: 'session',
  keys: ['key1']
}));
 
const lib = require('pipedrive');
 
app.get('/', (req, res) => {
    lib.Configuration.oAuthToken = req.session.token; // the access token stored in the session
});

Complete example

This example demonstrates an express application (which uses cookie-parser and cookie-session) for handling session persistence.

In this example, there are 2 endpoints. The base endpoint '/' first checks if the token is stored in the session. If it is, API endpoints can be called using the corresponding SDK controllers.

However, if the token is not set in the session, then authorization URL is built and opened up. The response comes back at the '/callback' endpoint, which uses the code to authorize the client and store the token in the session. It then redirects back to the base endpoint for calling endpoints from the SDK.

const express = require('express');
const app = express();
const cookieParser = require('cookie-parser');
const cookieSession = require('cookie-session');
 
app.use(cookieParser());
app.use(cookieSession({
  name: 'session',
  keys: ['key1']
}));
const PORT = 1800;
 
const lib = require('pipedrive');
const oAuthManager = lib.OAuthManager;
 
lib.Configuration.oAuthClientId = 'oAuthClientId'; // OAuth 2 Client ID
lib.Configuration.oAuthClientSecret = 'oAuthClientSecret'; // OAuth 2 Client Secret
lib.Configuration.oAuthRedirectUri = 'http://localhost:1800/callback'; // OAuth 2 Redirection endpoint or Callback Uri
 
 
app.listen(PORT, () => {
    console.log(`Listening on port ${PORT}`);
});
 
app.get('/', async (req, res) => {
    if (req.session.token !== null && req.session.token !== undefined) {
        // token is already set in the session
        // now make API calls as required
        // client will automatically refresh the token when it expires and call the token update callback
        const user = await lib.UsersController.getCurrentUserData();
 
        res.send(user);
    } else {
        const authUrl = oAuthManager.buildAuthorizationUrl();
 
        res.redirect(authUrl);
    }
});
 
app.get('/callback', (req, res) => {
    const authCode = req.query.code;
    const promise = oAuthManager.authorize(authCode);
 
    promise.then(() => {
        req.session.token = lib.Configuration.oAuthToken;
        res.redirect('/');
    }, (exception) => {
        // error occurred, exception will be of type lib/Exceptions/OAuthProviderException
    });
});
 

Contributing

Please be aware that most of the code is auto-generated. You are welcome to suggest changes and report bugs. However, any updates will have to be implemented in the underlying generator.

How to Test

These tests use Mocha framework for testing, coupled with Chai for assertions. These dependencies need to be installed for tests to run. Tests can be run in a number of ways:

Method 1 (Run all tests)

  1. Navigate to the root directory of the SDK folder from command prompt.
  2. Type mocha --recursive to run all the tests.

Method 2 (Run all tests)

  1. Navigate to the ../test/Controllers/ directory from command prompt.
  2. Type mocha * to run all the tests.

Method 3 (Run specific controller's tests)

  1. Navigate to the ../test/Controllers/ directory from command prompt.
  2. Type mocha Pipedrive API v1Controller to run all the tests in that controller file.

To increase mocha's default timeout, you can change the TEST_TIMEOUT parameter's value in TestBootstrap.js.

Class Reference

List of Controllers

Class: ActivitiesController

Get singleton instance

The singleton instance of the ActivitiesController class can be accessed from the API Client.

var controller = lib.ActivitiesController;

Method: deleteMultipleActivitiesInBulk

Marks multiple activities as deleted.

function deleteMultipleActivitiesInBulk(ids, callback)

Parameters

Parameter Tags Description
ids Required Comma-separated IDs that will be deleted

Example Usage

 
    var ids = 'ids';
 
    controller.deleteMultipleActivitiesInBulk(ids, function(error, response, context) {
 
    
    });

Method: getAllActivitiesAssignedToAParticularUser

Returns all activities assigned to a particular user.

function getAllActivitiesAssignedToAParticularUser(input, callback)

Parameters

Parameter Tags Description
userId Optional ID of the user whose activities will be fetched. If omitted, the user associated with the API token will be used. If 0, activities for all company users will be fetched based on the permission sets.
filterId Optional ID of the filter to use (will narrow down results if used together with user_id parameter).
type Optional Type of the activity, can be one type or multiple types separated by a comma. This is in correlation with the key_string parameter of ActivityTypes.
start Optional DefaultValue Pagination start
limit Optional Items shown per page
startDate Optional Date in format of YYYY-MM-DD from which activities to fetch from.
endDate Optional Date in format of YYYY-MM-DD until which activities to fetch to.
done Optional Whether the activity is done or not. 0 = Not done, 1 = Done. If omitted returns both Done and Not done activities.

Example Usage

 
    var input = [];
        input['userId'] = 58;
        input['filterId'] = 58;
        input['type'] = 'type';
        input['start'] = 0;
        input['limit'] = 58;
        input['startDate'] = '2019-11-22';
        input['endDate'] = '2019-11-22';
        input['done'] = Object.keys(NumberBoolean)[0];
 
    controller.getAllActivitiesAssignedToAParticularUser(input, function(error, response, context) {
 
    
    });

Method: addAnActivity

Adds a new activity. Includes more_activities_scheduled_in_context property in response's additional_data which indicates whether there are more undone activities scheduled with the same deal, person or organization (depending on the supplied data). For more information on how to add an activity, see this tutorial.

function addAnActivity(input, callback)

Parameters

Parameter Tags Description
subject Required Subject of the activity
type Required Type of the activity. This is in correlation with the key_string parameter of ActivityTypes.
done Optional TODO: Add a parameter description
dueDate Optional Due date of the activity. Format: YYYY-MM-DD
dueTime Optional Due time of the activity in UTC. Format: HH:MM
duration Optional Duration of the activity. Format: HH:MM
userId Optional ID of the user whom the activity will be assigned to. If omitted, the activity will be assigned to the authorized user.
dealId Optional ID of the deal this activity will be associated with
personId Optional ID of the person this activity will be associated with
participants Optional List of multiple persons (participants) this activity will be associated with. If omitted, single participant from person_id field is used. It requires a structure as follows: [{"person_id":1,"primary_flag":true}]
orgId Optional ID of the organization this activity will be associated with
note Optional Note of the activity (HTML format)

Example Usage

 
    var input = [];
        input['subject'] = 'subject';
        input['type'] = 'type';
        input['done'] = Object.keys(NumberBoolean)[0];
        input['dueDate'] = '2019-11-22';
        input['dueTime'] = due_time;
        input['duration'] = 'duration';
        input['userId'] = 58;
        input['dealId'] = 58;
        input['personId'] = 58;
        input['participants'] = 'participants';
        input['orgId'] = 58;
        input['note'] = 'note';
 
    controller.addAnActivity(input, function(error, response, context) {
 
    
    });

Method: deleteAnActivity

Deletes an activity.

function deleteAnActivity(id, callback)

Parameters

Parameter Tags Description
id Required ID of the activity

Example Usage

 
    var id = 58;
 
    controller.deleteAnActivity(id, function(error, response, context) {
 
    
    });

Method: getDetailsOfAnActivity

Returns details of a specific activity.

function getDetailsOfAnActivity(id, callback)

Parameters

Parameter Tags Description
id Required ID of the activity

Example Usage

 
    var id = 58;
 
    controller.getDetailsOfAnActivity(id, function(error, response, context) {
 
    
    });

Method: updateEditAnActivity

Modifies an activity. Includes more_activities_scheduled_in_context property in response's additional_data which indicates whether there are more undone activities scheduled with the same deal, person or organization (depending on the supplied data).

function updateEditAnActivity(input, callback)

Parameters

Parameter Tags Description
id Required ID of the activity
subject Required Subject of the activity
type Required Type of the activity. This is in correlation with the key_string parameter of ActivityTypes.
done Optional TODO: Add a parameter description
dueDate Optional Due date of the activity. Format: YYYY-MM-DD
dueTime Optional Due time of the activity in UTC. Format: HH:MM
duration Optional Duration of the activity. Format: HH:MM
userId Optional ID of the user whom the activity will be assigned to. If omitted, the activity will be assigned to the authorized user.
dealId Optional ID of the deal this activity will be associated with
personId Optional ID of the person this activity will be associated with
participants Optional List of multiple persons (participants) this activity will be associated with. If omitted, single participant from person_id field is used. It requires a structure as follows: [{"person_id":1,"primary_flag":true}]
orgId Optional ID of the organization this activity will be associated with
note Optional Note of the activity (HTML format)

Example Usage

 
    var input = [];
        input['id'] = 58;
        input['subject'] = 'subject';
        input['type'] = 'type';
        input['done'] = Object.keys(NumberBoolean)[0];
        input['dueDate'] = '2019-11-22';
        input['dueTime'] = due_time;
        input['duration'] = 'duration';
        input['userId'] = 58;
        input['dealId'] = 58;
        input['personId'] = 58;
        input['participants'] = 'participants';
        input['orgId'] = 58;
        input['note'] = 'note';
 
    controller.updateEditAnActivity(input, function(error, response, context) {
 
    
    });

Back to List of Controllers

Class: ActivityFieldsController

Get singleton instance

The singleton instance of the ActivityFieldsController class can be accessed from the API Client.

var controller = lib.ActivityFieldsController;

Method: getAllFieldsForAnActivity

Return list of all fields for activity

function getAllFieldsForAnActivity(callback)

Example Usage

 
 
    controller.getAllFieldsForAnActivity(function(error, response, context) {
 
    
    });

Back to List of Controllers

Class: ActivityTypesController

Get singleton instance

The singleton instance of the ActivityTypesController class can be accessed from the API Client.

var controller = lib.ActivityTypesController;

Method: deleteMultipleActivityTypesInBulk

Marks multiple activity types as deleted.

function deleteMultipleActivityTypesInBulk(ids, callback)

Parameters

Parameter Tags Description
ids Required Comma-separated activity type IDs to delete

Example Usage

 
    var ids = 'ids';
 
    controller.deleteMultipleActivityTypesInBulk(ids, function(error, response, context) {
 
    
    });

Method: getAllActivityTypes

Returns all activity types

function getAllActivityTypes(callback)

Example Usage

 
 
    controller.getAllActivityTypes(function(error, response, context) {
 
    
    });

Method: addNewActivityType

Adds a new activity type, returns the ID, the key_string and the order number of the newly added activity type upon success.

function addNewActivityType(input, callback)

Parameters

Parameter Tags Description
name Required Name of the activity type
iconKey Required Icon graphic to use for representing this activity type.
color Optional A designated color for the activity type in 6-character HEX format (e.g. FFFFFF for white, 000000 for black).

Example Usage

 
    var input = [];
        input['name'] = 'name';
        input['iconKey'] = Object.keys(IconKey)[0];
        input['color'] = 'color';
 
    controller.addNewActivityType(input, function(error, response, context) {
 
    
    });

Method: deleteAnActivityType

Marks an activity type as deleted.

function deleteAnActivityType(id, callback)

Parameters

Parameter Tags Description
id Required ID of the activity type

Example Usage

 
    var id = 58;
 
    controller.deleteAnActivityType(id, function(error, response, context) {
 
    
    });

Method: updateEditActivityType

Updates an activity type.

function updateEditActivityType(input, callback)

Parameters

Parameter Tags Description
id Required ID of the activity type
name Optional Name of the activity type
iconKey Optional Icon graphic to use for representing this activity type.
color Optional A designated color for the activity type in 6-character HEX format (e.g. FFFFFF for white, 000000 for black).
orderNr Optional An order number for this activity type. Order numbers should be used to order the types in the activity type selections.

Example Usage

 
    var input = [];
        input['id'] = 58;
        input['name'] = 'name';
        input['iconKey'] = Object.keys(IconKey)[0];
        input['color'] = 'color';
        input['orderNr'] = 58;
 
    controller.updateEditActivityType(input, function(error, response, context) {
 
    
    });

Back to List of Controllers

Class: CurrenciesController

Get singleton instance

The singleton instance of the CurrenciesController class can be accessed from the API Client.

var controller = lib.CurrenciesController;

Method: getAllSupportedCurrencies

Returns all supported currencies in given account which should be used when saving monetary values with other objects. The 'code' parameter of the returning objects is the currency code according to ISO 4217 for all non-custom currencies.

function getAllSupportedCurrencies(term, callback)

Parameters

Parameter Tags Description
term Optional Optional search term that is searched for from currency's name and/or code.

Example Usage

 
    var term = 'term';
 
    controller.getAllSupportedCurrencies(term, function(error, response, context) {
 
    
    });

Back to List of Controllers

Class: DealFieldsController

Get singleton instance

The singleton instance of the DealFieldsController class can be accessed from the API Client.

var controller = lib.DealFieldsController;

Method: deleteMultipleDealFieldsInBulk

Marks multiple fields as deleted.

function deleteMultipleDealFieldsInBulk(ids, callback)

Parameters

Parameter Tags Description
ids Required Comma-separated field IDs to delete

Example Usage

 
    var ids = 'ids';
 
    controller.deleteMultipleDealFieldsInBulk(ids, function(error, response, context) {
 
    
    });

Method: getAllDealFields

Returns data about all fields deals can have

function getAllDealFields(input, callback)

Parameters

Parameter Tags Description
start Optional DefaultValue Pagination start
limit Optional Items shown per page

Example Usage

 
    var input = [];
        input['start'] = 0;
        input['limit'] = 58;
 
    controller.getAllDealFields(input, function(error, response, context) {
 
    
    });

Method: addANewDealField

Adds a new deal field. For more information on adding a new custom field, see this tutorial.

function addANewDealField(input, callback)

Parameters

Parameter Tags Description
contentType Optional TODO: Add a parameter description
body Optional TODO: Add a parameter description

Example Usage

 
    var input = [];
        input['contentType'] = 'Content-Type';
        input['body'] = {
        id : 21
    };
 
    controller.addANewDealField(input, function(error, response, context) {
 
    
    });

Method: deleteADealField

Marks a field as deleted. For more information on how to delete a custom field, see this tutorial.

function deleteADealField(id, callback)

Parameters

Parameter Tags Description
id Required ID of the field

Example Usage

 
    var id = 58;
 
    controller.deleteADealField(id, function(error, response, context) {
 
    
    });

Method: getOneDealField

Returns data about a specific deal field.

function getOneDealField(id, callback)

Parameters

Parameter Tags Description
id Required ID of the field

Example Usage

 
    var id = 58;
 
    controller.getOneDealField(id, function(error, response, context) {
 
    
    });

Method: updateADealField

Updates a deal field. See an example of updating custom fields’ values in this tutorial.

function updateADealField(input, callback)

Parameters

Parameter Tags Description
id Required ID of the field
name Required Name of the field
options Optional When field_type is either set or enum, possible options must be supplied as a JSON-encoded sequential array, for example: ["red","blue","lilac"]

Example Usage

 
    var input = [];
        input['id'] = 58;
        input['name'] = 'name';
        input['options'] = 'options';
 
    controller.updateADealField(input, function(error, response, context) {
 
    
    });

Back to List of Controllers

Class: DealsController

Get singleton instance

The singleton instance of the DealsController class can be accessed from the API Client.

var controller = lib.DealsController;

Method: deleteMultipleDealsInBulk

Marks multiple deals as deleted.

function deleteMultipleDealsInBulk(ids, callback)

Parameters

Parameter Tags Description
ids Required Comma-separated IDs that will be deleted

Example Usage

 
    var ids = 'ids';
 
    controller.deleteMultipleDealsInBulk(ids, function(error, response, context) {
 
    
    });

Method: getAllDeals

Returns all deals. For more information on how to get all deals, see this tutorial.

function getAllDeals(input, callback)

Parameters

Parameter Tags Description
userId Optional If supplied, only deals matching the given user will be returned.
filterId Optional ID of the filter to use
stageId Optional If supplied, only deals within the given stage will be returned.
status Optional DefaultValue Only fetch deals with specific status. If omitted, all not deleted deals are fetched.
start Optional DefaultValue Pagination start
limit Optional Items shown per page
sort Optional Field names and sorting mode separated by a comma (field_name_1 ASC, field_name_2 DESC). Only first-level field keys are supported (no nested keys).
ownedByYou Optional When supplied, only deals owned by you are returned. However filter_id takes precedence over owned_by_you when both are supplied.

Example Usage

 
    var input = [];
        input['userId'] = 58;
        input['filterId'] = 58;
        input['stageId'] = 58;
        input['status'] = new Status2Enum(all_not_deleted);
        input['start'] = 0;
        input['limit'] = 58;
        input['sort'] = 'sort';
        input['ownedByYou'] = Object.keys(NumberBoolean)[0];
 
    controller.getAllDeals(input, function(error, response, context) {
 
    
    });

Method: addADeal

Adds a new deal. Note that you can supply additional custom fields along with the request that are not described here. These custom fields are different for each Pipedrive account and can be recognized by long hashes as keys. To determine which custom fields exists, fetch the dealFields and look for 'key' values. For more information on how to add a deal, see this tutorial.

function addADeal(input, callback)

Parameters

Parameter Tags Description
contentType Optional TODO: Add a parameter description
body Optional TODO: Add a parameter description

Example Usage

 
    var input = [];
        input['contentType'] = 'Content-Type';
        input['body'] = {
        id : 21
    };
 
    controller.addADeal(input, function(error, response, context) {
 
    
    });

Method: findDealsByName

Searches all deals by their title.

function findDealsByName(input, callback)

Parameters

Parameter Tags Description
term Required Search term to look for
personId Optional ID of the person the Deal is associated with.
orgId Optional ID of the organization the Deal is associated with.

Example Usage

 
    var input = [];
        input['term'] = 'term';
        input['personId'] = 58;
        input['orgId'] = 58;
 
    controller.findDealsByName(input, function(error, response, context) {
 
    
    });

Method: getDealsSummary

Returns summary of all the deals.

function getDealsSummary(input, callback)

Parameters

Parameter Tags Description
status Optional Only fetch deals with specific status. open = Open, won = Won, lost = Lost
filterId Optional user_id will not be considered. Only deals matching the given filter will be returned.
userId Optional Only deals matching the given user will be returned. user_id will not be considered if you use filter_id.
stageId Optional Only deals within the given stage will be returned.

Example Usage

 
    var input = [];
        input['status'] = Object.keys(status3)[0];
        input['filterId'] = 58;
        input['userId'] = 58;
        input['stageId'] = 58;
 
    controller.getDealsSummary(input, function(error, response, context) {
 
    
    });

Method: getDealsTimeline

Returns open and won deals, grouped by defined interval of time set in a date-type dealField (field_key) — e.g. when month is the chosen interval, and 3 months are asked starting from January 1st, 2012, deals are returned grouped into 3 groups — January, February and March — based on the value of the given field_key.

function getDealsTimeline(input, callback)

Parameters

Parameter Tags Description
startDate Required Date where first interval starts. Format: YYYY-MM-DD
interval Required Type of interval.
day
Day
week
A full week (7 days) starting from start_date
month
A full month (depending on the number of days in given month) starting from start_date
quarter
A full quarter (3 months) starting from start_date
amount Required Number of given intervals, starting from start_date, to fetch. E.g. 3 (months).
fieldKey Required The name of the date field by which to get deals by.
userId Optional If supplied, only deals matching the given user will be returned.
pipelineId Optional If supplied, only deals matching the given pipeline will be returned.
filterId Optional If supplied, only deals matching the given filter will be returned.
excludeDeals Optional Whether to exclude deals list (1) or not (0). Note that when deals are excluded, the timeline summary (counts and values) is still returned.
totalsConvertCurrency Optional 3-letter currency code of any of the supported currencies. When supplied, totals_converted is returned per each interval which contains the currency-converted total amounts in the given currency. You may also set this parameter to 'default_currency' in which case users default currency is used.

Example Usage

 
    var input = [];
        input['startDate'] = '2019-11-22';
        input['interval'] = Object.keys(interval2)[0];
        input['amount'] = 58;
        input['fieldKey'] = field_key;
        input['userId'] = 58;
        input['pipelineId'] = 58;
        input['filterId'] = 58;
        input['excludeDeals'] = Object.keys(NumberBoolean)[0];
        input['totalsConvertCurrency'] = totals_convert_currency;
 
    controller.getDealsTimeline(input, function(error, response, context) {
 
    
    });

Method: deleteADeal

Marks a deal as deleted.

function deleteADeal(id, callback)

Parameters

Parameter Tags Description
id Required ID of the deal

Example Usage

 
    var id = 58;
 
    controller.deleteADeal(id, function(error, response, context) {
 
    
    });

Method: getDetailsOfADeal

Returns details of a specific deal. Note that this also returns some additional fields which are not present when asking for all deals – such as deal age and stay in pipeline stages. Also note that custom fields appear as long hashes in the resulting data. These hashes can be mapped against the 'key' value of dealFields. For more information on how to get all details of a deal, see this tutorial.

function getDetailsOfADeal(id, callback)

Parameters

Parameter Tags Description
id Required ID of the deal

Example Usage

 
    var id = 58;
 
    controller.getDetailsOfADeal(id, function(error, response, context) {
 
    
    });

Method: updateADeal

Updates the properties of a deal. For more information on how to update a deal, see this tutorial.

function updateADeal(input, callback)

Parameters

Parameter Tags Description
id Required ID of the deal
title Optional Deal title
value Optional Value of the deal. If omitted, value will be set to 0.
currency Optional Currency of the deal. Accepts a 3-character currency code. If omitted, currency will be set to the default currency of the authorized user.
userId Optional ID of the user who will be marked as the owner of this deal. If omitted, the authorized user ID will be used.
personId Optional ID of the person this deal will be associated with
orgId Optional ID of the organization this deal will be associated with
stageId Optional ID of the stage this deal will be placed in a pipeline (note that you can't supply the ID of the pipeline as this will be assigned automatically based on stage_id). If omitted, the deal will be placed in the first stage of the default pipeline.
status Optional open = Open, won = Won, lost = Lost, deleted = Deleted. If omitted, status will be set to open.
probability Optional Deal success probability percentage. Used/shown only when deal_probability for the pipeline of the deal is enabled.
lostReason Optional Optional message about why the deal was lost (to be used when status=lost)
visibleTo Optional Visibility of the deal. If omitted, visibility will be set to the default visibility setting of this item type for the authorized user.
1
Owner & followers (private)
3
Entire company (shared)

Example Usage

 
    var input = [];
        input['id'] = 58;
        input['title'] = 'title';
        input['value'] = 'value';
        input['currency'] = 'currency';
        input['userId'] = 58;
        input['personId'] = 58;
        input['orgId'] = 58;
        input['stageId'] = 58;
        input['status'] = Object.keys(Status)[0];
        input['probability'] = 58.5644835925496;
        input['lostReason'] = lost_reason;
        input['visibleTo'] = Object.keys(VisibleTo)[0];
 
    controller.updateADeal(input, function(error, response, context) {
 
    
    });

Method: listActivitiesAssociatedWithADeal

Lists activities associated with a deal.

function listActivitiesAssociatedWithADeal(input, callback)

Parameters

Parameter Tags Description
id Required ID of the deal
start Optional DefaultValue Pagination start
limit Optional Items shown per page
done Optional Whether the activity is done or not. 0 = Not done, 1 = Done. If omitted returns both Done and Not done activities.
exclude Optional A comma-separated string of activity IDs to exclude from result

Example Usage

 
    var input = [];
        input['id'] = 58;
        input['start'] = 58;
        input['limit'] = 58;
        input['done'] = Object.keys(NumberBoolean)[0];
        input['exclude'] = 'exclude';
 
    controller.listActivitiesAssociatedWithADeal(input, function(error, response, context) {
 
    
    });

Method: createDuplicateDeal

Duplicate a deal

function createDuplicateDeal(id, callback)

Parameters

Parameter Tags Description
id Required ID of the deal

Example Usage

 
    var id = 58;
 
    controller.createDuplicateDeal(id, function(error, response, context) {
 
    
    });

Method: listFilesAttachedToADeal

Lists files associated with a deal.

function listFilesAttachedToADeal(input, callback)

Parameters

Parameter Tags Description
id Required ID of the deal
start Optional DefaultValue Pagination start
limit Optional Items shown per page
includeDeletedFiles Optional When enabled, the list of files will also include deleted files. Please note that trying to download these files will not work.
sort Optional Field names and sorting mode separated by a comma (field_name_1 ASC, field_name_2 DESC). Only first-level field keys are supported (no nested keys). Supported fields: id, user_id, deal_id, person_id, org_id, product_id, add_time, update_time, file_name, file_type, file_size, comment.

Example Usage

 
    var input = [];
        input['id'] = 58;
        input['start'] = 58;
        input['limit'] = 58;
        input['includeDeletedFiles'] = Object.keys(NumberBoolean)[0];
        input['sort'] = 'sort';
 
    controller.listFilesAttachedToADeal(input, function(error, response, context) {
 
    
    });

Method: listUpdatesAboutADeal

Lists updates about a deal.

function listUpdatesAboutADeal(input, callback)

Parameters

Parameter Tags Description
id Required ID of the deal
start Optional DefaultValue Pagination start
limit Optional Items shown per page

Example Usage

 
    var input = [];
        input['id'] = 58;
        input['start'] = 58;
        input['limit'] = 58;
 
    controller.listUpdatesAboutADeal(input, function(error, response, context) {
 
    
    });

Method: listFollowersOfADeal

Lists the followers of a deal.

function listFollowersOfADeal(id, callback)

Parameters

Parameter Tags Description
id Required ID of the deal

Example Usage

 
    var id = 58;
 
    controller.listFollowersOfADeal(id, function(error, response, context) {
 
    
    });

Method: addAFollowerToADeal

Adds a follower to a deal.

function addAFollowerToADeal(input, callback)

Parameters

Parameter Tags Description
id Required ID of the deal
userId Required ID of the user

Example Usage

 
    var input = [];
        input['id'] = 58;
        input['userId'] = 58;
 
    controller.addAFollowerToADeal(input, function(error, response, context) {
 
    
    });

Method: deleteAFollowerFromADeal

Deletes a follower from a deal.

function deleteAFollowerFromADeal(input, callback)

Parameters

Parameter Tags Description
id Required ID of the deal
followerId Required ID of the follower

Example Usage

 
    var input = [];
        input['id'] = 58;
        input['followerId'] = 58;
 
    controller.deleteAFollowerFromADeal(input, function(error, response, context) {
 
    
    });

Method: listMailMessagesAssociatedWithADeal

Lists mail messages associated with a deal.

function listMailMessagesAssociatedWithADeal(input, callback)

Parameters

Parameter Tags Description
id Required ID of the deal
start Optional DefaultValue Pagination start
limit Optional Items shown per page

Example Usage

 
    var input = [];
        input['id'] = 58;
        input['start'] = 58;
        input['limit'] = 58;
 
    controller.listMailMessagesAssociatedWithADeal(input, function(error, response, context) {
 
    
    });

Method: updateMergeTwoDeals

Merges a deal with another deal. For more information on how to merge two deals, see this tutorial.

function updateMergeTwoDeals(input, callback)

Parameters

Parameter Tags Description
id Required ID of the deal
mergeWithId Required ID of the deal that the deal will be merged with

Example Usage

 
    var input = [];
        input['id'] = 58;
        input['mergeWithId'] = 58;
 
    controller.updateMergeTwoDeals(input, function(error, response, context) {
 
    
    });

Method: listParticipantsOfADeal

Lists participants associated with a deal.

function listParticipantsOfADeal(input, callback)

Parameters

Parameter Tags Description
id Required ID of the deal
start Optional DefaultValue Pagination start
limit Optional Items shown per page

Example Usage

 
    var input = [];
        input['id'] = 58;
        input['start'] = 58;
        input['limit'] = 58;
 
    controller.listParticipantsOfADeal(input, function(error, response, context) {
 
    
    });

Method: addAParticipantToADeal

Adds a participant to a deal.

function addAParticipantToADeal(input, callback)

Parameters

Parameter Tags Description
id Required ID of the deal
personId Required ID of the person

Example Usage

 
    var input = [];
        input['id'] = 58;
        input['personId'] = 58;
 
    controller.addAParticipantToADeal(input, function(error, response, context) {
 
    
    });

Method: deleteAParticipantFromADeal

Deletes a participant from a deal.

function deleteAParticipantFromADeal(input, callback)

Parameters

Parameter Tags Description
id Required ID of the deal
dealParticipantId Required ID of the deal participant

Example Usage

 
    var input = [];
        input['id'] = 58;
        input['dealParticipantId'] = 58;
 
    controller.deleteAParticipantFromADeal(input, function(error, response, context) {
 
    
    });

Method: listPermittedUsers

List users permitted to access a deal

function listPermittedUsers(id, callback)

Parameters

Parameter Tags Description
id Required ID of the deal

Example Usage

 
    var id = 58;
 
    controller.listPermittedUsers(id, function(error, response, context) {
 
    
    });

Method: listAllPersonsAssociatedWithADeal

Lists all persons associated with a deal, regardless of whether the person is the primary contact of the deal, or added as a participant.

function listAllPersonsAssociatedWithADeal(input, callback)

Parameters

Parameter Tags Description
id Required ID of the deal
start Optional DefaultValue Pagination start
limit Optional Items shown per page

Example Usage

 
    var input = [];
        input['id'] = 58;
        input['start'] = 58;
        input['limit'] = 58;
 
    controller.listAllPersonsAssociatedWithADeal(input, function(error, response, context) {
 
    
    });

Method: listProductsAttachedToADeal

Lists products attached to a deal.

function listProductsAttachedToADeal(input, callback)

Parameters

Parameter Tags Description
id Required ID of the deal
start Optional DefaultValue Pagination start
limit Optional Items shown per page
includeProductData Optional Whether to fetch product data along with each attached product (1) or not (0, default).

Example Usage

 
    var input = [];
        input['id'] = 58;
        input['start'] = 58;
        input['limit'] = 58;
        input['includeProductData'] = Object.keys(NumberBoolean)[0];
 
    controller.listProductsAttachedToADeal(input, function(error, response, context) {
 
    
    });

Method: addAProductToTheDealEventuallyCreatingANewItemCalledADealProduct

Adds a product to the deal.

function addAProductToTheDealEventuallyCreatingANewItemCalledADealProduct(input, callback)

Parameters

Parameter Tags Description
id Required ID of the deal
contentType Optional TODO: Add a parameter description
body Optional TODO: Add a parameter description

Example Usage

 
    var input = [];
        input['id'] = 58;
        input['contentType'] = 'Content-Type';
        input['body'] = {
        id : 21
    };
 
    controller.addAProductToTheDealEventuallyCreatingANewItemCalledADealProduct(input, function(error, response, context) {
 
    
    });

Method: updateProductAttachmentDetailsOfTheDealProductAProductAlreadyAttachedToADeal

Updates product attachment details.

function updateProductAttachmentDetailsOfTheDealProductAProductAlreadyAttachedToADeal(input, callback)

Parameters

Parameter Tags Description
id Required ID of the deal
productAttachmentId Required ID of the deal-product (the ID of the product attached to the deal)
itemPrice Optional Price at which this product will be added to the deal
quantity Optional Quantity – e.g. how many items of this product will be added to the deal
discountPercentage Optional Discount %. If omitted, will be set to 0
duration Optional Duration of the product (when product durations are not enabled for the company or if omitted, defaults to 1)
productVariationId Optional ID of the product variation to use. When omitted, no variation will be used.
comments Optional Any textual comment associated with this product-deal attachment. Visible and editable in the application UI.
enabledFlag Optional Whether the product is enabled on the deal or not. This makes it possible to add products to a deal with specific price and discount criteria - but keep them disabled, which refrains them from being included in deal price calculation. When omitted, the product will be marked as enabled by default.

Example Usage

 
    var input = [];
        input['id'] = 58;
        input['productAttachmentId'] = 58;
        input['itemPrice'] = 58.5644835925496;
        input['quantity'] = 58;
        input['discountPercentage'] = 58.5644835925496;
        input['duration'] = 58.5644835925496;
        input['productVariationId'] = 58;
        input['comments'] = 'comments';
        input['enabledFlag'] = Object.keys(NumberBoolean)[0];
 
    controller.updateProductAttachmentDetailsOfTheDealProductAProductAlreadyAttachedToADeal(input, function(error, response, context) {
 
    
    });

Method: deleteAnAttachedProductFromADeal

Deletes a product attachment from a deal, using the product_attachment_id.

function deleteAnAttachedProductFromADeal(input, callback)

Parameters

Parameter Tags Description
id Required ID of the deal
productAttachmentId Required Product attachment ID. This is returned as product_attachment_id after attaching a product to a deal or as id when listing the products attached to a deal.

Example Usage

 
    var input = [];
        input['id'] = 58;
        input['productAttachmentId'] = 58;
 
    controller.deleteAnAttachedProductFromADeal(input, function(error, response, context) {
 
    
    });

Back to List of Controllers

Class: FilesController

Get singleton instance

The singleton instance of the FilesController class can be accessed from the API Client.

var controller = lib.FilesController;

Method: getAllFiles

Returns data about all files.

function getAllFiles(input, callback)

Parameters

Parameter Tags Description
start Optional DefaultValue Pagination start
limit Optional Items shown per page
includeDeletedFiles Optional When enabled, the list of files will also include deleted files. Please note that trying to download these files will not work.
sort Optional Field names and sorting mode separated by a comma (field_name_1 ASC, field_name_2 DESC). Only first-level field keys are supported (no nested keys). Supported fields: id, user_id, deal_id, person_id, org_id, product_id, add_time, update_time, file_name, file_type, file_size, comment.

Example Usage

 
    var input = [];
        input['start'] = 0;
        input['limit'] = 58;
        input['includeDeletedFiles'] = Object.keys(NumberBoolean)[0];
        input['sort'] = 'sort';
 
    controller.getAllFiles(input, function(error, response, context) {
 
    
    });

Method: addFile

Lets you upload a file and associate it with Deal, Person, Organization, Activity or Product. For more information on how to add a file, see this tutorial.

function addFile(input, callback)

Parameters

Parameter Tags Description
file Required A single file, supplied in the multipart/form-data encoding and contained within the given boundaries.
dealId Optional ID of the deal to associate file(s) with
personId Optional ID of the person to associate file(s) with
orgId Optional ID of the organization to associate file(s) with
productId Optional ID of the product to associate file(s) with
activityId Optional ID of the activity to associate file(s) with
noteId Optional ID of the note to associate file(s) with

Example Usage

 
    TestHelper.getFilePath('url', function(data) {
        var input = [];
        input['file'] = data;
        input['dealId'] = 58;
        input['personId'] = 58;
        input['orgId'] = 58;
        input['productId'] = 58;
        input['activityId'] = 58;
        input['noteId'] = 58;
 
        controller.addFile(input, function(error, response, context) {
 
        });
    });

Method: createARemoteFileAndLinkItToAnItem

Creates a new empty file in the remote location (googledrive) that will be linked to the item you supply. For more information on how to add a remote file, see this tutorial.

function createARemoteFileAndLinkItToAnItem(input, callback)

Parameters

Parameter Tags Description
fileType Required The file type
title Required The title of the file
itemType Required The item type
itemId Required ID of the item to associate the file with
remoteLocation Required The location type to send the file to. Only googledrive is supported at the moment.

Example Usage

 
    var input = [];
        input['fileType'] = Object.keys(file_type)[0];
        input['title'] = 'title';
        input['itemType'] = Object.keys(item_type)[0];
        input['itemId'] = 58;
        input['remoteLocation'] = Object.keys(remote_location)[0];
 
    controller.createARemoteFileAndLinkItToAnItem(input, function(error, response, context) {
 
    
    });

Method: createLinkARemoteFileToAnItem

Links an existing remote file (googledrive) to the item you supply. For more information on how to link a remote file, see this tutorial.

function createLinkARemoteFileToAnItem(input, callback)

Parameters

Parameter Tags Description
itemType Required The item type
itemId Required ID of the item to associate the file with
remoteId Required The remote item id
remoteLocation Required The location type to send the file to. Only googledrive is supported at the moment.

Example Usage

 
    var input = [];
        input['itemType'] = Object.keys(item_type)[0];
        input['itemId'] = 58;
        input['remoteId'] = remote_id;
        input['remoteLocation'] = Object.keys(remote_location)[0];
 
    controller.createLinkARemoteFileToAnItem(input, function(error, response, context) {
 
    
    });

Method: deleteAFile

Marks a file as deleted.

function deleteAFile(id, callback)

Parameters

Parameter Tags Description
id Required ID of the file

Example Usage

 
    var id = 58;
 
    controller.deleteAFile(id, function(error, response, context) {
 
    
    });

Method: getOneFile

Returns data about a specific file.

function getOneFile(id, callback)

Parameters

Parameter Tags Description
id Required ID of the file

Example Usage

 
    var id = 58;
 
    controller.getOneFile(id, function(error, response, context) {
 
    
    });

Method: updateFileDetails

Updates the properties of a file.

function updateFileDetails(input, callback)

Parameters

Parameter Tags Description
id Required ID of the file
name Optional Visible name of the file
description Optional Description of the file

Example Usage

 
    var input = [];
        input['id'] = 58;
        input['name'] = 'name';
        input['description'] = 'description';
 
    controller.updateFileDetails(input, function(error, response, context) {
 
    
    });

Method: getDownloadOneFile

Initializes a file download.

function getDownloadOneFile(id, callback)

Parameters

Parameter Tags Description
id Required ID of the file

Example Usage

 
    var id = 58;
 
    controller.getDownloadOneFile(id, function(error, response, context) {
 
    
    });

Back to List of Controllers

Class: FiltersController

Get singleton instance

The singleton instance of the FiltersController class can be accessed from the API Client.

var controller = lib.FiltersController;

Method: deleteMultipleFiltersInBulk

Marks multiple filters as deleted.

function deleteMultipleFiltersInBulk(ids, callback)

Parameters

Parameter Tags Description
ids Required Comma-separated filter IDs to delete

Example Usage

 
    var ids = 'ids';
 
    controller.deleteMultipleFiltersInBulk(ids, function(error, response, context) {
 
    
    });

Method: getAllFilters

Returns data about all filters

function getAllFilters(type, callback)

Parameters

Parameter Tags Description
type Optional Types of filters to fetch

Example Usage

 
    var type = Object.keys(FilterType)[0];
 
    controller.getAllFilters(type, function(error, response, context) {
 
    
    });

Method: addANewFilter

Adds a new filter, returns the ID upon success. Note that in the conditions json object only one first-level condition group is supported, and it must be glued with 'AND', and only two second level condition groups are supported of which one must be glued with 'AND' and the second with 'OR'. Other combinations do not work (yet) but the syntax supports introducing them in future. For more information on how to add a new filter, see this tutorial.

function addANewFilter(input, callback)

Parameters

Parameter Tags Description
name Required Filter name
conditions Required Filter conditions as a JSON object. It requires a minimum structure as follows: {"glue":"and","conditions":[{"glue":"and","conditions": [CONDITION_OBJECTS]},{"glue":"or","conditions":[CONDITION_OBJECTS]}]}. Replace CONDITION_OBJECTS with JSON objects of the following structure: {"object":"","field_id":"", "operator":"","value":"", "extra_value":""} or leave the array empty. Depending on the object type you should use another API endpoint to get field_id. There are five types of objects you can choose from: "person", "deal", "organization", "product", "activity" and you can use these types of operators depending on what type of a field you have: "IS NOT NULL", "IS NULL", "<=", ">=", "<", ">", "!=", "=", "LIKE '%$%'", "NOT LIKE '%$%'", "LIKE '$%'", "NOT LIKE '$%'", "LIKE '%$'", "NOT LIKE '%$'". To get a better understanding of how filters work try creating them directly from the Pipedrive application.
type Required Type of filter to create.

Example Usage

 
    var input = [];
        input['name'] = 'name';
        input['conditions'] = 'conditions';
        input['type'] = Object.keys(FilterType)[0];
 
    controller.addANewFilter(input, function(error, response, context) {
 
    
    });

Method: getAllFilterHelpers

Returns all supported filter helpers. It helps to know what conditions and helpers are available when you want to add or update filters. For more information on how filter’s helpers can be used, see this tutorial.

function getAllFilterHelpers(callback)

Example Usage

 
 
    controller.getAllFilterHelpers(function(error, response, context) {
 
    
    });

Method: deleteAFilter

Marks a filter as deleted.

function deleteAFilter(id, callback)

Parameters

Parameter Tags Description
id Required ID of the filter

Example Usage

 
    var id = 58;
 
    controller.deleteAFilter(id, function(error, response, context) {
 
    
    });

Method: getOneFilter

Returns data about a specific filter. Note that this also returns the condition lines of the filter.

function getOneFilter(id, callback)

Parameters

Parameter Tags Description
id Required ID of the filter

Example Usage

 
    var id = 58;
 
    controller.getOneFilter(id, function(error, response, context) {
 
    
    });

Method: updateFilter

Updates existing filter.

function updateFilter(input, callback)

Parameters

Parameter Tags Description
id Required ID of the filter
conditions Required Filter conditions as a JSON object. It requires a minimum structure as follows: {"glue":"and","conditions":[{"glue":"and","conditions": [CONDITION_OBJECTS]},{"glue":"or","conditions":[CONDITION_OBJECTS]}]}. Replace CONDITION_OBJECTS with JSON objects of the following structure: {"object":"","field_id":"", "operator":"","value":"", "extra_value":""} or leave the array empty. Depending on the object type you should use another API endpoint to get field_id. There are five types of objects you can choose from: "person", "deal", "organization", "product", "activity" and you can use these types of operators depending on what type of a field you have: "IS NOT NULL", "IS NULL", "<=", ">=", "<", ">", "!=", "=", "LIKE '%$%'", "NOT LIKE '%$%'", "LIKE '$%'", "NOT LIKE '$%'", "LIKE '%$'", "NOT LIKE '%$'". To get a better understanding of how filters work try creating them directly from the Pipedrive application.
name Optional Filter name

Example Usage

 
    var input = [];
        input['id'] = 58;
        input['conditions'] = 'conditions';
        input['name'] = 'name';
 
    controller.updateFilter(input, function(error, response, context) {
 
    
    });

Back to List of Controllers

Class: GlobalMessagesController

Get singleton instance

The singleton instance of the GlobalMessagesController class can be accessed from the API Client.

var controller = lib.GlobalMessagesController;

Method: getGlobalMessages

Returns data about global messages to display for the authorized user.

function getGlobalMessages(limit, callback)

Parameters

Parameter Tags Description
limit Optional DefaultValue Number of messages to get from 1 to 100. The message number 1 is returned by default.

Example Usage

 
    var limit = 58;
 
    controller.getGlobalMessages(limit, function(error, response, context) {
 
    
    });

Method: deleteDismissAGlobalMessage

Removes global message from being shown, if message is dismissible

function deleteDismissAGlobalMessage(id, callback)

Parameters

Parameter Tags Description
id Required ID of global message to be dismissed.

Example Usage

 
    var id = 58;
 
    controller.deleteDismissAGlobalMessage(id, function(error, response, context) {
 
    
    });

Back to List of Controllers

Class: GoalsController

Get singleton instance

The singleton instance of the GoalsController class can be accessed from the API Client.

var controller = lib.GoalsController;

Method: addANewGoal

Adds a new goal.

function addANewGoal(input, callback)

Parameters

Parameter Tags Description
contentType Optional TODO: Add a parameter description
body Optional TODO: Add a parameter description

Example Usage

 
    var input = [];
        input['contentType'] = 'Content-Type';
        input['body'] = {
        id : 21
    };
 
    controller.addANewGoal(input, function(error, response, context) {
 
    
    });

Method: findGoals

Returns data about goals based on criteria. For searching, append {searchField}={searchValue} to the URL, where searchField can be any one of the lowest-level fields in dot-notation (e.g. type.params.pipeline_id; title). searchValue should be the value you are looking for on that field. Additionally, is_active=<true|false> can be provided to search for only active/inactive goals. When providing period.start, period.end must also be provided and vice versa.

function findGoals(input, callback)

Parameters

Parameter Tags Description
typeName Optional Type of the goal. If provided, everyone's goals will be returned.
title Optional Title of the goal.
isActive Optional DefaultValue Whether goal is active or not.
assigneeId Optional ID of the user who's goal to fetch. When omitted, only your goals will be returned.
assigneeType Optional Type of the goal's assignee. If provided, everyone's goals will be returned.
expectedOutcomeTarget Optional Numeric value of the outcome. If provided, everyone's goals will be returned.
expectedOutcomeTrackingMetric Optional Tracking metric of the expected outcome of the goal. If provided, everyone's goals will be returned.
expectedOutcomeCurrencyId Optional Numeric ID of the goal's currency. Only applicable to goals with expected_outcome.tracking_metric with value sum. If provided, everyone's goals will be returned.
typeParamsPipelineId Optional ID of the pipeline or null for all pipelines. If provided, everyone's goals will be returned.
typeParamsStageId Optional ID of the stage. Applicable to only deals_progressed type of goals. If provided, everyone's goals will be returned.
typeParamsActivityTypeId Optional ID of the activity type. Applicable to only activities_completed or activities_added types of goals. If provided, everyone's goals will be returned.
periodStart Optional Start date of the period for which to find goals. Date in format of YYYY-MM-DD. When period.start is provided, period.end must be provided too.
periodEnd Optional End date of the period for which to find goals. Date in format of YYYY-MM-DD.

Example Usage

 
    var input = [];
        input['typeName'] = Object.keys(type.name)[0];
        input['title'] = 'title';
        input['isActive'] = True;
        input['assigneeId'] = 58;
        input['assigneeType'] = Object.keys(assignee.type)[0];
        input['expectedOutcomeTarget'] = 58.5644835925496;
        input['expectedOutcomeTrackingMetric'] = Object.keys(expected_outcome.tracking_metric)[0];
        input['expectedOutcomeCurrencyId'] = 58;
        input['typeParamsPipelineId'] = 58;
        input['typeParamsStageId'] = 58;
        input['typeParamsActivityTypeId'] = 58;
        input['periodStart'] = '2019-11-22';
        input['periodEnd'] = '2019-11-22';
 
    controller.findGoals(input, function(error, response, context) {
 
    
    });

Method: updateExistingGoal

Updates existing goal.

function updateExistingGoal(input, callback)

Parameters

Parameter Tags Description
id Required ID of the goal to be updated.
title Optional Title of the goal.
assignee Optional Who is this goal assigned to. It requires the following JSON structure: { "id": "1", "type": "person" }. type can be either person, company or team. ID of the assignee person, company or team.
type Optional Type of the goal. It requires the following JSON structure: { "name": "deals_started", "params": { "pipeline_id": 1 } }. Type can be one of: deals_won,deals_progressed,activities_completed,activities_added or deals_started. params can include pipeline_id, stage_id or activity_type_id. stage_id is related to only deals_progressed type of goals and activity_type_id to activities_completed or activities_added types of goals. To track goal in all pipelines set pipeline_id as null.
expectedOutcome Optional Expected outcome of the goal. Expected outcome can be tracked either by quantity or by sum. It requires the following JSON structure: { "target": "50", "tracking_metric": "quantity" } or { "target": "50", "tracking_metric": "sum", "currency_id": 1 }. currency_id should only be added to sum type of goals.
duration Optional Date when the goal starts and ends. It requires the following JSON structure: { "start": "2019-01-01", "end": "2022-12-31" }. Date in format of YYYY-MM-DD.
interval Optional Date when the goal starts and ends. It requires the following JSON structure: { "start": "2019-01-01", "end": "2022-12-31" }. Date in format of YYYY-MM-DD.

Example Usage

 
    var input = [];
        input['id'] = 'id';
        input['title'] = 'title';
        input['assignee'] = {
        id : 21
    };
        input['type'] = {
        id : 21
    };
        input['expectedOutcome'] = {
        id : 21
    };
        input['duration'] = {
        id : 21
    };
        input['interval'] = Object.keys(Interval)[0];
 
    controller.updateExistingGoal(input, function(error, response, context) {
 
    
    });

Method: deleteExistingGoal

Marks goal as deleted.

function deleteExistingGoal(id, callback)

Parameters

Parameter Tags Description
id Required ID of the goal to be deleted.

Example Usage

 
    var id = 'id';
 
    controller.deleteExistingGoal(id, function(error, response, context) {
 
    
    });

Method: getResultOfAGoal

Gets progress of a goal for specified period.

function getResultOfAGoal(input, callback)

Parameters

Parameter Tags Description
id Required ID of the goal that the results are looked for.
periodStart Required Start date of the period for which to find progress of a goal. Date in format of YYYY-MM-DD.
periodEnd Required End date of the period for which to find progress of a goal. Date in format of YYYY-MM-DD.

Example Usage

 
    var input = [];
        input['id'] = 'id';
        input['periodStart'] = '2019-11-22';
        input['periodEnd'] = '2019-11-22';
 
    controller.getResultOfAGoal(input, function(error, response, context) {
 
    
    });

Back to List of Controllers

Class: MailMessagesController

Get singleton instance

The singleton instance of the MailMessagesController class can be accessed from the API Client.

var controller = lib.MailMessagesController;

Method: getOneMailMessage

Returns data about specific mail message.

function getOneMailMessage(input, callback)

Parameters

Parameter Tags Description
id Required ID of the mail message to fetch.
includeBody Optional Whether to include full message body or not. 0 = Don't include, 1 = Include

Example Usage

 
    var input = [];
        input['id'] = 58;
        input['includeBody'] = Object.keys(NumberBoolean)[0];
 
    controller.getOneMailMessage(input, function(error, response, context) {
 
    
    });

Back to List of Controllers

Class: MailThreadsController

Get singleton instance

The singleton instance of the MailThreadsController class can be accessed from the API Client.

var controller = lib.MailThreadsController;

Method: getMailThreads

Returns mail threads in specified folder ordered by most recent message within.

function getMailThreads(input, callback)

Parameters

Parameter Tags Description
folder Required DefaultValue Type of folder to fetch.
start Optional DefaultValue Pagination start
limit Optional Items shown per page

Example Usage

 
    var input = [];
        input['folder'] = new FolderEnum(inbox);
        input['start'] = 0;
        input['limit'] = 58;
 
    controller.getMailThreads(input, function(error, response, context) {
 
    
    });

Method: deleteMailThread

Marks mail thread as deleted.

function deleteMailThread(id, callback)

Parameters

Parameter Tags Description
id Required ID of the mail thread

Example Usage

 
    var id = 58;
 
    controller.deleteMailThread(id, function(error, response, context) {
 
    
    });

Method: getOneMailThread

Returns specific mail thread.

function getOneMailThread(id, callback)

Parameters

Parameter Tags Description
id Required ID of the mail thread

Example Usage

 
    var id = 58;
 
    controller.getOneMailThread(id, function(error, response, context) {
 
    
    });

Method: updateMailThreadDetails

Updates the properties of a mail thread.

function updateMailThreadDetails(input, callback)

Parameters

Parameter Tags Description
id Required ID of the mail thread
dealId Optional ID of the deal this thread is associated with
sharedFlag Optional TODO: Add a parameter description
readFlag Optional TODO: Add a parameter description
archivedFlag Optional TODO: Add a parameter description

Example Usage

 
    var input = [];
        input['id'] = 58;
        input['dealId'] = 58;
        input['sharedFlag'] = Object.keys(NumberBoolean)[0];
        input['readFlag'] = Object.keys(NumberBoolean)[0];
        input['archivedFlag'] = Object.keys(NumberBoolean)[0];
 
    controller.updateMailThreadDetails(input, function(error, response, context) {
 
    
    });

Method: getAllMailMessagesOfMailThread

Get mail messages inside specified mail thread.

function getAllMailMessagesOfMailThread(id, callback)

Parameters

Parameter Tags Description
id Required ID of the mail thread

Example Usage

 
    var id = 58;
 
    controller.getAllMailMessagesOfMailThread(id, function(error, response, context) {
 
    
    });

Back to List of Controllers

Class: NoteFieldsController

Get singleton instance

The singleton instance of the NoteFieldsController class can be accessed from the API Client.

var controller = lib.NoteFieldsController;

Method: getAllFieldsForANote

Return list of all fields for note

function getAllFieldsForANote(callback)

Example Usage

 
 
    controller.getAllFieldsForANote(function(error, response, context) {
 
    
    });

Back to List of Controllers

Class: NotesController

Get singleton instance

The singleton instance of the NotesController class can be accessed from the API Client.

var controller = lib.NotesController;

Method: getAllNotes

Returns all notes.

function getAllNotes(input, callback)

Parameters

Parameter Tags Description
userId Optional ID of the user whose notes to fetch. If omitted, notes by all users will be returned.
dealId Optional ID of the deal which notes to fetch. If omitted, notes about all deals with be returned.
personId Optional ID of the person whose notes to fetch. If omitted, notes about all persons with be returned.
orgId Optional ID of the organization which notes to fetch. If omitted, notes about all organizations with be returned.
start Optional DefaultValue Pagination start
limit Optional Items shown per page
sort Optional Field names and sorting mode separated by a comma (field_name_1 ASC, field_name_2 DESC). Only first-level field keys are supported (no nested keys). Supported fields: id, user_id, deal_id, person_id, org_id, content, add_time, update_time.
startDate Optional Date in format of YYYY-MM-DD from which notes to fetch from.
endDate Optional Date in format of YYYY-MM-DD until which notes to fetch to.
pinnedToDealFlag Optional If set, then results are filtered by note to deal pinning state.
pinnedToOrganizationFlag Optional If set, then results are filtered by note to organization pinning state.
pinnedToPersonFlag Optional If set, then results are filtered by note to person pinning state.

Example Usage

 
    var input = [];
        input['userId'] = 58;
        input['dealId'] = 58;
        input['personId'] = 58;
        input['orgId'] = 58;
        input['start'] = 0;
        input['limit'] = 58;
        input['sort'] = 'sort';
        input['startDate'] = '2019-11-22';
        input['endDate'] = '2019-11-22';
        input['pinnedToDealFlag'] = Object.keys(NumberBoolean)[0];
        input['pinnedToOrganizationFlag'] = Object.keys(NumberBoolean)[0];
        input['pinnedToPersonFlag'] = Object.keys(NumberBoolean)[0];
 
    controller.getAllNotes(input, function(error, response, context) {
 
    
    });

Method: addANote

Adds a new note.

function addANote(input, callback)

Parameters

Parameter Tags Description
content Required Content of the note in HTML format. Subject to sanitization on the back-end.
userId Optional ID of the user who will be marked as the author of this note. Only an admin can change the author.
dealId Optional ID of the deal the note will be attached to.
personId Optional ID of the person this note will be attached to.
orgId Optional ID of the organization this note will be attached to.
addTime Optional Optional creation date & time of the Note in UTC. Can be set in the past or in the future. Requires admin user API token. Format: YYYY-MM-DD HH:MM:SS
pinnedToDealFlag Optional If set, then results are filtered by note to deal pinning state (deal_id is also required).
pinnedToOrganizationFlag Optional If set, then results are filtered by note to organization pinning state (org_id is also required).
pinnedToPersonFlag Optional If set, then results are filtered by note to person pinning state (person_id is also required).

Example Usage

 
    var input = [];
        input['content'] = 'content';
        input['userId'] = 58;
        input['dealId'] = 58;
        input['personId'] = 58;
        input['orgId'] = 58;
        input['addTime'] = add_time;
        input['pinnedToDealFlag'] = Object.keys(NumberBoolean)[0];
        input['pinnedToOrganizationFlag'] = Object.keys(NumberBoolean)[0];
        input['pinnedToPersonFlag'] = Object.keys(NumberBoolean)[0];
 
    controller.addANote(input, function(error, response, context) {
 
    
    });

Method: deleteANote

Deletes a specific note.

function deleteANote(id, callback)

Parameters

Parameter Tags Description
id Required ID of the note

Example Usage

 
    var id = 58;
 
    controller.deleteANote(id, function(error, response, context) {
 
    
    });

Method: getOneNote

Returns details about a specific note.

function getOneNote(id, callback)

Parameters

Parameter Tags Description
id Required ID of the note

Example Usage

 
    var id = 58;
 
    controller.getOneNote(id, function(error, response, context) {
 
    
    });

Method: updateANote

Updates a note.

function updateANote(input, callback)

Parameters

Parameter Tags Description
id Required ID of the note
content Required Content of the note in HTML format. Subject to sanitization on the back-end.
userId Optional ID of the user who will be marked as the author of this note. Only an admin can change the author.
dealId Optional ID of the deal the note will be attached to.
personId Optional ID of the person this note will be attached to.
orgId Optional ID of the organization this note will be attached to.
addTime Optional Optional creation date & time of the Note in UTC. Can be set in the past or in the future. Requires admin user API token. Format: YYYY-MM-DD HH:MM:SS
pinnedToDealFlag Optional If set, then results are filtered by note to deal pinning state (deal_id is also required).
pinnedToOrganizationFlag Optional If set, then results are filtered by note to organization pinning state (org_id is also required).
pinnedToPersonFlag Optional If set, then results are filtered by note to person pinning state (person_id is also required).

Example Usage

 
    var input = [];
        input['id'] = 58;
        input['content'] = 'content';
        input['userId'] = 58;
        input['dealId'] = 58;
        input['personId'] = 58;
        input['orgId'] = 58;
        input['addTime'] = add_time;
        input['pinnedToDealFlag'] = Object.keys(NumberBoolean)[0];
        input['pinnedToOrganizationFlag'] = Object.keys(NumberBoolean)[0];
        input['pinnedToPersonFlag'] = Object.keys(NumberBoolean)[0];
 
    controller.updateANote(input, function(error, response, context) {
 
    
    });

Back to List of Controllers

Class: OrganizationFieldsController

Get singleton instance

The singleton instance of the OrganizationFieldsController class can be accessed from the API Client.

var controller = lib.OrganizationFieldsController;

Method: deleteMultipleOrganizationFieldsInBulk

Marks multiple fields as deleted.

function deleteMultipleOrganizationFieldsInBulk(ids, callback)

Parameters

Parameter Tags Description
ids Required Comma-separated field IDs to delete

Example Usage

 
    var ids = 'ids';
 
    controller.deleteMultipleOrganizationFieldsInBulk(ids, function(error, response, context) {
 
    
    });

Method: getAllOrganizationFields

Returns data about all organization fields

function getAllOrganizationFields(callback)

Example Usage

 
 
    controller.getAllOrganizationFields(function(error, response, context) {
 
    
    });

Method: addANewOrganizationField

Adds a new organization field. For more information on adding a new custom field, see this tutorial.

function addANewOrganizationField(input, callback)

Parameters

Parameter Tags Description
contentType Optional TODO: Add a parameter description
body Optional TODO: Add a parameter description

Example Usage

 
    var input = [];
        input['contentType'] = 'Content-Type';
        input['body'] = {
        id : 21
    };
 
    controller.addANewOrganizationField(input, function(error, response, context) {
 
    
    });

Method: deleteAnOrganizationField

Marks a field as deleted. For more information on how to delete a custom field, see this tutorial.

function deleteAnOrganizationField(id, callback)

Parameters

Parameter Tags Description
id Required ID of the field

Example Usage

 
    var id = 58;
 
    controller.deleteAnOrganizationField(id, function(error, response, context) {
 
    
    });

Method: getOneOrganizationField

Returns data about a specific organization field.

function getOneOrganizationField(id, callback)

Parameters

Parameter Tags Description
id Required ID of the field

Example Usage

 
    var id = 58;
 
    controller.getOneOrganizationField(id, function(error, response, context) {
 
    
    });

Method: updateAnOrganizationField

Updates an organization field. See an example of updating custom fields’ values in this tutorial.

function updateAnOrganizationField(input, callback)

Parameters

Parameter Tags Description
id Required ID of the field
name Required Name of the field
options Optional When field_type is either set or enum, possible options must be supplied as a JSON-encoded sequential array of objects. All active items must be supplied and already existing items must have their ID supplied. New items only require a label. Example: [{"id":123,"label":"Existing Item"},{"label":"New Item"}]

Example Usage

 
    var input = [];
        input['id'] = 58;
        input['name'] = 'name';
        input['options'] = 'options';
 
    controller.updateAnOrganizationField(input, function(error, response, context) {
 
    
    });

Back to List of Controllers

Class: OrganizationRelationshipsController

Get singleton instance

The singleton instance of the OrganizationRelationshipsController class can be accessed from the API Client.

var controller = lib.OrganizationRelationshipsController;

Method: getAllRelationshipsForOrganization

Gets all of the relationships for a supplied organization id.

function getAllRelationshipsForOrganization(orgId, callback)

Parameters

Parameter Tags Description
orgId Required ID of the organization to get relationships for

Example Usage

 
    var orgId = 58;
 
    controller.getAllRelationshipsForOrganization(orgId, function(error, response, context) {
 
    
    });

Method: createAnOrganizationRelationship

Creates and returns an organization relationship.

function createAnOrganizationRelationship(input, callback)

Parameters

Parameter Tags Description
contentType Optional TODO: Add a parameter description
body Optional TODO: Add a parameter description

Example Usage

 
    var input = [];
        input['contentType'] = 'Content-Type';
        input['body'] = {
        id : 21
    };
 
    controller.createAnOrganizationRelationship(input, function(error, response, context) {
 
    
    });

Method: deleteAnOrganizationRelationship

Deletes an organization relationship and returns the deleted id.

function deleteAnOrganizationRelationship(id, callback)

Parameters

Parameter Tags Description
id Required ID of the organization relationship

Example Usage

 
    var id = 58;
 
    controller.deleteAnOrganizationRelationship(id, function(error, response, context) {
 
    
    });

Method: getOneOrganizationRelationship

Finds and returns an organization relationship from its ID.

function getOneOrganizationRelationship(input, callback)

Parameters

Parameter Tags Description
id Required ID of the organization relationship
orgId Optional ID of the base organization for the returned calculated values

Example Usage

 
    var input = [];
        input['id'] = 58;
        input['orgId'] = 58;
 
    controller.getOneOrganizationRelationship(input, function(error, response, context) {
 
    
    });

Method: updateAnOrganizationRelationship

Updates and returns an organization relationship.

function updateAnOrganizationRelationship(input, callback)

Parameters

Parameter Tags Description
id Required ID of the organization relationship
orgId Optional ID of the base organization for the returned calculated values
type Optional The type of organization relationship.
relOwnerOrgId Optional The owner of this relationship. If type is 'parent', then the owner is the parent and the linked organization is the daughter.
relLinkedOrgId Optional The linked organization in this relationship. If type is 'parent', then the linked organization is the daughter.

Example Usage

 
    var input = [];
        input['id'] = 58;
        input['orgId'] = 58;
        input['type'] = Object.keys(Type)[0];
        input['relOwnerOrgId'] = 58;
        input['relLinkedOrgId'] = 58;
 
    controller.updateAnOrganizationRelationship(input, function(error, response, context) {
 
    
    });

Back to List of Controllers

Class: OrganizationsController

Get singleton instance

The singleton instance of the OrganizationsController class can be accessed from the API Client.

var controller = lib.OrganizationsController;

Method: deleteMultipleOrganizationsInBulk

Marks multiple organizations as deleted.

function deleteMultipleOrganizationsInBulk(ids, callback)

Parameters

Parameter Tags Description
ids Required Comma-separated IDs that will be deleted

Example Usage

 
    var ids = 'ids';
 
    controller.deleteMultipleOrganizationsInBulk(ids, function(error, response, context) {
 
    
    });

Method: getAllOrganizations

Returns all organizations

function getAllOrganizations(input, callback)

Parameters

Parameter Tags Description
userId Optional If supplied, only organizations owned by the given user will be returned.
filterId Optional ID of the filter to use
firstChar Optional If supplied, only organizations whose name starts with the specified letter will be returned (case insensitive).
start Optional DefaultValue Pagination start
limit Optional Items shown per page
sort Optional Field names and sorting mode separated by a comma (field_name_1 ASC, field_name_2 DESC). Only first-level field keys are supported (no nested keys).

Example Usage

 
    var input = [];
        input['userId'] = 58;
        input['filterId'] = 58;
        input['firstChar'] = first_char;
        input['start'] = 0;
        input['limit'] = 58;
        input['sort'] = 'sort';
 
    controller.getAllOrganizations(input, function(error, response, context) {
 
    
    });

Method: addAnOrganization

Adds a new organization. Note that you can supply additional custom fields along with the request that are not described here. These custom fields are different for each Pipedrive account and can be recognized by long hashes as keys. To determine which custom fields exists, fetch the organizationFields and look for 'key' values. For more information on how to add an organization, see this tutorial.

function addAnOrganization(input, callback)

Parameters

Parameter Tags Description
contentType Optional TODO: Add a parameter description
body Optional TODO: Add a parameter description

Example Usage

 
    var input = [];
        input['contentType'] = 'Content-Type';
        input['body'] = {
        id : 21
    };
 
    controller.addAnOrganization(input, function(error, response, context) {
 
    
    });

Method: findOrganizationsByName

Searches all organizations by their name.

function findOrganizationsByName(input, callback)

Parameters

Parameter Tags Description
term Required Search term to look for
start Optional DefaultValue Pagination start
limit Optional Items shown per page

Example Usage

 
    var input = [];
        input['term'] = 'term';
        input['start'] = 58;
        input['limit'] = 58;
 
    controller.findOrganizationsByName(input, function(error, response, context) {
 
    
    });

Method: deleteAnOrganization

Marks an organization as deleted.

function deleteAnOrganization(id, callback)

Parameters

Parameter Tags Description
id Required ID of the organization

Example Usage

 
    var id = 58;
 
    controller.deleteAnOrganization(id, function(error, response, context) {
 
    
    });

Method: getDetailsOfAnOrganization

Returns details of an organization. Note that this also returns some additional fields which are not present when asking for all organizations. Also note that custom fields appear as long hashes in the resulting data. These hashes can be mapped against the 'key' value of organizationFields.

function getDetailsOfAnOrganization(id, callback)

Parameters

Parameter Tags Description
id Required ID of the organization

Example Usage

 
    var id = 58;
 
    controller.getDetailsOfAnOrganization(id, function(error, response, context) {
 
    
    });

Method: updateAnOrganization

Updates the properties of an organization.

function updateAnOrganization(input, callback)

Parameters

Parameter Tags Description
id Required ID of the organization
name Optional Organization name
ownerId Optional ID of the user who will be marked as the owner of this organization. When omitted, the authorized user ID will be used.
visibleTo Optional Visibility of the organization. If omitted, visibility will be set to the default visibility setting of this item type for the authorized user.<dl class="fields-list">
1
Owner & followers (private)
3
Entire company (shared)

Example Usage

 
    var input = [];
        input['id'] = 58;
        input['name'] = 'name';
        input['ownerId'] = 58;
        input['visibleTo'] = Object.keys(VisibleTo)[0];
 
    controller.updateAnOrganization(input, function(error, response, context) {
 
    
    });

Method: listActivitiesAssociatedWithAnOrganization

Lists activities associated with an organization.

function listActivitiesAssociatedWithAnOrganization(input, callback)

Parameters

Parameter Tags Description
id Required ID of the organization
start Optional DefaultValue Pagination start
limit Optional Items shown per page
done Optional Whether the activity is done or not. 0 = Not done, 1 = Done. If omitted returns both Done and Not done activities.
exclude Optional A comma-separated string of activity IDs to exclude from result

Example Usage

 
    var input = [];
        input['id'] = 58;
        input['start'] = 58;
        input['limit'] = 58;
        input['done'] = Object.keys(NumberBoolean)[0];
        input['exclude'] = 'exclude';
 
    controller.listActivitiesAssociatedWithAnOrganization(input, function(error, response, context) {
 
    
    });

Method: listDealsAssociatedWithAnOrganization

Lists deals associated with an organization.

function listDealsAssociatedWithAnOrganization(input, callback)

Parameters

Parameter Tags Description
id Required ID of the organization
start Optional DefaultValue Pagination start
limit Optional Items shown per page
status Optional DefaultValue Only fetch deals with specific status. If omitted, all not deleted deals are fetched.
sort Optional Field names and sorting mode separated by a comma (field_name_1 ASC, field_name_2 DESC). Only first-level field keys are supported (no nested keys).
onlyPrimaryAssociation Optional If set, only deals that are directly associated to the organization are fetched. If not set (default), all deals are fetched that are either directly or indirectly related to the organization. Indirect relations include relations through custom, organization-type fields and through persons of the given organization.

Example Usage

 
    var input = [];
        input['id'] = 58;
        input['start'] = 58;
        input['limit'] = 58;
        input['status'] = Object.keys(status2)[0];
        input['sort'] = 'sort';
        input['onlyPrimaryAssociation'] = Object.keys(NumberBoolean)[0];
 
    controller.listDealsAssociatedWithAnOrganization(input, function(error, response, context) {
 
    
    });

Method: listFilesAttachedToAnOrganization

Lists files associated with an organization.

function listFilesAttachedToAnOrganization(input, callback)

Parameters

Parameter Tags Description
id Required ID of the organization
start Optional DefaultValue Pagination start
limit Optional Items shown per page
includeDeletedFiles Optional When enabled, the list of files will also include deleted files. Please note that trying to download these files will not work.
sort Optional Field names and sorting mode separated by a comma (field_name_1 ASC, field_name_2 DESC). Only first-level field keys are supported (no nested keys). Supported fields: id, user_id, deal_id, person_id, org_id, product_id, add_time, update_time, file_name, file_type, file_size, comment.

Example Usage

 
    var input = [];
        input['id'] = 16;
        input['start'] = 16;
        input['limit'] = 16;
        input['includeDeletedFiles'] = Object.keys(NumberBoolean)[0];
        input['sort'] = 'sort';
 
    controller.listFilesAttachedToAnOrganization(input, function(error, response, context) {
 
    
    });

Method: listUpdatesAboutAnOrganization

Lists updates about an organization.

function listUpdatesAboutAnOrganization(input, callback)

Parameters

Parameter Tags Description
id Required ID of the organization
start Optional DefaultValue Pagination start
limit Optional Items shown per page

Example Usage

 
    var input = [];
        input['id'] = 16;
        input['start'] = 16;
        input['limit'] = 16;
 
    controller.listUpdatesAboutAnOrganization(input, function(error, response, context) {
 
    
    });

Method: listFollowersOfAnOrganization

Lists the followers of an organization.

function listFollowersOfAnOrganization(id, callback)

Parameters

Parameter Tags Description
id Required ID of the organization

Example Usage

 
    var id = 16;
 
    controller.listFollowersOfAnOrganization(id, function(error, response, context) {
 
    
    });

Method: addAFollowerToAnOrganization

Adds a follower to an organization.

function addAFollowerToAnOrganization(input, callback)

Parameters

Parameter Tags Description
id Required ID of the organization
userId Required ID of the user

Example Usage

 
    var input = [];
        input['id'] = 16;
        input['userId'] = 16;
 
    controller.addAFollowerToAnOrganization(input, function(error, response, context) {
 
    
    });

Method: deleteAFollowerFromAnOrganization

Deletes a follower from an organization. You can retrieve the follower_id from the List followers of an organization endpoint.

function deleteAFollowerFromAnOrganization(input, callback)

Parameters

Parameter Tags Description
id Required ID of the organization
followerId Required ID of the follower

Example Usage

 
    var input = [];
        input['id'] = 16;
        input['followerId'] = 16;
 
    controller.deleteAFollowerFromAnOrganization(input, function(error, response, context) {
 
    
    });

Method: listMailMessagesAssociatedWithAnOrganization

Lists mail messages associated with an organization.

function listMailMessagesAssociatedWithAnOrganization(input, callback)

Parameters

Parameter Tags Description
id Required ID of the organization
start Optional DefaultValue Pagination start
limit Optional Items shown per page

Example Usage

 
    var input = [];
        input['id'] = 16;
        input['start'] = 16;
        input['limit'] = 16;
 
    controller.listMailMessagesAssociatedWithAnOrganization(input, function(error, response, context) {
 
    
    });

Method: updateMergeTwoOrganizations

Merges an organization with another organization. For more information on how to merge two organizations, see this tutorial.

function updateMergeTwoOrganizations(input, callback)

Parameters

Parameter Tags Description
id Required ID of the organization
mergeWithId Required ID of the organization that the organization will be merged with

Example Usage

 
    var input = [];
        input['id'] = 16;
        input['mergeWithId'] = 16;
 
    controller.updateMergeTwoOrganizations(input, function(error, response, context) {
 
    
    });

Method: listPermittedUsers

List users permitted to access an organization

function listPermittedUsers(id, callback)

Parameters

Parameter Tags Description
id Required ID of the organization

Example Usage

 
    var id = 16;
 
    controller.listPermittedUsers(id, function(error, response, context) {
 
    
    });

Method: listPersonsOfAnOrganization

Lists persons associated with an organization.

function listPersonsOfAnOrganization(input, callback)

Parameters

Parameter Tags Description
id Required ID of the organization
start Optional DefaultValue Pagination start
limit Optional Items shown per page

Example Usage

 
    var input = [];
        input['id'] = 16;
        input['start'] = 16;
        input['limit'] = 16;
 
    controller.listPersonsOfAnOrganization(input, function(error, response, context) {
 
    
    });

Back to List of Controllers

Class: PermissionSetsController

Get singleton instance

The singleton instance of the PermissionSetsController class can be accessed from the API Client.

var controller = lib.PermissionSetsController;

Method: getAllPermissionSets

Get all Permission Sets

function getAllPermissionSets(callback)

Example Usage

 
 
    controller.getAllPermissionSets(function(error, response, context) {
 
    
    });

Errors

Error Code Error Description
404 If the User ID has no assignments, then it will return NotFound

Method: getOnePermissionSet

Get one Permission Set

function getOnePermissionSet(id, callback)

Parameters

Parameter Tags Description
id Required ID of the permission set

Example Usage

 
    var id = 16;
 
    controller.getOnePermissionSet(id, function(error, response, context) {
 
    
    });

Errors

Error Code Error Description
404 If the User ID has no assignments, then it will return NotFound

Method: listPermissionSetAssignments

The list of assignments for a Permission Set

function listPermissionSetAssignments(input, callback)

Parameters

Parameter Tags Description
id Required ID of the permission set
start Optional DefaultValue Pagination start
limit Optional Items shown per page

Example Usage

 
    var input = [];
        input['id'] = 16;
        input['start'] = 16;
        input['limit'] = 16;
 
    controller.listPermissionSetAssignments(input, function(error, response, context) {
 
    
    });

Errors

Error Code Error Description
404 If the User ID has no assignments, then it will return NotFound

Back to List of Controllers

Class: PersonFieldsController

Get singleton instance

The singleton instance of the PersonFieldsController class can be accessed from the API Client.

var controller = lib.PersonFieldsController;

Method: deleteMultiplePersonFieldsInBulk

Marks multiple fields as deleted.

function deleteMultiplePersonFieldsInBulk(ids, callback)

Parameters

Parameter Tags Description
ids Required Comma-separated field IDs to delete

Example Usage

 
    var ids = 'ids';
 
    controller.deleteMultiplePersonFieldsInBulk(ids, function(error, response, context) {
 
    
    });

Method: getAllPersonFields

Returns data about all person fields

function getAllPersonFields(callback)

Example Usage

 
 
    controller.getAllPersonFields(function(error, response, context) {
 
    
    });

Method: addANewPersonField

Adds a new person field. For more information on adding a new custom field, see this tutorial.

function addANewPersonField(input, callback)

Parameters

Parameter Tags Description
contentType Optional TODO: Add a parameter description
body Optional TODO: Add a parameter description

Example Usage

 
    var input = [];
        input['contentType'] = 'Content-Type';
        input['body'] = {
        id : 21
    };
 
    controller.addANewPersonField(input, function(error, response, context) {
 
    
    });

Method: deleteAPersonField

Marks a field as deleted. For more information on how to delete a custom field, see this tutorial.

function deleteAPersonField(id, callback)

Parameters

Parameter Tags Description
id Required ID of the field

Example Usage

 
    var id = 16;
 
    controller.deleteAPersonField(id, function(error, response, context) {
 
    
    });

Method: getOnePersonField

Returns data about a specific person field.

function getOnePersonField(id, callback)

Parameters

Parameter Tags Description
id Required ID of the field

Example Usage

 
    var id = 16;
 
    controller.getOnePersonField(id, function(error, response, context) {
 
    
    });

Method: updateAPersonField

Updates a person field. See an example of updating custom fields’ values in this tutorial.

function updateAPersonField(input, callback)

Parameters

Parameter Tags Description
id Required ID of the field
name Required Name of the field
options Optional When field_type is either set or enum, possible options must be supplied as a JSON-encoded sequential array of objects. All active items must be supplied and already existing items must have their ID supplied. New items only require a label. Example: [{"id":123,"label":"Existing Item"},{"label":"New Item"}]

Example Usage

 
    var input = [];
        input['id'] = 16;
        input['name'] = 'name';
        input['options'] = 'options';
 
    controller.updateAPersonField(input, function(error, response, context) {
 
    
    });

Back to List of Controllers

Class: PersonsController

Get singleton instance

The singleton instance of the PersonsController class can be accessed from the API Client.

var controller = lib.PersonsController;

Method: deleteMultiplePersonsInBulk

Marks multiple persons as deleted.

function deleteMultiplePersonsInBulk(ids, callback)

Parameters

Parameter Tags Description
ids Optional Comma-separated IDs that will be deleted

Example Usage

 
    var ids = 'ids';
 
    controller.deleteMultiplePersonsInBulk(ids, function(error, response, context) {
 
    
    });

Method: getAllPersons

Returns all persons

function getAllPersons(input, callback)

Parameters

Parameter Tags Description
userId Optional If supplied, only persons owned by the given user will be returned.
filterId Optional ID of the filter to use.
firstChar Optional If supplied, only persons whose name starts with the specified letter will be returned (case insensitive).
start Optional DefaultValue Pagination start
limit Optional Items shown per page
sort Optional Field names and sorting mode separated by a comma (field_name_1 ASC, field_name_2 DESC). Only first-level field keys are supported (no nested keys).

Example Usage

 
    var input = [];
        input['userId'] = 16;
        input['filterId'] = 16;
        input['firstChar'] = first_char;
        input['start'] = 0;
        input['limit'] = 16;
        input['sort'] = 'sort';
 
    controller.getAllPersons(input, function(error, response, context) {
 
    
    });

Method: addAPerson

Adds a new person. Note that you can supply additional custom fields along with the request that are not described here. These custom fields are different for each Pipedrive account and can be recognized by long hashes as keys. To determine which custom fields exists, fetch the personFields and look for 'key' values.

function addAPerson(input, callback)

Parameters

Parameter Tags Description
contentType Optional TODO: Add a parameter description
body Optional TODO: Add a parameter description

Example Usage

 
    var input = [];
        input['contentType'] = 'Content-Type';
        input['body'] = {
        id : 21
    };
 
    controller.addAPerson(input, function(error, response, context) {
 
    
    });

Method: findPersonsByName

Searches all persons by their name.

function findPersonsByName(input, callback)

Parameters

Parameter Tags Description
term Required Search term to look for
orgId Optional ID of the organization person is associated with.
start Optional DefaultValue Pagination start
limit Optional Items shown per page
searchByEmail Optional When enabled, term will only be matched against email addresses of people. Default: false

Example Usage

 
    var input = [];
        input['term'] = 'term';
        input['orgId'] = 16;
        input['start'] = 16;
        input['limit'] = 16;
        input['searchByEmail'] = Object.keys(NumberBoolean)[0];
 
    controller.findPersonsByName(input, function(error, response, context) {
 
    
    });

Method: deleteAPerson

Marks a person as deleted.

function deleteAPerson(id, callback)

Parameters

Parameter Tags Description
id Required ID of a person

Example Usage

 
    var id = 16;
 
    controller.deleteAPerson(id, function(error, response, context) {
 
    
    });

Method: getDetailsOfAPerson

Returns details of a person. Note that this also returns some additional fields which are not present when asking for all persons. Also note that custom fields appear as long hashes in the resulting data. These hashes can be mapped against the 'key' value of personFields.

function getDetailsOfAPerson(id, callback)

Parameters

Parameter Tags Description
id Required ID of a person

Example Usage

 
    var id = 16;
 
    controller.getDetailsOfAPerson(id, function(error, response, context) {
 
    
    });