Pipedrive API Documentation

Pipedrive's API Docs

Welcome to Pipedrive's Developer Documentation. Here you'll find comprehensive guides and documentation to help you start working with Pipedrive's API, as well as the Changelog to see any relevant changes regarding the public API.

Deleting a custom field

Let's say you've got a custom Person field named "Relationship status" and you've realized there's no need to fill this field in anymore, so now you want to delete it.

We don't recommend deleting a custom field, because it might permanently remove all data. In case you do delete by mistake, there's a chance that you can get it back by contacting our awesome support people.

If you still want to delete a custom field, follow the steps below.

You can adjust and apply this tutorial for deleting the custom field of a Deal, Organization, or a Product item.

Step 1: GET the ID of the custom Person field

First, create a file getPersonFields.php and follow our tutorials on how to find the API token and how to get the company domain.

To make a GET request, you'll need the correct URL meant for getting Person fields, an example would look like this https://companydomain.pipedrive.com/api/v1/personFields?api_token=659c9fddb16335e48cc67114694b52074e812e03. All available endpoints and their URLs are described in our API Reference.

Here's an example of what the request itself should look like in PHP. Don't forget to replace the data in the example code to yours (the $company_domain and the $api_token).

<?php
// Content of getPersonFields.php
  
// Pipedrive API token
$api_token = '659c9fddb16335e48cc67114694b52074e812e03';
  
// Pipedrive company domain
$company_domain = 'theunicorntail';
 
// URL for getting Person fields
$url = 'https://' . $company_domain . '.pipedrive.com/api/v1/personFields?start=0&api_token=' . $api_token;
 
// GET request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
   
echo 'Sending request...' . PHP_EOL;
   
$output = curl_exec($ch);
curl_close($ch);
 
// Create an array from the data that is sent back from the API
// As the original content from server is in JSON format, you need to convert it to a PHP array
$result = json_decode($output, true);
 
// Check if data returned in the result is empty
if (empty($result['data'])) {
    exit('Error: ' . $result['error'] . PHP_EOL);
}
 
// Print out full data if the result is not empty
print_r($result['data']);

Execute the code by using the php getPersonFields.php command in the command line.

Step 2: Check the payload of the GET request you just made

If the request was successful, you can now find the id of the custom Person field named "Relationship status" from the payload.

The original payload could be quite bulky, so here's the section from what you'll learn that the id of the custom Person field named "Relationship status" is 9068:

Array
(
    [0] => Array
        (
            [id] => 9068
            [key] => 199fda744ce708da51ac2500dcfc2811c0032365
            [name] => Relationship status
            [order_nr] => 1
            [field_type] => enum
            [add_time] => 2018-09-17 12:15:45
            [update_time] => 2018-09-17 12:16:53
        )

Step 3: Delete the custom Person field by making a DELETE request

Next, create a file deleteCustomPersonField.php

To make a DELETE request, you'll need the correct URL meant for deleting a Person field, an example would look like this https://companydomain.pipedrive.com/api/v1/personFields/9068?api_token=659c9fddb16335e48cc67114694b52074e812e03. If you want to use this tutorial for deleting other types of custom fields, you can find the needed URLs for that below:

Method
URL
Useful for

DELETE

Deleting a custom Deal field

DELETE

Deleting a custom Organization field

DELETE

Deleting a custom Person field

DELETE

Deleting a custom Product field

And as you can see from the example URL, you need to pass along the custom field's $id in the request URL.

Here's an example of what the request should look like in PHP. Don't forget to replace the data in the code example for your actual $id of the custom Person field you want to delete, and again the $company_domain, and the $api_token.

<?php
// Content of deleteCustomPersonField.php
   
// Pipedrive API token
$api_token = '659c9fddb16335e48cc67114694b52074e812e03';
  
// Pipedrive company domain
$company_domain = 'theunicorntail';
  
// The ID of the custom Person field you want to delete
$id = 9068;
  
// URL for deleting a custom Person field
$url = 'https://' . $company_domain . '.pipedrive.com/api/v1/personFields/' . $id . '?api_token=' . $api_token;
 
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
    
echo 'Sending request...' . PHP_EOL;
    
$output = curl_exec($ch);
curl_close($ch);
   
// Create an array from the data that is sent back from the API
// As the original content from server is in JSON format, you need to convert it to a PHP array
$result = json_decode($output, true);
 
// Check if data returned in the result is empty
if (empty($result['data'])) {
    exit('Error: ' . $result['error'] . PHP_EOL);
}
 
// If the custom Person field was deleted successfully, print the ID of the deleted field
if ($result['data']) {
    echo 'Success! The ID of the deleted custom Person field: ' . $result['data']['id'] . PHP_EOL;
}

And now execute the code by using the deleteCustomPersonField.php command in the command line.

Step 4: Check the output of the DELETE request you just made

In case of a successful request, this is the output you'll receive:

Sending request...
Success! The ID of the deleted custom Person field: 9068

You have now successfully deleted the custom Person field called "Relationship status". You can also check the change from the web app.

Updated 4 months ago


Further reading

Custom fields

Deleting a custom field


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.