client-nodejs

by pipedrive

pipedrive / client-nodejs

Pipedrive API client for NodeJS

129 Stars 47 Forks Last release: 8 months ago (v10.0.0) MIT License 401 Commits 43 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

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.
JavaScript
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. ```JavaScript 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 userid 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 moreactivitiesscheduledincontext property in response's additionaldata 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 <a href="https://pipedrive.readme.io/docs/adding-an-activity" target="blank" rel="noopener noreferrer">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 keystring 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: [{"personid":1,"primaryflag":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 moreactivitiesscheduledincontext 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 keystring 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: [{"personid":1,"primaryflag":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 (fieldname1 ASC, fieldname2 DESC). Only first-level field keys are supported (no nested keys). | | ownedByYou |
Optional
| When supplied, only deals owned by you are returned. However filterid takes precedence over ownedby_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
| userid 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 (fieldkey) — 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 fieldkey.

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 startdate
month
A full month (depending on the number of days in given month) starting from startdate
quarter
A full quarter (3 months) starting from startdate
| | amount |
Required
| Number of given intervals, starting from startdate, 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, totalsconverted is returned per each interval which contains the currency-converted total amounts in the given currency. You may also set this parameter to 'defaultcurrency' 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 stageid). 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 (fieldname1 ASC, fieldname2 DESC). Only first-level field keys are supported (no nested keys). Supported fields: id, userid, dealid, personid, orgid, productid, addtime, updatetime, filename, filetype, filesize, 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 productattachmentid.

function deleteAnAttachedProductFromADeal(input, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of the deal | | productAttachmentId |
Required
| Product attachment ID. This is returned as productattachmentid 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 (fieldname1 ASC, fieldname2 DESC). Only first-level field keys are supported (no nested keys). Supported fields: id, userid, dealid, personid, orgid, productid, addtime, updatetime, filename, filetype, filesize, 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": [CONDITIONOBJECTS]},{"glue":"or","conditions":[CONDITIONOBJECTS]}]}. Replace CONDITIONOBJECTS with JSON objects of the following structure: {"object":"","fieldid":"", "operator":"","value":"", "extravalue":""} or leave the array empty. Depending on the object type you should use another API endpoint to get fieldid. 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": [CONDITIONOBJECTS]},{"glue":"or","conditions":[CONDITIONOBJECTS]}]}. Replace CONDITIONOBJECTS with JSON objects of the following structure: {"object":"","fieldid":"", "operator":"","value":"", "extravalue":""} or leave the array empty. Depending on the object type you should use another API endpoint to get fieldid. 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=
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": "dealsstarted", "params": { "pipelineid": 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", "trackingmetric": "quantity" } or { "target": "50", "trackingmetric": "sum", "currencyid": 1 }. `currencyid
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 (fieldname1 ASC, fieldname2 DESC). Only first-level field keys are supported (no nested keys). Supported fields: id, userid, dealid, personid, orgid, content, addtime, updatetime. | | 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 (dealid 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 (dealid 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 (fieldname1 ASC, fieldname2 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.
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 (fieldname1 ASC, fieldname2 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 (fieldname1 ASC, fieldname2 DESC). Only first-level field keys are supported (no nested keys). Supported fields: id, userid, dealid, personid, orgid, productid, addtime, updatetime, filename, filetype, filesize, 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 followerid from the <a href="https://developers.pipedrive.com/docs/api/v1/#!/Organizations/getorganizationsidfollowers">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 (fieldname1 ASC, fieldname2 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) {


});

Method: updateAPerson

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

function updateAPerson(input, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of a person | | name |
Optional
| Person name | | ownerId |
Optional
| ID of the user who will be marked as the owner of this person. When omitted, the authorized user ID will be used. | | orgId |
Optional
| ID of the organization this person will belong to. | | email |
Optional
Collection
| Email addresses (one or more) associated with the person, presented in the same manner as received by GET request of a person. | | phone |
Optional
Collection
| Phone numbers (one or more) associated with the person, presented in the same manner as received by GET request of a person. | | visibleTo |
Optional
| Visibility of the person. 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'] = 16;
        input['name'] = 'name';
        input['ownerId'] = 16;
        input['orgId'] = 16;
        input['email'] = ['email'];
        input['phone'] = ['phone'];
        input['visibleTo'] = Object.keys(VisibleTo)[0];

controller.updateAPerson(input, function(error, response, context) {


});

Method: listActivitiesAssociatedWithAPerson

Lists activities associated with a person.

function listActivitiesAssociatedWithAPerson(input, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of a person | | 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'] = 16;
        input['start'] = 16;
        input['limit'] = 16;
        input['done'] = Object.keys(NumberBoolean)[0];
        input['exclude'] = 'exclude';

controller.listActivitiesAssociatedWithAPerson(input, function(error, response, context) {


});

Method: listDealsAssociatedWithAPerson

Lists deals associated with a person.

function listDealsAssociatedWithAPerson(input, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of a person | | 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 (fieldname1 ASC, fieldname2 DESC). Only first-level field keys are supported (no nested keys). |

Example Usage

    var input = [];
        input['id'] = 16;
        input['start'] = 16;
        input['limit'] = 16;
        input['status'] = Object.keys(status2)[0];
        input['sort'] = 'sort';

controller.listDealsAssociatedWithAPerson(input, function(error, response, context) {


});

Method: listFilesAttachedToAPerson

Lists files associated with a person.

function listFilesAttachedToAPerson(input, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of a person | | 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 (fieldname1 ASC, fieldname2 DESC). Only first-level field keys are supported (no nested keys). Supported fields: id, userid, dealid, personid, orgid, productid, addtime, updatetime, filename, filetype, filesize, comment. |

Example Usage

    var input = [];
        input['id'] = 16;
        input['start'] = 16;
        input['limit'] = 16;
        input['includeDeletedFiles'] = Object.keys(NumberBoolean)[0];
        input['sort'] = 'sort';

controller.listFilesAttachedToAPerson(input, function(error, response, context) {


});

Method: listUpdatesAboutAPerson

Lists updates about a person.

function listUpdatesAboutAPerson(input, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of a person | | 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.listUpdatesAboutAPerson(input, function(error, response, context) {


});

Method: listFollowersOfAPerson

Lists the followers of a person.

function listFollowersOfAPerson(id, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of a person |

Example Usage

    var id = 16;

controller.listFollowersOfAPerson(id, function(error, response, context) {


});

Method: addAFollowerToAPerson

Adds a follower to a person.

function addAFollowerToAPerson(input, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of a person | | userId |
Required
| ID of the user |

Example Usage

    var input = [];
        input['id'] = 16;
        input['userId'] = 16;

controller.addAFollowerToAPerson(input, function(error, response, context) {


});

Method: deletesAFollowerFromAPerson

Delete a follower from a person

function deletesAFollowerFromAPerson(input, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of a person | | followerId |
Required
| ID of the follower |

Example Usage

    var input = [];
        input['id'] = 16;
        input['followerId'] = 16;

controller.deletesAFollowerFromAPerson(input, function(error, response, context) {


});

Method: listMailMessagesAssociatedWithAPerson

Lists mail messages associated with a person.

function listMailMessagesAssociatedWithAPerson(input, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of a person | | 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.listMailMessagesAssociatedWithAPerson(input, function(error, response, context) {


});

Method: updateMergeTwoPersons

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

function updateMergeTwoPersons(input, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of a person | | mergeWithId |
Required
| ID of the person that the person will be merged with |

Example Usage

    var input = [];
        input['id'] = 16;
        input['mergeWithId'] = 16;

controller.updateMergeTwoPersons(input, function(error, response, context) {


});

Method: listPermittedUsers

List users permitted to access a person

function listPermittedUsers(id, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of a person |

Example Usage

    var id = 16;

controller.listPermittedUsers(id, function(error, response, context) {


});

Method: deletePersonPicture

Delete person picture

function deletePersonPicture(id, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of a person |

Example Usage

    var id = 16;

controller.deletePersonPicture(id, function(error, response, context) {


});

Method: addPersonPicture

Add a picture to a person. If a picture is already set, the old picture will be replaced. Added image (or the cropping parameters supplied with the request) should have an equal width and height and should be at least 128 pixels. GIF, JPG and PNG are accepted. All added images will be resized to 128 and 512 pixel wide squares.

function addPersonPicture(input, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of a person | | file |
Required
| One image supplied in the multipart/form-data encoding. | | cropX |
Optional
| X coordinate to where start cropping form (in pixels) | | cropY |
Optional
| Y coordinate to where start cropping form (in pixels) | | cropWidth |
Optional
| Width of cropping area (in pixels) | | cropHeight |
Optional
| Height of cropping area (in pixels) |

Example Usage

    TestHelper.getFilePath('url', function(data) {
        var input = [];
        input['id'] = 16;
        input['file'] = data;
        input['cropX'] = 16;
        input['cropY'] = 16;
        input['cropWidth'] = 16;
        input['cropHeight'] = 16;

    controller.addPersonPicture(input, function(error, response, context) {

    });
});

Method: listProductsAssociatedWithAPerson

Lists products associated with a person.

function listProductsAssociatedWithAPerson(input, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of a person | | 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.listProductsAssociatedWithAPerson(input, function(error, response, context) {


});

Back to List of Controllers

Class: PipelinesController

Get singleton instance

The singleton instance of the

PipelinesController
class can be accessed from the API Client.
var controller = lib.PipelinesController;

Method: getAllPipelines

Returns data about all pipelines

function getAllPipelines(callback)

Example Usage

controller.getAllPipelines(function(error, response, context) {


});

Method: addANewPipeline

Adds a new pipeline

function addANewPipeline(input, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | name |

Optional
| Name of the pipeline | | dealProbability |
Optional
| TODO: Add a parameter description | | orderNr |
Optional
| Defines pipelines order. First order(order_nr=0) is the default pipeline. | | active |
Optional
| TODO: Add a parameter description |

Example Usage

    var input = [];
        input['name'] = 'name';
        input['dealProbability'] = Object.keys(NumberBoolean)[0];
        input['orderNr'] = 16;
        input['active'] = Object.keys(NumberBoolean)[0];

controller.addANewPipeline(input, function(error, response, context) {


});

Method: deleteAPipeline

Marks a pipeline as deleted.

function deleteAPipeline(id, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of the pipeline |

Example Usage

    var id = 16;

controller.deleteAPipeline(id, function(error, response, context) {


});

Method: getOnePipeline

Returns data about a specific pipeline. Also returns the summary of the deals in this pipeline across its stages.

function getOnePipeline(input, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of the pipeline | | totalsConvertCurrency |
Optional
| 3-letter currency code of any of the supported currencies. When supplied, perstagesconverted is returned in dealssummary which contains the currency-converted total amounts in the given currency per each stage. You may also set this parameter to 'defaultcurrency' in which case users default currency is used. |

Example Usage

    var input = [];
        input['id'] = 16;
        input['totalsConvertCurrency'] = totals_convert_currency;

controller.getOnePipeline(input, function(error, response, context) {


});

Method: updateEditAPipeline

Updates pipeline properties

function updateEditAPipeline(input, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of the pipeline | | name |
Optional
| Name of the pipeline | | dealProbability |
Optional
| TODO: Add a parameter description | | orderNr |
Optional
| Defines pipelines order. First order(order_nr=0) is the default pipeline. | | active |
Optional
| TODO: Add a parameter description |

Example Usage

    var input = [];
        input['id'] = 16;
        input['name'] = 'name';
        input['dealProbability'] = Object.keys(NumberBoolean)[0];
        input['orderNr'] = 16;
        input['active'] = Object.keys(NumberBoolean)[0];

controller.updateEditAPipeline(input, function(error, response, context) {


});

Method: getDealsConversionRatesInPipeline

Returns all stage-to-stage conversion and pipeline-to-close rates for given time period.

function getDealsConversionRatesInPipeline(input, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of the pipeline | | startDate |
Required
| Start of the period. Date in format of YYYY-MM-DD. | | endDate |
Required
| End of the period. Date in format of YYYY-MM-DD. | | userId |
Optional
| ID of the user who's pipeline metrics statistics to fetch. If omitted, the authorized user will be used. |

Example Usage

    var input = [];
        input['id'] = 16;
        input['startDate'] = '2019-11-22';
        input['endDate'] = '2019-11-22';
        input['userId'] = 16;

controller.getDealsConversionRatesInPipeline(input, function(error, response, context) {


});

Method: getDealsInAPipeline

Lists deals in a specific pipeline across all its stages

function getDealsInAPipeline(input, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of the pipeline | | filterId |
Optional
| If supplied, only deals matching the given filter will be returned. | | userId |
Optional
| If supplied, filterid will not be considered and only deals owned by the given user will be returned. If omitted, deals owned by the authorized user will be returned. | | everyone |
Optional
| If supplied, filter
id and userid will not be considered – instead, deals owned by everyone will be returned. | | stageId |
Optional
| If supplied, only deals within the given stage will be returned. | | start |
Optional
DefaultValue
| Pagination start | | limit |
Optional
| Items shown per page | | getSummary |
Optional
| Whether to include summary of the pipeline in the additional
data or not. | | totalsConvertCurrency |
Optional
| 3-letter currency code of any of the supported currencies. When supplied, perstagesconverted is returned inside dealssummary inside additionaldata which contains the currency-converted total amounts in the given currency per each stage. You may also set this parameter to 'defaultcurrency' in which case users default currency is used. Only works when getsummary parameter flag is enabled. |

Example Usage

    var input = [];
        input['id'] = 16;
        input['filterId'] = 16;
        input['userId'] = 16;
        input['everyone'] = Object.keys(NumberBoolean)[0];
        input['stageId'] = 16;
        input['start'] = 16;
        input['limit'] = 16;
        input['getSummary'] = Object.keys(NumberBoolean)[0];
        input['totalsConvertCurrency'] = totals_convert_currency;

controller.getDealsInAPipeline(input, function(error, response, context) {


});

Method: getDealsMovementsInPipeline

Returns statistics for deals movements for given time period.

function getDealsMovementsInPipeline(input, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of the pipeline | | startDate |
Required
| Start of the period. Date in format of YYYY-MM-DD. | | endDate |
Required
| End of the period. Date in format of YYYY-MM-DD. | | userId |
Optional
| ID of the user who's pipeline statistics to fetch. If omitted, the authorized user will be used. |

Example Usage

    var input = [];
        input['id'] = 16;
        input['startDate'] = '2019-11-22';
        input['endDate'] = '2019-11-22';
        input['userId'] = 16;

controller.getDealsMovementsInPipeline(input, function(error, response, context) {


});

Back to List of Controllers

Class: ProductFieldsController

Get singleton instance

The singleton instance of the

ProductFieldsController
class can be accessed from the API Client.
var controller = lib.ProductFieldsController;

Method: deleteMultipleProductFieldsInBulk

Marks multiple fields as deleted.

function deleteMultipleProductFieldsInBulk(ids, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | ids |

Required
| Comma-separated field IDs to delete |

Example Usage

    var ids = 'ids';

controller.deleteMultipleProductFieldsInBulk(ids, function(error, response, context) {


});

Method: getAllProductFields

Returns data about all product fields

function getAllProductFields(callback)

Example Usage

controller.getAllProductFields(function(error, response, context) {


});

Method: addANewProductField

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

function addANewProductField(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.addANewProductField(input, function(error, response, context) {


});

Method: deleteAProductField

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

function deleteAProductField(id, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of the Product Field |

Example Usage

    var id = 16;

controller.deleteAProductField(id, function(error, response, context) {


});

Errors

| Error Code | Error Description | |------------|-------------------| | 410 | The Product Field with the specified ID does not exist or is inaccessible |

Method: getOneProductField

Returns data about a specific product field.

function getOneProductField(id, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of the Product Field |

Example Usage

    var id = 16;

controller.getOneProductField(id, function(error, response, context) {


});

Errors

| Error Code | Error Description | |------------|-------------------| | 410 | The Product Field with the specified ID does not exist or is inaccessible |

Method: updateAProductField

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

function updateAProductField(input, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of the Product 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'] = 16;
        input['name'] = 'name';
        input['options'] = 'options';

controller.updateAProductField(input, function(error, response, context) {


});

Back to List of Controllers

Class: ProductsController

Get singleton instance

The singleton instance of the

ProductsController
class can be accessed from the API Client.
var controller = lib.ProductsController;

Method: getAllProducts

Returns data about all products.

function getAllProducts(input, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | userId |

Optional
| If supplied, only products owned by the given user will be returned. | | filterId |
Optional
| ID of the filter to use | | firstChar |
Optional
| If supplied, only products whose name starts with the specified letter will be returned (case insensitive). | | start |
Optional
DefaultValue
| Pagination start | | limit |
Optional
| Items shown per page |

Example Usage

    var input = [];
        input['userId'] = 16;
        input['filterId'] = 16;
        input['firstChar'] = first_char;
        input['start'] = 0;
        input['limit'] = 16;

controller.getAllProducts(input, function(error, response, context) {


});

Method: addAProduct

Adds a new product to the products inventory. For more information on how to add a product, see this tutorial.

function addAProduct(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.addAProduct(input, function(error, response, context) {


});

Method: findProductsByName

Returns data about the products that were found. If currency was set in request, prices in that currency are served back.

function findProductsByName(input, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | term |

Required
| Search term to look for, minimum 3 characters. | | currency |
Optional
| Currency code in which prices should be returned in. If omitted, prices in user's default currency will be returned. | | start |
Optional
DefaultValue
| Pagination start | | limit |
Optional
| Items shown per page |

Example Usage

    var input = [];
        input['term'] = 'term';
        input['currency'] = 'currency';
        input['start'] = 16;
        input['limit'] = 16;

controller.findProductsByName(input, function(error, response, context) {


});

Method: deleteAProduct

Marks a product as deleted.

function deleteAProduct(id, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of the product |

Example Usage

    var id = 16;

controller.deleteAProduct(id, function(error, response, context) {


});

Method: getOneProduct

Returns data about a specific product.

function getOneProduct(id, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of the product |

Example Usage

    var id = 16;

controller.getOneProduct(id, function(error, response, context) {


});

Method: updateAProduct

Updates product data.

function updateAProduct(input, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of the product | | name |
Optional
| Name of the product. | | code |
Optional
| Product code. | | unit |
Optional
| Unit in which this product is sold | | tax |
Optional
| Tax percentage | | activeFlag |
Optional
| Whether this product will be made active or not. | | visibleTo |
Optional
| Visibility of the product. 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)
| | ownerId |
Optional
| ID of the user who will be marked as the owner of this product. When omitted, the authorized user ID will be used. | | prices |
Optional
| Array of objects, each containing: currency (string), price (number), cost (number, optional), overhead_cost (number, optional). Note that there can only be one price per product per currency. When 'prices' is omitted altogether, no prices will be set up for the product. |

Example Usage

    var input = [];
        input['id'] = 16;
        input['name'] = 'name';
        input['code'] = 'code';
        input['unit'] = 'unit';
        input['tax'] = 16.841310365983;
        input['activeFlag'] = Object.keys(NumberBoolean)[0];
        input['visibleTo'] = Object.keys(VisibleTo)[0];
        input['ownerId'] = 16;
        input['prices'] = 'prices';

controller.updateAProduct(input, function(error, response, context) {


});

Method: getDealsWhereAProductIsAttachedTo

Returns data about deals that have a product attached to.

function getDealsWhereAProductIsAttachedTo(input, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of the product | | 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. |

Example Usage

    var input = [];
        input['id'] = 16;
        input['start'] = 16;
        input['limit'] = 16;
        input['status'] = Object.keys(status2)[0];

controller.getDealsWhereAProductIsAttachedTo(input, function(error, response, context) {


});

Method: listFilesAttachedToAProduct

Lists files associated with a product.

function listFilesAttachedToAProduct(input, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of the product | | 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 (fieldname1 ASC, fieldname2 DESC). Only first-level field keys are supported (no nested keys). Supported fields: id, userid, dealid, personid, orgid, productid, addtime, updatetime, filename, filetype, filesize, comment. |

Example Usage

    var input = [];
        input['id'] = 16;
        input['start'] = 16;
        input['limit'] = 16;
        input['includeDeletedFiles'] = Object.keys(NumberBoolean)[0];
        input['sort'] = 'sort';

controller.listFilesAttachedToAProduct(input, function(error, response, context) {


});

Method: listFollowersOfAProduct

Lists the followers of a Product

function listFollowersOfAProduct(id, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of the product |

Example Usage

    var id = 16;

controller.listFollowersOfAProduct(id, function(error, response, context) {


});

Method: addAFollowerToAProduct

Adds a follower to a product.

function addAFollowerToAProduct(input, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of the product | | userId |
Required
| ID of the user |

Example Usage

    var input = [];
        input['id'] = 16;
        input['userId'] = 16;

controller.addAFollowerToAProduct(input, function(error, response, context) {


});

Method: deleteAFollowerFromAProduct

Deletes a follower from a product.

function deleteAFollowerFromAProduct(input, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of the product | | followerId |
Required
| ID of the follower |

Example Usage

    var input = [];
        input['id'] = 16;
        input['followerId'] = 16;

controller.deleteAFollowerFromAProduct(input, function(error, response, context) {


});

Method: listPermittedUsers

Lists users permitted to access a product.

function listPermittedUsers(id, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of the product |

Example Usage

    var id = 16;

controller.listPermittedUsers(id, function(error, response, context) {


});

Back to List of Controllers

Class: RecentsController

Get singleton instance

The singleton instance of the

RecentsController
class can be accessed from the API Client.
var controller = lib.RecentsController;

Method: getRecents

Returns data about all recent changes occured after given timestamp.

function getRecents(input, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | sinceTimestamp |

Required
| Timestamp in UTC. Format: YYYY-MM-DD HH:MM:SS | | items |
Optional
| Multiple selection of item types to include in query (optional) | | start |
Optional
DefaultValue
| Pagination start | | limit |
Optional
| Items shown per page |

Example Usage

    var input = [];
        input['sinceTimestamp'] = since_timestamp;
        input['items'] = Object.keys(items)[0];
        input['start'] = 16;
        input['limit'] = 16;

controller.getRecents(input, function(error, response, context) {


});

Back to List of Controllers

Class: RolesController

Get singleton instance

The singleton instance of the

RolesController
class can be accessed from the API Client.
var controller = lib.RolesController;

Method: getAllRoles

Get all roles

function getAllRoles(input, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | start |

Optional
DefaultValue
| Pagination start | | limit |
Optional
| Items shown per page |

Example Usage

    var input = [];
        input['start'] = 16;
        input['limit'] = 16;

controller.getAllRoles(input, function(error, response, context) {


});

Method: addARole

Add a role

function addARole(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.addARole(input, function(error, response, context) {


});

Method: deleteARole

Delete a role

function deleteARole(id, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of the role |

Example Usage

    var id = 16;

controller.deleteARole(id, function(error, response, context) {


});

Method: getOneRole

Get one role

function getOneRole(id, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of the role |

Example Usage

    var id = 16;

controller.getOneRole(id, function(error, response, context) {


});

Method: updateRoleDetails

Update role details

function updateRoleDetails(input, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of the role | | parentRoleId |
Optional
| The ID of the parent Role | | name |
Optional
| The name of the Role |

Example Usage

    var input = [];
        input['id'] = 16;
        input['parentRoleId'] = 16;
        input['name'] = 'name';

controller.updateRoleDetails(input, function(error, response, context) {


});

Method: deleteARoleAssignment

Delete assignment from a role

function deleteARoleAssignment(input, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of the role | | userId |
Required
| ID of the user |

Example Usage

    var input = [];
        input['id'] = 16;
        input['userId'] = 16;

controller.deleteARoleAssignment(input, function(error, response, context) {


});

Method: listRoleAssignments

List assignments for a role

function listRoleAssignments(input, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of the role | | 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.listRoleAssignments(input, function(error, response, context) {


});

Method: addRoleAssignment

Add assignment for a role

function addRoleAssignment(input, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of the role | | userId |
Required
| ID of the user |

Example Usage

    var input = [];
        input['id'] = 16;
        input['userId'] = 16;

controller.addRoleAssignment(input, function(error, response, context) {


});

Method: listRoleSubRoles

List role sub-roles

function listRoleSubRoles(input, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of the role | | 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.listRoleSubRoles(input, function(error, response, context) {


});

Method: listRoleSettings

List role settings

function listRoleSettings(id, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of the role |

Example Usage

    var id = 16;

controller.listRoleSettings(id, function(error, response, context) {


});

Method: addOrUpdateRoleSetting

Add or update role setting

function addOrUpdateRoleSetting(input, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of the role | | settingKey |
Required
| TODO: Add a parameter description | | value |
Required
| Possible values for default_visibility settings: 0...1. |

Example Usage

    var input = [];
        input['id'] = 16;
        input['settingKey'] = Object.keys(setting_key)[0];
        input['value'] = Object.keys(NumberBoolean)[0];

controller.addOrUpdateRoleSetting(input, function(error, response, context) {


});

Back to List of Controllers

Class: SearchResultsController

Get singleton instance

The singleton instance of the

SearchResultsController
class can be accessed from the API Client.
var controller = lib.SearchResultsController;

Method: getPerformASearch

Performs a search across the account and returns SearchResults.

function getPerformASearch(input, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | term |

Required
| Search term to look for, minimum 2 characters. | | itemType |
Optional
| Search for items of exact type. If omitted, all types of items are searched. | | start |
Optional
DefaultValue
| Pagination start | | limit |
Optional
| Items shown per page | | exactMatch |
Optional
| When enabled, only full exact matches against the given term are returned. The minimum 2 character limit for the term is discarded when exact_match is enabled. It will only work if search term is 30 characters or less. |

Example Usage

    var input = [];
        input['term'] = 'term';
        input['itemType'] = Object.keys(item_type2)[0];
        input['start'] = 16;
        input['limit'] = 16;
        input['exactMatch'] = Object.keys(NumberBoolean)[0];

controller.getPerformASearch(input, function(error, response, context) {


});

Method: getPerformASearchUsingASpecificFieldValue

Performs a search from a specific field's values. Results can be either the distinct values of the field (useful for searching autocomplete field values), or actual items IDs (deals, persons, organizations or products). Works only with the following field types: varchar, varchar_auto, double, address, text, phone, date.

function getPerformASearchUsingASpecificFieldValue(input, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | term |

Required
| Search term to look for, minimum 2 characters. | | fieldType |
Required
| Type of the field to perform the search from. | | fieldKey |
Required
| Key of the field to search from. Field key can be obtained by fetching the list of fields using any of fields API GET methods (dealFields, personFields, ..). | | exactMatch |
Optional
| When enabled, only full exact matches against the given term are returned. By default, term can be present anywhere in the resulting field values to be considered a match. The minimum 2 character limit for the term is discarded when exactmatch is enabled. | | returnFieldKey |
Optional
| Name of the field in search results from which the search was performed. When omitted, 'value' will be used. You may want to set this parameter to match the field
key. | | returnItemIds |
Optional
| Whether to return matching items IDs in search results. When omitted or set to 0, only distinct values of the searched field are returned. When enabled, the returnfieldkey parameter is ignored and the results include the searched field as its own key. | | start |
Optional
DefaultValue
| Pagination start | | limit |
Optional
| Items shown per page |

Example Usage

    var input = [];
        input['term'] = 'term';
        input['fieldType'] = Object.keys(field_type6)[0];
        input['fieldKey'] = field_key;
        input['exactMatch'] = Object.keys(NumberBoolean)[0];
        input['returnFieldKey'] = return_field_key;
        input['returnItemIds'] = Object.keys(NumberBoolean)[0];
        input['start'] = 16;
        input['limit'] = 16;

controller.getPerformASearchUsingASpecificFieldValue(input, function(error, response, context) {


});

Back to List of Controllers

Class: StagesController

Get singleton instance

The singleton instance of the

StagesController
class can be accessed from the API Client.
var controller = lib.StagesController;

Method: deleteMultipleStagesInBulk

Marks multiple stages as deleted.

function deleteMultipleStagesInBulk(ids, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | ids |

Required
| Comma-separated stage IDs to delete |

Example Usage

    var ids = 'ids';

controller.deleteMultipleStagesInBulk(ids, function(error, response, context) {


});

Method: getAllStages

Returns data about all stages

function getAllStages(pipelineId, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | pipelineId |

Optional
| ID of the pipeline to fetch stages for. If omitted, stages for all pipelines will be fetched. |

Example Usage

    var pipelineId = 16;

controller.getAllStages(pipelineId, function(error, response, context) {


});

Method: addANewStage

Adds a new stage, returns the ID upon success.

function addANewStage(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.addANewStage(input, function(error, response, context) {


});

Method: deleteAStage

Marks a stage as deleted.

function deleteAStage(id, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of the stage |

Example Usage

    var id = 16;

controller.deleteAStage(id, function(error, response, context) {


});

Method: getOneStage

Returns data about a specific stage

function getOneStage(id, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of the stage |

Example Usage

    var id = 16;

controller.getOneStage(id, function(error, response, context) {


});

Method: updateStageDetails

Updates the properties of a stage.

function updateStageDetails(input, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of the stage | | contentType |
Optional
| TODO: Add a parameter description | | body |
Optional
| TODO: Add a parameter description |

Example Usage

    var input = [];
        input['id'] = 16;
        input['contentType'] = 'Content-Type';
        input['body'] = {
        id : 21
    };

controller.updateStageDetails(input, function(error, response, context) {


});

Method: getDealsInAStage

Lists deals in a specific stage

function getDealsInAStage(input, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of the stage | | filterId |
Optional
| If supplied, only deals matching the given filter will be returned. | | userId |
Optional
| If supplied, filterid will not be considered and only deals owned by the given user will be returned. If omitted, deals owned by the authorized user will be returned. | | everyone |
Optional
| If supplied, filter
id and user_id will not be considered – instead, deals owned by everyone will be returned. | | start |
Optional
DefaultValue
| Pagination start | | limit |
Optional
| Items shown per page |

Example Usage

    var input = [];
        input['id'] = 16;
        input['filterId'] = 16;
        input['userId'] = 16;
        input['everyone'] = Object.keys(NumberBoolean)[0];
        input['start'] = 16;
        input['limit'] = 16;

controller.getDealsInAStage(input, function(error, response, context) {


});

Back to List of Controllers

Class: TeamsController

Get singleton instance

The singleton instance of the

TeamsController
class can be accessed from the API Client.
var controller = lib.TeamsController;

Method: getAllTeams

Returns data about teams within the company

function getAllTeams(input, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | orderBy |

Optional
DefaultValue
| Field name to sort returned teams by | | skipUsers |
Optional
| When enabled, the teams will not include IDs of member users |

Example Usage

    var input = [];
        input['orderBy'] = new OrderByEnum(id);
        input['skipUsers'] = Object.keys(NumberBoolean)[0];

controller.getAllTeams(input, function(error, response, context) {


});

Method: addANewTeam

Adds a new team to the company and returns the created object

function addANewTeam(input, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | name |

Required
| The Team name | | managerId |
Required
| The Team manager ID | | description |
Optional
| The Team description | | users |
Optional
Collection
| IDs of the Users that belong to the Team |

Example Usage

    var input = [];
        input['name'] = 'name';
        input['managerId'] = 16;
        input['description'] = 'description';
        input['users'] = [16];

controller.addANewTeam(input, function(error, response, context) {


});

Errors

| Error Code | Error Description | |------------|-------------------| | 403 | Forbidden response |

Method: getASingleTeam

Returns data about a specific team

function getASingleTeam(input, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of the team | | skipUsers |
Optional
| When enabled, the teams will not include IDs of member users |

Example Usage

    var input = [];
        input['id'] = 16;
        input['skipUsers'] = Object.keys(NumberBoolean)[0];

controller.getASingleTeam(input, function(error, response, context) {


});

Errors

| Error Code | Error Description | |------------|-------------------| | 404 | Team with specified ID does not exist or is inaccessible |

Method: updateATeam

Updates an existing team and returns the updated object

function updateATeam(input, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of the team | | contentType |
Optional
| TODO: Add a parameter description | | body |
Optional
| TODO: Add a parameter description |

Example Usage

    var input = [];
        input['id'] = 16;
        input['contentType'] = 'Content-Type';
        input['body'] = {
        id : 21
    };

controller.updateATeam(input, function(error, response, context) {


});

Errors

| Error Code | Error Description | |------------|-------------------| | 403 | Forbidden response | | 404 | Team with specified ID does not exist or is inaccessible |

Method: getAllUsersInATeam

Returns list of all user IDs within a team

function getAllUsersInATeam(id, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of the team |

Example Usage

    var id = 16;

controller.getAllUsersInATeam(id, function(error, response, context) {


});

Errors

| Error Code | Error Description | |------------|-------------------| | 404 | Team with specified ID does not exist or is inaccessible |

Method: addUsersToATeam

Adds users to an existing team

function addUsersToATeam(input, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of the team | | users |
Required
Collection
| List of User IDs |

Example Usage

    var input = [];
        input['id'] = 16;
        input['users'] = [16];

controller.addUsersToATeam(input, function(error, response, context) {


});

Errors

| Error Code | Error Description | |------------|-------------------| | 403 | Forbidden response | | 404 | Team with specified ID does not exist or is inaccessible |

Method: deleteUsersFromATeam

Deletes users from an existing team

function deleteUsersFromATeam(input, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of the team | | users |
Required
Collection
| List of User IDs |

Example Usage

    var input = [];
        input['id'] = 16;
        input['users'] = [16];

controller.deleteUsersFromATeam(input, function(error, response, context) {


});

Errors

| Error Code | Error Description | |------------|-------------------| | 403 | Forbidden response | | 404 | Team with specified ID does not exist or is inaccessible |

Method: getAllTeamsOfAUser

Returns data about all teams which have specified user as a member

function getAllTeamsOfAUser(input, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of the user | | orderBy |
Optional
DefaultValue
| Field name to sort returned teams by | | skipUsers |
Optional
| When enabled, the teams will not include IDs of member users |

Example Usage

    var input = [];
        input['id'] = 16;
        input['orderBy'] = Object.keys(order_by)[0];
        input['skipUsers'] = Object.keys(NumberBoolean)[0];

controller.getAllTeamsOfAUser(input, function(error, response, context) {


});

Back to List of Controllers

Class: UserConnectionsController

Get singleton instance

The singleton instance of the

UserConnectionsController
class can be accessed from the API Client.
var controller = lib.UserConnectionsController;

Method: getAllUserConnections

Returns data about all connections for authorized user.

function getAllUserConnections(callback)

Example Usage

controller.getAllUserConnections(function(error, response, context) {


});

Errors

| Error Code | Error Description | |------------|-------------------| | 401 | Unauthorized response |

Back to List of Controllers

Class: UserSettingsController

Get singleton instance

The singleton instance of the

UserSettingsController
class can be accessed from the API Client.
var controller = lib.UserSettingsController;

Method: listSettingsOfAuthorizedUser

Lists settings of authorized user.

function listSettingsOfAuthorizedUser(callback)

Example Usage

controller.listSettingsOfAuthorizedUser(function(error, response, context) {


});

Back to List of Controllers

Class: UsersController

Get singleton instance

The singleton instance of the

UsersController
class can be accessed from the API Client.
var controller = lib.UsersController;

Method: getAllUsers

Returns data about all users within the company

function getAllUsers(callback)

Example Usage

controller.getAllUsers(function(error, response, context) {


});

Method: addANewUser

Adds a new user to the company, returns the ID upon success.

function addANewUser(input, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | name |

Required
| Name of the user | | email |
Required
| Email of the user | | activeFlag |
Required
| Whether the user is active or not. false = Not activated, true = Activated |

Example Usage

    var input = [];
        input['name'] = 'name';
        input['email'] = 'email';
        input['activeFlag'] = false;

controller.addANewUser(input, function(error, response, context) {


});

Errors

| Error Code | Error Description | |------------|-------------------| | 403 | Forbidden response |

Method: findUsersByName

Finds users by their name.

function findUsersByName(input, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | term |

Required
| Search term to look for | | searchByEmail |
Optional
| When enabled, term will only be matched against email addresses of users. Default: false |

Example Usage

    var input = [];
        input['term'] = 'term';
        input['searchByEmail'] = Object.keys(NumberBoolean)[0];

controller.findUsersByName(input, function(error, response, context) {


});

Method: getCurrentUserData

Returns data about an authorized user within the company with bound company data: company ID, company name, and domain. Note that the 'locale' property means 'Date and number format' in the Pipedrive settings, not the chosen language.

function getCurrentUserData(callback)

Example Usage

controller.getCurrentUserData(function(error, response, context) {


});

Errors

| Error Code | Error Description | |------------|-------------------| | 401 | Unauthorized response |

Method: getOneUser

Returns data about a specific user within the company

function getOneUser(id, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of the user |

Example Usage

    var id = 16;

controller.getOneUser(id, function(error, response, context) {


});

Errors

| Error Code | Error Description | |------------|-------------------| | 404 | User with specified ID does not exist or is inaccessible |

Method: updateUserDetails

Updates the properties of a user. Currently, only active_flag can be updated.

function updateUserDetails(input, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of the user | | activeFlag |
Required
| Whether the user is active or not. false = Not activated, true = Activated |

Example Usage

    var input = [];
        input['id'] = 16;
        input['activeFlag'] = false;

controller.updateUserDetails(input, function(error, response, context) {


});

Errors

| Error Code | Error Description | |------------|-------------------| | 403 | Forbidden response | | 404 | User with specified ID does not exist or is inaccessible |

Method: listBlacklistedEmailAddressesOfAUser

Lists blacklisted email addresses of a specific user. Blacklisted emails are such that will not get synced in to Pipedrive when using the built-in Mailbox.

function listBlacklistedEmailAddressesOfAUser(id, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of the user |

Example Usage

    var id = 16;

controller.listBlacklistedEmailAddressesOfAUser(id, function(error, response, context) {


});

Method: addBlacklistedEmailAddressForAUser

Add blacklisted email address for a specific user.

function addBlacklistedEmailAddressForAUser(input, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of the user | | address |
Required
| Email address to blacklist (can contain \* for wildcards, e.g. \*@example.com, or john\*@ex\*.com) |

Example Usage

    var input = [];
        input['id'] = 16;
        input['address'] = 'address';

controller.addBlacklistedEmailAddressForAUser(input, function(error, response, context) {


});

Method: listFollowersOfAUser

Lists followers of a specific user.

function listFollowersOfAUser(id, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of the user |

Example Usage

    var id = 16;

controller.listFollowersOfAUser(id, function(error, response, context) {


});

Errors

| Error Code | Error Description | |------------|-------------------| | 403 | Forbidden response |

Method: listUserPermissions

List aggregated permissions over all assigned permission sets for a user

function listUserPermissions(id, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of the user |

Example Usage

    var id = 16;

controller.listUserPermissions(id, function(error, response, context) {


});

Method: deleteARoleAssignment

Delete a role assignment for a user

function deleteARoleAssignment(input, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of the user | | roleId |
Required
| ID of the role |

Example Usage

    var input = [];
        input['id'] = 16;
        input['roleId'] = 16;

controller.deleteARoleAssignment(input, function(error, response, context) {


});

Method: listRoleAssignments

List role assignments for a user

function listRoleAssignments(input, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of the user | | 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.listRoleAssignments(input, function(error, response, context) {


});

Method: addRoleAssignment

Add role assignment for a user

function addRoleAssignment(input, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of the user | | roleId |
Required
| ID of the role |

Example Usage

    var input = [];
        input['id'] = 16;
        input['roleId'] = 16;

controller.addRoleAssignment(input, function(error, response, context) {


});

Method: listUserRoleSettings

List settings of user's assigned role

function listUserRoleSettings(id, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| ID of the user |

Example Usage

    var id = 16;

controller.listUserRoleSettings(id, function(error, response, context) {


});

Back to List of Controllers

Class: WebhooksController

Get singleton instance

The singleton instance of the

WebhooksController
class can be accessed from the API Client.
var controller = lib.WebhooksController;

Method: getAllWebhooks

Returns data about all webhooks of a company.

function getAllWebhooks(callback)

Example Usage

controller.getAllWebhooks(function(error, response, context) {


});

Errors

| Error Code | Error Description | |------------|-------------------| | 401 | Unauthorized response |

Method: createANewWebhook

Creates a new webhook and returns its details. Note that specifying an event which triggers the webhook combines 2 parameters - 'eventaction' and 'eventobject'. E.g., use '*.*' for getting notifications about all events, 'added.deal' for any newly added deals, 'deleted.persons' for any deleted persons, etc. See https://pipedrive.readme.io/docs/guide-for-webhooks for more details.

function createANewWebhook(input, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | subscriptionUrl |

Required
| A full, valid, publicly accessible URL. Determines where to send the notifications. Please note that you cannot use Pipedrive API endpoints as the subscription_url. | | eventAction |
Required
| Type of action to receive notifications about. Wildcard will match all supported actions. | | eventObject |
Required
| Type of object to receive notifications about. Wildcard will match all supported objects. | | userId |
Optional
| The ID of the user this webhook will be authorized with. If not set, current authorized user will be used. Note that this does not filter only certain user's events — rather, this specifies the user's permissions under which each event is checked. Events about objects the selected user is not entitled to access are not sent. If you want to receive notifications for all events, a top-level admin user should be used. | | httpAuthUser |
Optional
| HTTP basic auth username of the subscription URL endpoint (if required). | | httpAuthPassword |
Optional
| HTTP basic auth password of the subscription URL endpoint (if required). |

Example Usage

    var input = [];
        input['subscriptionUrl'] = subscription_url;
        input['eventAction'] = Object.keys(event_action)[0];
        input['eventObject'] = Object.keys(event_object)[0];
        input['userId'] = 16;
        input['httpAuthUser'] = http_auth_user;
        input['httpAuthPassword'] = http_auth_password;

controller.createANewWebhook(input, function(error, response, context) {


});

Errors

| Error Code | Error Description | |------------|-------------------| | 400 | The bad response on webhook creation | | 401 | Unauthorized response |

Method: deleteExistingWebhook

Deletes the specified webhook.

function deleteExistingWebhook(id, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id |

Required
| The ID of the webhook to delete |

Example Usage

    var id = 16;

controller.deleteExistingWebhook(id, function(error, response, context) {


});

Errors

| Error Code | Error Description | |------------|-------------------| | 401 | Unauthorized response | | 403 | The webhook deletion forbidden response | | 404 | The webhook deletion not found response |

Back to List of Controllers

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.