# Cannot delete collection items via the Postman API

**URL:** <https://community.postman.com/t/cannot-delete-collection-items-via-the-postman-api/52146>\
**Category:** Help Hub\
**Tags:** collections, postman-api\
**Created:** [September 21, 2023, 9:20am UTC](https://community.postman.com/t/cannot-delete-collection-items-via-the-postman-api/52146 "2023-09-21T09:20:03Z")\
**Posts on this page:** 16\
**Page:** 2

<div class="post-metadata">

**Author:** ![supply-technologist8](https://avatars.discourse-cdn.com/v4/letter/s/53a042/32.png) [@supply-technologist8](https://community.postman.com/u/supply-technologist8)\
**Post date:** [October 5, 2023, 9:37am UTC](https://community.postman.com/t/cannot-delete-collection-items-via-the-postman-api/52146/21 "2023-10-05T09:37:57Z")

</div>

Ok this seems to be a recent change as Danny told me in earlier inquiries of mine that I need to add it otherwise I will see errors (which was true at the time).

When you say just for the /apis/ endpoints isn’t this an example of an api call?

[https://api.getpostman.com/collections/11112000-bxxxd3xx-y1y2-54jk-1lkj-8af111288881/requests](https://api.getpostman.com/collections/11112000-bxxxd3xx-y1y2-54jk-1lkj-8af111288881/requests)

this is an example endpoint where I added the x-api-key header and the one we’re discussing above

---

<div class="post-metadata">

**Author:** ![david-espi-hernandez](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/david-espi-hernandez/32/25537_2.png) [@david-espi-hernandez](https://community.postman.com/u/david-espi-hernandez)\
**Post date:** [October 5, 2023, 10:31am UTC](https://community.postman.com/t/cannot-delete-collection-items-via-the-postman-api/52146/22 "2023-10-05T10:31:10Z")

</div>

Yes, it is a recent change. Before, the v2 header was necessary for these endpoints, but now they are part of the regular Postman API.  
The `/apis` endpoints are the `https://api.getpostman.com/apis` endpoints. Endpoints to manage your APIs via the Postman API ([Postman](https://www.postman.com/postman/workspace/postman-public-workspace/folder/12959542-1ef9fee3-610f-4cae-8f66-af128b33341b)). If you take a look at that documentation, you’ll see two folders in the collection: v9 and v10. The v10 header is necessary for the v10 endpoints.

---

<div class="post-metadata">

**Author:** ![supply-technologist8](https://avatars.discourse-cdn.com/v4/letter/s/53a042/32.png) [@supply-technologist8](https://community.postman.com/u/supply-technologist8)\
**Post date:** [October 5, 2023, 10:42am UTC](https://community.postman.com/t/cannot-delete-collection-items-via-the-postman-api/52146/23 "2023-10-05T10:42:42Z")

</div>

Thank you I think I understand now, I got mixed up the /apis/ with [https://api.getpostman.com/collections](https://api.getpostman.com/collections), thought I am calling the collections endpoint wrongly because of v2 v9 v10.

Thanks again for the time and explanation, have you got any comments with regards to the initial problem. I’ve provided the request bodies I am using for the collection examples, have you seen anything wrong with them etc.?

The collection in question is still in a really funky state, all changes I am doing on it keep adding more new requests and it’s a big mess. I am mostly surprised by calling PUT on the collection does not even clearing it up from all its items.

Are there postman logs available where I could see what’s going on under the hood when I try to delete something or when a request to the collection is made, presumably it fails but unsure why.

Thanks again for your time!

---

<div class="post-metadata">

**Author:** ![supply-technologist8](https://avatars.discourse-cdn.com/v4/letter/s/53a042/32.png) [@supply-technologist8](https://community.postman.com/u/supply-technologist8)\
**Post date:** [October 5, 2023, 11:17am UTC](https://community.postman.com/t/cannot-delete-collection-items-via-the-postman-api/52146/24 "2023-10-05T11:17:16Z")

</div>

In the console log I am seeing the following

![image](https://us1.discourse-cdn.com/getpostman/original/3X/b/6/b68dbef755ea6c599060c92361c27134ba162fd2.png)

Unsure whether this is a problem at all?

---

<div class="post-metadata">

**Author:** ![supply-technologist8](https://avatars.discourse-cdn.com/v4/letter/s/53a042/32.png) [@supply-technologist8](https://community.postman.com/u/supply-technologist8)\
**Post date:** [October 5, 2023, 12:16pm UTC](https://community.postman.com/t/cannot-delete-collection-items-via-the-postman-api/52146/25 "2023-10-05T12:16:48Z")

</div>

loading the collection from incognito browser  
 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/0/4/0486a0a96d3b223d6789e8fff1a106fd6938024c.png)

how the collection looks on the postman desktop client (masked/deleted the names on the image)

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/5/7/57f3d675364b7caa5e2ee831749ffcd966b6f9e2.png)

if I click for the first image on create request, all items from the 2nd image appear from somewhere, and this is the only collection which behaves like this

if I call GET collections/collectionID  
I get the following response

```auto
{
    "collection": {
        "info": {
            "_postman_id": "some-guid-id",
            "name": "some-name",
            "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
            "updatedAt": "2023-10-05T12:02:02.000Z",
            "uid": "some-uid"
        },
        "item": []
    }
}

```

if I export the collection from the desktop client I get a json with all the items that appear in the collection…  
if I call a response example POST serverUrl/path/collectionItemName I get the expected response, but the Get collections/collectionID suggests my collection is empty… this is really confusing. I have deleted the mock server and mocked collection several times but the new ones behave exactly the same.

Thanks for reading my wall of text, hope it helps!

---

<div class="post-metadata">

**Author:** ![david-espi-hernandez](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/david-espi-hernandez/32/25537_2.png) [@david-espi-hernandez](https://community.postman.com/u/david-espi-hernandez)\
**Post date:** [October 5, 2023, 12:32pm UTC](https://community.postman.com/t/cannot-delete-collection-items-via-the-postman-api/52146/26 "2023-10-05T12:32:14Z")

</div>

Hi, Cris!  
I’ll read the whole thread and will come back to you tomorrow.

---

<div class="post-metadata">

**Author:** ![david-espi-hernandez](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/david-espi-hernandez/32/25537_2.png) [@david-espi-hernandez](https://community.postman.com/u/david-espi-hernandez)\
**Post date:** [October 6, 2023, 7:52am UTC](https://community.postman.com/t/cannot-delete-collection-items-via-the-postman-api/52146/27 "2023-10-06T07:52:30Z")

</div>

Hi, Cris!  
The main issues I see in the thread are:

- You must use the PATCH endpoint to update the collection name, not the PUT endpoint. The PUT endpoint overwrites the whole collection. That’s probably why you lose the information.
- You can manage the collection items (requests, responses, and folders) using the collection items API. You can fully CRUD these items (create, update, read, and delete them). Please see the examples we provide in the public postman collection here: [Postman](https://www.postman.com/postman/workspace/postman-public-workspace/folder/12959542-efeda219-66e1-474c-a83b-253d15723bf7)

I would advise working initially with a single request and creating a process that works with just that request. The collection items API works well if you follow the examples we provide in the public Postman collection. We provide examples to create requests and responses of many different types (GET, POST, with auth, with tests…), please check the body you are sending when you create the request is correct. Once you have that working collection, with a single request, add the rest of the requests, and it should work the same way.

Thanks!

---

<div class="post-metadata">

**Author:** ![supply-technologist8](https://avatars.discourse-cdn.com/v4/letter/s/53a042/32.png) [@supply-technologist8](https://community.postman.com/u/supply-technologist8)\
**Post date:** [October 6, 2023, 8:16am UTC](https://community.postman.com/t/cannot-delete-collection-items-via-the-postman-api/52146/28 "2023-10-06T08:16:09Z")

</div>

Hi David @david-espi-hernandez ,

I am doing everything right, I promise! I got your point mixing up PATCH/PUT, I only reset the collection with PUT and do not make any updates with it. The actual problem is around that and deleting ghost collection items.

when I do a PUT with this body

```auto
{
    "collection": {
        "info": {
            "name": "test_collection",
            "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
        },
        "item": []
    }
}

```

Nothing changes, which is not our expectation?

Yesterday I tried to delete one directly with the api i.e.  
[https://api.getpostman.com/collections/collectionId/requests/requestId](https://api.getpostman.com/collections/collectionId/requests/requestId)

and got this response

```auto
{
    "error": {
        "name": "forbiddenError",
        "message": "You are not permitted to perform the action.",
        "details": {
            "model": "request",
            "model_id": "some-guid",
            "owner": "12345678",
            "message": "You are not authorized to access this instance."
        }
    }
}

```

any ideas why I am not authorized to perform delete?

---

<div class="post-metadata">

**Author:** ![supply-technologist8](https://avatars.discourse-cdn.com/v4/letter/s/53a042/32.png) [@supply-technologist8](https://community.postman.com/u/supply-technologist8)\
**Post date:** [October 6, 2023, 8:50am UTC](https://community.postman.com/t/cannot-delete-collection-items-via-the-postman-api/52146/29 "2023-10-06T08:50:36Z")

</div>

logs from the desktop app

```auto
[21388][1696581943647][requester][info]["RequestInterfaceV2~deleteRequest - Delete request failed: ",{"error":{"name":"instanceNotFoundError","message":"We could not find the request you are looking for","details":{"model":"request","model_id":"fa236d55-f286-f510-2e8d-8070f019cf8b","owner":"11111111"}},"status":404,"headers":{}}]
[21388][1696581943675][requester][error]["Error in pipeline for deleting request",{"name":"Error","message":"Error in deleting request: 11111111-fa236d55-f286-f510-2e8d-8070f019cf8b","stack":"Error: Error in deleting request: 11111111-fa236d55-f286-f510-2e8d-8070f019cf8b\n at https://desktop.postman.com/_ar-assets/common-a195baebf2b28d18.min.js:10182:491102\n at nrWrapper (https://desktop.postman.com/?desktopVersion=10.18.10&userId=11111111&teamId=540469:10:29518)"}]

```

it’s funny as I am deleting it manually and it’s there but it’s not there?

also doing get collection returns no items but I actually see them and can actually request them?!

a bulk delete attempt

```auto
[21388][1696582585450][requester][error]["CollectionSidebarModel~handleDelete: Delete call failed",{"name":"Error","message":"Failed to apply patches to collections","stack":"Error: Failed to apply patches to collections\n at https://desktop.postman.com/_ar-assets/common-a195baebf2b28d18.min.js:10182:325054\n at nrWrapper (https://desktop.postman.com/?desktopVersion=10.18.10&userId=11111111&teamId=540469:10:29518)"}]

```

also not sure what this means and whether it is important but there u go

```auto
[21388][1696582576035][requester][error]["ReleaseListStore~getReleases: apiId or apiVersionId is missing"]
[21388][1696582576127][requester][info]["AutosaveManager~subscribeToSettingsUpdates: Settings is initialised."]
[21388][1696582576442][requester][error]["CommentController~getCommentCount: Something went wrong while fetching comment count.",{"trace":"v=1;t=906950452c04b6e1","error":{"name":"unauthorized","message":"You do not have access to this resource","code":403}}]
[21388][1696582576442][requester][error]["CommentsContributor~fetchRequestCommentsCount: Failed to fetch comments count"]

```

---

<div class="post-metadata">

**Author:** ![david-espi-hernandez](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/david-espi-hernandez/32/25537_2.png) [@david-espi-hernandez](https://community.postman.com/u/david-espi-hernandez)\
**Post date:** [October 6, 2023, 12:37pm UTC](https://community.postman.com/t/cannot-delete-collection-items-via-the-postman-api/52146/30 "2023-10-06T12:37:40Z")

</div>

Hi!  
Can you provide me with a collection that I can import and execute locally to reproduce the error? It’s difficult for me to figure out what’s going on.  
Thanks!

---

<div class="post-metadata">

**Author:** ![supply-technologist8](https://avatars.discourse-cdn.com/v4/letter/s/53a042/32.png) [@supply-technologist8](https://community.postman.com/u/supply-technologist8)\
**Post date:** [October 9, 2023, 12:12pm UTC](https://community.postman.com/t/cannot-delete-collection-items-via-the-postman-api/52146/31 "2023-10-09T12:12:15Z")

</div>

Hi @david-espi-hernandez,

Let me know if I should open a new thread. I will try to illustrate the problem again

1. I create a postman mock server mocking a collection
2. I create requests and example responses (programmatically by creating the request then using its id to create the example response, this happens in a foreach loop for all collection items I am creating ~15 in total)
3. I then need to recrate all examples and responses
4. I request a PUT to the collection
5. I then create requests and example responses (programmatically by creating the request then using its id to create the example response, this happens in a foreach loop for all collection items I am creating ~15 in total)

What I am experiencing is that the postman client is showing me duplicates of the requests/responses. When I try to delete any or all I receive these errors

![image](https://us1.discourse-cdn.com/getpostman/original/3X/a/f/af47324027c31ec68dd22b7baf608a0482dcbad2.png)  
and  
 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/c/9/c9b319e8b46117b7d1dafef1bd11b75d0343de76.png)

then I check the content of the collection with a GET and the response is emtpty

```auto
{
    "collection": {
        "info": {
            "_postman_id": "b53ed3ce-a5c7-43ad-9faa-8af055220261",
            "name": "collection",
            "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
            "updatedAt": "2023-10-09T11:17:22.000Z",
            "uid": "userId-collectionId"
        },
        "item": []
    }
}

```

but the postman client is still showing me all these duplicate requests which I cannot manually remove.

1. Using the postman web-client I am getting the stale responses ids from the url (remember according to result of GET collection, the collection is empty)

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/e/b/eb6f35317369efdb4c4c96aae8cb3b24fe08160f.png)

1. Calling Delete on [https://api.getpostman.com/collections/cid/requests/rid](https://api.getpostman.com/collections/cid/requests/rid) now returns

```auto
{
    "model_id": "f7b0b560-7444-a49b-b731-b3d54737c86a",
    "meta": {
        "model": "request",
        "action": "destroy"
    },
    "data": {
        "id": "f7b0b560-7444-a49b-b731-b3d54737c86a",
        "owner": "15363406"
    },
    "revision": 33003106812
}

```

1. Observing the collection with stale items, the deleted item is now gone, however, it’s really tedious to do this by hand just to clean up the collection.

Previously I was creating the whole collection with a PUT with all requests and responses as a single call, but hit the problem with postman mock payload of 1mb, and my collections have different sizes up to 15mbs and would probably grow more. So I resorted to create collection items one by one executing the correct api endpoints for that, but that appeared troublesome.

Questions to answer here would be

1. why the desktop/web clients seem out of sync and somehow retain old request/example pairs?
2. why PUT with empty collection does not seem to do what it is expected of it (at least not according to the web/desktop clients)
3. why Delete request work when the API returns an empty collection

Hope this can help your attempt in reproducing this issue.

Thanks

EDIT: After I manually deleted all stale items, and programatically created them anew, calling GET on the collection still returns empty collection, when I can actually see all responses created in the web and desktop clients.

Note the desktop client shown compounded count of items (matching my attemts to create/recreate) I have found that using this option

![image](https://us1.discourse-cdn.com/getpostman/original/3X/7/b/7b12f8eb951ed101f060998db219c2a20df43158.png)

helped syncronised the view between the web and desktop clients, however calling GET on the collection returns empty collection response via both clients.

calling GET on mockserverUrl/path/itemName  
returns correctly the response

---

<div class="post-metadata">

**Author:** ![supply-technologist8](https://avatars.discourse-cdn.com/v4/letter/s/53a042/32.png) [@supply-technologist8](https://community.postman.com/u/supply-technologist8)\
**Post date:** [October 11, 2023, 8:32am UTC](https://community.postman.com/t/cannot-delete-collection-items-via-the-postman-api/52146/32 "2023-10-11T08:32:46Z")

</div>

@danny-dainton @david-espi-hernandez I appreciate your help thus far, but the issue is still unresolved, anny suggestions on what we could do next to investigate and fix?

Thank you!

---

<div class="post-metadata">

**Author:** ![david-espi-hernandez](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/david-espi-hernandez/32/25537_2.png) [@david-espi-hernandez](https://community.postman.com/u/david-espi-hernandez)\
**Post date:** [October 11, 2023, 10:04am UTC](https://community.postman.com/t/cannot-delete-collection-items-via-the-postman-api/52146/33 "2023-10-11T10:04:50Z")

</div>

Hi, Cris!  
I think the best option is to have a short meeting where you can show me what you do. Please try to find a slot in my calendar so we can talk: [Calendly - David Espi Hernandez](https://calendly.com/david-espi-cya/30min?month=2023-10)  
In any case, if in step 4 you are doing a PUT, you probably want to do a PATCH instead.

---

<div class="post-metadata">

**Author:** ![supply-technologist8](https://avatars.discourse-cdn.com/v4/letter/s/53a042/32.png) [@supply-technologist8](https://community.postman.com/u/supply-technologist8)\
**Post date:** [October 11, 2023, 12:51pm UTC](https://community.postman.com/t/cannot-delete-collection-items-via-the-postman-api/52146/34 "2023-10-11T12:51:15Z")

</div>

Booked for Monday! Thanks!

---

<div class="post-metadata">

**Author:** ![david-espi-hernandez](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/david-espi-hernandez/32/25537_2.png) [@david-espi-hernandez](https://community.postman.com/u/david-espi-hernandez)\
**Post date:** [October 25, 2023, 8:56am UTC](https://community.postman.com/t/cannot-delete-collection-items-via-the-postman-api/52146/35 "2023-10-25T08:56:00Z")

</div>

Hi! I’ve replied to this issue in the GitHub ticket here: [Postman API and Postman Client out of sync · Issue #12350 · postmanlabs/postman-app-support · GitHub](https://github.com/postmanlabs/postman-app-support/issues/12350)

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/system/32/29796_2.png) [@system](https://community.postman.com/u/system)\
**Post date:** [November 24, 2023, 8:56am UTC](https://community.postman.com/t/cannot-delete-collection-items-via-the-postman-api/52146/36 "2023-11-24T08:56:59Z")

</div>

Closed on November 24, 2023, 8:56am UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.

[Previous page](https://community.postman.com/t/cannot-delete-collection-items-via-the-postman-api/52146.md?page=1)
