Command line integration and testing
cURL is pre-installed on most Unix-based systems (Linux, macOS). For Windows, use Git Bash or WSL.
Export your API key as an environment variable for convenience:
export API_KEY="c2p_live_your_api_key_here"
Then use $API_KEY in your commands.
Fetch account information:
curl -X GET "https://app1.connect2print.com/api/v1/account" \
-H "Authorization: Bearer c2p_live_your_api_key_here" \
-H "Accept: application/json"
curl -X GET "https://app1.connect2print.com/api/v1/account" \
-H "Authorization: Bearer $API_KEY" \
-H "Accept: application/json"
curl -X GET "https://app1.connect2print.com/api/v1/account" \
-H "Authorization: Bearer $API_KEY" \
-H "Accept: application/json" | jq .
Fetch orders with pagination:
curl -X GET "https://app1.connect2print.com/api/v1/orders?page=1&per_page=25" \
-H "Authorization: Bearer $API_KEY" \
-H "Accept: application/json"
curl -X GET "https://app1.connect2print.com/api/v1/orders?status=completed&page=1" \
-H "Authorization: Bearer $API_KEY" \
-H "Accept: application/json"
curl -X GET "https://app1.connect2print.com/api/v1/orders?created_after=2026-01-01&created_before=2026-01-31" \
-H "Authorization: Bearer $API_KEY" \
-H "Accept: application/json"
Fetch a specific order by ID:
curl -X GET "https://app1.connect2print.com/api/v1/orders/123" \
-H "Authorization: Bearer $API_KEY" \
-H "Accept: application/json"
curl -X GET "https://app1.connect2print.com/api/v1/orders/123" \
-H "Authorization: Bearer $API_KEY" \
-H "Accept: application/json" \
-o order_123.json
Create a new customer with JSON data:
curl -X POST "https://app1.connect2print.com/api/v1/customers" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"email": "john.doe@example.com",
"company_name": "Acme Corporation",
"contact_name": "John Doe",
"phone": "+45 12 34 56 78",
"billing_address": {
"street_address": "Main Street 123",
"city": "Copenhagen",
"postal_code": "1000",
"country": "DK"
}
}'
curl -X POST "https://app1.connect2print.com/api/v1/customers" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d @customer.json
Update specific fields of an order:
curl -X PATCH "https://app1.connect2print.com/api/v1/orders/123" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"status": "processing",
"internal_notes": "Printing started on machine #2"
}'
Upload a production file:
curl -X POST "https://app1.connect2print.com/api/v1/files/upload" \
-H "Authorization: Bearer $API_KEY" \
-H "Accept: application/json" \
-F "file=@/path/to/your/file.pdf" \
-F "related_type=order" \
-F "related_id=123"
curl -X POST "https://app1.connect2print.com/api/v1/files/upload" \
-H "Authorization: Bearer $API_KEY" \
-H "Accept: application/json" \
-F "file=@brochure.pdf" \
-F "related_type=order" \
-F "related_id=123" \
--progress-bar
Delete an address:
curl -X DELETE "https://app1.connect2print.com/api/v1/addresses/456" \
-H "Authorization: Bearer $API_KEY" \
-H "Accept: application/json"
Include headers in output to see rate limits and other metadata:
curl -X GET "https://app1.connect2print.com/api/v1/orders" \
-H "Authorization: Bearer $API_KEY" \
-H "Accept: application/json" \
-i
curl -X GET "https://app1.connect2print.com/api/v1/orders" \
-H "Authorization: Bearer $API_KEY" \
-H "Accept: application/json" \
-I
Look for these important headers:
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 58
X-RateLimit-Reset: 1643723400
X-Request-Id: abc123def456
Simulate a webhook call with signature:
# Generate signature
PAYLOAD='{"event":"order.created","data":{"id":123}}'
SECRET="your_webhook_secret"
SIGNATURE=$(echo -n "$PAYLOAD" | openssl dgst -sha256 -hmac "$SECRET" | cut -d ' ' -f 2)
# Send webhook test
curl -X POST "http://your-server.com/webhooks/connect2print" \
-H "Content-Type: application/json" \
-H "X-Webhook-Signature: $SIGNATURE" \
-d "$PAYLOAD"
Capture HTTP status code and handle errors:
# Save HTTP status code to variable
HTTP_STATUS=$(curl -X GET "https://app1.connect2print.com/api/v1/orders/123" \
-H "Authorization: Bearer $API_KEY" \
-H "Accept: application/json" \
-o response.json \
-w '%{http_code}' \
-s)
# Check status code
if [ "$HTTP_STATUS" -eq 200 ]; then
echo "Success!"
cat response.json | jq .
elif [ "$HTTP_STATUS" -eq 404 ]; then
echo "Order not found"
elif [ "$HTTP_STATUS" -eq 401 ]; then
echo "Authentication failed - check your API key"
else
echo "Error: HTTP $HTTP_STATUS"
cat response.json
fi
Fetch all pages in a bash script:
#!/bin/bash
API_KEY="c2p_live_your_api_key_here"
BASE_URL="https://app1.connect2print.com/api/v1"
PAGE=1
HAS_MORE=true
# Fetch all orders
while [ "$HAS_MORE" = "true" ]; do
echo "Fetching page $PAGE..."
RESPONSE=$(curl -s -X GET "$BASE_URL/orders?page=$PAGE&per_page=50" \
-H "Authorization: Bearer $API_KEY" \
-H "Accept: application/json")
# Save orders from this page
echo "$RESPONSE" | jq '.data[]' >> all_orders.json
# Check if there are more pages
HAS_MORE=$(echo "$RESPONSE" | jq -r '.pagination.has_more')
if [ "$HAS_MORE" = "true" ]; then
PAGE=$((PAGE + 1))
sleep 0.1 # Rate limit protection
fi
done
echo "All orders fetched!"
Update multiple resources from a CSV file:
#!/bin/bash
# orders.csv format: order_id,new_status
# 123,processing
# 124,completed
# 125,processing
API_KEY="c2p_live_your_api_key_here"
BASE_URL="https://app1.connect2print.com/api/v1"
while IFS=',' read -r order_id status; do
echo "Updating order $order_id to $status..."
curl -X PATCH "$BASE_URL/orders/$order_id" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d "{\"status\":\"$status\"}" \
-s -o /dev/null -w "HTTP %{http_code}\n"
sleep 0.1 # Rate limit protection
done < orders.csv
echo "Batch update complete!"
-X METHOD - Specify HTTP method (GET, POST, PATCH, DELETE)
-H "Header: Value" - Add HTTP header
-d 'data' - Send data in request body
-d @file.json - Send data from file
-F "field=value" - Send multipart form data
-F "file=@path" - Upload file
-o file - Save output to file
-i - Include response headers
-I - Fetch headers only
-s - Silent mode (no progress bar)
-w - Output format after transfer
-v - Verbose output (debugging)
--progress-bar - Show progress bar
Never hardcode API keys in scripts. Use export API_KEY="..." and $API_KEY.
Use -o response.json to save responses for later inspection.
Always check the status code with -w '%{http_code}' to detect errors.
Install jq (brew install jq or apt-get install jq) for parsing JSON responses.
Use sleep 0.1 between requests to respect rate limits.
Add -v flag to see full request/response for troubleshooting.