---
title: Delete
description: Examples in this documentation depend on features activated in the ds-evaluation setup profile.
component: pingds
version: 7.3
page_id: pingds:rest-guide:delete-rest
canonical_url: https://docs.pingidentity.com/pingds/8.1/rest-guide/delete-rest.html
llms_txt: https://docs.pingidentity.com/pingds/llms.txt
docs_for_agents: https://developer.pingidentity.com/build-with-ai/docs-for-agents.md
revdate: 2023-05-16T09:42:49Z
keywords: ["REST API"]
superseded_by: https://docs.pingidentity.com/pingds/8.1/rest-guide/delete-rest.html
---

# Delete

|   |                                                                                                                                                                                                                        |
| - | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|   | Examples in this documentation depend on features activated in the `ds-evaluation` setup profile.For details, refer to [Learn about the evaluation setup profile](../install-guide/setup-ds.html#about-ds-evaluation). |

To delete a resource, perform an HTTP DELETE on the resource URL. The operation returns the resource you deleted:

```bash
$ curl \
 --request DELETE \
 --cacert ca-cert.pem \
 --user kvaughan:bribery \
 --silent \
 https://localhost:8443/api/users/newuser?_prettyPrint=true

{
  "_id" : "newuser",
  "_rev" : "<revision>",
  "_schema" : "frapi:opendj:rest2ldap:user:1.0",
  "_meta" : {
    "created" : "<datestamp>"
  },
  "userName" : "newuser@example.com",
  "displayName" : [ "New User" ],
  "name" : {
    "givenName" : "User",
    "familyName" : "New"
  },
  "contactInformation" : {
    "telephoneNumber" : "+1 408 555 1212",
    "emailAddress" : "newuser@example.com"
  },
  "manager" : {
    "_id" : "kvaughan",
    "_rev" : "<revision>"
  }
}
```

To delete a resource only if the resource matches a particular version, use an `If-Match: revision` header:

```bash
$ export REVISION=$(cut -d \" -f 8 <(curl --silent \
 --user kvaughan:bribery \
 --cacert ca-cert.pem \
 https://localhost:8443/api/users/newuser?_fields=_rev))

$ curl \
 --request DELETE \
 --cacert ca-cert.pem \
 --user kvaughan:bribery \
 --header "If-Match: $REVISION" \
 --silent \
 https://localhost:8443/api/users/newuser?_prettyPrint=true

{
  "_id" : "newuser",
  "_rev" : "<revision>",
  "_schema" : "frapi:opendj:rest2ldap:user:1.0",
  "_meta" : {
    "created" : "<datestamp>"
  },
  "userName" : "newuser@example.com",
  "displayName" : [ "New User" ],
  "name" : {
    "givenName" : "User",
    "familyName" : "New"
  },
  "contactInformation" : {
    "telephoneNumber" : "+1 408 555 1212",
    "emailAddress" : "newuser@example.com"
  },
  "manager" : {
    "_id" : "kvaughan",
    "_rev" : "<revision>"
  }
}
```

To delete a resource and all of its children, follow these high-level steps:

* Make sure that the REST to LDAP configuration does map the resources to delete to LDAP entries.

  For an example, refer to [Nested resources](rest-config.html#rest-add-subresource).

* If you are using the gateway, this requires the default setting of true for `useSubtreeDelete` in `WEB-INF/classes/rest2ldap/rest2ldap.json`.

  |   |                                                                                         |
  | - | --------------------------------------------------------------------------------------- |
  |   | Only users who have access to request a tree delete can delete resources with children. |

* Allow the REST user to use the subtree delete control:

  ```bash
  $ dsconfig \
   set-access-control-handler-prop \
   --hostname localhost \
   --port 4444 \
   --bindDN uid=admin \
   --bindPassword password \
   --add global-aci:"(targetcontrol=\"SubtreeDelete\")\
   (version 3.0; acl \"Allow Subtree Delete\"; allow(read) \
   userdn=\"ldap:///uid=kvaughan,ou=People,dc=example,dc=com\";)" \
   --usePkcs12TrustStore /path/to/opendj/config/keystore \
   --trustStorePassword:file /path/to/opendj/config/keystore.pin \
   --no-prompt
  ```

* Request the delete as a user who has rights to perform a subtree delete on the resource.

  |   |                                                                                                                                       |
  | - | ------------------------------------------------------------------------------------------------------------------------------------- |
  |   | This can be a resource-intensive operation. The resources required to remove a branch depend on the number of LDAP entries to delete. |
