Last active
March 5, 2026 21:24
-
-
Save DannyDainton/be112eb94dfd57186e203273bc9d52b6 to your computer and use it in GitHub Desktop.
Revisions
-
DannyDainton revised this gist
Mar 5, 2026 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,7 +6,7 @@ set -euo pipefail API_KEY="POSTMAN_API_KEY" BASE_URL="https://api.getpostman.com" COLLECTION_ID="${1:?Usage: $0 <collection_id> <workspace_id>}" -
DannyDainton revised this gist
Mar 5, 2026 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,7 @@ #!/bin/bash # Copy a Postman Collection to a different workspace # Create a new Postman API Key for your user https://go.postman.co/settings/me/api-keys and add this to the API_KEY variable # Usage: ./copy_collection.sh <collection_id> <workspace_id> set -euo pipefail -
DannyDainton created this gist
Mar 5, 2026 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,47 @@ #!/bin/bash # Copy a Postman Collection to a different workspace # Usage: ./copy_collection.sh <collection_id> <workspace_id> set -euo pipefail API_KEY="POST API KEY" BASE_URL="https://api.getpostman.com" COLLECTION_ID="${1:?Usage: $0 <collection_id> <workspace_id>}" WORKSPACE_ID="${2:?Usage: $0 <collection_id> <workspace_id>}" echo "Fetching collection ${COLLECTION_ID}..." RESPONSE=$(curl -s -w "\n%{http_code}" \ -X GET "${BASE_URL}/collections/${COLLECTION_ID}" \ -H "X-Api-Key: ${API_KEY}") HTTP_CODE=$(echo "$RESPONSE" | tail -n1) BODY=$(echo "$RESPONSE" | sed '$d') if [[ "$HTTP_CODE" -ne 200 ]]; then echo "Error: GET /collections/${COLLECTION_ID} returned HTTP ${HTTP_CODE}" echo "$BODY" exit 1 fi echo "Creating collection in workspace ${WORKSPACE_ID}..." POST_RESPONSE=$(curl -s -w "\n%{http_code}" \ -X POST "${BASE_URL}/collections?workspace=${WORKSPACE_ID}" \ -H "X-Api-Key: ${API_KEY}" \ -H "Content-Type: application/json" \ -d "$BODY") POST_HTTP_CODE=$(echo "$POST_RESPONSE" | tail -n1) POST_BODY=$(echo "$POST_RESPONSE" | sed '$d') if [[ "$POST_HTTP_CODE" -ne 200 ]]; then echo "Error: POST /collections returned HTTP ${POST_HTTP_CODE}" echo "$POST_BODY" exit 1 fi echo "Collection copied successfully!" echo "$POST_BODY"