# Import Swagger file in a shared workspace with API

**URL:** <https://community.postman.com/t/import-swagger-file-in-a-shared-workspace-with-api/8746>\
**Category:** Help Hub\
**Tags:** import\
**Created:** [November 1, 2019, 7:30pm UTC](https://community.postman.com/t/import-swagger-file-in-a-shared-workspace-with-api/8746 "2019-11-01T19:30:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![adrien](https://avatars.discourse-cdn.com/v4/letter/a/ea666f/32.png) [@adrien](https://community.postman.com/u/adrien)\
**Post date:** [November 1, 2019, 7:30pm UTC](https://community.postman.com/t/import-swagger-file-in-a-shared-workspace-with-api/8746/1 "2019-11-01T19:30:56Z")

</div>

Hi everyone,

I want to subscribe to the pro version of Postman but somethings is getting on the way.

With my application, I generate a swagger file in json that I can successfully import with the API ([Postman](https://docs.api.getpostman.com/?version=latest#09886971-e1e2-4a62-8f59-f7abfd79ff5e)) in my personnal workspace, but I want to share the new import collection in a shared workspace using the API. It is important that everything will be done with the API, because I want the operation to be automatic in the CI.

I try to put the url parameter ?workspace={workspace\_id} but without success.

Do you have any idea?

Thank you in advance.

Adrien

---

<div class="post-metadata">

**Author:** ![odanylewycz](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/odanylewycz/32/3240_2.png) [@odanylewycz](https://community.postman.com/u/odanylewycz)\
**Post date:** [November 1, 2019, 11:37pm UTC](https://community.postman.com/t/import-swagger-file-in-a-shared-workspace-with-api/8746/2 "2019-11-01T23:37:40Z")

</div>

HI @adrien,

Great question! So using the URL parameter won’t work, because their API specification doesn’t seem to allow it.

However, I just did some research and thought of this.

To share the the newly imported collection, get the collection ID, do a PUT on the workspace, and insert that collection ID into the body of the PUT call, and that may then share the collection with that team/shared workspace.

[https://docs.api.getpostman.com/?\_ga=2.40496162.122951159.1572644688-77696017.1572375204&version=latest#34edebd3-8a53-4927-8ed6-4874a298c2e3](https://docs.api.getpostman.com/?_ga=2.40496162.122951159.1572644688-77696017.1572375204&version=latest#34edebd3-8a53-4927-8ed6-4874a298c2e3)

```
curl --location --request PUT "https://api.getpostman.com/workspaces/{{SHARED_workspace_id}}" \
  --header "x-api-key: " \
  --header "Content-Type: application/json" \
  --data "{
\"workspace\": {
    \"name\": \"New Workspace updated\",
    \"type\": \"personal\",
    \"description\": \"Some description\",
    \"collections\": [
        {
            \"id\": \"{{YOUR_NEW_COLLECTION_ID}}",
            \"name\": \"COLLECTION NAME\",
            \"uid\": \"{{USER_ID}}-{{YOUR_NEW_COLLECTION_ID}}"
        }
    ],
    \"environments\": [
        {
            \"id\": \"83a1aaa2-a204-4bd8-9b92-4d486918906b\",
            \"name\": \"env\",
            \"uid\": \"8154-83a1aaa2-a204-4bd8-9b92-4d486918906b\"
        }
    ],
    \"mocks\": [
        {
            \"id\": \"cda672ef-1375-40e9-baee-e20ece8d7b65\"
        }
    ],
    \"monitors\": [
        {
            \"id\": \"1e889bd2-3862-4be0-b2c2-9b1fe9673aec\"
        }
    ]
}
}"

```

I have not tried this and do not know if it would work, but feel free to give it a shot.

I hope it works!

Regards,  
Orest

---

<div class="post-metadata">

**Author:** ![adrien](https://avatars.discourse-cdn.com/v4/letter/a/ea666f/32.png) [@adrien](https://community.postman.com/u/adrien)\
**Post date:** [November 4, 2019, 10:45am UTC](https://community.postman.com/t/import-swagger-file-in-a-shared-workspace-with-api/8746/3 "2019-11-04T10:45:14Z")

</div>

This is even better than creating a new collection each time I import a swagger file, because I can keep all by the collection preferences that are only available manually, like publishing.

Thank you very much.

---

<div class="post-metadata">

**Author:** ![odanylewycz](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/odanylewycz/32/3240_2.png) [@odanylewycz](https://community.postman.com/u/odanylewycz)\
**Post date:** [November 4, 2019, 11:52am UTC](https://community.postman.com/t/import-swagger-file-in-a-shared-workspace-with-api/8746/4 "2019-11-04T11:52:04Z")

</div>

Hi @adrien,

You’re welcome! I’m glad this helps and gives you the functionality you need, and then some.

All the best,  
Orest
